use of org.xwiki.component.namespace.Namespace in project xwiki-platform by xwiki.
the class AbstractExtensionValidator method checkAccess.
protected void checkAccess(Right entityRight, String namespaceString, Request request) throws AccessDeniedException {
Namespace namespace = NamespaceUtils.toNamespace(namespaceString);
// Root namespace
if (namespace == null) {
checkRootRight(entityRight, request);
return;
}
if (namespace.getType() != null) {
// User
if (namespace.getType().equals("user")) {
EntityReference reference = this.resolver.resolve(namespace.getValue(), EntityType.DOCUMENT);
checkUserRight(reference, request);
return;
}
// Entity
EntityType entityType = EnumUtils.getEnum(EntityType.class, namespace.getType().toUpperCase());
if (entityType != null) {
EntityReference reference = this.resolver.resolve(namespace.getValue(), entityType);
checkAccess(reference, entityRight, request);
return;
}
}
// Unknown namespace
checkNamespaceRight(namespace, Right.PROGRAM, request);
}
use of org.xwiki.component.namespace.Namespace in project xwiki-platform by xwiki.
the class OutdatedExtensionsDistributionStep method prepare.
@Override
public void prepare() {
if (getState() == null) {
setState(State.COMPLETED);
if (isMainWiki()) {
Collection<InstalledExtension> installedExtensions = this.installedRepository.getInstalledExtensions();
// Upgrade outdated extensions only when there is invalid extensions
for (InstalledExtension extension : installedExtensions) {
Collection<String> installedNamespaces = extension.getNamespaces();
if (installedNamespaces == null) {
if (!extension.isValid(null)) {
this.logger.debug("Enabling outdate extension step on main wiki " + "because extension [{}] is invalid on root namespace", extension.getId());
setState(null);
break;
}
} else {
for (String installedNamespace : installedNamespaces) {
if (!extension.isValid(installedNamespace)) {
this.logger.debug("Enabling outdate extension step on main wiki " + "because extension [{}] is invalid on namespace [{}]", extension.getId(), installedNamespace);
setState(null);
break;
}
}
}
}
} else {
Namespace currentNamespace = getNamespace();
Collection<InstalledExtension> installedExtensions = this.installedRepository.getInstalledExtensions(currentNamespace.toString());
// Upgrade outdated extensions only when there is invalid extensions
for (InstalledExtension extension : installedExtensions) {
if (!extension.isValid(currentNamespace.toString())) {
this.logger.debug("Enabling outdate extension step on wiki [{}]" + "because extension [{}] is invalid", getWiki(), extension.getId());
setState(null);
break;
}
}
}
}
}
use of org.xwiki.component.namespace.Namespace in project xwiki-platform by xwiki.
the class WikisDefaultUIDistributionStep method executeNonInteractive.
@Override
public void executeNonInteractive() throws Exception {
WikiDescriptorManager wikiDescriptorManager = this.wikiDescriptorManagerProvider.get();
Collection<String> wikiIds;
try {
wikiIds = wikiDescriptorManager.getAllIds();
} catch (WikiManagerException e) {
this.logger.error("Failed to get the list of wikis", e);
setState(null);
return;
}
ExtensionId wikiExtensionUI = this.distributionManager.getWikiUIExtensionId();
for (String wikiId : wikiIds) {
if (!wikiDescriptorManager.getMainWikiId().equals(wikiId)) {
String namespace = new Namespace("wiki", wikiId).toString();
// Only if the UI is not already installed
if (wikiExtensionUI != null) {
InstalledExtension installedExtension = this.installedRepository.getInstalledExtension(wikiExtensionUI.getId(), namespace);
if (installedExtension == null || !installedExtension.getId().getVersion().equals(wikiExtensionUI.getVersion())) {
install(wikiExtensionUI, namespace, false);
}
}
}
}
// Complete task
setState(State.COMPLETED);
}
use of org.xwiki.component.namespace.Namespace in project xwiki-platform by xwiki.
the class DefaultUIDistributionStep method prepare.
@Override
public void prepare() {
if (getState() == null) {
setState(State.COMPLETED);
Namespace namespace = getNamespace();
ExtensionId extensionUI = this.distributionJob.getStatus().getDistributionExtensionUI();
// Only if the UI is not already installed
if (extensionUI != null) {
InstalledExtension installedExtension = this.installedRepository.getInstalledExtension(extensionUI.getId(), namespace.toString());
if (installedExtension == null || !installedExtension.getId().getVersion().equals(extensionUI.getVersion())) {
setState(null);
}
}
}
}
use of org.xwiki.component.namespace.Namespace in project xwiki-platform by xwiki.
the class DefaultRecordableEventDescriptorManager method getDescriptorsFromWiki.
private List<RecordableEventDescriptor> getDescriptorsFromWiki(String wikiId) throws ComponentLookupException {
Namespace namespace = new WikiNamespace(wikiId);
ComponentManager wikiComponentManager = componentManagerManager.getComponentManager(namespace.serialize(), false);
if (wikiComponentManager == null) {
return Collections.emptyList();
}
List<RecordableEventDescriptor> descriptors = new ArrayList<>();
descriptors.addAll(wikiComponentManager.getInstanceList(RecordableEventDescriptor.class));
descriptors.addAll(wikiComponentManager.getInstanceList(UntypedRecordableEventDescriptor.class));
return descriptors;
}
Aggregations