Example #1
0
 @Override
 public int execute(String[] parameters) throws SQLException {
   if (Context.getLoggedHolder() == null) {
     LOGGER.warn("Error: User isn't logged in.");
     return 1;
   }
   if (!Context.getLoggedHolder().getRights()) {
     LOGGER.warn("Error: Access only for librarians.");
     return 2;
   }
   if (parameters.length != parametersNumber) {
     LOGGER.warn("Error: Wrong number of parameters.");
     return 3;
   }
   boolean result;
   try {
     result = dao.deleteBookType(new BigInteger(parameters[1]));
   } catch (NumberFormatException e) {
     LOGGER.warn("Error: ID should be number.");
     return 6;
   }
   if (!result) {
     LOGGER.warn("Error: Unsuccessful delete.");
     return 15;
   }
   LOGGER.info("Book type successfully deleted.");
   return 0;
 }
Example #2
0
 @Override
 public int execute(String[] parameters) throws IOException, SQLException {
   if (Context.getLoggedHolder() == null) {
     LOGGER.warn("Error: User isn't logged in.");
     return 1;
   }
   if (!Context.getLoggedHolder().getRights()) {
     LOGGER.warn("Error: Access only for librarians.");
     return 2;
   }
   if (parameters.length != parametersNumber) {
     LOGGER.warn("Error: Wrong number of parameters.");
     return 3;
   }
   Book book;
   try {
     book = new Book(new BigInteger(parameters[1]));
   } catch (NumberFormatException e) {
     LOGGER.warn("Error: ID shouldn't be null or negative value.");
     return 5;
   }
   if (!dao.addBook(book)) {
     LOGGER.info("Error: unsuccessfully query. Book hasn't been added.");
     return 18;
   }
   LOGGER.info("Book successfully added.");
   return 0;
 }
Example #3
0
 @Override
 public int execute(String[] parameters) throws SQLException {
   if (Context.getLoggedHolder() == null) {
     LOGGER.warn("Error: User isn't logged in.");
     return 1;
   }
   if (!Context.getLoggedHolder().getRights()) {
     LOGGER.warn("Error: Access only for librarians.");
     return 2;
   }
   if (parameters.length != parametersNumber) {
     LOGGER.warn("Error: Wrong number of parameters.");
     return 3;
   }
   BookType bookType;
   try {
     bookType =
         new BookType(parameters[1], new BigInteger(parameters[2]), new BigInteger(parameters[3]));
   } catch (IllegalArgumentException e) {
     LOGGER.warn("Error: Name shouldn't be null or void.");
     return 4;
   } catch (NullPointerException e) {
     LOGGER.warn("Error: ID shouldn't be null or negative value.");
     return 5;
   }
   if (!dao.addBookType(bookType)) {
     LOGGER.info("Error: unsuccessfully query. Book type hasn't been added.");
     return 18;
   }
   LOGGER.info("Book type successfully added.");
   return 0;
 }
Example #4
0
 @Override
 public int execute(String[] parameters) {
   if (Context.getLoggedHolder() == null) {
     LOGGER.warn("Error: User isn't logged in.");
     return notLoggedInToLogOut;
   }
   Context.removeUserFromSignedUsers();
   LOGGER.info("User successfully logged out.");
   return success;
 }