use of org.xwiki.bridge.event.WikiProvisionedEvent in project xwiki-platform by xwiki.
the class TemplateWikiProvisioningJob method runInternal.
@Override
protected void runInternal() throws Exception {
WikiProvisioningJobRequest request = getRequest();
if (!(request.getProvisioningJobParameter() instanceof String)) {
throw new Exception("The provisioning parameter is not a valid String.");
}
XWikiContext xcontext = xcontextProvider.get();
String wikiId = request.getWikiId();
String templateId = (String) request.getProvisioningJobParameter();
// Set the user actually doing the action in the context
xcontext.setUserReference(request.getProvisioningUser());
try {
observationManager.notify(new WikiProvisioningEvent(wikiId), wikiId, xcontext);
wikiCopier.copyDocuments(templateId, wikiId, false);
observationManager.notify(new WikiProvisionedEvent(wikiId), wikiId, xcontext);
observationManager.notify(new WikiCopiedEvent(templateId, wikiId), templateId, xcontext);
} catch (WikiManagerException e) {
logger.error("Failed to provision wiki [{}] from template [{}].", wikiId, templateId, e);
observationManager.notify(new WikiProvisioningFailedEvent(wikiId), wikiId, xcontext);
}
}
use of org.xwiki.bridge.event.WikiProvisionedEvent in project xwiki-platform by xwiki.
the class ProvisionWikiStepTest method executeWhenSourceIsExtension.
@Test
public void executeWhenSourceIsExtension() throws Exception {
WikiCreationRequest request = new WikiCreationRequest();
request.setWikiId("wikiId");
request.setWikiSource(WikiSource.EXTENSION);
ExtensionId extensionId = new ExtensionId("id", "version");
request.setExtensionId(extensionId);
// Test
mocker.getComponentUnderTest().execute(request);
// Verify
verify(extensionInstaller).installExtension(eq("wikiId"), eq(extensionId));
verify(observationManager).notify(eq(new WikiProvisioningEvent("wikiId")), eq("wikiId"), eq(xcontext));
verify(observationManager).notify(eq(new WikiProvisionedEvent("wikiId")), eq("wikiId"), eq(xcontext));
verifyZeroInteractions(wikiCopier);
}
use of org.xwiki.bridge.event.WikiProvisionedEvent in project xwiki-platform by xwiki.
the class ProvisionWikiStepTest method executeWhenSourceIsTemplate.
@Test
public void executeWhenSourceIsTemplate() throws Exception {
WikiCreationRequest request = new WikiCreationRequest();
request.setWikiId("wikiId");
request.setWikiSource(WikiSource.TEMPLATE);
request.setTemplateId("template");
// Test
mocker.getComponentUnderTest().execute(request);
// Verify
verify(wikiCopier).copyDocuments(eq("template"), eq("wikiId"), eq(false));
verify(observationManager).notify(eq(new WikiProvisioningEvent("wikiId")), eq("wikiId"), eq(xcontext));
verify(observationManager).notify(eq(new WikiCopiedEvent("template", "wikiId")), eq("template"), eq(xcontext));
verify(observationManager).notify(eq(new WikiProvisionedEvent("wikiId")), eq("wikiId"), eq(xcontext));
verifyZeroInteractions(extensionInstaller);
}
Aggregations