@Override public void create(C configuration) throws EntityNotProvidedException, EntityAlreadyExistsException, EntityVersionMismatchException { EntityID entityID = getEntityID(); try { this.entityManager .createEntity( entityID, this.version, entityClientService.serializeConfiguration(configuration)) .get(); } catch (EntityException e) { // Note that we must externally only present the specific exception types we were expecting. // Thus, we need to check // that this is one of those supported types, asserting that there was an unexpected wire // inconsistency, otherwise. e = ExceptionUtils.addLocalStackTraceToEntityException(e); if (e instanceof EntityNotProvidedException) { throw (EntityNotProvidedException) e; } else if (e instanceof EntityAlreadyExistsException) { throw (EntityAlreadyExistsException) e; } else if (e instanceof EntityVersionMismatchException) { throw (EntityVersionMismatchException) e; } else { // WARNING: Assert.failure returns an exception, instead of throwing one. throw Assert.failure("Unsupported exception type returned to create", e); } } catch (InterruptedException e) { // We don't expect an interruption here. throw new RuntimeException(e); } }
@Override public C reconfigure(C configuration) throws EntityException { EntityID entityID = getEntityID(); try { return entityClientService.deserializeConfiguration( this.entityManager .reconfigureEntity( entityID, this.version, entityClientService.serializeConfiguration(configuration)) .get()); } catch (EntityException e) { throw ExceptionUtils.addLocalStackTraceToEntityException(e); } catch (InterruptedException e) { // We don't expect an interruption here. throw new RuntimeException(e); } }