Search in sources :

Example 1 with DiffXarJobStatus

use of org.xwiki.extension.xar.job.diff.DiffXarJobStatus in project xwiki-platform by xwiki.

the class XarExtensionScriptService method reset.

/**
 * @param reference the reference of the document to reset to its standard state (what it looks like in the
 *            extension XAR)
 * @param jobId the id of the job which computed the diff if any
 * @return true if the reset actually did something, false otherwise (any produced error can be accessed using
 *         {@link #getLastError()})
 * @since 9.3RC1
 */
public boolean reset(DocumentReference reference, List<String> jobId) {
    setError(null);
    try {
        // Only current author is allowed to modify (and so reset) the target document
        this.genericAuthorization.checkAccess(Right.EDIT, this.xcontextProvider.get().getAuthorReference(), reference);
        // Reset the document in the DB
        this.packager.reset(reference, this.xcontextProvider.get().getUserReference());
        // Update the existing job status if any
        if (jobId != null) {
            JobStatus jobStatus = getJobStatus(jobId);
            if (jobStatus != null && jobStatus instanceof DiffXarJobStatus) {
                ((DiffXarJobStatus) jobStatus).reset(reference);
            }
        }
        return true;
    } catch (Exception e) {
        setError(e);
    }
    return false;
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) DiffXarJobStatus(org.xwiki.extension.xar.job.diff.DiffXarJobStatus) DiffXarJobStatus(org.xwiki.extension.xar.job.diff.DiffXarJobStatus) IOException(java.io.IOException) JobException(org.xwiki.job.JobException) XarException(org.xwiki.xar.XarException)

Aggregations

IOException (java.io.IOException)1 DiffXarJobStatus (org.xwiki.extension.xar.job.diff.DiffXarJobStatus)1 JobException (org.xwiki.job.JobException)1 JobStatus (org.xwiki.job.event.status.JobStatus)1 XarException (org.xwiki.xar.XarException)1