/**
* @see org.olat.repository.handlers.RepositoryHandler#createCopy(org.olat.resource.OLATResourceable,
* org.olat.core.gui.UserRequest)
*/
public OLATResourceable createCopy(OLATResourceable res, UserRequest ureq) {
FileResourceManager frm = FileResourceManager.getInstance();
VFSContainer wikiContainer = WikiManager.getInstance().getWikiContainer(res, WikiManager.WIKI_RESOURCE_FOLDER_NAME);
if(wikiContainer==null) {
//if the wiki container is null, let the WikiManager to create one
WikiManager.getInstance().getOrLoadWiki(res);
}
OLATResourceable copy = frm.createCopy(res, WikiManager.WIKI_RESOURCE_FOLDER_NAME);
VFSContainer rootContainer = frm.getFileResourceRootImpl(copy);
//reset properties files to default values
VFSContainer wikiCont = (VFSContainer)rootContainer.resolve(WikiManager.WIKI_RESOURCE_FOLDER_NAME);
List leafs = wikiCont.getItems(new VFSItemSuffixFilter(new String[]{WikiManager.WIKI_PROPERTIES_SUFFIX}));
for (Iterator iter = leafs.iterator(); iter.hasNext();) {
VFSLeaf leaf = (VFSLeaf) iter.next();
WikiPage page = Wiki.assignPropertiesToPage(leaf);
//reset the copied pages to a the default values
page.resetCopiedPage();
WikiManager.getInstance().updateWikiPageProperties(copy, page);
}
//create folders
VFSContainer newMediaCont = rootContainer.createChildContainer(WikiContainer.MEDIA_FOLDER_NAME);
rootContainer.createChildContainer(WikiManager.VERSION_FOLDER_NAME);
//copy media files to folders
VFSContainer origRootContainer = frm.getFileResourceRootImpl(res);
VFSContainer origMediaCont = (VFSContainer)origRootContainer.resolve(WikiContainer.MEDIA_FOLDER_NAME);
List mediaFiles = origMediaCont.getItems();
for (Iterator iter = mediaFiles.iterator(); iter.hasNext();) {
VFSLeaf element = (VFSLeaf) iter.next();
newMediaCont.copyFrom(element);