use of nl.uva.cs.lobcder.rest.wrappers.UsersWrapper in project lobcder by skoulouzis.
the class JDBCatalogue method getUsers.
public List<UsersWrapper> getUsers(Connection connection) throws SQLException {
List<UsersWrapper> users = new ArrayList<>();
try (PreparedStatement preparedStatement = connection.prepareStatement("select * from auth_usernames_table")) {
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
UsersWrapper uw = new UsersWrapper();
long id = rs.getLong(1);
uw.setId(id);
String token = rs.getString(2);
// token = "****";
uw.setToken(token);
uw.setUname(rs.getString(3));
List<String> roles = new ArrayList<>();
try (PreparedStatement preparedStatement2 = connection.prepareStatement("SELECT roleName FROM auth_roles_tables WHERE unameRef = " + id)) {
ResultSet rs2 = preparedStatement2.executeQuery();
while (rs2.next()) {
roles.add(rs2.getString(1));
}
}
uw.setRoles(roles);
users.add(uw);
}
}
return users;
}
use of nl.uva.cs.lobcder.rest.wrappers.UsersWrapper 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;
}
Aggregations