try {
ObjectMapper mapper = new ObjectMapper();
label = mapper.readValue(requestJSONContent, Label.class);
} catch (Exception e) {
logger.info("Malformed JSON request: {}", e.getMessage());
throw new BadRequestException("Malformed JSON request");
}
}
if (label.getName() == null && labelName == null) {
throw new BadRequestException("Label name must be specified");
}
Integer newLabelId = null;
try {
newLabelId = labelDAO.add(mailbox, label);
} catch (IllegalLabelException ile) {
throw new BadRequestException(ile.getMessage());
} catch (ExistingLabelException ele) {
throw new RESTApplicationException(Status.CONFLICT, ele.getMessage());
} catch (Exception e) {
logger.error("Adding label failed", e);
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);