throw new ExistingLabelException("Label with this name already exists");
throw new BadRequestException(ile.getMessage()); } catch (ExistingLabelException ele) { throw new RESTApplicationException(Status.CONFLICT, ele.getMessage()); } catch (Exception e) { logger.error("Adding label failed", e);
@Override public void update(Mailbox mailbox, Label label) throws IOException { // get all existing labels LabelMap existingLabels = AccountPersistence.getLabels(mailbox.getId()); // validate only if name is changed (skips letter case changes) if (label.getName() != null && !existingLabels.containsName(label.getName())) { LabelUtils.validateLabelName(label.getName(), existingLabels); } // check if label id reserved if (ReservedLabels.contains(label.getId())) { throw new ExistingLabelException("This is reserved label and can't be modified"); } // check if label id exists if (!existingLabels.containsId(label.getId())) { throw new IllegalLabelException("Label does not exist"); } // begin batch operation Mutator<String> mutator = createMutator(keyspace, strSe); // set new name AccountPersistence.putLabel(mutator, mailbox.getId(), label); // commit batch operation mutator.execute(); }
throw new BadRequestException(ile.getMessage()); } catch (ExistingLabelException ele) { throw new RESTApplicationException(Status.CONFLICT, ele.getMessage()); } catch (Exception e) { logger.error("Updating label failed: ", e);