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