@GET @Path("/subjects/{subject}/versions") @ApiOperation(value = "Get all schema versions of given subject", response = Integer.class, responseContainer = "List", tags = OPERATION_GROUP_CONFLUENT_SR) @Timed @UnitOfWork public Response getAllVersions(@ApiParam(value = "subject", required = true) @PathParam("subject") String subject) { Response response; try { List<Integer> registeredSubjects = schemaRegistry.getAllVersions(subject) .stream() .map(SchemaVersionInfo::getVersion) .collect(Collectors.toList()); response = WSUtils.respondEntity(registeredSubjects, Response.Status.OK); } catch (SchemaNotFoundException ex) { LOG.error("No schema found with subject [{}]", subject, ex); response = subjectNotFoundError(); } catch (Exception ex) { LOG.error("Encountered error while retrieving all subjects", ex); response = serverError(); } return response; }
@GET @Path("/subjects/{subject}/versions") @ApiOperation(value = "Get all schema versions of given subject", response = Integer.class, responseContainer = "List", tags = OPERATION_GROUP_CONFLUENT_SR) @Timed @UnitOfWork public Response getAllVersions(@ApiParam(value = "subject", required = true) @PathParam("subject") String subject) { Response response; try { List<Integer> registeredSubjects = schemaRegistry.getAllVersions(subject) .stream() .map(SchemaVersionInfo::getVersion) .collect(Collectors.toList()); response = WSUtils.respondEntity(registeredSubjects, Response.Status.OK); } catch (SchemaNotFoundException ex) { LOG.error("No schema found with subject [{}]", subject, ex); response = subjectNotFoundError(); } catch (Exception ex) { LOG.error("Encountered error while retrieving all subjects", ex); response = serverError(); } return response; }
@GET @Path("/subjects") @ApiOperation(value = "Get all registered subjects", response = String.class, responseContainer = "List", tags = OPERATION_GROUP_CONFLUENT_SR) @Timed @UnitOfWork public Response getSubjects() { Response response; try { List<String> registeredSubjects = schemaRegistry.findSchemaMetadata(Collections.emptyMap()) .stream() .map(x -> x.getSchemaMetadata().getName()) .collect(Collectors.toList()); response = WSUtils.respondEntity(registeredSubjects, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while retrieving all subjects", ex); response = serverError(); } return response; }
@GET @Path("/subjects") @ApiOperation(value = "Get all registered subjects", response = String.class, responseContainer = "List", tags = OPERATION_GROUP_CONFLUENT_SR) @Timed @UnitOfWork public Response getSubjects() { Response response; try { List<String> registeredSubjects = schemaRegistry.findSchemaMetadata(Collections.emptyMap()) .stream() .map(x -> x.getSchemaMetadata().getName()) .collect(Collectors.toList()); response = WSUtils.respondEntity(registeredSubjects, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while retrieving all subjects", ex); response = serverError(); } return response; }
@GET @Path("/schemas/ids/{id}") @ApiOperation(value = "Get schema version by id", response = Schema.class, tags = OPERATION_GROUP_CONFLUENT_SR) @Timed @UnitOfWork public Response getSchemaById(@ApiParam(value = "schema version id", required = true) @PathParam("id") Long id) { Response response; try { SchemaVersionInfo schemaVersionInfo = schemaRegistry.getSchemaVersionInfo(new SchemaIdVersion(id)); SchemaString schema = new SchemaString(); schema.setSchema(schemaVersionInfo.getSchemaText()); response = WSUtils.respondEntity(schema, Response.Status.OK); } catch (SchemaNotFoundException ex) { LOG.error("No schema version found with id [{}]", id, ex); response = schemaNotFoundError(); } catch (Exception ex) { LOG.error("Encountered error while retrieving Schema with id: [{}]", id, ex); response = serverError(); } return response; }
@GET @Path("/schemas/ids/{id}") @ApiOperation(value = "Get schema version by id", response = Schema.class, tags = OPERATION_GROUP_CONFLUENT_SR) @Timed @UnitOfWork public Response getSchemaById(@ApiParam(value = "schema version id", required = true) @PathParam("id") Long id) { Response response; try { SchemaVersionInfo schemaVersionInfo = schemaRegistry.getSchemaVersionInfo(new SchemaIdVersion(id)); SchemaString schema = new SchemaString(); schema.setSchema(schemaVersionInfo.getSchemaText()); response = WSUtils.respondEntity(schema, Response.Status.OK); } catch (SchemaNotFoundException ex) { LOG.error("No schema version found with id [{}]", id, ex); response = schemaNotFoundError(); } catch (Exception ex) { LOG.error("Encountered error while retrieving Schema with id: [{}]", id, ex); response = serverError(); } return response; }
@POST @Path("/subjects/{subject}") @ApiOperation(value = "Get schema information for the given schema subject and schema text", response = Schema.class, tags = OPERATION_GROUP_CONFLUENT_SR) @Timed @UnitOfWork public Response lookupSubjectVersion(@ApiParam(value = "Schema subject", required = true) @PathParam("subject") String subject, @ApiParam(value = "The schema ", required = true) String schema) { Response response; try { SchemaVersionInfo schemaVersionInfo = schemaRegistry.getSchemaVersionInfo(subject, schemaStringFromJson(schema).getSchema()); if (schemaVersionInfo != null) { response = WSUtils.respondEntity(new Schema(schemaVersionInfo.getName(), schemaVersionInfo.getVersion(), schemaVersionInfo.getId(), schemaVersionInfo.getSchemaText()), Response.Status.OK); } else { response = WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, subject); } } catch (InvalidSchemaException ex) { LOG.error("Given schema is invalid", ex); response = invalidSchemaError(); } catch (SchemaNotFoundException ex) { LOG.error("No schema found with subject [{}]", subject, ex); response = subjectNotFoundError(); } catch (Exception ex) { LOG.error("Encountered error while retrieving schema version with subject: [{}]", subject, ex); response = serverError(); } return response; }
@POST @Path("/subjects/{subject}") @ApiOperation(value = "Get schema information for the given schema subject and schema text", response = Schema.class, tags = OPERATION_GROUP_CONFLUENT_SR) @Timed @UnitOfWork public Response lookupSubjectVersion(@ApiParam(value = "Schema subject", required = true) @PathParam("subject") String subject, @ApiParam(value = "The schema ", required = true) String schema) { Response response; try { SchemaVersionInfo schemaVersionInfo = schemaRegistry.getSchemaVersionInfo(subject, schemaStringFromJson(schema).getSchema()); if (schemaVersionInfo != null) { response = WSUtils.respondEntity(new Schema(schemaVersionInfo.getName(), schemaVersionInfo.getVersion(), schemaVersionInfo.getId(), schemaVersionInfo.getSchemaText()), Response.Status.OK); } else { response = WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, subject); } } catch (InvalidSchemaException ex) { LOG.error("Given schema is invalid", ex); response = invalidSchemaError(); } catch (SchemaNotFoundException ex) { LOG.error("No schema found with subject [{}]", subject, ex); response = subjectNotFoundError(); } catch (Exception ex) { LOG.error("Encountered error while retrieving schema version with subject: [{}]", subject, ex); response = serverError(); } return response; }
} catch (Exception ex) { LOG.error("Encountered error while retrieving all subjects", ex); response = serverError();
} catch (Exception ex) { LOG.error("Encountered error while retrieving all subjects", ex); response = serverError();
} catch (Exception ex) { LOG.error("Encountered error while adding subject [{}]", subject, ex); response = serverError();
} catch (Exception ex) { LOG.error("Encountered error while adding subject [{}]", subject, ex); response = serverError();