use of org.xwiki.xar.XarEntry in project xwiki-platform by xwiki.
the class XarExtensionHandler method uninstall.
@Override
public void uninstall(InstalledExtension installedExtension, String namespace, Request request) throws UninstallException {
try {
initializePagesIndex(request);
initJobPackageConfiguration(request, false);
} catch (Exception e) {
throw new UninstallException("Failed to initialize extension plan index", e);
}
// probably not be in an expected state)
if (!request.isRemote()) {
Job currentJob;
try {
currentJob = this.componentManager.<JobContext>getInstance(JobContext.class).getCurrentJob();
} catch (ComponentLookupException e) {
currentJob = null;
}
if (currentJob == null) {
String wiki;
try {
wiki = XarHandlerUtils.getWikiFromNamespace(namespace);
} catch (UnsupportedNamespaceException e) {
throw new UninstallException("Failed to extract wiki id from namespace", e);
}
PackageConfiguration configuration = createPackageConfiguration(null, request, wiki);
try {
XarInstalledExtension xarLocalExtension = (XarInstalledExtension) this.xarRepository.resolve(installedExtension.getId());
Collection<XarEntry> pages = xarLocalExtension.getXarPackage().getEntries();
this.packager.unimportPages(pages, configuration);
} catch (Exception e) {
// Not supposed to be possible
throw new UninstallException("Failed to get xar extension [" + installedExtension.getId() + "] from xar repository", e);
}
} else {
// The actual delete of pages is done in XarExtensionJobFinishedListener
}
}
}
use of org.xwiki.xar.XarEntry in project xwiki-platform by xwiki.
the class XarExtensionPlan method getPreviousXarExtensionPlanEntry.
public XarExtensionPlanEntry getPreviousXarExtensionPlanEntry(String wiki, LocalDocumentReference localDocumentReference) {
XarEntry xarEntry = new XarEntry(localDocumentReference);
XarExtensionPlanEntry planEntry = null;
Map<XarEntry, XarExtensionPlanEntry> wikiEntry = this.previousXAREntries.get(wiki);
if (wikiEntry != null) {
planEntry = wikiEntry.get(xarEntry);
}
if (planEntry == null) {
wikiEntry = this.previousXAREntries.get(null);
if (wikiEntry != null) {
planEntry = wikiEntry.get(xarEntry);
}
}
return planEntry;
}
use of org.xwiki.xar.XarEntry in project xwiki-platform by xwiki.
the class DocumentMergeImporter method merge.
private XarEntryMergeResult merge(String comment, XWikiDocument currentDocument, XWikiDocument previousDocument, XWikiDocument nextDocument, PackageConfiguration configuration) throws Exception {
XWikiContext xcontext = this.xcontextProvider.get();
// 3 ways merge
XWikiDocument mergedDocument = currentDocument.clone();
MergeConfiguration mergeConfiguration = new MergeConfiguration();
mergeConfiguration.setProvidedVersionsModifiables(true);
MergeResult documentMergeResult;
try {
documentMergeResult = mergedDocument.merge(previousDocument, nextDocument, mergeConfiguration, xcontext);
} catch (Exception e) {
// Unexpected error, lets behave as if there was a conflict
documentMergeResult = new MergeResult();
documentMergeResult.getLog().error("Unexpected exception thrown. Usually means there is a bug in the merge.", e);
documentMergeResult.setModified(true);
}
documentMergeResult.getLog().log(this.logger);
XWikiDocument documentToSave;
if (documentMergeResult.isModified() || !documentMergeResult.getLog().getLogsFrom(LogLevel.ERROR).isEmpty()) {
documentToSave = askDocumentToSave(currentDocument, previousDocument, nextDocument, mergedDocument, configuration, documentMergeResult);
if (documentToSave != currentDocument) {
saveDocument(documentToSave, comment, false, configuration);
}
}
return new XarEntryMergeResult(new XarEntry(new LocalDocumentReference(mergedDocument.getDocumentReferenceWithLocale())), documentMergeResult);
}
use of org.xwiki.xar.XarEntry in project xwiki-platform by xwiki.
the class XarInstalledExtensionRepository method pagesUpdated.
private void pagesUpdated(XarInstalledExtension installedExtension, String namespace, boolean add) throws UnsupportedNamespaceException {
if (installedExtension != null) {
for (XarEntry xarEntry : installedExtension.getXarPackage().getEntries()) {
if (namespace != null) {
DocumentReference reference = new DocumentReference(xarEntry, new WikiReference(XarHandlerUtils.getWikiFromNamespace(namespace)));
synchronized (this.documents) {
Collection<XarInstalledExtension> referenceExtensions = this.documents.get(reference);
if (referenceExtensions != null || add) {
Set<XarInstalledExtension> newSet = referenceExtensions != null ? new LinkedHashSet<>(referenceExtensions) : new LinkedHashSet<>();
if (add) {
newSet.add(installedExtension);
} else {
newSet.remove(installedExtension);
}
this.documents.put(reference, newSet);
}
}
} else {
synchronized (this.rootDocuments) {
Collection<XarInstalledExtension> referenceExtensions = this.rootDocuments.get(xarEntry);
if (referenceExtensions != null || add) {
Set<XarInstalledExtension> newSet = referenceExtensions != null ? new LinkedHashSet<>(referenceExtensions) : new LinkedHashSet<>();
if (add) {
newSet.add(installedExtension);
} else {
newSet.remove(installedExtension);
}
this.rootDocuments.put(xarEntry, newSet);
}
}
}
}
}
}
use of org.xwiki.xar.XarEntry in project xwiki-platform by xwiki.
the class HTTPPerformanceTest method addXarFiles.
private static void addXarFiles(List<HTTPSampler> samplers) throws UnsupportedEncodingException, XarException, IOException {
String path = System.getProperty("pathToDocuments");
String patternFilter = System.getProperty("documentsToTest");
Pattern pattern = patternFilter == null ? null : Pattern.compile(patternFilter);
for (XarEntry xarEntry : XarPackage.getEntries(new File(path))) {
if (pattern == null || pattern.matcher(SERIALIZER.serialize(xarEntry)).matches()) {
samplers.add(createSample(xarEntry, "get"));
samplers.add(createSample(xarEntry, "view"));
}
}
}
Aggregations