use of org.olat.ims.cp.CPManager in project openolat by klemens.
the class CPFileImportController method addItem.
/**
* Adds the vfs item to the menu tree below the parentId item.
*
* @param item
* @param parentId
*/
private CPPage addItem(VFSItem item, String parentId, boolean isRoot) {
CPManager cpMgr = CPManager.getInstance();
// Make an item in the menu tree only if the item is a container that
// contains any items to be added or its type is selected in the form.
// Upload any files in case they are referenced to.
// Get the file types that should be added as items in the menu tree
Collection<String> menuItemTypes = checkboxes.getSelectedKeys();
if (menuItemTypes.contains("htm"))
menuItemTypes.add("html");
// show info.
if (isRoot && item instanceof VFSContainer && !containsItemsToAdd((VFSContainer) item, menuItemTypes)) {
showInfo("cpfileuploadcontroller.no.files.imported");
}
CPPage newPage = null;
if (isSingleFile || item instanceof VFSLeaf && isToBeAdded((VFSLeaf) item, menuItemTypes) || item instanceof VFSContainer && containsItemsToAdd((VFSContainer) item, menuItemTypes)) {
// Create the menu item
String newId = cpMgr.addBlankPage(cp, item.getName(), parentId);
newPage = new CPPage(newId, cp);
if (item instanceof VFSLeaf) {
VFSLeaf leaf = (VFSLeaf) item;
newPage.setFile(leaf);
}
cpMgr.updatePage(cp, newPage);
}
// Add any sub items
if (item instanceof VFSContainer && containsItemsToAdd((VFSContainer) item, menuItemTypes)) {
VFSContainer dir = (VFSContainer) item;
addSubItems(dir, newPage.getIdentifier());
}
return newPage;
}
use of org.olat.ims.cp.CPManager in project openolat by klemens.
the class ImsCPHandler method copy.
@Override
public RepositoryEntry copy(Identity author, RepositoryEntry source, RepositoryEntry target) {
final CPManager cpManager = CPManager.getInstance();
OLATResource sourceResource = source.getOlatResource();
OLATResource targetResource = target.getOlatResource();
File sourceFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(sourceResource).getBasefile();
File zipRoot = new File(sourceFileroot, FileResourceManager.ZIPDIR);
File targetFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(targetResource).getBasefile();
FileUtils.copyFileToDir(zipRoot, targetFileroot, "add file resource");
// copy packaging info
CPPackageConfig cpConfig = cpManager.getCPPackageConfig(sourceResource);
if (cpConfig != null) {
cpManager.setCPPackageConfig(targetResource, cpConfig);
}
CPOfflineReadableManager.getInstance().makeCPOfflineReadable(targetResource, target.getDisplayname() + ".zip");
return target;
}
use of org.olat.ims.cp.CPManager in project OpenOLAT by OpenOLAT.
the class CPContentController method displayPage.
/**
* Displays the correct edit page when node with the given id is selected.
*
* @param ureq
* @param nodeID
*/
protected void displayPage(UserRequest ureq, String nodeID) {
CPManager cpMgm = CPManager.getInstance();
currentPage = new CPPage(nodeID, cp);
String filePath = cpMgm.getPageByItemId(cp, currentPage.getIdentifier());
logInfo("I display the page with id: " + currentPage.getIdentifier(), null);
VFSItem f = cp.getRootDir().resolve(filePath);
if (filePath == null) {
displayInfoPage();
} else if (f == null) {
displayNotFoundPage();
} else {
currentPage.setFile((VFSLeaf) f);
setContent(ureq, filePath);
}
fireEvent(ureq, new Event("Page loaded"));
}
use of org.olat.ims.cp.CPManager in project OpenOLAT by OpenOLAT.
the class CPFileImportController method addItem.
/**
* Adds the vfs item to the menu tree below the parentId item.
*
* @param item
* @param parentId
*/
private CPPage addItem(VFSItem item, String parentId, boolean isRoot) {
CPManager cpMgr = CPManager.getInstance();
// Make an item in the menu tree only if the item is a container that
// contains any items to be added or its type is selected in the form.
// Upload any files in case they are referenced to.
// Get the file types that should be added as items in the menu tree
Collection<String> menuItemTypes = checkboxes.getSelectedKeys();
if (menuItemTypes.contains("htm"))
menuItemTypes.add("html");
// show info.
if (isRoot && item instanceof VFSContainer && !containsItemsToAdd((VFSContainer) item, menuItemTypes)) {
showInfo("cpfileuploadcontroller.no.files.imported");
}
CPPage newPage = null;
if (isSingleFile || item instanceof VFSLeaf && isToBeAdded((VFSLeaf) item, menuItemTypes) || item instanceof VFSContainer && containsItemsToAdd((VFSContainer) item, menuItemTypes)) {
// Create the menu item
String newId = cpMgr.addBlankPage(cp, item.getName(), parentId);
newPage = new CPPage(newId, cp);
if (item instanceof VFSLeaf) {
VFSLeaf leaf = (VFSLeaf) item;
newPage.setFile(leaf);
}
cpMgr.updatePage(cp, newPage);
}
// Add any sub items
if (item instanceof VFSContainer && containsItemsToAdd((VFSContainer) item, menuItemTypes)) {
VFSContainer dir = (VFSContainer) item;
addSubItems(dir, newPage.getIdentifier());
}
return newPage;
}
use of org.olat.ims.cp.CPManager in project OpenOLAT by OpenOLAT.
the class CPPage method getResource.
protected CPResource getResource() {
CPResource resource = null;
CPManager mgr = CPManager.getInstance();
DefaultElement resElement = mgr.getElementByIdentifier(cp, idRef);
if (resElement instanceof CPResource) {
resource = (CPResource) resElement;
}
return resource;
}
Aggregations