Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
ConfiguredDocumentDisplayer | 45 | 8 | 0% | 4 | 4 | 0.660% |
Class ConfiguredDocumentDisplayer |
Line # 45 |
8 |
0% |
4 |
4 |
0.660% |
---|---|---|---|---|---|---|
display(DocumentModelBridge,DocumentDisplayerParameters) : XDOM display(DocumentModelBridge,DocumentDisplayerParameters) : XDOM | 6565 | 1.01 | 0.00% | 1.01 | 0.00 | 1.0 1.0100% |
getDocumentDisplayer() : DocumentDisplayer getDocumentDisplayer() : DocumentDisplayer | 8585 | 7.07 | 0.00% | 3.03 | 4.04 | 0.42857143 0.4285714342.9% |
1.0
|
org.xwiki.rendering.internal.macro.DisplayMacroTest.testDisplayMacroWhenSectionSpecifiedorg.xwiki.rendering.internal.macro.DisplayMacroTest.testDisplayMacroWhenSectionSpecified | 3FAIL | ||
1.0
|
org.xwiki.rendering.internal.macro.IncludeMacroTest.testIncludeMacroWhenSectionSpecifiedorg.xwiki.rendering.internal.macro.IncludeMacroTest.testIncludeMacroWhenSectionSpecified | 3FAIL | ||
1.0
|
org.xwiki.rendering.internal.macro.IncludeMacroTest.testIncludeMacroInsideSourceMetaDataBlockAndWithRelativeDocumentReferencePassedorg.xwiki.rendering.internal.macro.IncludeMacroTest.testIncludeMacroInsideSourceMetaDataBlockAndWithRelativeDocumentReferencePassed | 3FAIL | ||
1.0
|
org.xwiki.activitystream.WebRssTest.webRssFiltersHiddenDocumentsorg.xwiki.activitystream.WebRssTest.webRssFiltersHiddenDocuments | 3FAIL | ||
1.0
|
org.xwiki.rendering.internal.macro.IncludeMacroTest.testIncludeMacroWithNewContextShowsPassingOnRestrictedFlagorg.xwiki.rendering.internal.macro.IncludeMacroTest.testIncludeMacroWithNewContextShowsPassingOnRestrictedFlag | 3FAIL | ||
1.0
|
org.xwiki.rendering.internal.macro.DisplayMacroTest.testDisplayMacroWhenInvalidSectionSpecifiedorg.xwiki.rendering.internal.macro.DisplayMacroTest.testDisplayMacroWhenInvalidSectionSpecified | 3FAIL | ||
1.0
|
org.xwiki.help.HelpTest.verifySubHeadingVelocityVariableCorrectlyEvaluatedWhenUsedInSectionorg.xwiki.help.HelpTest.verifySubHeadingVelocityVariableCorrectlyEvaluatedWhenUsedInSection | 3FAIL | ||
1.0
|
org.xwiki.rendering.internal.macro.DisplayMacroTest.testDisplayMacroInsideBaseMetaDataBlockAndWithRelativeDocumentReferencePassedorg.xwiki.rendering.internal.macro.DisplayMacroTest.testDisplayMacroInsideBaseMetaDataBlockAndWithRelativeDocumentReferencePassed | 3FAIL | ||
1.0
|
org.xwiki.rendering.internal.macro.IncludeMacroTest.testIncludeMacroWhenIncludingDocumentWithRelativeReferencesorg.xwiki.rendering.internal.macro.IncludeMacroTest.testIncludeMacroWhenIncludingDocumentWithRelativeReferences | 3FAIL | ||
1.0
|
org.xwiki.rendering.internal.macro.IncludeMacroTest.testIncludeMacroWhenInvalidSectionSpecifiedorg.xwiki.rendering.internal.macro.IncludeMacroTest.testIncludeMacroWhenInvalidSectionSpecified | 3FAIL | ||
1.0
|
org.xwiki.activitystream.WebRssTest.webRssDisplayorg.xwiki.activitystream.WebRssTest.webRssDisplay | 3FAIL | ||
1.0
|
org.xwiki.rendering.internal.macro.DisplayMacroTest.testDisplayMacroWhenDisplayingDocumentWithRelativeReferencesorg.xwiki.rendering.internal.macro.DisplayMacroTest.testDisplayMacroWhenDisplayingDocumentWithRelativeReferences | 3FAIL | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentTest.testDisplaycom.xpn.xwiki.doc.XWikiDocumentTest.testDisplay | 1PASS | ||
0.6
|
com.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testSourcePolymorphismcom.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testSourcePolymorphism | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleWhenMatchingTitleHeaderDepthcom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleWhenMatchingTitleHeaderDepth | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedContentTextWithSourceSyntaxcom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedContentTextWithSourceSyntax | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleRecursivecom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleRecursive | 1PASS | ||
0.6
|
com.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testArticleSourcePlainContentLengthcom.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testArticleSourcePlainContentLength | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleWhenNotMatchingTitleHeaderDepthcom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleWhenNotMatchingTitleHeaderDepth | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleWithTitlecom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleWithTitle | 1PASS | ||
0.6
|
com.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testSourceConsistencycom.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testSourceConsistency | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedContentcom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedContent | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleWithoutTitleHTMLcom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleWithoutTitleHTML | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleWithoutTitlePLAINcom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleWithoutTitlePLAIN | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentTest.testDisplayTemplate20com.xpn.xwiki.doc.XWikiDocumentTest.testDisplayTemplate20 | 1PASS | ||
0.6
|
com.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testArticleSourceXMLContentLengthcom.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testArticleSourceXMLContentLength | 1PASS | ||
0.6
|
com.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testArticleSourceHTMLContentLengthcom.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testArticleSourceHTMLContentLength | 1PASS | ||
0.6
|
com.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testSourceContentTypecom.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testSourceContentType | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleNoTitleAndContentcom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedTitleNoTitleAndContent | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentTest.testGetRenderedContentWithSourceSyntaxcom.xpn.xwiki.doc.XWikiDocumentTest.testGetRenderedContentWithSourceSyntax | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedContentCleansVelocityMacroCachecom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedContentCleansVelocityMacroCache | 1PASS | ||
0.6
|
com.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testSourceAccessRightscom.xpn.xwiki.plugin.feed.SyndEntryDocumentSourceTest.testSourceAccessRights | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedContentRightscom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedContentRights | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testCurrentDocumentVariableIsInjectedBeforeRenderingcom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testCurrentDocumentVariableIsInjectedBeforeRendering | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentTest.testGetRenderedContentcom.xpn.xwiki.doc.XWikiDocumentTest.testGetRenderedContent | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedContentTextRightscom.xpn.xwiki.doc.XWikiDocumentRenderingTest.testGetRenderedContentTextRights | 1PASS | ||
0.6
|
com.xpn.xwiki.doc.XWikiDocumentTest.testDisplay1020com.xpn.xwiki.doc.XWikiDocumentTest.testDisplay1020 | 1PASS |
1 | /* | ||||||
2 | * See the NOTICE file distributed with this work for additional | ||||||
3 | * information regarding copyright ownership. | ||||||
4 | * | ||||||
5 | * This is free software; you can redistribute it and/or modify it | ||||||
6 | * under the terms of the GNU Lesser General Public License as | ||||||
7 | * published by the Free Software Foundation; either version 2.1 of | ||||||
8 | * the License, or (at your option) any later version. | ||||||
9 | * | ||||||
10 | * This software is distributed in the hope that it will be useful, | ||||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||
13 | * Lesser General Public License for more details. | ||||||
14 | * | ||||||
15 | * You should have received a copy of the GNU Lesser General Public | ||||||
16 | * License along with this software; if not, write to the Free | ||||||
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||||||
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||||||
19 | */ | ||||||
20 | package org.xwiki.display.internal; | ||||||
21 | |||||||
22 | import javax.inject.Inject; | ||||||
23 | import javax.inject.Named; | ||||||
24 | import javax.inject.Singleton; | ||||||
25 | |||||||
26 | import org.apache.commons.lang.exception.ExceptionUtils; | ||||||
27 | import org.slf4j.Logger; | ||||||
28 | import org.xwiki.bridge.DocumentModelBridge; | ||||||
29 | import org.xwiki.component.annotation.Component; | ||||||
30 | import org.xwiki.component.manager.ComponentLookupException; | ||||||
31 | import org.xwiki.component.manager.ComponentManager; | ||||||
32 | import org.xwiki.rendering.block.XDOM; | ||||||
33 | |||||||
34 | /** | ||||||
35 | * This is just a wrapper for the document displayer specified in the configuration. If there is no | ||||||
36 | * {@link DocumentDisplayer} component registered with the {@link DisplayConfiguration#getDocumentDisplayerHint()} hint | ||||||
37 | * then the default document displayer is used instead. | ||||||
38 | * | ||||||
39 | * @version $Id: 4c986125e78f8eb63c6d6229b6d807446b98a934 $ | ||||||
40 | * @since 3.2M3 | ||||||
41 | */ | ||||||
42 | @Component | ||||||
43 | @Named("configured") | ||||||
44 | @Singleton | ||||||
|
|||||||
45 | public class ConfiguredDocumentDisplayer implements DocumentDisplayer | ||||||
46 | { | ||||||
47 | /** | ||||||
48 | * The object used for logging. | ||||||
49 | */ | ||||||
50 | @Inject | ||||||
51 | private Logger logger; | ||||||
52 | |||||||
53 | /** | ||||||
54 | * The display configuration. | ||||||
55 | */ | ||||||
56 | @Inject | ||||||
57 | private DisplayConfiguration displayConfiguration; | ||||||
58 | |||||||
59 | /** | ||||||
60 | * The component manager. | ||||||
61 | */ | ||||||
62 | @Inject | ||||||
63 | private ComponentManager componentManager; | ||||||
64 | |||||||
|
|||||||
65 | 27032 | @Override... | |||||
66 | public XDOM display(DocumentModelBridge data, DocumentDisplayerParameters parameters) | ||||||
67 | { | ||||||
68 | 27032 | return getDocumentDisplayer().display(data, parameters); | |||||
69 | } | ||||||
70 | |||||||
71 | /** | ||||||
72 | * Tries to lookup the document displayer with the configured hint, falling back on the default document displayer. | ||||||
73 | * <p> | ||||||
74 | * Note: There are two reasons why we don't do this in the component initialization phase: | ||||||
75 | * <ul> | ||||||
76 | * <li>it would trigger an infinite recursion if XWikiDocument class initializes the document displayer in the | ||||||
77 | * constructor (or field initialization) because accessing the configuration triggers the load of the | ||||||
78 | * XWiki.XWikiPreferences document which would trigger displayer initialization which would trigger the load of the | ||||||
79 | * XWiki.XWikiPreferences document and so on..</li> | ||||||
80 | * <li>we want to support the live change of the configured document displayer</li> | ||||||
81 | * </ul> | ||||||
82 | * | ||||||
83 | * @return the configured document displayer | ||||||
84 | */ | ||||||
|
|||||||
85 | 27026 | private DocumentDisplayer getDocumentDisplayer()... | |||||
86 | { | ||||||
87 | 27031 | String documentDisplayerHint = displayConfiguration.getDocumentDisplayerHint(); | |||||
88 | 27032 | try { | |||||
89 | 27032 | return componentManager.getInstance(DocumentDisplayer.class, documentDisplayerHint); | |||||
90 | } catch (ComponentLookupException e) { | ||||||
91 | 0 | logger.warn("Failed to lookup document displayer with hint [{}] (Root cause: [{}]). " | |||||
92 | + "Using default document displayer.", documentDisplayerHint, ExceptionUtils.getRootCauseMessage(e)); | ||||||
93 | 0 | try { | |||||
94 | 0 | return componentManager.getInstance(DocumentDisplayer.class); | |||||
95 | } catch (ComponentLookupException ex) { | ||||||
96 | 0 | throw new RuntimeException("Failed to lookup default document displayer.", ex); | |||||
97 | } | ||||||
98 | } | ||||||
99 | } | ||||||
100 | } |