use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class QTI21AssessmentTestHandler method copyMetadata.
private RepositoryEntry copyMetadata(RepositoryEntry originalRe, RepositoryEntry re, File targetDirectory) {
// copy some metadata
re.setAuthors(originalRe.getAuthors());
re.setDescription(originalRe.getDescription());
re.setObjectives(originalRe.getObjectives());
re.setRequirements(originalRe.getRequirements());
re.setExpenditureOfWork(originalRe.getExpenditureOfWork());
re.setCredits(originalRe.getCredits());
re.setLocation(originalRe.getLocation());
RepositoryManager repositoryManager = CoreSpringFactory.getImpl(RepositoryManager.class);
repositoryManager.copyImage(originalRe, re);
File resourceFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(originalRe.getOlatResource()).getBasefile();
FileUtils.copyDirToDir(new File(resourceFileroot, "media"), targetDirectory.getParentFile(), "copy media folder");
re = CoreSpringFactory.getImpl(RepositoryService.class).update(re);
return re;
}
use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class FeedMediaDispatcher method hasAccess.
/**
* Verifies the access of an identity to a course node.
*
* @param identity
* @param token
* @param course
* @param node
* @return True if the identity has access to the node in the given course.
* False otherwise.
*/
private boolean hasAccess(Identity identity, String token, ICourse course, CourseNode node) {
boolean hasAccess = false;
final RepositoryManager resMgr = RepositoryManager.getInstance();
final RepositoryEntry repoEntry = resMgr.lookupRepositoryEntry(course, false);
if (allowsGuestAccess(repoEntry)) {
hasAccess = true;
} else {
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(identity);
Roles roles = BaseSecurityManager.getInstance().getRoles(identity);
ienv.setRoles(roles);
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
// Build an evaluation tree
TreeEvaluation treeEval = new TreeEvaluation();
NodeEvaluation nodeEval = node.eval(userCourseEnv.getConditionInterpreter(), treeEval, new VisibleTreeFilter());
if (nodeEval.isVisible() && validAuthentication(identity, token)) {
hasAccess = true;
}
}
return hasAccess;
}
use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class FeedViewHelper method getJumpInLink.
/**
* @param feed
* the target feed for the jumpInLink
* @param item
* the target item for the jumpInLink or null if not want to
* refer to a specific item
* @return the jump in link
*/
public String getJumpInLink(Feed feed, Item item) {
String jumpInLink = null;
RepositoryManager resMgr = RepositoryManager.getInstance();
if (courseId != null && nodeId != null) {
OLATResourceable oresCourse = OLATResourceManager.getInstance().findResourceable(courseId, CourseModule.getCourseTypeName());
OLATResourceable oresNode = OresHelper.createOLATResourceableInstance("CourseNode", Long.valueOf(nodeId));
RepositoryEntry repositoryEntry = resMgr.lookupRepositoryEntry(oresCourse, false);
List<ContextEntry> ces = new ArrayList<>();
ces.add(BusinessControlFactory.getInstance().createContextEntry(repositoryEntry));
ces.add(BusinessControlFactory.getInstance().createContextEntry(oresNode));
jumpInLink = BusinessControlFactory.getInstance().getAsURIString(ces, false);
} else {
RepositoryEntry repositoryEntry = resMgr.lookupRepositoryEntry(feed, false);
if (repositoryEntry != null) {
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(repositoryEntry);
jumpInLink = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
} else {
// its a liveblog-helperFeed
final BusinessControlFactory bCF = BusinessControlFactory.getInstance();
String feedBP = LiveBlogArtefactHandler.LIVEBLOG + feed.getResourceableId() + "]";
final List<ContextEntry> ceList = bCF.createCEListFromString(feedBP);
jumpInLink = bCF.getAsURIString(ceList, true);
}
}
if (item != null && jumpInLink != null) {
jumpInLink += "/item=" + item.getKey() + "/0";
}
return jumpInLink;
}
use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class VideoHandler method getAsMediaResource.
@Override
public MediaResource getAsMediaResource(OLATResourceable res, boolean backwardsCompatible) {
RepositoryManager repoManager = CoreSpringFactory.getImpl(RepositoryManager.class);
RepositoryEntry repoEntry = repoManager.lookupRepositoryEntry(res, false);
if (repoEntry == null) {
return new NotFoundMediaResource();
}
VideoManager videoManager = CoreSpringFactory.getImpl(VideoManager.class);
VideoExportMediaResource exportResource = videoManager.getVideoExportMediaResource(repoEntry);
return exportResource;
}
use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class RepositorySearchController method doSearchByOwnerLimitTypeInternal.
private void doSearchByOwnerLimitTypeInternal(Identity owner, String[] limitTypes, boolean updateFilters) {
searchType = SearchType.byOwner;
RepositoryManager rm = RepositoryManager.getInstance();
List<RepositoryEntry> entries = rm.queryByOwner(owner, limitTypes);
filterRepositoryEntries(entries);
if (updateFilters) {
updateFilters(entries, owner);
}
repoTableModel.setObjects(entries);
tableCtr.modelChanged(updateFilters);
displaySearchResults(null);
}
Aggregations