Search in sources :

Example 16 with EPFrontendManager

use of org.olat.portfolio.manager.EPFrontendManager in project openolat by klemens.

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)

Example 17 with EPFrontendManager

use of org.olat.portfolio.manager.EPFrontendManager in project openolat by klemens.

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 18 with EPFrontendManager

use of org.olat.portfolio.manager.EPFrontendManager in project openolat by klemens.

the class CollaborationTools method createPortfolioController.

/**
 * return an controller for the wiki tool
 * @param ureq
 * @param wControl
 * @return
 */
public Controller createPortfolioController(final UserRequest ureq, final WindowControl wControl, final TooledStackedPanel stackPanel, final BusinessGroup group) {
    final NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    Property mapProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO);
    if (mapProperty != null) {
        return createPortfolioController(ureq, wControl, stackPanel, mapProperty);
    } else {
        return coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Controller>() {

            @Override
            public Controller execute() {
                Controller ctrl;
                Property mapKeyProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO);
                if (mapKeyProperty == null) {
                    PortfolioV2Module moduleV2 = CoreSpringFactory.getImpl(PortfolioV2Module.class);
                    if (moduleV2.isEnabled()) {
                        PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
                        Binder binder = portfolioService.createNewBinder(group.getName(), group.getDescription(), null, null);
                        CoreSpringFactory.getImpl(BinderUserInformationsDAO.class).updateBinderUserInformationsInSync(binder, ureq.getIdentity());
                        mapKeyProperty = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO, null, binder.getKey(), "2", null);
                        BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForBusinessGroup();
                        BinderController binderCtrl = new BinderController(ureq, wControl, stackPanel, secCallback, binder, BinderConfiguration.createBusinessGroupConfig());
                        List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType("Toc");
                        binderCtrl.activate(ureq, entries, null);
                        ctrl = binderCtrl;
                        ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(binder));
                        ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_BINDER_CREATED, getClass());
                    } else {
                        EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
                        PortfolioStructureMap map = ePFMgr.createAndPersistPortfolioDefaultMap(group.getName(), group.getDescription());
                        Translator pT = Util.createPackageTranslator(EPCreateMapController.class, ureq.getLocale());
                        // add a page, as each map should have at least one per default!
                        ePFMgr.createAndPersistPortfolioPage(map, pT.translate("new.page.title"), pT.translate("new.page.desc"));
                        mapKeyProperty = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO, null, map.getKey(), null, null);
                        EPSecurityCallback secCallback = new EPSecurityCallbackImpl(true, true);
                        ctrl = EPUIFactory.createMapViewController(ureq, wControl, map, secCallback);
                    }
                    npm.saveProperty(mapKeyProperty);
                } else {
                    ctrl = createPortfolioController(ureq, wControl, stackPanel, mapProperty);
                }
                return ctrl;
            }
        });
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioV2Module(org.olat.modules.portfolio.PortfolioV2Module) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) WeeklyCalendarController(org.olat.commons.calendar.ui.WeeklyCalendarController) EPCreateMapController(org.olat.portfolio.ui.structel.EPCreateMapController) OpenMeetingsRunController(org.olat.modules.openmeetings.ui.OpenMeetingsRunController) ChatToolController(org.olat.instantMessaging.ui.ChatToolController) CourseLinkProviderController(org.olat.course.run.calendar.CourseLinkProviderController) BinderController(org.olat.modules.portfolio.ui.BinderController) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) ContactFormController(org.olat.modules.co.ContactFormController) Controller(org.olat.core.gui.control.Controller) CalendarController(org.olat.commons.calendar.ui.CalendarController) InfoGroupRunController(org.olat.group.ui.run.InfoGroupRunController) EPSecurityCallbackImpl(org.olat.portfolio.EPSecurityCallbackImpl) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager) Binder(org.olat.modules.portfolio.Binder) PortfolioService(org.olat.modules.portfolio.PortfolioService) BinderController(org.olat.modules.portfolio.ui.BinderController) Translator(org.olat.core.gui.translator.Translator) EPCreateMapController(org.olat.portfolio.ui.structel.EPCreateMapController) EPSecurityCallback(org.olat.portfolio.EPSecurityCallback) ArrayList(java.util.ArrayList) List(java.util.List) NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property)

Example 19 with EPFrontendManager

use of org.olat.portfolio.manager.EPFrontendManager in project openolat by klemens.

the class EfficiencyStatementArtefactHandler method createDetailsController.

@Override
public Controller createDetailsController(UserRequest ureq, WindowControl wControl, AbstractArtefact artefact, boolean readOnlyMode) {
    EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
    String statementXml = ePFMgr.getArtefactFullTextContent(artefact);
    EfficiencyStatement statement = null;
    if (StringHelper.containsNonWhitespace(statementXml)) {
        try {
            statement = (EfficiencyStatement) myXStream.fromXML(statementXml);
        } catch (Exception e) {
            log.error("Cannot load efficiency statement from artefact", e);
        }
    }
    CertificateAndEfficiencyStatementController efficiencyCtrl = new CertificateAndEfficiencyStatementController(wControl, ureq, statement);
    return new LayoutMain3ColsController(ureq, wControl, efficiencyCtrl);
}
Also used : LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CertificateAndEfficiencyStatementController(org.olat.course.certificate.ui.CertificateAndEfficiencyStatementController) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager)

Example 20 with EPFrontendManager

use of org.olat.portfolio.manager.EPFrontendManager in project openolat by klemens.

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)

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