use of org.xwiki.component.wiki.WikiComponentException in project xwiki-platform by xwiki.
the class WikiUIExtensionComponentBuilderTest method buildWikiLevelComponentsWithoutAdminRights.
@Test
public void buildWikiLevelComponentsWithoutAdminRights() throws Exception {
BaseObject extensionObject = createExtensionObject("id", "extensionPointId", "content", "parameters", "wiki");
try {
this.mocker.getComponentUnderTest().buildComponents(extensionObject);
fail("You shouldn't be able to register UI extensions at wiki level without wiki admin rights.");
} catch (WikiComponentException expected) {
assertEquals("Registering UI extensions at wiki level requires wiki administration rights", expected.getMessage());
}
}
use of org.xwiki.component.wiki.WikiComponentException in project xwiki-platform by xwiki.
the class DefaultWikiComponentBridge method getDependencies.
@Override
public Map<String, ComponentDescriptor> getDependencies(DocumentReference reference) throws WikiComponentException {
Map<String, ComponentDescriptor> dependencies = new HashMap<String, ComponentDescriptor>();
XWikiDocument componentDocument = this.getDocument(reference);
if (componentDocument.getObjectNumbers(DEPENDENCY_CLASS) > 0) {
for (BaseObject dependency : componentDocument.getObjects(DEPENDENCY_CLASS)) {
try {
DefaultComponentDescriptor cd = new DefaultComponentDescriptor();
cd.setRoleType(ReflectionUtils.unserializeType(dependency.getStringValue(COMPONENT_ROLE_TYPE_FIELD), Thread.currentThread().getContextClassLoader()));
cd.setRoleHint(dependency.getStringValue(COMPONENT_ROLE_HINT_FIELD));
dependencies.put(dependency.getStringValue(DEPENDENCY_BINDING_NAME_FIELD), cd);
} catch (Exception e) {
this.logger.warn("Interface [{}] not found, declared as dependency for wiki component [{}]", dependency.getStringValue(COMPONENT_ROLE_TYPE_FIELD), componentDocument.getDocumentReference());
}
}
}
return dependencies;
}
use of org.xwiki.component.wiki.WikiComponentException in project xwiki-platform by xwiki.
the class DefaultWikiComponentBridge method getDeclaredInterfaces.
@Override
public List<Class<?>> getDeclaredInterfaces(DocumentReference reference) throws WikiComponentException {
List<Class<?>> interfaces = new ArrayList<Class<?>>();
XWikiDocument componentDocument = this.getDocument(reference);
if (componentDocument.getObjectNumbers(INTERFACE_CLASS) > 0) {
for (BaseObject iface : componentDocument.getObjects(INTERFACE_CLASS)) {
if (!StringUtils.isBlank(iface.getStringValue(INTERFACE_NAME_FIELD))) {
try {
Class<?> implemented = Class.forName(iface.getStringValue(INTERFACE_NAME_FIELD));
interfaces.add(implemented);
} catch (Exception e) {
this.logger.warn("Interface [{}] not found, declared for wiki component [{}]", iface.getStringValue(INTERFACE_NAME_FIELD), componentDocument.getDocumentReference());
}
}
}
}
return interfaces;
}
use of org.xwiki.component.wiki.WikiComponentException in project xwiki-platform by xwiki.
the class DefaultWikiComponentBridge method getRoleType.
@Override
public Type getRoleType(DocumentReference reference) throws WikiComponentException {
BaseObject componentObject = getComponentObject(reference);
String role = componentObject.getStringValue(COMPONENT_ROLE_TYPE_FIELD);
Type roleType;
try {
roleType = ReflectionUtils.unserializeType(role, Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
throw new WikiComponentException(String.format("The role type [%s] does not exist", role), e);
}
return roleType;
}
use of org.xwiki.component.wiki.WikiComponentException in project xwiki-platform by xwiki.
the class DefaultWikiComponentManagerEventListener method registerAllDocumentComponents.
/**
* Register all the wiki components that come from a document in the current wiki.
*/
private void registerAllDocumentComponents() {
try {
// Retrieve all components definitions and register them.
this.wikiComponentProviders = this.componentManager.getInstanceList(WikiComponentBuilder.class);
for (WikiComponentBuilder provider : this.wikiComponentProviders) {
for (DocumentReference reference : provider.getDocumentReferences()) {
try {
List<WikiComponent> components = provider.buildComponents(reference);
this.wikiComponentManagerEventListenerHelper.registerComponentList(components);
} catch (WikiComponentException e) {
this.logger.warn("Failed to build the wiki component located in the document [{}]: {}", reference, ExceptionUtils.getRootCauseMessage(e));
}
}
}
} catch (ComponentLookupException e) {
this.logger.warn(String.format("Unable to get a list of registered WikiComponentBuilder: %s", e));
}
}
Aggregations