private Response _addSerDesInfo(SerDesPair serDesInfo) { Response response; try { Long serializerId = schemaRegistry.addSerDes(serDesInfo); response = WSUtils.respondEntity(serializerId, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while adding serializer/deserializer [{}]", serDesInfo, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@POST @Path(("/notifications/node/debut")) public Response registerNodeDebut(String nodeUrl) { try { LOG.debug("Acknowledged another peer server : {}", nodeUrl); schemaRegistry.registerNodeDebut(nodeUrl); return WSUtils.respond(Response.Status.OK); } catch (Exception e) { return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, e.getMessage()); } }
@GET @Path("/schemaproviders") @ApiOperation(value = "Get list of registered Schema Providers", notes = "The Schema Registry supports different types of schemas, such as Avro, JSON etc. " + "" + "A Schema Provider is needed for each type of schema supported by the Schema Registry. " + "Schema Provider supports defining schema, serializing and deserializing data using the schema, " + " and checking compatibility between different versions of the schema.", response = SchemaProviderInfo.class, responseContainer = "List", tags = OPERATION_GROUP_OTHER) @Timed public Response getRegisteredSchemaProviderInfos(@Context UriInfo uriInfo) { try { Collection<SchemaProviderInfo> schemaProviderInfos = schemaRegistry.getSupportedSchemaProviders(); return WSUtils.respondEntities(schemaProviderInfos, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while listing schemas", ex); return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } }
private Response _getSerDesInfo(Long serializerId) { Response response; try { SerDesInfo serializerInfo = schemaRegistry.getSerDes(serializerId); response = WSUtils.respondEntity(serializerInfo, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while getting serializer/deserializer [{}]", serializerId, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@GET @Path("/search/schemas") @ApiOperation(value = "Search for schemas containing the given name and description", notes = "Search the schemas for given name and description, return a list of schemas that contain the field.", response = SchemaMetadataInfo.class, responseContainer = "List", tags = OPERATION_GROUP_SCHEMA) @Timed @UnitOfWork public Response findSchemas(@Context UriInfo uriInfo) { MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters(); try { Collection<SchemaMetadataInfo> schemaMetadataInfos = findSchemaMetadataInfos(queryParameters); return WSUtils.respondEntities(schemaMetadataInfos, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while finding schemas for given fields [{}]", queryParameters, ex); return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } }
@POST @Path(("/notifications/node/debut")) public Response registerNodeDebut(String nodeUrl) { try { LOG.debug("Acknowledged another peer server : {}", nodeUrl); schemaRegistry.registerNodeDebut(nodeUrl); return WSUtils.respond(Response.Status.OK); } catch (Exception e) { return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, e.getMessage()); } }
private Response _addSerDesInfo(SerDesPair serDesInfo) { Response response; try { Long serializerId = schemaRegistry.addSerDes(serDesInfo); response = WSUtils.respondEntity(serializerId, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while adding serializer/deserializer [{}]", serDesInfo, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@GET @Path("/search/schemas") @ApiOperation(value = "Search for schemas containing the given name and description", notes = "Search the schemas for given name and description, return a list of schemas that contain the field.", response = SchemaMetadataInfo.class, responseContainer = "List", tags = OPERATION_GROUP_SCHEMA) @Timed @UnitOfWork public Response findSchemas(@Context UriInfo uriInfo) { MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters(); try { Collection<SchemaMetadataInfo> schemaMetadataInfos = findSchemaMetadataInfos(queryParameters); return WSUtils.respondEntities(schemaMetadataInfos, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while finding schemas for given fields [{}]", queryParameters, ex); return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } }
@POST @Path("/cache/{cacheType}/invalidate") @UnitOfWork public Response invalidateCache(@ApiParam(value = "Cache Id to be invalidated", required = true) @PathParam("cacheType") SchemaRegistryCacheType cacheType, String keyString) { try { LOG.debug("Request to invalidate cache : {} with key : {} accepted", cacheType.name(), keyString); schemaRegistry.invalidateCache(cacheType, keyString); return WSUtils.respond(Response.Status.OK); } catch (Exception e) { return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, e.getMessage()); } }
private Response _getSerDesInfo(Long serializerId) { Response response; try { SerDesInfo serializerInfo = schemaRegistry.getSerDes(serializerId); response = WSUtils.respondEntity(serializerInfo, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while getting serializer/deserializer [{}]", serializerId, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@GET @Path("/search/schemas/fields") @ApiOperation(value = "Search for schemas containing the given field names", notes = "Search the schemas for given field names and return a list of schemas that contain the field.", response = SchemaVersionKey.class, responseContainer = "List", tags = OPERATION_GROUP_SCHEMA) @Timed @UnitOfWork public Response findSchemasByFields(@Context UriInfo uriInfo) { MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters(); try { Collection<SchemaVersionKey> schemaVersionKeys = schemaRegistry.findSchemasByFields(buildSchemaFieldQuery(queryParameters)); return WSUtils.respondEntities(schemaVersionKeys, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while finding schemas for given fields [{}]", queryParameters, ex); return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } }
@POST @Path("/cache/{cacheType}/invalidate") @UnitOfWork public Response invalidateCache(@ApiParam(value = "Cache Id to be invalidated", required = true) @PathParam("cacheType") SchemaRegistryCacheType cacheType, String keyString) { try { LOG.debug("Request to invalidate cache : {} with key : {} accepted", cacheType.name(), keyString); schemaRegistry.invalidateCache(cacheType, keyString); return WSUtils.respond(Response.Status.OK); } catch (Exception e) { return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, e.getMessage()); } }
@GET @Path("/schemas/versions/statemachine") @ApiOperation(value = "Get schema version life cycle states", response = SchemaVersionInfo.class, tags = OPERATION_GROUP_SCHEMA) @Timed public Response getSchemaVersionLifeCycleStates() { Response response; try { SchemaVersionLifecycleStateMachineInfo states = schemaRegistry.getSchemaVersionLifecycleStateMachineInfo(); response = WSUtils.respondEntity(states, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while getting schema version lifecycle states", ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@GET @Path("/search/schemas/fields") @ApiOperation(value = "Search for schemas containing the given field names", notes = "Search the schemas for given field names and return a list of schemas that contain the field.", response = SchemaVersionKey.class, responseContainer = "List", tags = OPERATION_GROUP_SCHEMA) @Timed @UnitOfWork public Response findSchemasByFields(@Context UriInfo uriInfo) { MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters(); try { Collection<SchemaVersionKey> schemaVersionKeys = schemaRegistry.findSchemasByFields(buildSchemaFieldQuery(queryParameters)); return WSUtils.respondEntities(schemaVersionKeys, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while finding schemas for given fields [{}]", queryParameters, ex); return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } }
@DELETE @Path("/schemas/branch/{branchId}") @ApiOperation(value = "Delete a branch give its name", tags = OPERATION_GROUP_SCHEMA) @UnitOfWork public Response deleteSchemaBranch(@ApiParam(value = "Schema Branch Name", required = true) @PathParam("branchId") Long schemaBranchId) { try { schemaRegistry.deleteSchemaBranch(schemaBranchId); return WSUtils.respond(Response.Status.OK); } catch (SchemaBranchNotFoundException e) { return WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, schemaBranchId.toString()); } catch (InvalidSchemaBranchDeletionException e) { return WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.BAD_REQUEST_WITH_MESSAGE, e.getMessage()); } catch (Exception ex) { LOG.error("Encountered error while deleting a branch with name: [{}]", schemaBranchId, ex); return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } }
@GET @Path("/schemas/versions/statemachine") @ApiOperation(value = "Get schema version life cycle states", response = SchemaVersionInfo.class, tags = OPERATION_GROUP_SCHEMA) @Timed public Response getSchemaVersionLifeCycleStates() { Response response; try { SchemaVersionLifecycleStateMachineInfo states = schemaRegistry.getSchemaVersionLifecycleStateMachineInfo(); response = WSUtils.respondEntity(states, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while getting schema version lifecycle states", ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@DELETE @Path("/schemas/branch/{branchId}") @ApiOperation(value = "Delete a branch give its name", tags = OPERATION_GROUP_SCHEMA) @UnitOfWork public Response deleteSchemaBranch(@ApiParam(value = "Schema Branch Name", required = true) @PathParam("branchId") Long schemaBranchId) { try { schemaRegistry.deleteSchemaBranch(schemaBranchId); return WSUtils.respond(Response.Status.OK); } catch (SchemaBranchNotFoundException e) { return WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, schemaBranchId.toString()); } catch (InvalidSchemaBranchDeletionException e) { return WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.BAD_REQUEST_WITH_MESSAGE, e.getMessage()); } catch (Exception ex) { LOG.error("Encountered error while deleting a branch with name: [{}]", schemaBranchId, ex); return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } }
@GET @Produces({"application/octet-stream", "application/json"}) @Path("/files/download/{fileId}") @ApiOperation(value = "Downloads the respective for the given fileId if it exists", response = StreamingOutput.class, tags = OPERATION_GROUP_OTHER) @Timed public Response downloadFile(@ApiParam(value = "Identifier of the file to be downloaded", required = true) @PathParam("fileId") String fileId) { Response response; try { StreamingOutput streamOutput = WSUtils.wrapWithStreamingOutput(schemaRegistry.downloadFile(fileId)); response = Response.ok(streamOutput).build(); return response; } catch (FileNotFoundException e) { LOG.error("No file found for fileId [{}]", fileId, e); response = WSUtils.respondEntity(fileId, Response.Status.NOT_FOUND); } catch (Exception ex) { LOG.error("Encountered error while downloading file [{}]", fileId, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/files") @ApiOperation(value = "Upload the given file and returns respective identifier.", response = String.class, tags = OPERATION_GROUP_OTHER) @Timed public Response uploadFile(@FormDataParam("file") final InputStream inputStream, @FormDataParam("file") final FormDataContentDisposition contentDispositionHeader) { Response response; try { LOG.info("Received contentDispositionHeader: [{}]", contentDispositionHeader); String uploadedFileId = schemaRegistry.uploadFile(inputStream); response = WSUtils.respondEntity(uploadedFileId, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while uploading file", ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/files") @ApiOperation(value = "Upload the given file and returns respective identifier.", response = String.class, tags = OPERATION_GROUP_OTHER) @Timed public Response uploadFile(@FormDataParam("file") final InputStream inputStream, @FormDataParam("file") final FormDataContentDisposition contentDispositionHeader) { Response response; try { LOG.info("Received contentDispositionHeader: [{}]", contentDispositionHeader); String uploadedFileId = schemaRegistry.uploadFile(inputStream); response = WSUtils.respondEntity(uploadedFileId, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while uploading file", ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }