@Override public Long addSchemaMetadata(SchemaMetadata schemaMetadata) { return schemaRegistry.addSchemaMetadata(schemaMetadata); }
@Override public SchemaIdVersion addSchemaVersion(String schemaBranchName, SchemaMetadata schemaMetadata, SchemaVersion schemaVersion) throws InvalidSchemaException, IncompatibleSchemaException, SchemaNotFoundException, SchemaBranchNotFoundException { return schemaRegistry.addSchemaVersion(schemaBranchName, schemaMetadata, schemaVersion); }
@Override public Long addSerDes(SerDesPair serializerInfo) { return schemaRegistry.addSerDes(serializerInfo); }
try { LOG.info("registerSchema for [{}] is [{}]", subject); SchemaMetadataInfo schemaMetadataInfo = schemaRegistry.getSchemaMetadataInfo(subject); if (schemaMetadataInfo == null) { SchemaMetadata schemaMetadata = new SchemaMetadata.Builder(subject) .build(); schemaRegistry.addSchemaMetadata(schemaMetadata); schemaMetadataInfo = schemaRegistry.getSchemaMetadataInfo(subject); SchemaIdVersion schemaVersionInfo = schemaRegistry.addSchemaVersion(schemaMetadataInfo.getSchemaMetadata(), new SchemaVersion(schemaStringFromJson(schema).getSchema(), null));
@Override public Collection<SchemaVersionInfo> getAllVersions(String schemaName) throws SchemaNotFoundException { return schemaRegistry.getAllVersions(schemaName); }
@Override public void deleteSchemaVersion(SchemaVersionKey schemaVersionKey) throws SchemaNotFoundException, SchemaLifecycleException { schemaRegistry.deleteSchemaVersion(schemaVersionKey); }
@Override public CompatibilityResult checkCompatibility(String schemaBranchName, String schemaName, String toSchemaText) throws SchemaNotFoundException, SchemaBranchNotFoundException { return schemaRegistry.checkCompatibility(schemaBranchName, schemaName, toSchemaText); }
@Override public InputStream downloadFile(String fileId) throws FileNotFoundException { try { return schemaRegistry.downloadFile(fileId); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public Collection<SchemaVersionKey> findSchemasByFields(SchemaFieldQuery schemaFieldQuery) throws SchemaBranchNotFoundException, SchemaNotFoundException { return schemaRegistry.findSchemasByFields(schemaFieldQuery); }
@Override public SchemaBranch createSchemaBranch(Long schemaVersionId, SchemaBranch schemaBranch) throws SchemaBranchAlreadyExistsException, SchemaNotFoundException { return schemaRegistry.createSchemaBranch(schemaVersionId, schemaBranch); }
@Override public void deleteSchemaBranch(Long schemaBranchId) throws SchemaBranchNotFoundException, InvalidSchemaBranchDeletionException { schemaRegistry.deleteSchemaBranch(schemaBranchId); }
try { LOG.info("registerSchema for [{}] is [{}]", subject); SchemaMetadataInfo schemaMetadataInfo = schemaRegistry.getSchemaMetadataInfo(subject); if (schemaMetadataInfo == null) { SchemaMetadata schemaMetadata = new SchemaMetadata.Builder(subject) .build(); schemaRegistry.addSchemaMetadata(schemaMetadata); schemaMetadataInfo = schemaRegistry.getSchemaMetadataInfo(subject); SchemaIdVersion schemaVersionInfo = schemaRegistry.addSchemaVersion(schemaMetadataInfo.getSchemaMetadata(), new SchemaVersion(schemaStringFromJson(schema).getSchema(), null));
@Override public Collection<SchemaVersionInfo> getAllVersions(String schemaBranchName, String schemaName) throws SchemaNotFoundException, SchemaBranchNotFoundException { return schemaRegistry.getAllVersions(schemaBranchName, schemaName); }
@POST @Path("/schemas/versions/{id}/state/delete") @ApiOperation(value = "Disables version of the schema identified by the given version id", response = Boolean.class, tags = OPERATION_GROUP_SCHEMA) @Timed @UnitOfWork public Response deleteSchema(@ApiParam(value = "version identifier of the schema", required = true) @PathParam("id") Long versionId) { Response response; try { schemaRegistry.deleteSchemaVersion(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(SchemaLifecycleException e) { LOG.error("Encountered error while disabling schema version with id [{}]", versionId, e); response = WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.BAD_REQUEST_WITH_MESSAGE, 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; }
@Override public CompatibilityResult checkCompatibility(String schemaName, String toSchemaText) throws SchemaNotFoundException, SchemaBranchNotFoundException { return schemaRegistry.checkCompatibility(schemaName, toSchemaText); }
@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; }
@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("/schemas/versionsById/{versionId}/branch") @ApiOperation(value = "Fork a new schema branch given its schema name and version id", response = SchemaBranch.class, tags = OPERATION_GROUP_SCHEMA) @UnitOfWork public Response createSchemaBranch( @ApiParam(value = "Details about schema version",required = true) @PathParam("versionId") Long schemaVersionId, @ApiParam(value = "Schema Branch Name", required = true) SchemaBranch schemaBranch) { try { SchemaBranch createdSchemaBranch = schemaRegistry.createSchemaBranch(schemaVersionId, schemaBranch); return WSUtils.respondEntity(createdSchemaBranch, Response.Status.OK) ; } catch (SchemaBranchAlreadyExistsException e) { return WSUtils.respond(Response.Status.CONFLICT, CatalogResponse.ResponseMessage.ENTITY_CONFLICT, schemaBranch.getName()); } catch (SchemaNotFoundException e) { return WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, schemaVersionId.toString()); } catch (Exception ex) { LOG.error("Encountered error while creating a new branch with name: [{}], version : [{}]", schemaBranch.getName(), schemaVersionId, 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()); } }
@Override public Collection<SchemaVersionInfo> getAllVersions(String schemaBranchName, String schemaName, List<Byte> stateIds) throws SchemaNotFoundException, SchemaBranchNotFoundException { return schemaRegistry.getAllVersions(schemaBranchName, schemaName, stateIds); }