use of org.opencastproject.security.api.JaxbUserList in project opencast by opencast.
the class UserEndpoint method getUsersAsXml.
@GET
@Path("users.xml")
@Produces(MediaType.APPLICATION_XML)
@RestQuery(name = "allusersasxml", description = "Returns a list of users", returnDescription = "Returns a XML representation of the list of user accounts", restParameters = { @RestParameter(description = "The search query, must be at lest 3 characters long.", isRequired = false, name = "query", type = RestParameter.Type.STRING), @RestParameter(defaultValue = "100", description = "The maximum number of items to return per page.", isRequired = false, name = "limit", type = RestParameter.Type.INTEGER), @RestParameter(defaultValue = "0", description = "The page number.", isRequired = false, name = "offset", type = RestParameter.Type.INTEGER) }, reponses = { @RestResponse(responseCode = SC_OK, description = "The user accounts.") })
public Response getUsersAsXml(@QueryParam("query") String queryString, @QueryParam("limit") int limit, @QueryParam("offset") int offset) throws IOException {
if (limit < 1)
limit = 100;
String query = "%";
if (StringUtils.isNotBlank(queryString)) {
if (queryString.trim().length() < 3)
return Response.status(Status.BAD_REQUEST).build();
query = queryString;
}
JaxbUserList userList = new JaxbUserList();
for (Iterator<User> i = userDirectoryService.findUsers(query, offset, limit); i.hasNext(); ) {
userList.add(i.next());
}
return Response.ok(userList).build();
}
Aggregations