Search in sources :

Example 1 with CPPackageConfig

use of org.olat.ims.cp.ui.CPPackageConfig in project OpenOLAT by OpenOLAT.

the class CPManagerImpl method getCPPackageConfig.

@Override
public CPPackageConfig getCPPackageConfig(OLATResourceable ores) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File reFolder = frm.getFileResourceRoot(ores);
    File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
    CPPackageConfig config;
    if (configXml.exists()) {
        config = (CPPackageConfig) configXstream.fromXML(configXml);
    } else {
        // set default config
        config = new CPPackageConfig();
        config.setDeliveryOptions(DeliveryOptions.defaultWithGlossary());
        setCPPackageConfig(ores, config);
    }
    return config;
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) CPPackageConfig(org.olat.ims.cp.ui.CPPackageConfig) File(java.io.File)

Example 2 with CPPackageConfig

use of org.olat.ims.cp.ui.CPPackageConfig in project OpenOLAT by OpenOLAT.

the class CPManagerImpl method createNewCP.

/**
 * @see org.olat.ims.cp.CPManager#createNewCP(org.olat.core.id.OLATResourceable)
 */
public ContentPackage createNewCP(OLATResourceable ores, String initalPageTitle) {
    // copy template cp to new repo-location
    if (copyTemplCP(ores)) {
        File cpRoot = FileResourceManager.getInstance().unzipFileResource(ores);
        logDebug("createNewCP: cpRoot=" + cpRoot);
        logDebug("createNewCP: cpRoot.getAbsolutePath()=" + cpRoot.getAbsolutePath());
        LocalFolderImpl vfsWrapper = new LocalFolderImpl(cpRoot);
        ContentPackage cp = load(vfsWrapper, ores);
        // Modify the copy of the template to get a unique identifier
        CPOrganization orga = setUniqueOrgaIdentifier(cp);
        setOrgaTitleToRepoEntryTitle(ores, orga);
        // Also set the translated title of the inital page.
        orga.getItems().get(0).setTitle(initalPageTitle);
        writeToFile(cp);
        // set the default settings for file delivery
        DeliveryOptions defOptions = DeliveryOptions.defaultWithGlossary();
        CPPackageConfig config = new CPPackageConfig();
        config.setDeliveryOptions(defOptions);
        setCPPackageConfig(ores, config);
        return cp;
    } else {
        logError("CP couldn't be created. Error when copying template. Ores: " + ores.getResourceableId(), null);
        throw new OLATRuntimeException("ERROR while creating new empty cp. an error occured while trying to copy template CP", null);
    }
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) CPPackageConfig(org.olat.ims.cp.ui.CPPackageConfig) File(java.io.File) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) CPOrganization(org.olat.ims.cp.objects.CPOrganization) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 3 with CPPackageConfig

use of org.olat.ims.cp.ui.CPPackageConfig in project OpenOLAT by OpenOLAT.

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 4 with CPPackageConfig

use of org.olat.ims.cp.ui.CPPackageConfig in project openolat by klemens.

the class CPRunController method doLaunch.

private void doLaunch(UserRequest ureq) {
    DeliveryOptions deliveryOptions = (DeliveryOptions) config.get(CPEditController.CONFIG_DELIVERYOPTIONS);
    if (cpRoot == null) {
        // it is the first time we start the contentpackaging from this instance
        // of this controller.
        // need to be strict when launching -> "true"
        RepositoryEntry re = CPEditController.getCPReference(config, false);
        if (re == null) {
            showError(CPEditController.NLS_ERROR_CPREPOENTRYMISSING);
            return;
        }
        cpRoot = FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
        // nodes reference them
        if (cpRoot == null) {
            showError(CPEditController.NLS_ERROR_CPREPOENTRYMISSING);
            return;
        }
        if (deliveryOptions != null && deliveryOptions.getInherit() != null && deliveryOptions.getInherit().booleanValue()) {
            CPPackageConfig packageConfig = CPManager.getInstance().getCPPackageConfig(re.getOlatResource());
            if (packageConfig != null && packageConfig.getDeliveryOptions() != null) {
                deliveryOptions = packageConfig.getDeliveryOptions();
            }
        }
    }
    // else cpRoot is already set (save some db access if the user opens /
    // closes / reopens the cp from the same CPRuncontroller instance)
    boolean activateFirstPage = true;
    if ((nodecmd != null) && !nodecmd.equals("")) {
        activateFirstPage = false;
    }
    boolean showNavigation = !config.getBooleanSafe(NodeEditController.CONFIG_COMPONENT_MENU);
    cpDispC = CPUIFactory.getInstance().createContentOnlyCPDisplayController(ureq, getWindowControl(), new LocalFolderImpl(cpRoot), activateFirstPage, showNavigation, deliveryOptions, nodecmd, courseResource, cpNode.getIdent(), preview);
    cpDispC.setContentEncoding(deliveryOptions.getContentEncoding());
    cpDispC.setJSEncoding(deliveryOptions.getJavascriptEncoding());
    cpDispC.addControllerListener(this);
    main.setContent(cpDispC.getInitialComponent());
    if (isExternalMenuConfigured()) {
        treeModel = cpDispC.getTreeModel();
        treeNodeClickListener = this;
        if (activateFirstPage) {
            selNodeId = cpDispC.getInitialSelectedNodeId();
        } else {
            String uri = nodecmd;
            if (uri.startsWith("/")) {
                uri = uri.substring(1, uri.length());
            }
            selNodeId = cpDispC.getNodeByUri(uri);
        }
    }
}
Also used : CPPackageConfig(org.olat.ims.cp.ui.CPPackageConfig) RepositoryEntry(org.olat.repository.RepositoryEntry) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 5 with CPPackageConfig

use of org.olat.ims.cp.ui.CPPackageConfig in project openolat by klemens.

the class ImsCPHandler method createLaunchController.

@Override
public MainLayoutController createLaunchController(RepositoryEntry re, RepositoryEntrySecurity reSecurity, UserRequest ureq, WindowControl wControl) {
    OLATResource res = re.getOlatResource();
    File cpRoot = FileResourceManager.getInstance().unzipFileResource(res);
    final LocalFolderImpl vfsWrapper = new LocalFolderImpl(cpRoot);
    CPPackageConfig packageConfig = CPManager.getInstance().getCPPackageConfig(res);
    final DeliveryOptions deliveryOptions = (packageConfig == null ? null : packageConfig.getDeliveryOptions());
    return new CPRuntimeController(ureq, wControl, re, reSecurity, new RuntimeControllerCreator() {

        @Override
        public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
            boolean activateFirstPage = true;
            String initialUri = null;
            CoreSpringFactory.getImpl(UserCourseInformationsManager.class).updateUserCourseInformations(entry.getOlatResource(), uureq.getIdentity());
            CPDisplayController cpCtr = new CPDisplayController(uureq, wwControl, vfsWrapper, true, true, activateFirstPage, true, deliveryOptions, initialUri, entry.getOlatResource(), "", false);
            MainLayout3ColumnsController ctr = new LayoutMain3ColsController(uureq, wwControl, cpCtr.getMenuComponent(), cpCtr.getInitialComponent(), vfsWrapper.getName());
            ctr.addDisposableChildController(cpCtr);
            return ctr;
        }
    });
}
Also used : TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) AssessmentMode(org.olat.course.assessment.AssessmentMode) MainLayout3ColumnsController(org.olat.core.gui.control.generic.layout.MainLayout3ColumnsController) CPDisplayController(org.olat.modules.cp.CPDisplayController) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) MainLayout3ColumnsController(org.olat.core.gui.control.generic.layout.MainLayout3ColumnsController) CPContentController(org.olat.ims.cp.ui.CPContentController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CPDisplayController(org.olat.modules.cp.CPDisplayController) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) CPRuntimeController(org.olat.ims.cp.ui.CPRuntimeController) CPEditMainController(org.olat.ims.cp.ui.CPEditMainController) Controller(org.olat.core.gui.control.Controller) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl) RuntimeControllerCreator(org.olat.repository.ui.RepositoryEntryRuntimeController.RuntimeControllerCreator) CPRuntimeController(org.olat.ims.cp.ui.CPRuntimeController) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CPPackageConfig(org.olat.ims.cp.ui.CPPackageConfig) File(java.io.File) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

CPPackageConfig (org.olat.ims.cp.ui.CPPackageConfig)14 File (java.io.File)8 DeliveryOptions (org.olat.core.gui.control.generic.iframe.DeliveryOptions)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)6 OLATResource (org.olat.resource.OLATResource)4 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 UserRequest (org.olat.core.gui.UserRequest)2 TooledStackedPanel (org.olat.core.gui.components.stack.TooledStackedPanel)2 Controller (org.olat.core.gui.control.Controller)2 WindowControl (org.olat.core.gui.control.WindowControl)2 MainLayout3ColumnsController (org.olat.core.gui.control.generic.layout.MainLayout3ColumnsController)2 MainLayoutController (org.olat.core.gui.control.generic.layout.MainLayoutController)2 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2 OLog (org.olat.core.logging.OLog)2 AssessmentMode (org.olat.course.assessment.AssessmentMode)2 Condition (org.olat.course.condition.Condition)2 FileResourceManager (org.olat.fileresource.FileResourceManager)2 CPManager (org.olat.ims.cp.CPManager)2