use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.
the class DefaultWikiDescriptorDocumentHelper method getAllXWikiServerClassDocumentNames.
@Override
public List<String> getAllXWikiServerClassDocumentNames() throws WikiManagerException {
WikiDescriptorManager wikiDescriptorManager = wikiDescriptorManagerProvider.get();
try {
Query query = this.queryManager.createQuery("from doc.object(XWiki.XWikiServerClass) as descriptor where doc.name like 'XWikiServer%' " + "and doc.fullName <> 'XWiki.XWikiServerClassTemplate'", Query.XWQL);
query.setWiki(wikiDescriptorManager.getMainWikiId());
query.addFilter(componentManager.<QueryFilter>getInstance(QueryFilter.class, "unique"));
return query.execute();
} catch (Exception e) {
throw new WikiManagerException("Failed to locate XWiki.XWikiServerClass documents", e);
}
}
use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.
the class SaveWikiMetaDataStep method execute.
@Override
public void execute(WikiCreationRequest request) throws WikiCreationException {
try {
String wikiId = request.getWikiId();
// Meta data about the wiki
WikiDescriptor descriptor = wikiDescriptorManager.getById(wikiId);
descriptor.setDescription(request.getDescription());
descriptor.setPrettyName(request.getPrettyName());
descriptor.setOwnerId(request.getOwnerId());
wikiDescriptorManager.saveDescriptor(descriptor);
// Meta data about the templates
wikiTemplateManager.setTemplate(wikiId, request.isTemplate());
// Meta data about the users
wikiUserManager.setUserScope(wikiId, request.getUserScope());
wikiUserManager.setMembershipType(wikiId, request.getMembershipType());
} catch (WikiManagerException | WikiTemplateManagerException | WikiUserManagerException e) {
throw new WikiCreationException(String.format("Failed to set metadata to the wiki [%s].", request.getWikiId()), e);
}
}
use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.
the class DefaultWikiCreator method create.
@Override
public WikiDescriptor create(String wikiId, String wikiAlias) throws WikiManagerException {
XWikiContext context = xcontextProvider.get();
XWiki xwiki = context.getWiki();
// Create database/schema
try {
xwiki.getStore().createWiki(wikiId, context);
} catch (Exception e) {
throw new WikiManagerException(localizationManager.getTranslationPlain("wiki.databasecreation", wikiId), e);
}
// Create the descriptor
// Since XWiki#updateDatabase is generating documents it needs the wiki to actually exist
// from XWiki point of view as otherwise various codes are going to be lost
WikiDescriptor descriptor = createDescriptor(wikiId, wikiAlias);
// Init database/schema
try {
xwiki.initializeWiki(wikiId, true, context);
} catch (Exception e) {
throw new WikiManagerException(localizationManager.getTranslationPlain("wiki.databaseupdate", wikiId), e);
}
return descriptor;
}
use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.
the class DefaultWikiCreator method createDescriptor.
private WikiDescriptor createDescriptor(String wikiId, String wikiAlias) throws WikiManagerException {
// Create the descriptor
WikiDescriptor descriptor = new DefaultWikiDescriptor(wikiId, wikiAlias);
try {
// Build the document
wikiDescriptorBuilder.save(descriptor);
// Reload the descriptor from the cache because it should have been seen by the DescriptorListener.
descriptor = wikiDescriptorManager.getById(wikiId);
} catch (WikiDescriptorBuilderException e) {
throw new WikiManagerException("Failed to build the descriptor document.", e);
}
return descriptor;
}
use of org.xwiki.wiki.manager.WikiManagerException in project xwiki-platform by xwiki.
the class DefaultWikiManager method idAvailable.
@Override
public boolean idAvailable(String wikiId) throws WikiManagerException {
// Get the store
XWikiContext xcontext = xcontextProvider.get();
XWiki xwiki = xcontext.getWiki();
// Get the forbidden list
String wikiForbiddenList = xcontextProvider.get().getWiki().Param("xwiki.virtual.reserved_wikis");
try {
return !wikiDescriptorManager.exists(wikiId) && !Util.contains(wikiId, wikiForbiddenList, ", ") && xwiki.getStore().isWikiNameAvailable(wikiId, xcontext);
} catch (XWikiException e) {
throw new WikiManagerException("Fail to look at the databases.");
}
}
Aggregations