Search in sources :

Example 81 with RepositoryManager

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

the class CourseElementWebService method updateWiki.

/**
 * Attaches an wiki 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 nodeId The node's id which of this wiki
 * @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 wikiResourceableId The repository entry key of the wiki
 * @param request The HTTP request
 * @return
 */
@POST
@Path("wiki/{nodeId}")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public // fxdiff FXOLAT-122: course management
Response updateWiki(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @FormParam("shortTitle") @DefaultValue("undefined") String shortTitle, @FormParam("longTitle") @DefaultValue("undefined") String longTitle, @FormParam("objectives") @DefaultValue("undefined") String objectives, @FormParam("visibilityExpertRules") String visibilityExpertRules, @FormParam("accessExpertRules") String accessExpertRules, @FormParam("wikiResourceableId") Long wikiResourceableId, @Context HttpServletRequest request) {
    RepositoryEntry wikiRepoEntry = null;
    if (wikiResourceableId != null) {
        RepositoryManager rm = RepositoryManager.getInstance();
        wikiRepoEntry = rm.lookupRepositoryEntry(wikiResourceableId);
        if (wikiRepoEntry == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
    }
    WikiCustomConfig config = new WikiCustomConfig(wikiRepoEntry);
    return update(courseId, nodeId, shortTitle, longTitle, objectives, visibilityExpertRules, accessExpertRules, config, request);
}
Also used : RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 82 with RepositoryManager

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

the class CourseElementWebService method updateBlog.

/**
 * Update 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 nodeId The node's id of this blog
 * @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
 */
@POST
@Path("blog/{nodeId}")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public // fxdiff FXOLAT-122: course management
Response updateBlog(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @FormParam("shortTitle") @DefaultValue("undefined") String shortTitle, @FormParam("longTitle") @DefaultValue("undefined") String longTitle, @FormParam("objectives") @DefaultValue("undefined") String objectives, @FormParam("visibilityExpertRules") String visibilityExpertRules, @FormParam("accessExpertRules") String accessExpertRules, @FormParam("repoEntry") Long blogResourceableId, @Context HttpServletRequest request) {
    RepositoryEntry blogRepoEntry = null;
    if (blogResourceableId != null) {
        RepositoryManager rm = RepositoryManager.getInstance();
        blogRepoEntry = rm.lookupRepositoryEntry(blogResourceableId);
        if (blogRepoEntry == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
    }
    BlogCustomConfig config = new BlogCustomConfig(blogRepoEntry);
    return update(courseId, nodeId, shortTitle, longTitle, objectives, visibilityExpertRules, accessExpertRules, config, request);
}
Also used : RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 83 with RepositoryManager

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

the class CourseElementWebService method attachWiki.

/**
 * Attaches an wiki 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 request The HTTP request
 * @return
 */
@PUT
@Path("wiki")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response attachWiki(@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("wikiResourceableId") Long wikiResourceableId, @Context HttpServletRequest request) {
    RepositoryManager rm = RepositoryManager.getInstance();
    RepositoryEntry wikiRepoEntry = rm.lookupRepositoryEntry(wikiResourceableId);
    if (wikiRepoEntry == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    WikiCustomConfig config = new WikiCustomConfig(wikiRepoEntry);
    return attach(courseId, parentNodeId, "wiki", 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 84 with RepositoryManager

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

the class CourseElementWebService method attachSurveyPost.

/**
 * Attaches an survey 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 request The HTTP request
 * @return
 */
@POST
@Path("survey/{nodeId}")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response attachSurveyPost(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @FormParam("shortTitle") @DefaultValue("undefined") String shortTitle, @FormParam("longTitle") @DefaultValue("undefined") String longTitle, @FormParam("objectives") @DefaultValue("undefined") String objectives, @FormParam("visibilityExpertRules") String visibilityExpertRules, @FormParam("accessExpertRules") String accessExpertRules, @FormParam("surveyResourceableId") Long surveyResourceableId, @Context HttpServletRequest request) {
    RepositoryManager rm = RepositoryManager.getInstance();
    RepositoryEntry surveyRepoEntry = rm.lookupRepositoryEntry(surveyResourceableId);
    if (surveyRepoEntry == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    CustomConfigDelegate config = CustomConfigFactory.getSurveyCustomConfig(surveyRepoEntry);
    return update(courseId, nodeId, shortTitle, longTitle, objectives, visibilityExpertRules, accessExpertRules, config, request);
}
Also used : RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 85 with RepositoryManager

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

the class CoursesInfosWebService method getCourseInfoList.

/**
 * Get courses informations viewable by the authenticated user
 * @response.representation.200.qname {http://www.example.com}courseVO
 * @response.representation.200.mediaType application/xml, application/json, application/json;pagingspec=1.0
 * @response.representation.200.doc List of visible courses
 * @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_COURSEINFOVOes}
 * @param start
 * @param limit
 * @param httpRequest The HTTP request
 * @param request The REST request
 * @return
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getCourseInfoList(@QueryParam("start") @DefaultValue("0") Integer start, @QueryParam("limit") @DefaultValue("25") Integer limit, @Context HttpServletRequest httpRequest, @Context Request request) {
    RepositoryManager rm = RepositoryManager.getInstance();
    // fxdiff VCRP-1,2: access control of resources
    Roles roles = getRoles(httpRequest);
    Identity identity = getIdentity(httpRequest);
    SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(identity, roles, CourseModule.getCourseTypeName());
    if (MediaTypeVariants.isPaged(httpRequest, request)) {
        int totalCount = rm.countGenericANDQueryWithRolesRestriction(params);
        List<RepositoryEntry> repoEntries = rm.genericANDQueryWithRolesRestriction(params, start, limit, true);
        List<CourseInfoVO> infos = new ArrayList<CourseInfoVO>();
        final Set<Long> forumNotified = new HashSet<Long>();
        final Map<Long, Set<String>> courseNotified = new HashMap<Long, Set<String>>();
        collectSubscriptions(identity, forumNotified, courseNotified);
        for (RepositoryEntry entry : repoEntries) {
            CourseInfoVO info = collect(identity, roles, entry, forumNotified, courseNotified);
            if (info != null) {
                infos.add(info);
            }
        }
        CourseInfoVO[] vos = infos.toArray(new CourseInfoVO[infos.size()]);
        CourseInfoVOes voes = new CourseInfoVOes();
        voes.setInfos(vos);
        voes.setTotalCount(totalCount);
        return Response.ok(voes).build();
    } else {
        return Response.serverError().status(Status.FORBIDDEN).build();
    }
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) CourseInfoVOes(org.olat.restapi.support.vo.CourseInfoVOes) ArrayList(java.util.ArrayList) Roles(org.olat.core.id.Roles) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryManager(org.olat.repository.RepositoryManager) Identity(org.olat.core.id.Identity) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) CourseInfoVO(org.olat.restapi.support.vo.CourseInfoVO) HashSet(java.util.HashSet) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

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