use of org.xwiki.job.JobException in project xwiki-platform by xwiki.
the class DefaultWikiCreatorTest method createWikiWithException.
@Test
public void createWikiWithException() throws Exception {
WikiCreationRequest request = new WikiCreationRequest();
request.setWikiId("wikiId");
// Mock
JobException jobException = new JobException("Error in JobException");
when(jobExecutor.execute("wikicreationjob", request)).thenThrow(jobException);
// Test
WikiCreationException caughtException = null;
try {
mocker.getComponentUnderTest().createWiki(request);
} catch (WikiCreationException e) {
caughtException = e;
}
// Verify
assertNotNull(caughtException);
}
use of org.xwiki.job.JobException in project xwiki-platform by xwiki.
the class XarExtensionScriptService method repairInstalledExtension.
/**
* Make sure the provided XAR extension properly is registered in the installed extensions index.
* <p>
* Start an asynchronous Job.
*
* @param id the extension identifier
* @param version the extension version
* @param wiki the wiki where the extension is installed
* @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 repairInstalledExtension(String id, String version, String wiki) {
setError(null);
if (!this.authorization.hasAccess(Right.PROGRAM)) {
setError(new JobException("Need programming right to repair a XAR"));
return null;
}
String namespace = getWikiNamespace(wiki);
InstallRequest installRequest = new InstallRequest();
installRequest.setId(ExtensionRequest.getJobId(ExtensionRequest.JOBID_ACTION_PREFIX, id, namespace));
DocumentReference currentUserReference = this.documentAccessBridge.getCurrentUserReference();
if (currentUserReference != null) {
installRequest.setProperty(PROPERTY_USER_REFERENCE, currentUserReference);
// 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, currentUserReference.toString());
}
installRequest.addExtension(new ExtensionId(id, version));
if (StringUtils.isNotBlank(namespace)) {
installRequest.addNamespace(namespace);
}
Job job = null;
try {
job = this.jobExecutor.execute(RepairXarJob.JOBTYPE, installRequest);
} catch (Exception e) {
setError(e);
}
return job;
}
use of org.xwiki.job.JobException in project xwiki-platform by xwiki.
the class ExtensionHistoryScriptService method replay.
/**
* Replay the given list of extension history records.
*
* @param records the history records to replay
* @return the {@link Job} object that can be used to monitor the progress of the replay process, or {@code null} in
* case of failure
*/
public Job replay(List<ExtensionJobHistoryRecord> records) {
setError(null);
ReplayRequest request = createReplayRequest(createReplayPlan(records, true, null));
try {
return this.jobExecutor.execute(ReplayJob.JOB_TYPE, request);
} catch (JobException e) {
setError(e);
return null;
}
}
use of org.xwiki.job.JobException in project xwiki-platform by xwiki.
the class ExtensionManagerScriptService method createUninstallPlan.
/**
* Adds a new job to the job queue to perform the given uninstall plan request.
* <p>
* This method requires programming rights.
*
* @param uninstallRequest the uninstall plan request to perform
* @return the {@link Job} object which can be used to monitor the progress of the uninstall plan process, or
* {@code null} in case of failure
*/
private Job createUninstallPlan(UninstallRequest uninstallRequest) {
setError(null);
if (!this.authorization.hasAccess(Right.PROGRAM)) {
// Make sure only PR user can remove the right checking or change the users
setRightsProperties(uninstallRequest);
}
Job job = null;
try {
job = this.jobExecutor.execute(UninstallPlanJob.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 createInstallPlan.
/**
* Start the asynchronous installation plan creation process for an extension.
*
* @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 createInstallPlan(InstallRequest installRequest) {
setError(null);
if (!this.authorization.hasAccess(Right.PROGRAM)) {
// Make sure only PR user can remove the right checking or change the users
setRightsProperties(installRequest);
}
Job job = null;
try {
job = this.jobExecutor.execute(InstallPlanJob.JOBTYPE, installRequest);
} catch (JobException e) {
setError(e);
}
return job;
}
Aggregations