Search in sources :

Example 1 with JaxbUserList

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();
}
Also used : User(org.opencastproject.security.api.User) JaxbUser(org.opencastproject.security.api.JaxbUser) JaxbUserList(org.opencastproject.security.api.JaxbUserList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) RestQuery(org.opencastproject.util.doc.rest.RestQuery)

Aggregations

GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 JaxbUser (org.opencastproject.security.api.JaxbUser)1 JaxbUserList (org.opencastproject.security.api.JaxbUserList)1 User (org.opencastproject.security.api.User)1 RestQuery (org.opencastproject.util.doc.rest.RestQuery)1