Search in sources :

Example 11 with CPManager

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;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) CPManager(org.olat.ims.cp.CPManager)

Example 12 with CPManager

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;
}
Also used : CPManager(org.olat.ims.cp.CPManager) OLATResource(org.olat.resource.OLATResource) CPPackageConfig(org.olat.ims.cp.ui.CPPackageConfig) File(java.io.File)

Example 13 with CPManager

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"));
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) CPManager(org.olat.ims.cp.CPManager) VFSItem(org.olat.core.util.vfs.VFSItem) NewIframeUriEvent(org.olat.core.gui.control.generic.iframe.NewIframeUriEvent) Event(org.olat.core.gui.control.Event)

Example 14 with CPManager

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;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) CPManager(org.olat.ims.cp.CPManager)

Example 15 with CPManager

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;
}
Also used : DefaultElement(org.dom4j.tree.DefaultElement) CPManager(org.olat.ims.cp.CPManager) CPResource(org.olat.ims.cp.objects.CPResource)

Aggregations

CPManager (org.olat.ims.cp.CPManager)22 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)6 DefaultElement (org.dom4j.tree.DefaultElement)4 TreeNode (org.olat.core.gui.components.tree.TreeNode)4 VFSItem (org.olat.core.util.vfs.VFSItem)4 CPResource (org.olat.ims.cp.objects.CPResource)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)2 Event (org.olat.core.gui.control.Event)2 NewIframeUriEvent (org.olat.core.gui.control.generic.iframe.NewIframeUriEvent)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 CPPackageConfig (org.olat.ims.cp.ui.CPPackageConfig)2 OLATResource (org.olat.resource.OLATResource)2