Ignore:
Timestamp:
Sep 4, 2012, 6:02:59 PM (12 years ago)
Author:
casties
Branch:
default
Message:

CLOSED - # 252: Tags for Annotations
https://it-dev.mpiwg-berlin.mpg.de/tracs/mpdl-project-software/ticket/252

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorResourceImpl.java

    r15 r16  
    1010import java.util.ArrayList;
    1111import java.util.Calendar;
     12import java.util.HashSet;
    1213import java.util.List;
     14import java.util.Set;
    1315import java.util.regex.Matcher;
    1416import java.util.regex.Pattern;
     
    190192            jo.put("uri", annot.getTargetBaseUri());
    191193
     194            /*
     195             * user
     196             */
    192197            if (makeUserObject) {
    193198                // create user object
     
    214219            }
    215220
     221            /*
     222             * ranges
     223             */
    216224            if (annot.getTargetFragment() != null) {
    217225                // we only look at the first xpointer
     
    226234            }
    227235           
    228             // permissions
     236            /*
     237             * permissions
     238             */
    229239            JSONObject perms = new JSONObject();
    230240            jo.put("permissions", perms);
     
    267277            }
    268278           
     279            /*
     280             * tags
     281             */
     282            Set<String> tagset = annot.getTags();
     283            if (tagset != null) {
     284                JSONArray tags = new JSONArray();
     285                jo.put("tags", tags);
     286                for (String tag : tagset) {
     287                    tags.put(tag);
     288                }
     289            }
     290           
     291            /*
     292             * id
     293             */
    269294            // encode Annotation URL (=id) in base64
    270295            String annotUrl = annot.getUri();
     
    413438    public Annotation updateAnnotation(Annotation annot, JSONObject jo, Representation entity) throws JSONException,
    414439            UnsupportedEncodingException {
    415         // target uri
     440        /*
     441         * target uri
     442         */
    416443        if (jo.has("uri")) {
    417444            annot.setTargetBaseUri(jo.getString("uri"));
    418445        }
    419         // annotation text
     446        /*
     447         * annotation text
     448         */
    420449        if (jo.has("text")) {
    421450            annot.setBodyText(jo.getString("text"));
    422451        }
    423         // check authentication
     452        /*
     453         * check authentication
     454         */
    424455        String authUser = checkAuthToken(entity);
    425456        if (authUser == null) {
     
    434465             */
    435466        }
    436         // get or create creator object
     467        /*
     468         * get or create creator object
     469         */
    437470        Actor creator = annot.getCreator();
    438471        if (creator == null) {
     
    483516            creator.setUri(userUri);
    484517        }
    485 
     518        /*
     519         * creation date
     520         */
    486521        if (annot.getCreated() == null) {
    487522            // set creation date
     
    491526        }
    492527
    493         // create xpointer from the first range/area
     528        /*
     529         * create xpointer from the first range/area
     530         */
    494531        if (jo.has("ranges")) {
    495532            JSONObject ranges = jo.getJSONArray("ranges").getJSONObject(0);
     
    505542        }
    506543
    507         // permissions
     544        /*
     545         * permissions
     546         */
    508547        if (jo.has("permissions")) {
    509548            JSONObject permissions = jo.getJSONObject("permissions");
     
    530569        }
    531570
     571        /*
     572         * tags
     573         */
     574        if (jo.has("tags")) {
     575            HashSet<String> tagset = new HashSet<String>();
     576            JSONArray tags = jo.getJSONArray("tags");
     577            for (int i = 0; i < tags.length(); ++i) {
     578                tagset.add(tags.getString(i));
     579            }
     580            annot.setTags(tagset);
     581        }
     582
     583       
    532584        return annot;
    533585    }
Note: See TracChangeset for help on using the changeset viewer.