@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; }
new SchemaVersion(schemaStringFromJson(schema).getSchema(), null));
new SchemaVersion(schemaStringFromJson(schema).getSchema(), null));
@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; }
@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; }
private Response postSubjectSchema(String subjectName, String schemaText) throws IOException { WebTarget subjectsTarget = rootTarget.path("/subjects/" + subjectName + "/versions"); SchemaString schemaString = new SchemaString(); schemaString.setSchema(schemaText); return subjectsTarget.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(schemaString)); }