Search in sources :

Example 36 with RepositoryManager

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;
}
Also used : RepositoryManager(org.olat.repository.RepositoryManager) File(java.io.File)

Example 37 with RepositoryManager

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;
}
Also used : UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) RepositoryManager(org.olat.repository.RepositoryManager) Roles(org.olat.core.id.Roles) RepositoryEntry(org.olat.repository.RepositoryEntry) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation)

Example 38 with RepositoryManager

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;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) RepositoryManager(org.olat.repository.RepositoryManager) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) RepositoryEntry(org.olat.repository.RepositoryEntry) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 39 with RepositoryManager

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;
}
Also used : NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) VideoExportMediaResource(org.olat.modules.video.manager.VideoExportMediaResource) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) VideoManager(org.olat.modules.video.VideoManager)

Example 40 with RepositoryManager

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);
}
Also used : RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry)

Aggregations

RepositoryManager (org.olat.repository.RepositoryManager)136 RepositoryEntry (org.olat.repository.RepositoryEntry)122 Path (javax.ws.rs.Path)42 Identity (org.olat.core.id.Identity)32 Produces (javax.ws.rs.Produces)30 Roles (org.olat.core.id.Roles)30 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)26 ArrayList (java.util.ArrayList)20 Consumes (javax.ws.rs.Consumes)20 PUT (javax.ws.rs.PUT)18 MailPackage (org.olat.core.util.mail.MailPackage)16 GET (javax.ws.rs.GET)14 BaseSecurity (org.olat.basesecurity.BaseSecurity)14 AssertException (org.olat.core.logging.AssertException)14 SearchRepositoryEntryParameters (org.olat.repository.model.SearchRepositoryEntryParameters)14 IdentitiesAddEvent (org.olat.admin.securitygroup.gui.IdentitiesAddEvent)12 Controller (org.olat.core.gui.control.Controller)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 UserRequest (org.olat.core.gui.UserRequest)10 WindowControl (org.olat.core.gui.control.WindowControl)10