use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.
the class WikisDefaultUIDistributionStep method prepare.
@Override
public void prepare() {
if (getState() == null) {
setState(State.COMPLETED);
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();
if (wikiExtensionUI != null) {
for (String wikiId : wikiIds) {
if (!wikiDescriptorManager.getMainWikiId().equals(wikiId)) {
String namespace = "wiki:" + wikiId;
// Only if the UI is not already installed
InstalledExtension installedExtension = this.installedRepository.getInstalledExtension(wikiExtensionUI.getId(), namespace);
if (installedExtension == null || !installedExtension.getId().getVersion().equals(wikiExtensionUI.getVersion())) {
setState(null);
return;
}
}
}
}
}
}
use of org.xwiki.wiki.manager.WikiManagerException 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.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.
the class WikisFlavorDistributionStep method prepare.
@Override
public void prepare() {
if (getState() == null) {
setState(State.COMPLETED);
if (!isMainWiki()) {
return;
}
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;
}
String mainWiki = wikiDescriptorManager.getMainWikiId();
// Enable if any of the wikis has no valid top level flavor extension
for (String wikiId : wikiIds) {
if (mainWiki.equals(wikiId)) {
continue;
}
String namespace = "wiki:" + wikiId;
ExtensionId flavor = flavorManager.getFlavorOfWiki(getWiki());
if (flavor == null || !installedRepository.getInstalledExtension(flavor).isValid(namespace)) {
setState(null);
return;
}
}
}
}
use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.
the class DefaultRecordableEventDescriptorManager method getRecordableEventDescriptors.
@Override
public List<RecordableEventDescriptor> getRecordableEventDescriptors(boolean allWikis) throws EventStreamException {
try {
// We use an hashSet to be sure we won't store the same descriptor twice (in case the same application
// is installed on several wikis).
Set<RecordableEventDescriptor> recordableEventDescriptors = new HashSet<>();
// Load the component from the context component manager (root + wiki + user component managers, etc...)
recordableEventDescriptors.addAll(contextComponentManager.getInstanceList(RecordableEventDescriptor.class));
// Maybe add components of the other wikis too
if (allWikis) {
for (String wikiId : wikiDescriptorManager.getAllIds()) {
recordableEventDescriptors.addAll(getDescriptorsFromWiki(wikiId));
}
}
return new ArrayList<>(recordableEventDescriptors);
} catch (WikiManagerException | ComponentLookupException e) {
throw new EventStreamException("Failed to get the list of all Recordable Event Descriptors.", e);
}
}
use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.
the class DefaultWikiUserManager method getMembers.
@Override
public Collection<String> getMembers(String wikiId) throws WikiUserManagerException {
List<String> members = new ArrayList<>();
try {
// Get the descriptor
WikiDescriptor descriptor = wikiDescriptorManager.getById(wikiId);
// Add the wiki owner
members.add(descriptor.getOwnerId());
} catch (WikiManagerException e) {
throw new WikiUserManagerException(String.format("Failed to get the descriptor for [%s]", wikiId), e);
}
// Get the other members from the wiki AllGroup
XWikiDocument groupDoc = getMembersGroupDocument(wikiId);
List<BaseObject> memberObjects = groupDoc.getXObjects(GROUPCLASS_REFERENCE);
if (memberObjects != null) {
for (BaseObject object : memberObjects) {
if (object == null) {
continue;
}
String member = object.getStringValue(GROUP_CLASS_MEMBER_FIELD);
if (!member.isEmpty() && !members.contains(member)) {
members.add(member);
}
}
}
return members;
}
Aggregations