/** * A {@link DelegatingSubject} delegates work to a provided Subject. **/ protected DelegatingSubject(Subject delegate) { super(delegate.getName()); this.delegate = delegate; }
/** * A {@link DelegatingSubject} delegates work to a provided Subject. **/ protected DelegatingSubject(Subject delegate) { super(delegate.getName()); this.delegate = delegate; }
public class Subject implements Comparable<Subject> { .... @Override public int compareTo(Subject other) { return this.getName().compareTo(other.getName()); } }
@Override public Subject add(Subject subject) { if (subject == null) { return subject; } Subject prior = subjects.putIfAbsent(subject.getName(), subject); return (null != prior) ? prior : subject; }
@Override public Subject add(Subject subject) { if (subject == null) { return subject; } Subject prior = subjects.putIfAbsent(subject.getName(), subject); return (null != prior) ? prior : subject; }
/** * Encode {@link Subject}s into a {@link String} for use by * {@link #subjectNamesFromString(String)} * * @param subjects * the Subject objects to encode * @return The {@link Subject} objects encoded as a String */ public static String subjectsToString(Iterable<Subject> subjects) { StringBuilder sb = new StringBuilder(); for (Subject s : subjects) { sb.append(s.getName()).append("\n"); } return sb.toString(); }
/** * Encode {@link Subject}s into a {@link String} for use by * {@link #subjectNamesFromString(String)} * * @param subjects * the Subject objects to encode * @return The {@link Subject} objects encoded as a String */ public static String subjectsToString(Iterable<Subject> subjects) { StringBuilder sb = new StringBuilder(); for (Subject s : subjects) { sb.append(s.getName()).append("\n"); } return sb.toString(); }
/** * This retrieves mutable data, hence it is not cache-able and will always * result in a call to the underlying schema repo implementation. * * @return the list of all Subjects currently registered */ public List<SUBJECT> getSubjects() { List<SUBJECT> subjects = Lists.newArrayList(); for (Subject subject: repo.subjects()) { subjects.add(convertSubject.fromString(subject.getName())); } return subjects; } }
/** * This retrieves mutable data, hence it is not cache-able and will always * result in a call to the underlying schema repo implementation. * * @return the list of all Subjects currently registered */ public List<SUBJECT> getSubjects() { List<SUBJECT> subjects = Lists.newArrayList(); for (Subject subject: repo.subjects()) { subjects.add(convertSubject.fromString(subject.getName())); } return subjects; } }
/** * Create a subject if it does not already exist. * * @param subject * the name of the subject * @param configParams * the configuration values for the Subject, as form parameters * @return the subject name in a 200 response if successful. * HTTP 404 if the subject does not exist, or HTTP 409 if there was a conflict creating the subject */ @PUT @Path("{subject}") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response createSubject(@PathParam("subject") String subject, MultivaluedMap<String, String> configParams) { if (null == subject) { return Response.status(400).build(); } SubjectConfig.Builder builder = new SubjectConfig.Builder(); for(Map.Entry<String, List<String>> entry : configParams.entrySet()) { List<String> val = entry.getValue(); if(val.size() > 0) { builder.set(entry.getKey(), val.get(0)); } } Subject created = repo.register(subject, builder.build()); return Response.ok(created.getName()).build(); }
/** * Create a subject if it does not already exist. * * @param subject * the name of the subject * @param configParams * the configuration values for the Subject, as form parameters * @return the subject name in a 200 response if successful. * HTTP 404 if the subject does not exist, or HTTP 409 if there was a conflict creating the subject */ @PUT @Path("{subject}") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response createSubject(@PathParam("subject") String subject, MultivaluedMap<String, String> configParams) { if (null == subject) { return Response.status(400).build(); } SubjectConfig.Builder builder = new SubjectConfig.Builder(); for(Map.Entry<String, List<String>> entry : configParams.entrySet()) { List<String> val = entry.getValue(); if(val.size() > 0) { builder.set(entry.getKey(), val.get(0)); } } Subject created = repo.register(subject, builder.build()); return Response.ok(created.getName()).build(); }
private void validate(Iterable<String> names, Iterable<Subject> subjects) { Iterator<String> nameIter = names.iterator(); for (Subject s : subjects) { String name = nameIter.next(); Assert.assertEquals(s.getName(), name); } }
private void validate(Iterable<String> names, Iterable<Subject> subjects) { Iterator<String> nameIter = names.iterator(); for (Subject s : subjects) { String name = nameIter.next(); Assert.assertEquals(s.getName(), name); } }