Search in sources :

Example 1 with UsersWrapperList

use of nl.uva.cs.lobcder.rest.wrappers.UsersWrapperList in project lobcder by skoulouzis.

the class UsersService method getXml.

@Path("query/")
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public UsersWrapperList getXml() throws FileNotFoundException, VlException, URISyntaxException, IOException, MalformedURLException, Exception {
    MyPrincipal mp = (MyPrincipal) request.getAttribute("myprincipal");
    if (mp.isAdmin()) {
        try (Connection cn = getCatalogue().getConnection()) {
            List<UsersWrapper> res = queryUsers(cn);
            UsersWrapperList uwl = new UsersWrapperList();
            uwl.setUsers(res);
            return uwl;
        } catch (SQLException ex) {
            log.log(Level.SEVERE, null, ex);
            throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
        }
    }
    return null;
}
Also used : MyPrincipal(nl.uva.cs.lobcder.auth.MyPrincipal) WebApplicationException(javax.ws.rs.WebApplicationException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) UsersWrapperList(nl.uva.cs.lobcder.rest.wrappers.UsersWrapperList) UsersWrapper(nl.uva.cs.lobcder.rest.wrappers.UsersWrapper) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 MyPrincipal (nl.uva.cs.lobcder.auth.MyPrincipal)1 UsersWrapper (nl.uva.cs.lobcder.rest.wrappers.UsersWrapper)1 UsersWrapperList (nl.uva.cs.lobcder.rest.wrappers.UsersWrapperList)1