use of org.xwiki.extension.handler.ExtensionHandler in project xwiki-platform by xwiki.
the class WikiEventListener method onWikiCreated.
private void onWikiCreated(WikiCreatedEvent event, XWikiContext context) {
String namespace = "wiki:" + event.getWikiId();
Collection<InstalledExtension> installedExtensions = this.installedRepository.getInstalledExtensions(null);
InstallRequest installRequest = new InstallRequest();
DocumentReference userReference = context.getUserReference();
if (userReference != null) {
installRequest.setProperty(PROPERTY_USER_REFERENCE, userReference);
// We set the string value because the extension repository doesn't know how to serialize/parse an extension
// property whose value is a DocumentReference, and adding support for it requires considerable refactoring
// because ExtensionPropertySerializers are not components (they are currently hard-coded).
installRequest.setExtensionProperty(PROPERTY_USER_REFERENCE, userReference.toString());
}
installRequest.setVerbose(false);
// TODO: make it interactive ? (require wiki creation to be job based)
installRequest.setInteractive(false);
ExtensionHandler xarHandler = this.xarHandlerProvider.get();
for (InstalledExtension installedExtension : installedExtensions) {
if (installedExtension.getType().equals(XarExtensionHandler.TYPE)) {
installRequest.addExtension(installedExtension.getId());
try {
xarHandler.install(installedExtension, namespace, installRequest);
} catch (InstallException e) {
this.logger.error("Failed to import extension [{}] in wiki [{}]", installedExtension, event.getWikiId(), e);
}
}
}
}
Aggregations