use of org.xwiki.job.JobException in project xwiki-platform by xwiki.
the class ExtensionManagerScriptService method uninstall.
/**
* Adds a new job to the job queue to perform the given uninstall request.
* <p>
* This method requires programming rights.
*
* @param uninstallRequest the uninstall request to perform
* @return the {@link Job} object which can be used to monitor the progress of the uninstall process, or
* {@code null} in case of failure
*/
public Job uninstall(UninstallRequest uninstallRequest) {
setError(null);
// Force proper id
String extensionId = uninstallRequest.getExtensions().iterator().next().getId();
String namespace = uninstallRequest.getNamespaces() == null ? null : uninstallRequest.getNamespaces().iterator().next();
uninstallRequest.setId(ExtensionRequest.getJobId(ExtensionRequest.JOBID_ACTION_PREFIX, extensionId, namespace));
// Check rights
if (!this.authorization.hasAccess(Right.PROGRAM)) {
// Make sure only PR user can remove the right checking or change the users
setRightsProperties(uninstallRequest);
}
// Start job
Job job = null;
try {
job = this.jobExecutor.execute(UninstallJob.JOBTYPE, uninstallRequest);
} catch (JobException e) {
setError(e);
}
return job;
}
use of org.xwiki.job.JobException in project xwiki-platform by xwiki.
the class ExtensionManagerScriptService method install.
/**
* Start the asynchronous installation process for an extension if the context document has programming rights.
*
* @param installRequest installation instructions
* @return the {@link Job} object which can be used to monitor the progress of the installation process, or
* {@code null} in case of failure
*/
public Job install(InstallRequest installRequest) {
setError(null);
// Force proper id
String extensionId = installRequest.getExtensions().iterator().next().getId();
String namespace = installRequest.getNamespaces() == null ? null : installRequest.getNamespaces().iterator().next();
installRequest.setId(ExtensionRequest.getJobId(ExtensionRequest.JOBID_ACTION_PREFIX, extensionId, namespace));
// Check rights
if (!this.authorization.hasAccess(Right.PROGRAM)) {
// Make sure only PR user can remove the right checking or change the users
setRightsProperties(installRequest);
}
// Remember current user
DocumentReference currentUserReference = this.documentAccessBridge.getCurrentUserReference();
if (currentUserReference != null) {
// 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(AbstractExtensionValidator.PROPERTY_USERREFERENCE, currentUserReference.toString());
}
// Start job
Job job = null;
try {
job = this.jobExecutor.execute(InstallJob.JOBTYPE, installRequest);
} catch (JobException e) {
setError(e);
}
return job;
}
use of org.xwiki.job.JobException in project xwiki-platform by xwiki.
the class ExtensionManagerScriptService method createUpgradePlan.
/**
* Schedule the upgrade plan creation job.
*
* @param request the request to pass to pass to the upgrade plan job
* @return the {@link Job} object which can be used to monitor the progress of the upgrade plan creation process, or
* {@code null} in case of failure
*/
public Job createUpgradePlan(InstallRequest request) {
request.setProperty(AbstractExtensionValidator.PROPERTY_USERREFERENCE, this.documentAccessBridge.getCurrentUserReference());
XWikiDocument callerDocument = getCallerDocument();
if (callerDocument != null) {
request.setProperty(AbstractExtensionValidator.PROPERTY_CALLERREFERENCE, callerDocument.getContentAuthorReference());
}
request.setProperty(AbstractExtensionValidator.PROPERTY_CHECKRIGHTS, true);
Job job = null;
try {
job = safe(this.jobExecutor.execute(UpgradePlanJob.JOBTYPE, request));
} catch (JobException e) {
setError(e);
}
return job;
}
Aggregations