Search in sources :

Example 11 with WikiComponentException

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);
    }
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) WikiComponentException(org.xwiki.component.wiki.WikiComponentException) WikiComponentException(org.xwiki.component.wiki.WikiComponentException) EventStreamException(org.xwiki.eventstream.EventStreamException)

Example 12 with WikiComponentException

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);
    }
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) WikiComponentException(org.xwiki.component.wiki.WikiComponentException) WikiComponentException(org.xwiki.component.wiki.WikiComponentException) NotificationException(org.xwiki.notifications.NotificationException)

Example 13 with WikiComponentException

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);
    }
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) WikiComponentException(org.xwiki.component.wiki.WikiComponentException) WikiComponentException(org.xwiki.component.wiki.WikiComponentException) NotificationException(org.xwiki.notifications.NotificationException)

Example 14 with WikiComponentException

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());
    }
}
Also used : WikiComponentException(org.xwiki.component.wiki.WikiComponentException) BaseObject(com.xpn.xwiki.objects.BaseObject) Test(org.junit.Test)

Example 15 with WikiComponentException

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;
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) WikiComponentException(org.xwiki.component.wiki.WikiComponentException) BaseObject(com.xpn.xwiki.objects.BaseObject)

Aggregations

WikiComponentException (org.xwiki.component.wiki.WikiComponentException)18 BaseObject (com.xpn.xwiki.objects.BaseObject)7 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)6 WikiComponent (org.xwiki.component.wiki.WikiComponent)5 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)4 DocumentReference (org.xwiki.model.reference.DocumentReference)4 XWikiException (com.xpn.xwiki.XWikiException)3 Type (java.lang.reflect.Type)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 ComponentDescriptor (org.xwiki.component.descriptor.ComponentDescriptor)2 DefaultComponentDescriptor (org.xwiki.component.descriptor.DefaultComponentDescriptor)2 WikiComponentBuilder (org.xwiki.component.wiki.WikiComponentBuilder)2 EntityReference (org.xwiki.model.reference.EntityReference)2 NotificationException (org.xwiki.notifications.NotificationException)2 XWikiContext (com.xpn.xwiki.XWikiContext)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 HashMap (java.util.HashMap)1 ComponentRepositoryException (org.xwiki.component.manager.ComponentRepositoryException)1 Initializable (org.xwiki.component.phase.Initializable)1