Search in sources :

Example 16 with RepositoryManager

use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.

the class CourseElementWebService method attachBlog.

/**
 * Attaches an blog building block.
 * @response.representation.mediaType application/x-www-form-urlencoded
 * @response.representation.doc The assessment node metadatas
 * @response.representation.200.qname {http://www.example.com}courseNodeVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc The course node metadatas
 * @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_COURSENODEVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The course or parentNode not found
 * @param courseId The course resourceable's id
 * @param parentNodeId The node's id which will be the parent of this assessment
 * @param position The node's position relative to its sibling nodes (optional)
 * @param shortTitle The node short title
 * @param longTitle The node long title
 * @param objectives The node learning objectives
 * @param visibilityExpertRules The rules to view the node (optional)
 * @param accessExpertRules The rules to access the node (optional)
 * @param blogResourceableId The softkey of the blog resourceable (optional)
 * @param request The HTTP request
 * @return
 */
@PUT
@Path("blog")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response attachBlog(@PathParam("courseId") Long courseId, @QueryParam("parentNodeId") String parentNodeId, @QueryParam("position") Integer position, @QueryParam("shortTitle") @DefaultValue("undefined") String shortTitle, @QueryParam("longTitle") @DefaultValue("undefined") String longTitle, @QueryParam("objectives") @DefaultValue("undefined") String objectives, @QueryParam("visibilityExpertRules") String visibilityExpertRules, @QueryParam("accessExpertRules") String accessExpertRules, @QueryParam("repoEntry") Long blogResourceableId, @Context HttpServletRequest request) {
    RepositoryManager rm = RepositoryManager.getInstance();
    RepositoryEntry blogRepoEntry = rm.lookupRepositoryEntry(blogResourceableId);
    if (blogRepoEntry == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    BlogCustomConfig config = new BlogCustomConfig(blogRepoEntry);
    return attach(courseId, parentNodeId, "blog", position, shortTitle, longTitle, objectives, visibilityExpertRules, accessExpertRules, config, request);
}
Also used : RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 17 with RepositoryManager

use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.

the class RepositoryEntriesResource method getEntries.

/**
 * List all entries in the OLAT repository
 * @response.representation.200.qname {http://www.example.com}repositoryEntryVO
 * @response.representation.200.mediaType text/plain, text/html, application/xml, application/json
 * @response.representation.200.doc List all entries in the repository
 * @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_REPOENTRYVOes}
 * @param start (optional)
 * @param limit (optional)
 * @param managed (optional)
 * @param externalId External ID (optional)
 * @param externalRef External reference number (optional)
 * @param resourceType The resource type (CourseModule) (optional)
 * @param httpRequest The HTTP request
 * @param request The RESt request
 * @return
 */
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getEntries(@QueryParam("start") @DefaultValue("0") Integer start, @QueryParam("limit") @DefaultValue("25") Integer limit, @QueryParam("managed") Boolean managed, @QueryParam("externalId") String externalId, @QueryParam("externalRef") String externalRef, @QueryParam("resourceType") String resourceType, @Context HttpServletRequest httpRequest, @Context Request request) {
    try {
        // list of courses open for everybody
        Roles roles = getRoles(httpRequest);
        Identity identity = getIdentity(httpRequest);
        RepositoryManager rm = RepositoryManager.getInstance();
        SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(identity, roles);
        params.setManaged(managed);
        if (StringHelper.containsNonWhitespace(externalId)) {
            params.setExternalId(externalId);
        }
        if (StringHelper.containsNonWhitespace(externalRef)) {
            params.setExternalRef(externalRef);
        }
        if (StringHelper.containsNonWhitespace(resourceType)) {
            params.setResourceTypes(Collections.singletonList(resourceType));
        }
        if (MediaTypeVariants.isPaged(httpRequest, request)) {
            int totalCount = rm.countGenericANDQueryWithRolesRestriction(params);
            List<RepositoryEntry> res = rm.genericANDQueryWithRolesRestriction(params, start, limit, true);
            RepositoryEntryVOes voes = new RepositoryEntryVOes();
            voes.setRepositoryEntries(toArrayOfVOes(res));
            voes.setTotalCount(totalCount);
            return Response.ok(voes).build();
        } else {
            List<RepositoryEntry> res = rm.genericANDQueryWithRolesRestriction(params, 0, -1, false);
            RepositoryEntryVO[] voes = toArrayOfVOes(res);
            return Response.ok(voes).build();
        }
    } catch (Exception e) {
        throw new WebApplicationException(e);
    }
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) RepositoryEntryVOes(org.olat.restapi.support.vo.RepositoryEntryVOes) RepositoryEntryVO(org.olat.restapi.support.vo.RepositoryEntryVO) WebApplicationException(javax.ws.rs.WebApplicationException) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) Identity(org.olat.core.id.Identity) WebApplicationException(javax.ws.rs.WebApplicationException) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 18 with RepositoryManager

use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.

the class RepositoryEntriesResource method getRepositoryEntryResource.

@Path("{repoEntryKey}")
public RepositoryEntryResource getRepositoryEntryResource() {
    RepositoryManager rm = RepositoryManager.getInstance();
    BaseSecurity securityManager = BaseSecurityManager.getInstance();
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    return new RepositoryEntryResource(rm, repositoryService, securityManager);
}
Also used : RepositoryManager(org.olat.repository.RepositoryManager) BaseSecurity(org.olat.basesecurity.BaseSecurity) RepositoryService(org.olat.repository.RepositoryService) Path(javax.ws.rs.Path)

Example 19 with RepositoryManager

use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.

the class OpenOLATStatisticsWebService method getRepositoryStatisticsVO.

private RepositoryStatisticsVO getRepositoryStatisticsVO() {
    RepositoryStatisticsVO stats = new RepositoryStatisticsVO();
    RepositoryManager repoMgr = CoreSpringFactory.getImpl(RepositoryManager.class);
    int allCourses = repoMgr.countByTypeLimitAccess(CourseModule.ORES_TYPE_COURSE, RepositoryEntry.ACC_OWNERS);
    int publishedCourses = repoMgr.countByTypeLimitAccess(CourseModule.ORES_TYPE_COURSE, RepositoryEntry.ACC_USERS);
    stats.setCoursesCount(allCourses);
    stats.setPublishedCoursesCount(publishedCourses);
    return stats;
}
Also used : RepositoryStatisticsVO(org.olat.restapi.system.vo.RepositoryStatisticsVO) RepositoryManager(org.olat.repository.RepositoryManager)

Example 20 with RepositoryManager

use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.

the class ViteroCourseNode method createNodeRunConstructionResult.

@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    updateModuleConfigDefaults(false);
    Controller runCtr;
    Roles roles = ureq.getUserSession().getRoles();
    if (roles.isGuestOnly()) {
        Translator trans = Util.createPackageTranslator(ViteroPeekViewController.class, ureq.getLocale());
        String title = trans.translate("guestnoaccess.title");
        String message = trans.translate("guestnoaccess.message");
        runCtr = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
    } else {
        // check if user is moderator of the virtual classroom
        boolean moderator = roles.isOLATAdmin();
        Long key = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
        if (!moderator) {
            if (roles.isInstitutionalResourceManager() | roles.isAuthor()) {
                RepositoryManager rm = RepositoryManager.getInstance();
                ICourse course = CourseFactory.loadCourse(key);
                RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
                if (re != null) {
                    moderator = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re);
                    if (!moderator) {
                        moderator = rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), ureq.getUserSession().getRoles(), re);
                    }
                }
            }
        }
        // create run controller
        Long resourceId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
        OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.class, resourceId);
        String courseTitle = userCourseEnv.getCourseEnvironment().getCourseTitle();
        runCtr = new ViteroBookingsRunController(ureq, wControl, null, ores, getIdent(), courseTitle, moderator, userCourseEnv.isCourseReadOnly());
    }
    Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, runCtr, this, "o_vitero_icon");
    return new NodeRunConstructionResult(controller);
}
Also used : Translator(org.olat.core.gui.translator.Translator) OLATResourceable(org.olat.core.id.OLATResourceable) Roles(org.olat.core.id.Roles) RepositoryManager(org.olat.repository.RepositoryManager) ICourse(org.olat.course.ICourse) ViteroBookingsRunController(org.olat.modules.vitero.ui.ViteroBookingsRunController) RepositoryEntry(org.olat.repository.RepositoryEntry) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) ViteroBookingsRunController(org.olat.modules.vitero.ui.ViteroBookingsRunController) Controller(org.olat.core.gui.control.Controller) NodeEditController(org.olat.course.editor.NodeEditController) ViteroEditController(org.olat.course.nodes.vitero.ViteroEditController) ViteroPeekViewController(org.olat.course.nodes.vitero.ViteroPeekViewController) ConditionEditController(org.olat.course.condition.ConditionEditController) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult)

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