@Override public void transitionState(Long schemaVersionId, Byte targetStateId, byte [] transitionDetails) throws SchemaNotFoundException, SchemaLifecycleException { schemaRegistry.transitionState(schemaVersionId, targetStateId, transitionDetails); }
@POST @Path("/schemas/versions/{id}/state/{stateId}") @ApiOperation(value = "Runs the state execution for schema version identified by the given version id and executes action associated with target state id", response = Boolean.class, tags = OPERATION_GROUP_SCHEMA) @Timed @UnitOfWork public Response executeState(@ApiParam(value = "version identifier of the schema", required = true) @PathParam("id") Long versionId, @ApiParam(value = "", required = true) @PathParam("stateId") Byte stateId, byte [] transitionDetails) { Response response; try { schemaRegistry.transitionState(versionId, stateId, transitionDetails); response = WSUtils.respondEntity(true, Response.Status.OK); } catch (SchemaNotFoundException e) { LOG.info("No schema version is found with schema version id : [{}]", versionId); response = WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, versionId.toString()); } catch(SchemaLifecycleException e) { LOG.error("Encountered error while disabling schema version with id [{}]", versionId, e); CatalogResponse.ResponseMessage badRequestResponse = e.getCause() != null && e.getCause() instanceof IncompatibleSchemaException ? CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA : CatalogResponse.ResponseMessage.BAD_REQUEST; response = WSUtils.respond(Response.Status.BAD_REQUEST, badRequestResponse, e.getMessage()); } catch (Exception ex) { LOG.error("Encountered error while getting schema version with id [{}]", versionId, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@POST @Path("/schemas/versions/{id}/state/{stateId}") @ApiOperation(value = "Runs the state execution for schema version identified by the given version id and executes action associated with target state id", response = Boolean.class, tags = OPERATION_GROUP_SCHEMA) @Timed @UnitOfWork public Response executeState(@ApiParam(value = "version identifier of the schema", required = true) @PathParam("id") Long versionId, @ApiParam(value = "", required = true) @PathParam("stateId") Byte stateId, byte [] transitionDetails) { Response response; try { schemaRegistry.transitionState(versionId, stateId, transitionDetails); response = WSUtils.respondEntity(true, Response.Status.OK); } catch (SchemaNotFoundException e) { LOG.info("No schema version is found with schema version id : [{}]", versionId); response = WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, versionId.toString()); } catch(SchemaLifecycleException e) { LOG.error("Encountered error while disabling schema version with id [{}]", versionId, e); CatalogResponse.ResponseMessage badRequestResponse = e.getCause() != null && e.getCause() instanceof IncompatibleSchemaException ? CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA : CatalogResponse.ResponseMessage.BAD_REQUEST; response = WSUtils.respond(Response.Status.BAD_REQUEST, badRequestResponse, e.getMessage()); } catch (Exception ex) { LOG.error("Encountered error while getting schema version with id [{}]", versionId, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }