use of org.xwiki.bridge.event.WikiCopiedEvent 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.WikiCopiedEvent in project xwiki-platform by xwiki.
the class WikiCopiedEventListenerTest method testCopyOneExtension.
@Test
public void testCopyOneExtension() throws InstallException {
InstalledExtension extensionDependency1 = this.installedExtensionRepository.installExtension(this.localExtensionDependency1, "wiki:source", false);
InstalledExtension extension1 = this.installedExtensionRepository.installExtension(this.localExtension1, "wiki:source", false);
Assert.assertFalse(extension1.isInstalled("wiki:target"));
Assert.assertFalse(extensionDependency1.isInstalled("wiki:target"));
this.observation.notify(new WikiCopiedEvent("source", "target"), null, null);
Assert.assertTrue(extension1.isInstalled("wiki:target"));
Assert.assertTrue(extensionDependency1.isInstalled("wiki:target"));
}
use of org.xwiki.bridge.event.WikiCopiedEvent in project xwiki-platform by xwiki.
the class XWiki method copyWiki.
/**
* Copy an entire wiki to a target wiki.
*
* @param sourceWiki the source wiki identifier
* @param targetWiki the target wiki identifier
* @param locale the locale to copy
* @param clean clean the target wiki before copying
* @param context see {@link XWikiContext}
* @return the number of copied documents
* @throws XWikiException failed to copy wiki
* @deprecated since 5.3, use {@link WikiManager#copy(String, String, String, boolean, boolean, boolean)} instead
*/
@Deprecated
public int copyWiki(String sourceWiki, String targetWiki, String locale, boolean clean, XWikiContext context) throws XWikiException {
int documents = copySpaceBetweenWikis(null, sourceWiki, targetWiki, locale, clean, context);
ObservationManager om = getObservationManager();
if (om != null) {
om.notify(new WikiCopiedEvent(sourceWiki, targetWiki), sourceWiki, context);
}
return documents;
}
use of org.xwiki.bridge.event.WikiCopiedEvent in project xwiki-platform by xwiki.
the class DefaultWikiManager method copy.
@Override
public WikiDescriptor copy(String fromWikiId, String newWikiId, String newWikiAlias, boolean copyHistory, boolean copyRecycleBin, boolean failOnExist) throws WikiManagerException {
WikiDescriptor newWiki = create(newWikiId, newWikiAlias, failOnExist);
wikiCopier.copyDocuments(fromWikiId, newWikiId, copyHistory);
if (copyRecycleBin) {
wikiCopier.copyDeletedDocuments(fromWikiId, newWikiId);
}
observationManager.notify(new WikiCopiedEvent(fromWikiId, newWikiId), fromWikiId, xcontextProvider.get());
return newWiki;
}
use of org.xwiki.bridge.event.WikiCopiedEvent in project xwiki-platform by xwiki.
the class ProvisionWikiStep method execute.
@Override
public void execute(WikiCreationRequest request) throws WikiCreationException {
try {
if (request.getWikiSource() == null) {
// No source is defined, we let the wiki empty and DW will do the rest
return;
}
switch(request.getWikiSource()) {
case EXTENSION:
sendWikiProvisioningEvent(request);
extensionInstaller.installExtension(request.getWikiId(), request.getExtensionId());
sendWikiProvisionedEvent(request);
break;
case TEMPLATE:
sendWikiProvisioningEvent(request);
wikiCopier.copyDocuments(request.getTemplateId(), request.getWikiId(), false);
observationManager.notify(new WikiCopiedEvent(request.getTemplateId(), request.getWikiId()), request.getTemplateId(), xcontextProvider.get());
sendWikiProvisionedEvent(request);
break;
default:
// No source is defined, we let the wiki empty and DW will do the rest
break;
}
} catch (WikiManagerException | WikiCreationException e) {
observationManager.notify(new WikiProvisioningFailedEvent(request.getWikiId()), request.getWikiId(), xcontextProvider.get());
throw new WikiCreationException(String.format("Failed to provision the wiki [%s].", request.getWikiId()), e);
}
}
Aggregations