@StartBeforeEnd private static class MissingStartDate { @SuppressWarnings("unused") private Date end; }
@ResourceModel @Path("/attachment") public class AttachmentResource extends RepositoryResource<Attachment, AttachmentRepresentation> implements MetadataResource { public static final String ATTACHMENT_XML_MEDIA_TYPE = BASE_XML_MEDIA_TYPE + "; type=attachment"; public static final String ATTACHMENT_JSON_MEDIA_TYPE = BASE_JSON_MEDIA_TYPE + "; type=attachment"; public AttachmentResource() { super(AttachmentResource.class, Attachment.class, AttachmentRepresentation.class); } @Override public String getResourceMediaType() { return ATTACHMENT_XML_MEDIA_TYPE; } @Override protected String[] getMediaTypes() { return new String[]{ATTACHMENT_XML_MEDIA_TYPE, ATTACHMENT_JSON_MEDIA_TYPE}; } @Override public ResourceMetadata getResourceMetadata() { return new ResourceMetadata(Attachment.class) .incoming(new Relation("attached_to")); } }
@REST @Interceptor public class RESTInterceptorEnabler {
@Override public boolean isValid(Object value, ConstraintValidatorContext context) { Class<?> type = value.getClass(); Field startField = getField(annotation.start(), type); Field endField = getField(annotation.end(), type); Date startValue = getValue(startField, value); if(startValue == null) { return true; } Date endValue = getValue(endField, value); if(endValue == null) { return true; } if(endValue.before(startValue)) { context.buildConstraintViolationWithTemplate("EndBeforeStart") .addNode(annotation.end()) .addConstraintViolation(); return false; } return true; }
@ResourceModel @Path("/user") public class UserResource extends RepositoryResource<User, UserRepresentation> implements MetadataResource {
@StartBeforeEnd private static class StartEndDate { @SuppressWarnings("unused") private Date start; @SuppressWarnings("unused") private Date end; }
@ResourceModel @Path("/session") public class SessionResource extends RepositoryResource<Session, SessionRepresentation> implements MetadataResource {
@StartBeforeEnd(start = "startOther", end = "endOther") private static class StartEndOtherDate { @SuppressWarnings("unused") private Date startOther; @SuppressWarnings("unused") private Date endOther; } }
@ResourceModel @Path("target") public class TargetResource implements MetadataResource { @Override public ResourceMetadata getResourceMetadata() { return new ResourceMetadata(TargetObject.class) .incoming(new Relation("connected_to")); } }
@StartBeforeEnd private static class MissingEndDate { @SuppressWarnings("unused") private Date start; }
@Path("/bookmark") @ResourceModel public class BookmarkResource {
@StartBeforeEnd private static class WrongType { @SuppressWarnings("unused") private String start; @SuppressWarnings("unused") private String end; }
@ResourceModel @Path("/") public class RootResource {
@StartBeforeEnd @XmlRootElement(name = "conference", namespace = "urn:ced:conference") public class ConferenceRepresentation extends LinkableRepresentation<Conference> implements Identifiable {
@ResourceModel @Path("/conference") public class ConferenceResource extends RepositoryResource<Conference, ConferenceRepresentation>
@StartBeforeEnd @XmlRootElement(name = "session", namespace = "urn:ced:session") public class SessionRepresentation extends LinkableRepresentation<Session> implements Identifiable {
@ResourceModel @Path("test") public class TestResource {
@ResourceModel @Path("/security/whoami") public class WhoAmIResource implements TopLevelResource {
@ResourceModel @Path("/test") public class TestResource implements TopLevelResource {
@ResourceModel @Path("source") public class SourceResource implements MetadataResource {