public static RUserDto getUser(DbConn cnx, int id) { List<RUserDto> res = getUsers(cnx, "user_select_by_id", 0, id); if (res.size() == 1) { return res.get(0); } else { throw new JqmAdminApiUserException("no result"); } }
public static RRoleDto getRole(DbConn cnx, int id) { List<RRoleDto> res = getRoles(cnx, "role_select_by_id", 0, id); if (res.size() == 1) { return res.get(0); } else { throw new JqmAdminApiUserException("no result"); } }
public static RUserDto getUser(DbConn cnx, int id) { List<RUserDto> res = getUsers(cnx, "user_select_by_id", 0, id); if (res.size() == 1) { return res.get(0); } else { throw new JqmAdminApiUserException("no result"); } }
public static RRoleDto getRole(DbConn cnx, int id) { List<RRoleDto> res = getRoles(cnx, "role_select_by_id", 0, id); if (res.size() == 1) { return res.get(0); } else { throw new JqmAdminApiUserException("no result"); } }
public static void deleteQueueMapping(DbConn cnx, int id) { QueryResult qr = cnx.runUpdate("dp_delete_by_id", id); if (qr.nbUpdated != 1) { cnx.setRollbackOnly(); throw new JqmAdminApiUserException("no item with ID " + id); } }
public static void deleteGlobalParameter(DbConn cnx, int id) { QueryResult qr = cnx.runUpdate("globalprm_delete_by_id", id); if (qr.nbUpdated != 1) { cnx.setRollbackOnly(); throw new JqmAdminApiUserException("no item with ID " + id); } }
public static void deleteGlobalParameter(DbConn cnx, int id) { QueryResult qr = cnx.runUpdate("globalprm_delete_by_id", id); if (qr.nbUpdated != 1) { cnx.setRollbackOnly(); throw new JqmAdminApiUserException("no item with ID " + id); } }
public static void deleteQueueMapping(DbConn cnx, int id) { QueryResult qr = cnx.runUpdate("dp_delete_by_id", id); if (qr.nbUpdated != 1) { cnx.setRollbackOnly(); throw new JqmAdminApiUserException("no item with ID " + id); } }
public static void deleteUser(DbConn cnx, int id) { QueryResult qr = cnx.runUpdate("user_delete_by_id", id); if (qr.nbUpdated != 1) { cnx.setRollbackOnly(); throw new JqmAdminApiUserException("no item with ID " + id); } }
public static void changeUserPassword(DbConn cnx, String userLogin, String newPassword) { List<RUserDto> dtos = getUsers(cnx, "user_select_by_key", 0, userLogin); if (dtos.size() == 0) { throw new JqmAdminApiUserException("Cannot update the password of a user which does not exist - given login was " + userLogin); } changeUserPassword(cnx, dtos.get(0).getId(), newPassword); }
public static void deleteUser(DbConn cnx, int id) { QueryResult qr = cnx.runUpdate("user_delete_by_id", id); if (qr.nbUpdated != 1) { cnx.setRollbackOnly(); throw new JqmAdminApiUserException("no item with ID " + id); } }
public static void changeUserPassword(DbConn cnx, String userLogin, String newPassword) { List<RUserDto> dtos = getUsers(cnx, "user_select_by_key", 0, userLogin); if (dtos.size() == 0) { throw new JqmAdminApiUserException("Cannot update the password of a user which does not exist - given login was " + userLogin); } changeUserPassword(cnx, dtos.get(0).getId(), newPassword); }
public static void deleteJobDef(DbConn cnx, int id) { int countRunning = cnx.runSelectSingle("ji_select_count_by_jd", Integer.class, id); if (countRunning > 0) { throw new JqmAdminApiUserException( "cannot delete a job definition with running instances. Disable it, wait for the end of all running instances, then retry."); } cnx.runUpdate("jdprm_delete_all_for_jd", id); QueryResult qr = cnx.runUpdate("jd_delete_by_id", id); if (qr.nbUpdated != 1) { cnx.setRollbackOnly(); throw new JqmAdminApiUserException("no item with ID " + id); } }
public static void deleteJobDef(DbConn cnx, int id) { int countRunning = cnx.runSelectSingle("ji_select_count_by_jd", Integer.class, id); if (countRunning > 0) { throw new JqmAdminApiUserException( "cannot delete a job definition with running instances. Disable it, wait for the end of all running instances, then retry."); } cnx.runUpdate("jdprm_delete_all_for_jd", id); QueryResult qr = cnx.runUpdate("jd_delete_by_id", id); if (qr.nbUpdated != 1) { cnx.setRollbackOnly(); throw new JqmAdminApiUserException("no item with ID " + id); } }
public static QueueDto getQueue(DbConn cnx, int id) { ResultSet rs = null; try { rs = cnx.runSelect("q_select_by_id", id); if (!rs.next()) { throw new JqmAdminApiUserException("no result"); } return mapQueue(rs, 0); } catch (SQLException e) { throw new DatabaseException(e); } }
public static void deleteJndiObjectResource(DbConn cnx, int id) { cnx.runUpdate("jndiprm_delete_for_resource", id); QueryResult qr = cnx.runUpdate("jndi_delete_by_id", id); if (qr.nbUpdated != 1) { cnx.setRollbackOnly(); throw new JqmAdminApiUserException("no item with ID " + id); } }
public static void deleteQueue(DbConn cnx, int id) { int countRunning = cnx.runSelectSingle("ji_select_count_by_queue", Integer.class, id); if (countRunning > 0) { cnx.setRollbackOnly(); throw new JqmAdminApiUserException( "cannot delete a queue with running instances. Disable it, wait for the end of all running instances, then retry."); } cnx.runUpdate("dp_delete_for_queue", id); QueryResult qr = cnx.runUpdate("q_delete_by_id", id); if (qr.nbUpdated != 1) { cnx.setRollbackOnly(); throw new JqmAdminApiUserException("no item with ID " + id); } }
public static void deleteJndiObjectResource(DbConn cnx, int id) { cnx.runUpdate("jndiprm_delete_for_resource", id); QueryResult qr = cnx.runUpdate("jndi_delete_by_id", id); if (qr.nbUpdated != 1) { cnx.setRollbackOnly(); throw new JqmAdminApiUserException("no item with ID " + id); } }
public static void changeUserPassword(DbConn cnx, int userId, String newPassword) { ByteSource salt = new SecureRandomNumberGenerator().nextBytes(); String hash = new Sha512Hash(newPassword, salt, 100000).toHex(); QueryResult qr = cnx.runUpdate("user_update_password_by_id", hash, salt.toHex(), userId); if (qr.nbUpdated == 0) { throw new JqmAdminApiUserException("user with this ID does not exist"); } }
public static void changeUserPassword(DbConn cnx, int userId, String newPassword) { ByteSource salt = new SecureRandomNumberGenerator().nextBytes(); String hash = new Sha512Hash(newPassword, salt, 100000).toHex(); QueryResult qr = cnx.runUpdate("user_update_password_by_id", hash, salt.toHex(), userId); if (qr.nbUpdated == 0) { throw new JqmAdminApiUserException("user with this ID does not exist"); } }