@POST @Path("/schemas/{versionId}/merge") @ApiOperation(value = "Merge a schema version to master given its version id", response = SchemaVersionMergeResult.class, tags = OPERATION_GROUP_SCHEMA) @UnitOfWork public Response mergeSchemaVersion(@ApiParam(value = "Details about schema version",required = true) @PathParam("versionId") Long schemaVersionId) { try { SchemaVersionMergeResult schemaVersionMergeResult = schemaRegistry.mergeSchemaVersion(schemaVersionId); return WSUtils.respondEntity(schemaVersionMergeResult, Response.Status.OK); } catch (SchemaNotFoundException e) { return WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, schemaVersionId.toString()); } catch (IncompatibleSchemaException e) { return WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA, e.getMessage()); } catch (Exception ex) { LOG.error("Encountered error while merging a schema version to {} branch with version : [{}]", SchemaBranch.MASTER_BRANCH, schemaVersionId, ex); return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } }
@POST @Path("/schemas/{versionId}/merge") @ApiOperation(value = "Merge a schema version to master given its version id", response = SchemaVersionMergeResult.class, tags = OPERATION_GROUP_SCHEMA) @UnitOfWork public Response mergeSchemaVersion(@ApiParam(value = "Details about schema version",required = true) @PathParam("versionId") Long schemaVersionId) { try { SchemaVersionMergeResult schemaVersionMergeResult = schemaRegistry.mergeSchemaVersion(schemaVersionId); return WSUtils.respondEntity(schemaVersionMergeResult, Response.Status.OK); } catch (SchemaNotFoundException e) { return WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, schemaVersionId.toString()); } catch (IncompatibleSchemaException e) { return WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA, e.getMessage()); } catch (Exception ex) { LOG.error("Encountered error while merging a schema version to {} branch with version : [{}]", SchemaBranch.MASTER_BRANCH, schemaVersionId, ex); return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } }
@POST @Path("/schemas/versions/{id}/state/enable") @ApiOperation(value = "Enables version of the schema identified by the given versionid", response = Boolean.class, tags = OPERATION_GROUP_SCHEMA) @Timed @UnitOfWork public Response enableSchema(@ApiParam(value = "version identifier of the schema", required = true) @PathParam("id") Long versionId) { Response response; try { schemaRegistry.enableSchemaVersion(versionId); 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(IncompatibleSchemaException e) { LOG.error("Encountered error while enabling schema version with id [{}]", versionId, e); response = WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA, e.getMessage()); } catch(SchemaLifecycleException e) { LOG.error("Encountered error while enabling schema version with id [{}]", versionId, e); response = WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.BAD_REQUEST, 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/enable") @ApiOperation(value = "Enables version of the schema identified by the given versionid", response = Boolean.class, tags = OPERATION_GROUP_SCHEMA) @Timed @UnitOfWork public Response enableSchema(@ApiParam(value = "version identifier of the schema", required = true) @PathParam("id") Long versionId) { Response response; try { schemaRegistry.enableSchemaVersion(versionId); 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(IncompatibleSchemaException e) { LOG.error("Encountered error while enabling schema version with id [{}]", versionId, e); response = WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA, e.getMessage()); } catch(SchemaLifecycleException e) { LOG.error("Encountered error while enabling schema version with id [{}]", versionId, e); response = WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.BAD_REQUEST, 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; }
} catch (IncompatibleSchemaException ex) { LOG.error("Incompatible schema error encountered while adding schema [{}] with key [{}]", schemaVersion, schemaName, ex); response = WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA, ex.getMessage()); } catch (UnsupportedSchemaTypeException ex) { LOG.error("Unsupported schema type encountered while adding schema [{}] with key [{}]", schemaVersion, schemaName, ex);
} catch (IncompatibleSchemaException ex) { LOG.error("Incompatible schema error encountered while adding schema [{}] with key [{}]", schemaVersion, schemaName, ex); response = WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA, ex.getMessage()); } catch (UnsupportedSchemaTypeException ex) { LOG.error("Unsupported schema type encountered while adding schema [{}] with key [{}]", schemaVersion, schemaName, ex);