use of org.xwiki.extension.InstallException 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);
}
}
}
}
use of org.xwiki.extension.InstallException in project xwiki-platform by xwiki.
the class XarExtensionHandler method install.
@Override
public void install(LocalExtension localExtension, String namespace, Request request) throws InstallException {
// probably not be in an expected state)
if (!request.isRemote()) {
String wiki;
try {
wiki = XarHandlerUtils.getWikiFromNamespace(namespace);
} catch (UnsupportedNamespaceException e) {
throw new InstallException("Failed to extract wiki id from namespace", e);
}
installInternal(localExtension, wiki, request);
}
}
use of org.xwiki.extension.InstallException in project xwiki-platform by xwiki.
the class RepairXarJob method getLocalXARExtension.
/**
* @param extensionId the extension unique identifier
* @return the stored local extension
* @throws InstallException failed to store extension
*/
private LocalExtension getLocalXARExtension(ExtensionId extensionId) throws InstallException {
LocalExtension localExtension = this.localRepository.getLocalExtension(extensionId);
if (localExtension == null) {
this.progressManager.pushLevelProgress(2, this);
try {
this.progressManager.startStep(this);
Extension extension = this.repositoryManager.resolve(extensionId);
this.progressManager.endStep(this);
this.progressManager.startStep(this);
if (extension.getType().equals(XarExtensionHandler.TYPE)) {
localExtension = this.localExtensionRepository.storeExtension(extension);
}
this.progressManager.endStep(this);
} catch (ResolveException e) {
throw new InstallException("Failed to find extension", e);
} catch (LocalExtensionRepositoryException e) {
throw new InstallException("Failed save extension in local repository", e);
} finally {
this.progressManager.popLevelProgress(this);
}
} else if (!localExtension.getType().equals(XarExtensionHandler.TYPE)) {
localExtension = null;
}
return localExtension;
}
use of org.xwiki.extension.InstallException in project xwiki-platform by xwiki.
the class FlavorSearchJob method tryInstallExtension.
/**
* Try to install the provided extension and update the plan if it's working.
*
* @param extensionId the extension version to install
* @param namespace the namespace where to install the extension
* @return true if the installation would succeed, false otherwise
*/
private Extension tryInstallExtension(ExtensionId extensionId, String namespace) {
DefaultExtensionPlanTree currentTree = new DefaultExtensionPlanTree();
try {
installExtension(extensionId, namespace, currentTree);
// Cleanup
this.extensionsNodeCache.clear();
return currentTree.get(0).getAction().getExtension();
} catch (InstallException e) {
this.logger.debug("Can't install extension [{}] on namespace [{}].", extensionId, namespace, e);
}
return null;
}
use of org.xwiki.extension.InstallException in project xwiki-platform by xwiki.
the class XarExtensionHandler method upgrade.
@Override
public void upgrade(Collection<InstalledExtension> previousLocalExtensions, LocalExtension newLocalExtension, String namespace, Request request) throws InstallException {
// probably not be in an expected state)
if (!request.isRemote()) {
String wiki;
try {
wiki = XarHandlerUtils.getWikiFromNamespace(namespace);
} catch (UnsupportedNamespaceException e) {
throw new InstallException("Failed to extract wiki id from namespace", e);
}
// Install new pages
installInternal(newLocalExtension, wiki, request);
}
}
Aggregations