@Override public void add(final ApplicationDTO dto) throws InterruptedException, CrudException { log.info("ApplicationDTO in update method {}", dto); if (exists(dto.getCode())) { throw new CrudException("ERROR.VALIDATION.UNIQUE"); } // do nothing else }
@Override public void update(final ApplicationDTO dto) throws InterruptedException, CrudException { log.debug("ApplicationDTO in update method {}", dto); try { final Response response = restApplicationsService .path(dto.getCode()) .request() .put(entity(dto, MediaType.APPLICATION_JSON_TYPE)); final Response.StatusType statusInfo = response.getStatusInfo(); if (!(OK == statusInfo.getStatusCode())) { log.error("response status expected {} but got {}", OK, statusInfo.getStatusCode()); throw new CrudException(format("Impossible de modifier l'application [%s]", dto.getCode())); } } catch (Exception e) { log.error("error in update", e); if (e instanceof CrudException) { throw e; } throw new InterruptedException(e.getMessage()); } }
@Override public void add(final ApplicationDTO dto) throws InterruptedException, CrudException { log.debug("ApplicationDTO in add method {}", dto); try { if (exists(dto.getCode())) { throw new CrudException("Violation de la contrainte d'unicité"); } final Response response = restApplicationsService.request().post(entity(dto, MediaType.APPLICATION_JSON_TYPE)); final Response.StatusType statusInfo = response.getStatusInfo(); if (!(CREATED == statusInfo.getStatusCode())) { log.error("response status expected {} but got {}", CREATED, statusInfo.getStatusCode()); throw new CrudException(format("Impossible d'ajouter l'application [%s]", dto.getCode())); } } catch (Exception e) { log.error("error in add", e); if (e instanceof CrudException) { throw e; } throw new InterruptedException(e.getMessage()); } }
public Ordering f(final ApplicationDTO a, final ApplicationDTO b) { final String s1 = format("%s %s", a.getTitle(), a.getCaption()).trim().toLowerCase(); final String s2 = format("%s %s", b.getTitle(), b.getCaption()).trim().toLowerCase(); return stringOrd.compare(s1, s2); }