use of org.olat.restapi.support.vo.CourseVOes in project openolat by klemens.
the class UserCoursesWebService method getMyCourses.
/**
* Retrieves the list of "My entries" but limited to courses.
* @response.representation.200.qname {http://www.example.com}courseVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The courses
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_COURSEVOes}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param start The first result
* @param limit Max result
* @param httpRequest The HTTP request
* @param request The REST request
* @return The list of my entries
*/
@GET
@Path("my")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getMyCourses(@QueryParam("start") @DefaultValue("0") Integer start, @QueryParam("limit") @DefaultValue("25") Integer limit, @Context HttpServletRequest httpRequest, @Context Request request) {
RepositoryManager rm = RepositoryManager.getInstance();
if (MediaTypeVariants.isPaged(httpRequest, request)) {
List<RepositoryEntry> repoEntries = rm.getLearningResourcesAsStudent(identity, null, start, limit, RepositoryEntryOrder.nameAsc);
int totalCount = rm.countLearningResourcesAsStudent(identity);
CourseVO[] vos = toCourseVo(repoEntries);
CourseVOes voes = new CourseVOes();
voes.setCourses(vos);
voes.setTotalCount(totalCount);
return Response.ok(voes).build();
} else {
List<RepositoryEntry> repoEntries = rm.getLearningResourcesAsStudent(identity, null, 0, -1, RepositoryEntryOrder.nameAsc);
CourseVO[] vos = toCourseVo(repoEntries);
return Response.ok(vos).build();
}
}
Aggregations