use of org.xwiki.component.wiki.WikiComponentException in project xwiki-platform by xwiki.
the class UntypedRecordableEventDescriptorComponentBuilder method buildComponents.
@Override
public List<WikiComponent> buildComponents(BaseObject baseObject) throws WikiComponentException {
try {
XWikiDocument parentDocument = baseObject.getOwnerDocument();
this.checkRights(parentDocument.getDocumentReference(), parentDocument.getAuthorReference());
return Arrays.asList(new DefaultUntypedRecordableEventDescriptor(baseObject.getReference(), parentDocument.getAuthorReference(), baseObject, contextualLocalizationManager));
} catch (Exception e) {
throw new WikiComponentException(String.format("Unable to build the UntypedRecordableEvent wiki component " + "for [%s].", baseObject), e);
}
}
use of org.xwiki.component.wiki.WikiComponentException in project xwiki-platform by xwiki.
the class AbstractWikiNotificationRendererComponentBuilder method buildComponents.
@Override
public List<WikiComponent> buildComponents(BaseObject baseObject) throws WikiComponentException {
try {
// Check that the document owner is allowed to build the components
XWikiDocument parentDocument = baseObject.getOwnerDocument();
this.checkRights(parentDocument.getDocumentReference(), parentDocument.getAuthorReference());
// Instantiate the component
return Arrays.asList(instantiateComponent(parentDocument.getAuthorReference(), baseObject));
} catch (Exception e) {
throw new WikiComponentException(String.format("Unable to build the WikiNotificationDisplayer wiki component " + "for [%s].", baseObject), e);
}
}
use of org.xwiki.component.wiki.WikiComponentException in project xwiki-platform by xwiki.
the class WikiNotificationFilterDisplayerComponentBuilder method buildComponents.
@Override
public List<WikiComponent> buildComponents(BaseObject baseObject) throws WikiComponentException {
try {
// Check that the document owner is allowed to build the components
XWikiDocument parentDocument = baseObject.getOwnerDocument();
this.checkRights(parentDocument.getDocumentReference(), parentDocument.getAuthorReference());
// Instantiate the component
return Arrays.asList(new WikiNotificationFilterDisplayer(parentDocument.getAuthorReference(), this.componentManager, baseObject));
} catch (Exception e) {
throw new WikiComponentException(String.format("Unable to build the WikiNotificationFilterDisplayer wiki component " + "for [%s].", baseObject), e);
}
}
use of org.xwiki.component.wiki.WikiComponentException in project xwiki-platform by xwiki.
the class WikiUIExtensionComponentBuilderTest method buildGlobalComponentsWithoutPR.
@Test
public void buildGlobalComponentsWithoutPR() throws Exception {
BaseObject extensionObject = createExtensionObject("id", "extensionPointId", "content", "parameters", "global");
try {
this.mocker.getComponentUnderTest().buildComponents(extensionObject);
fail("You shouldn't be able to register global UI extensions without PR.");
} catch (WikiComponentException expected) {
assertEquals("Registering global UI extensions requires programming rights", expected.getMessage());
}
}
use of org.xwiki.component.wiki.WikiComponentException in project xwiki-platform by xwiki.
the class DefaultWikiComponentBridge method getComponentObject.
/**
* Get the main component object from a wiki component document.
*
* @param reference a reference to the document holding the component
* @return the object defining the component
* @throws WikiComponentException if the document can't be retrieved
*/
private BaseObject getComponentObject(DocumentReference reference) throws WikiComponentException {
XWikiDocument componentDocument = this.getDocument(reference);
BaseObject componentObject = componentDocument.getObject(COMPONENT_CLASS);
if (componentObject == null) {
throw new WikiComponentException(String.format("No component object could be found in document [%s]", reference));
}
return componentObject;
}
Aggregations