Skip to content
Snippets Groups Projects
Commit 7771923d authored by Thomas Mortagne's avatar Thomas Mortagne
Browse files

XWIKI-20462: Add support for content coming from a different source in the code macro

* add missing exception causes
* improve javadoc
* use the already resolved DocumentReference for better performances

(cherry picked from commit 8c5fc56a)
parent 990a3fcd
No related branches found
No related tags found
No related merge requests found
......@@ -86,7 +86,7 @@ public CodeMacroSource getContent(CodeMacroSourceReference reference, MacroTrans
this.authorization.checkAccess(Right.VIEW, xcontext.getAuthorReference(), documentReference);
} catch (AccessDeniedException e) {
throw new MacroExecutionException(
"Current author is not allowed to access document [" + documentReference + "]");
"Current author is not allowed to access document [" + documentReference + "]", e);
}
// Current user must have view right on the document
......@@ -98,9 +98,9 @@ public CodeMacroSource getContent(CodeMacroSourceReference reference, MacroTrans
// Get the content
XWikiDocument document;
try {
document = xcontext.getWiki().getDocument(entityReference, xcontext);
document = xcontext.getWiki().getDocument(documentReference, xcontext);
} catch (XWikiException e) {
throw new MacroExecutionException("Failed to load document [" + documentReference + "]");
throw new MacroExecutionException("Failed to load document [" + documentReference + "]", e);
}
// Get the current translation
......@@ -109,7 +109,7 @@ public CodeMacroSource getContent(CodeMacroSourceReference reference, MacroTrans
document = document.getTranslatedDocument(xcontext);
} catch (XWikiException e) {
throw new MacroExecutionException(
"Failed to load document translation for reference [" + documentReference + "]");
"Failed to load document translation for reference [" + documentReference + "]", e);
}
}
......@@ -132,7 +132,7 @@ private CodeMacroSource getContent(XWikiDocument document, EntityReference entit
this.componentManager.getInstance(EntityCodeMacroSourceLoader.class, entityReference.getType().name());
} catch (ComponentLookupException e) {
throw new MacroExecutionException("Unexpected error when initializing the content loader for entity type ["
+ entityReference.getType() + "]");
+ entityReference.getType() + "]", e);
}
return loader.load(document, entityReference, reference, xcontext);
......
......@@ -44,7 +44,7 @@ public class CodeMacroSource
/**
* @param reference the reference of the content
* @param content the content to highlight
* @param language the language of the content
* @param language the language of the content if known, null otherwise
*/
public CodeMacroSource(CodeMacroSourceReference reference, String content, String language)
{
......@@ -70,7 +70,7 @@ public String getContent()
}
/**
* @return the language of the content
* @return the language of the content if known, null otherwise
*/
public String getLanguage()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment