@GET @Path("/release/{process}/{token}") public void release(@PathParam("process") String processName, @PathParam("token") String token) { UUID tokenUuid; try { tokenUuid = UUID.fromString(token); } catch (Exception e) { final String errMsg = "[" + token + "] doesn't seem a valid UUID"; throw new SynchronizerServiceException(SynchronizerServiceException.Status.ERROR, errMsg); } LoggableSynchronizer synchronizer = instanceManager.getSynchronizer(); try { synchronizer.release(processName, tokenUuid); } catch (AlreadyReleasedSynchronizerException e) { throw new SynchronizerServiceException( SynchronizerServiceException.Status.RELEASED, e.getMessage()); } catch (ReleaseNotPermittedSynchronizerException e) { throw new SynchronizerServiceException( SynchronizerServiceException.Status.WAIT, e.getMessage()); } catch (WrongTurnSynchronizerException e) { throw new SynchronizerServiceException( SynchronizerServiceException.Status.WAIT, e.getMessage()); } catch (SynchronizerException e) { throw new SynchronizerServiceException( SynchronizerServiceException.Status.ERROR, e.getMessage()); } throw new SynchronizerServiceException( SynchronizerServiceException.Status.OK, "[" + processName + "] releases"); }
@GET @Path("/token/{process}") public UUID getToken(@PathParam("process") String processName) { LoggableSynchronizer synchronizer = instanceManager.getSynchronizer(); try { return synchronizer.getToken(processName); } catch (SynchronizerException e) { throw new SynchronizerServiceException( SynchronizerServiceException.Status.ERROR, e.getMessage()); } }
@GET @Path("/status") public Status getStatus() { LoggableSynchronizer synchronizer = instanceManager.getSynchronizer(); try { return synchronizer.getStatus(); } catch (SynchronizerException e) { throw new SynchronizerServiceException( SynchronizerServiceException.Status.ERROR, e.getMessage()); } }