use of org.olat.restapi.support.vo.CourseInfoVOes in project openolat by klemens.
the class CoursesInfosTest method testGetCourseInfos.
@Test
public void testGetCourseInfos() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI uri = conn.getContextURI().path("repo").path("courses").path("infos").build();
HttpGet get = conn.createGet(uri, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse response = conn.execute(get);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
CourseInfoVOes infos = conn.parse(response, CourseInfoVOes.class);
Assert.assertNotNull(infos);
conn.shutdown();
}
use of org.olat.restapi.support.vo.CourseInfoVOes 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();
}
}
use of org.olat.restapi.support.vo.CourseInfoVOes in project OpenOLAT by OpenOLAT.
the class CoursesInfosTest method testGetCourseInfos.
@Test
public void testGetCourseInfos() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
URI uri = conn.getContextURI().path("repo").path("courses").path("infos").build();
HttpGet get = conn.createGet(uri, MediaType.APPLICATION_JSON + ";pagingspec=1.0", true);
HttpResponse response = conn.execute(get);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
CourseInfoVOes infos = conn.parse(response, CourseInfoVOes.class);
Assert.assertNotNull(infos);
conn.shutdown();
}
use of org.olat.restapi.support.vo.CourseInfoVOes in project openolat by klemens.
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