Search in sources :

Example 1 with EPFrontendManager

use of org.olat.portfolio.manager.EPFrontendManager in project OpenOLAT by OpenOLAT.

the class PortfolioCourseNode method importNode.

@Override
public void importNode(File importDirectory, ICourse course, Identity owner, Locale locale, boolean withReferences) {
    RepositoryEntryImportExport rie = new RepositoryEntryImportExport(importDirectory, getIdent());
    if (withReferences && rie.anyExportedPropertiesAvailable()) {
        RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(EPTemplateMapResource.TYPE_NAME);
        RepositoryEntry re = handler.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
        if (re != null) {
            EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
            PortfolioStructure map = ePFMgr.loadPortfolioStructure(re.getOlatResource());
            PortfolioCourseNodeEditController.setReference(re, map, getModuleConfiguration());
        } else {
            PortfolioCourseNodeEditController.removeReference(getModuleConfiguration());
        }
    } else {
        PortfolioCourseNodeEditController.removeReference(getModuleConfiguration());
    }
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) RepositoryEntry(org.olat.repository.RepositoryEntry) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager)

Example 2 with EPFrontendManager

use of org.olat.portfolio.manager.EPFrontendManager in project OpenOLAT by OpenOLAT.

the class FeedMediaDispatcher method hasAccess.

/**
 * Verifiy if the identity has access to the feed.
 *
 * @param identity
 * @param token
 * @param feed
 * @return true if the identity has access.
 */
private boolean hasAccess(Identity identity, String token, OLATResourceable feed) {
    boolean hasAccess = false;
    RepositoryManager resMgr = RepositoryManager.getInstance();
    RepositoryEntry repoEntry = resMgr.lookupRepositoryEntry(feed, false);
    if (allowsGuestAccess(repoEntry)) {
        hasAccess = true;
    } else if (identity != null) {
        if (repoEntry != null) {
            final Roles roles = BaseSecurityManager.getInstance().getRoles(identity);
            final boolean isAllowedToLaunch = resMgr.isAllowedToLaunch(identity, roles, repoEntry);
            if (isAllowedToLaunch && validAuthentication(identity, token)) {
                hasAccess = true;
            }
        } else {
            // no repository entry -> could be a feed without a repository-entry (ePortfolio-Blog-feed)
            EPFrontendManager ePFMgr = (EPFrontendManager) CoreSpringFactory.getBean("epFrontendManager");
            if (ePFMgr.checkFeedAccess(feed, identity)) {
                return validAuthentication(identity, token);
            }
        }
    }
    return hasAccess;
}
Also used : RepositoryManager(org.olat.repository.RepositoryManager) Roles(org.olat.core.id.Roles) RepositoryEntry(org.olat.repository.RepositoryEntry) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager)

Example 3 with EPFrontendManager

use of org.olat.portfolio.manager.EPFrontendManager in project OpenOLAT by OpenOLAT.

the class PortfolioHandler method copy.

@Override
public RepositoryEntry copy(Identity author, RepositoryEntry source, RepositoryEntry target) {
    OLATResource sourceResource = source.getOlatResource();
    OLATResource targetResource = target.getOlatResource();
    EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
    PortfolioStructure structure = ePFMgr.loadPortfolioStructure(sourceResource);
    PortfolioStructure newStructure = EPXStreamHandler.copy(structure);
    ePFMgr.importPortfolioMapTemplate(newStructure, targetResource);
    return target;
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager)

Example 4 with EPFrontendManager

use of org.olat.portfolio.manager.EPFrontendManager in project OpenOLAT by OpenOLAT.

the class PortfolioHandler method createResource.

@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
    EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
    EPStructureManager eSTMgr = CoreSpringFactory.getImpl(EPStructureManager.class);
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    OLATResource resource = eSTMgr.createPortfolioMapTemplateResource();
    RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
    PortfolioStructureMap mapTemp = eSTMgr.createAndPersistPortfolioMapTemplateFromEntry(initialAuthor, re);
    // add a page, as each map should have at least one per default!
    Translator pt = Util.createPackageTranslator(EPCreateMapController.class, locale);
    String pageTitle = pt.translate("new.page.title");
    String pageDescription = pt.translate("new.page.desc");
    ePFMgr.createAndPersistPortfolioPage(mapTemp, pageTitle, pageDescription);
    DBFactory.getInstance().commit();
    return re;
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Translator(org.olat.core.gui.translator.Translator) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager) EPStructureManager(org.olat.portfolio.manager.EPStructureManager) RepositoryService(org.olat.repository.RepositoryService)

Example 5 with EPFrontendManager

use of org.olat.portfolio.manager.EPFrontendManager in project OpenOLAT by OpenOLAT.

the class PortfolioHandler method getAsMediaResource.

/**
 * Transform the map in a XML file and zip it (Repository export want a zip)
 * @see org.olat.repository.handlers.RepositoryHandler#getAsMediaResource(org.olat.core.id.OLATResourceable)
 */
@Override
public MediaResource getAsMediaResource(OLATResourceable res, boolean backwardsCompatible) {
    MediaResource mr = null;
    EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
    PortfolioStructure structure = ePFMgr.loadPortfolioStructure(res);
    try {
        InputStream inOut = EPXStreamHandler.toStream(structure);
        mr = new StreamedMediaResource(inOut, null, null, null);
    } catch (IOException e) {
        log.error("Cannot export this map: " + structure, e);
    }
    return mr;
}
Also used : InputStream(java.io.InputStream) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) MediaResource(org.olat.core.gui.media.MediaResource) StreamedMediaResource(org.olat.core.gui.media.StreamedMediaResource) IOException(java.io.IOException) StreamedMediaResource(org.olat.core.gui.media.StreamedMediaResource) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager)

Aggregations

EPFrontendManager (org.olat.portfolio.manager.EPFrontendManager)20 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)10 RepositoryEntry (org.olat.repository.RepositoryEntry)8 Translator (org.olat.core.gui.translator.Translator)6 OLATResource (org.olat.resource.OLATResource)6 EPStructureManager (org.olat.portfolio.manager.EPStructureManager)4 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)4 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CalendarController (org.olat.commons.calendar.ui.CalendarController)2 WeeklyCalendarController (org.olat.commons.calendar.ui.WeeklyCalendarController)2 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)2 Controller (org.olat.core.gui.control.Controller)2 MediaResource (org.olat.core.gui.media.MediaResource)2 StreamedMediaResource (org.olat.core.gui.media.StreamedMediaResource)2 Roles (org.olat.core.id.Roles)2 EfficiencyStatement (org.olat.course.assessment.EfficiencyStatement)2