use of org.xwiki.wiki.internal.descriptor.DefaultWikiDescriptor in project xwiki-platform by xwiki.
the class DefaultWikiManagerTest method createWhenWikiIdIsValid.
@Test
public void createWhenWikiIdIsValid() throws Exception {
// The wiki does not already exist
when(wikiDescriptorManager.exists("wikiid1")).thenReturn(false);
// The wiki id is valid
when(xwiki.Param("xwiki.virtual.reserved_wikis")).thenReturn("forbidden");
// The wiki name is available
when(store.isWikiNameAvailable(eq("wikiid1"), any(XWikiContext.class))).thenReturn(true);
DefaultWikiDescriptor descriptor = new DefaultWikiDescriptor("wikiid1", "wikialias1");
when(wikiCreator.create("wikiid1", "wikialias1")).thenReturn(descriptor);
// Create
WikiDescriptor newWikiDescriptor = this.mocker.getComponentUnderTest().create("wikiid1", "wikialias1", true);
// Verify a descriptor has been returned
assertNotNull(newWikiDescriptor);
// Verify that the wiki descriptor is an instance of DefaultWikiDescriptor
assertTrue(newWikiDescriptor instanceof DefaultWikiDescriptor);
// Verify that the wiki has been created
verify(wikiCreator).create("wikiid1", "wikialias1");
// Verify the events has been sent
verify(observationManager).notify(new WikiCreatingEvent("wikiid1"), "wikiid1", xcontext);
verify(observationManager).notify(new WikiCreatedEvent("wikiid1"), "wikiid1", xcontext);
}
use of org.xwiki.wiki.internal.descriptor.DefaultWikiDescriptor in project xwiki-platform by xwiki.
the class WikiDescriptorCacheTest method remove.
@Test
public void remove() throws Exception {
DefaultWikiDescriptor descriptor = new DefaultWikiDescriptor("wikiid", "wikialias");
descriptor.addAlias("alias2");
this.mocker.getComponentUnderTest().remove(descriptor.getId(), descriptor.getAliases());
verify(wikiIdCache).remove("wikiid");
verify(wikiAliasCache).remove("wikialias");
verify(wikiAliasCache).remove("alias2");
}
use of org.xwiki.wiki.internal.descriptor.DefaultWikiDescriptor in project xwiki-platform by xwiki.
the class DefaultWikiDescriptorBuilder method extractWikiDescriptor.
private DefaultWikiDescriptor extractWikiDescriptor(BaseObject serverClassObject, XWikiDocument document) {
DefaultWikiDescriptor descriptor = null;
// If the server property is empty then consider we have an invalid Wiki
String serverProperty = extractWikiAlias(serverClassObject);
if (!StringUtils.isBlank(serverProperty)) {
// If the page name doesn't start with "XWikiServer" then consider we have an invalid Wiki
String wikiId = extractWikiId(document);
if (wikiId != null) {
descriptor = new DefaultWikiDescriptor(wikiId, serverProperty);
}
}
return descriptor;
}
use of org.xwiki.wiki.internal.descriptor.DefaultWikiDescriptor 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;
}
Aggregations