Search in sources :

Example 6 with AnnotationField

use of org.xwiki.annotation.rest.model.jaxb.AnnotationField in project xwiki-platform by xwiki.

the class AbstractFormUrlEncodedAnnotationRequestReader method saveField.

/**
 * Helper function to save a parameter in the read object. To implement in subclasses to provide type specific
 * behaviour.
 *
 * @param readObject the request to fill with data
 * @param key the key of the field
 * @param value the value of the field
 * @param objectFactory the objects factory to create the annotation fields
 * @return true if the field was saved at this level, false otherwise
 */
protected boolean saveField(T readObject, String key, String value, ObjectFactory objectFactory) {
    // if the field is a requested field, put it in the requested fields list
    if (REQUESTED_FIELD.equals(key)) {
        readObject.getRequest().getFields().add(value);
        return true;
    }
    // if the field is a filter field, direct it to the filter fields collection
    if (key.startsWith(FILTER_FIELD_PREFIX)) {
        AnnotationField filterField = objectFactory.createAnnotationField();
        // put only the name of the prop to filter for, not the filter prefix too
        filterField.setName(key.substring(FILTER_FIELD_PREFIX.length()));
        filterField.setValue(value);
        readObject.getFilter().getFields().add(filterField);
        return true;
    }
    return false;
}
Also used : AnnotationField(org.xwiki.annotation.rest.model.jaxb.AnnotationField)

Aggregations

AnnotationField (org.xwiki.annotation.rest.model.jaxb.AnnotationField)6 ArrayList (java.util.ArrayList)3 Annotation (org.xwiki.annotation.Annotation)3 XWikiException (com.xpn.xwiki.XWikiException)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 AnnotationServiceException (org.xwiki.annotation.AnnotationServiceException)2 AnnotationResponse (org.xwiki.annotation.rest.model.jaxb.AnnotationResponse)2 DocumentReference (org.xwiki.model.reference.DocumentReference)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 GET (javax.ws.rs.GET)1 PUT (javax.ws.rs.PUT)1 Request (org.restlet.Request)1 Form (org.restlet.data.Form)1 AnnotationAddRequest (org.xwiki.annotation.rest.model.jaxb.AnnotationAddRequest)1 AnnotationFieldCollection (org.xwiki.annotation.rest.model.jaxb.AnnotationFieldCollection)1 AnnotationRequest (org.xwiki.annotation.rest.model.jaxb.AnnotationRequest)1 AnnotationStub (org.xwiki.annotation.rest.model.jaxb.AnnotationStub)1