use of org.xwiki.extension.InstalledExtension in project xwiki-platform by xwiki.
the class InstalledExtensionScriptService method getBackwardDependencies.
/**
* Get all the installed extensions that depend on the specified root extension. The results are grouped by
* namespace.
*
* @param feature the extension id or provided feature (virtual extension) of the extension to resolve
* @return a map namespace -> list of dependent extensions, or {@code null} if any error occurs while computing
* the result, in which case {@link #getLastError()} contains the failure reason
*/
public Map<String, Collection<InstalledExtension>> getBackwardDependencies(String feature) {
InstalledExtension installedExtension = this.installedExtensionRepository.getInstalledExtension(feature, null);
Map<String, Collection<InstalledExtension>> extensions;
if (installedExtension != null) {
extensions = getBackwardDependencies(installedExtension.getId());
} else {
extensions = null;
}
return extensions;
}
use of org.xwiki.extension.InstalledExtension in project xwiki-platform by xwiki.
the class InstalledExtensionSynchronizer method onEvent.
@Override
public void onEvent(Event event, Object source, Object data) {
ExtensionEvent extensionEvent = (ExtensionEvent) event;
try {
if (extensionEvent instanceof ExtensionUninstalledEvent) {
// Update documents index
getXarRepository().pagesRemoved(extensionEvent.getExtensionId(), extensionEvent.getNamespace());
// Update extension cache
getXarRepository().updateCachedXarExtension(extensionEvent.getExtensionId());
} else {
if (data != null) {
for (InstalledExtension installedExtension : (Collection<InstalledExtension>) data) {
// Update documents index
getXarRepository().pagesRemoved(installedExtension.getId(), extensionEvent.getNamespace());
// Update extension cache
getXarRepository().updateCachedXarExtension(installedExtension.getId());
}
}
// New extension
// Update extension cache
getXarRepository().updateCachedXarExtension(extensionEvent.getExtensionId());
// Update documents index
getXarRepository().pagesAdded(extensionEvent.getExtensionId(), extensionEvent.getNamespace());
}
} catch (UnsupportedNamespaceException e) {
logger.error("Failed to extract wiki from namespace [{}]", extensionEvent.getNamespace());
}
}
use of org.xwiki.extension.InstalledExtension in project xwiki-platform by xwiki.
the class DefaultFlavorManager method getFlavorOfWiki.
@Override
public ExtensionId getFlavorOfWiki(String wikiId) {
Namespace namespace = new Namespace("wiki", wikiId);
InstalledExtension flavor = getFlavorExtension(namespace);
if (flavor != null) {
return flavor.getId();
}
return null;
}
use of org.xwiki.extension.InstalledExtension in project xwiki-platform by xwiki.
the class AbstractImportMojo method installExtension.
protected void installExtension(Artifact artifact, String namespace) throws MojoExecutionException {
// We need to distinguish between extensions installed explicitly and their transitive dependencies.
// We have to create our own Set because Maven changes the fields from the dependency Artifacts (e.g. resolves
// their version) after they are added to the Set of dependencies and this causes the hash code to change. As a
// result the #contains(Artifact) method doesn't work as expected because it uses the new hash code.
Set<Artifact> directDependencies = new HashSet<>(this.project.getDependencyArtifacts());
InstalledExtension installedExtension = this.extensionHelper.registerInstalledExtension(artifact, namespace, !directDependencies.contains(artifact), Collections.<String, Object>singletonMap("user.reference", this.installUser));
getLog().info(" ... Registered extension [" + installedExtension + "]");
}
use of org.xwiki.extension.InstalledExtension in project xwiki-platform by xwiki.
the class WebJarsScriptServiceTest method computeURLWithoutVersion.
@Test
public void computeURLWithoutVersion() throws Exception {
WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("math");
InstalledExtensionRepository installedExtensionRepository = this.mocker.getInstance(InstalledExtensionRepository.class);
InstalledExtension extension = mock(InstalledExtension.class);
when(installedExtensionRepository.getInstalledExtension("org.webjars:angular", "wiki:math")).thenReturn(extension);
when(extension.getId()).thenReturn(new ExtensionId("bar", "2.1.11"));
WebJarsResourceReference resourceReference = new WebJarsResourceReference("wiki:math", Arrays.asList("angular", "2.1.11", "angular.css"));
when(this.serializer.serialize(resourceReference)).thenReturn(new ExtendedURL(Arrays.asList("xwiki", "angular", "2.1.11", "angular.css")));
assertEquals("/xwiki/angular/2.1.11/angular.css", this.mocker.getComponentUnderTest().url("angular", "angular.css"));
}
Aggregations