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());
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations