use of org.xwiki.extension.xar.question.DefaultConflictActionQuestion in project xwiki-platform by xwiki.
the class XarExtensionHandler method initJobPackageConfiguration.
private void initJobPackageConfiguration(Request request, boolean defaultConflict) throws InterruptedException {
ExecutionContext context = this.execution.getContext();
if (context != null && context.getProperty(CONTEXTKEY_PACKAGECONFIGURATION) == null) {
Job currentJob = null;
try {
currentJob = this.componentManager.<JobContext>getInstance(JobContext.class).getCurrentJob();
} catch (Exception e) {
this.logger.error("Failed to lookup JobContext, it will be impossible to do interactive install");
}
if (currentJob != null) {
PackageConfiguration configuration = new PackageConfiguration();
context.setProperty(CONTEXTKEY_PACKAGECONFIGURATION, configuration);
DocumentReference userReference = getRequestUserReference(AbstractExtensionValidator.PROPERTY_USERREFERENCE, request);
configuration.setInteractive(request.isInteractive());
configuration.setUser(userReference);
configuration.setVerbose(request.isVerbose());
configuration.setSkipMandatorytDocuments(true);
configuration.setXarExtensionPlan(getXARExtensionPlan());
configuration.setJobStatus(currentJob.getStatus());
// Non blocker conflicts
configuration.setConflictAction(ConflictType.CURRENT_DELETED, request.getProperty(ConflictQuestion.REQUEST_CONFLICT_DEFAULTANSWER_CURRENT_DELETED), GlobalAction.CURRENT);
configuration.setConflictAction(ConflictType.MERGE_SUCCESS, request.getProperty(ConflictQuestion.REQUEST_CONFLICT_DEFAULTANSWER_MERGE_SUCCESS), GlobalAction.MERGED);
// Blocker conflicts
configuration.setConflictAction(ConflictType.CURRENT_EXIST, request.getProperty(ConflictQuestion.REQUEST_CONFLICT_DEFAULTANSWER_CURRENT_EXIST), configuration.isInteractive() ? GlobalAction.ASK : GlobalAction.NEXT);
configuration.setConflictAction(ConflictType.MERGE_FAILURE, request.getProperty(ConflictQuestion.REQUEST_CONFLICT_DEFAULTANSWER_MERGE_FAILURE), configuration.isInteractive() ? GlobalAction.ASK : GlobalAction.MERGED);
// If user asked to be asked about conflict behavior
if (defaultConflict && currentJob.getStatus().getRequest().isInteractive()) {
XWikiContext xcontext = xcontextProvider.get();
// Make sure the context has the right user
xcontext.setUserReference(userReference);
int extensionConflictSetup = NumberUtils.toInt(xcontext.getWiki().getUserPreference("extensionConflictSetup", xcontext), 0);
if (extensionConflictSetup == 1) {
DefaultConflictActionQuestion question = new DefaultConflictActionQuestion(configuration);
currentJob.getStatus().ask(question, 1, TimeUnit.HOURS);
}
}
}
}
}
Aggregations