Skip to content
Browse files

XWIKI-7700: Give public script access to job status for a specific ex…

…tension id
  • Loading branch information...
1 parent 0ea7e72 commit f7c6b252006e9c4d2fc3d2fcb85ca450b26dab65 @tmortagne tmortagne committed
View
20 ...ript/src/main/java/org/xwiki/extension/script/internal/ExtensionManagerScriptService.java
@@ -84,6 +84,11 @@
public static final String EXTENSIONERROR_KEY = "scriptservice.extension.error";
/**
+ * The prefix put behind all job ids.
+ */
+ public static final String EXTENSION_JOBID_PREFIX = "extension_";
+
+ /**
* The real extension manager bridged by this script service.
*/
@Inject
@@ -382,7 +387,7 @@ public Job install(String id, String version, String namespace)
setError(null);
InstallRequest installRequest = new InstallRequest();
- installRequest.setId(id);
+ installRequest.setId(EXTENSION_JOBID_PREFIX + id);
installRequest.addExtension(new ExtensionId(id, version));
if (StringUtils.isNotBlank(namespace)) {
installRequest.addNamespace(namespace);
@@ -496,7 +501,7 @@ public Job uninstall(ExtensionId extensionId)
setError(null);
UninstallRequest uninstallRequest = new UninstallRequest();
- uninstallRequest.setId(extensionId.getId());
+ uninstallRequest.setId(EXTENSION_JOBID_PREFIX + extensionId.getId());
uninstallRequest.addExtension(extensionId);
Job job;
@@ -596,6 +601,17 @@ public Job getCurrentJob()
}
/**
+ * Return job status corresponding to the provided extension id from the current executed job or stored history.
+ *
+ * @param extensionId the extension identifier
+ * @return the job status corresponding to the provided extension
+ */
+ public JobStatus getExtensionJobStatus(String extensionId)
+ {
+ return this.jobManager.getJobStatus(EXTENSION_JOBID_PREFIX + extensionId);
+ }
+
+ /**
* Get the status of the currently executing job, if any.
*
* @return status of the currently executing job, or {@code null} if no job is being executed

0 comments on commit f7c6b25

Please sign in to comment.
Something went wrong with that request. Please try again.