@Override public void validate(String schemaToValidate, Iterable<SchemaEntry> schemasInOrder) throws SchemaValidationException { throw new SchemaValidationException( "repo.validator.reject validator always rejects validation"); } }
/** * Register a schema with a subject * * @param subject * The subject name to register the schema in * @param schema * The schema to register * @return A 200 response with the corresponding id if successful, * a 403 forbidden response with exception message if the schema fails validation, * or a 404 not found response if the subject does not exist */ @PUT @Path("{subject}/register") @Consumes(MediaType.TEXT_PLAIN) public Response addSchema(@PathParam("subject") String subject, String schema) { try { return Response.ok(getSubject(subject).register(schema).getId()).build(); } catch (SchemaValidationException e) { return Response.status(Status.FORBIDDEN).entity(e.getMessage()).build(); } }
return Response.status(Status.FORBIDDEN).entity(e.getMessage()).build();
@Override public void validate(String schemaToValidate, Iterable<SchemaEntry> schemasInOrder) throws SchemaValidationException { throw new SchemaValidationException( "repo.validator.reject validator always rejects validation"); } }
e.getMessage()); } finally { try {
@Override public void validate(String schemaToValidate, Iterable<SchemaEntry> schemasInOrder) throws SchemaValidationException { throw new SchemaValidationException("no"); } }
private SchemaEntry handleRegisterRequest(String path, String schema, boolean resourceNotFoundExpected) throws SchemaValidationException { SchemaEntry schemaEntry = null; try { String schemaId = webResource.path(path) .type(MediaType.TEXT_PLAIN_TYPE) .put(String.class, schema); schemaEntry = new SchemaEntry(schemaId, schema); } catch (UniformInterfaceException e) { ClientResponse cr = e.getResponse(); if (ClientResponse.Status.fromStatusCode(cr.getStatus()).equals(FORBIDDEN)) { throw new SchemaValidationException("Invalid schema: " + schema); } else { //any other status should return null handleException(e, format("Failed to register new schema for subject %s", getName()), resourceNotFoundExpected); } } catch (ClientHandlerException e) { handleException(e, format("Failed to register new schema for subject %s", getName()), resourceNotFoundExpected); } return schemaEntry; }
private SchemaEntry handleRegisterRequest(String path, String schema, boolean resourceNotFoundExpected) throws SchemaValidationException { SchemaEntry schemaEntry = null; try { String schemaId = webResource.path(path) .type(MediaType.TEXT_PLAIN_TYPE) .put(String.class, schema); schemaEntry = new SchemaEntry(schemaId, schema); } catch (UniformInterfaceException e) { ClientResponse cr = e.getResponse(); if (ClientResponse.Status.fromStatusCode(cr.getStatus()).equals(FORBIDDEN)) { throw new SchemaValidationException("Invalid schema: " + schema + ". Reason: " + cr.getEntity(String.class)); } else { //any other status should return null handleException(e, format("Failed to register new schema for subject %s", getName()), resourceNotFoundExpected); } } catch (ClientHandlerException e) { handleException(e, format("Failed to register new schema for subject %s", getName()), resourceNotFoundExpected); } return schemaEntry; }
private SchemaEntry handleRegisterRequest(String path, String schema) throws SchemaValidationException { String schemaId; try { schemaId = webResource.path(path).type(MediaType.TEXT_PLAIN_TYPE).put(String.class, schema); return new SchemaEntry(schemaId, schema); } catch (UniformInterfaceException e) { ClientResponse cr = e.getResponse(); if (ClientResponse.Status.fromStatusCode(cr.getStatus()).equals( ClientResponse.Status.FORBIDDEN)) { throw new SchemaValidationException("Invalid schema: " + schema); } else { //any other status should return null return null; } } catch (ClientHandlerException e) { return null; } }
private SchemaEntry handleRegisterRequest(String path, String schema) throws SchemaValidationException { String schemaId; try { schemaId = webResource.path(path).type(MediaType.TEXT_PLAIN_TYPE).put(String.class, schema); return new SchemaEntry(schemaId, schema); } catch (UniformInterfaceException e) { ClientResponse cr = e.getResponse(); if (ClientResponse.Status.fromStatusCode(cr.getStatus()).equals( ClientResponse.Status.FORBIDDEN)) { throw new SchemaValidationException("Invalid schema: " + schema + ". Reason: " + cr.getEntity(String.class)); } else { //any other status should return null return null; } } catch (ClientHandlerException e) { return null; } }