Ignore:
Timestamp:
Dec 5, 2012, 2:36:43 PM (11 years ago)
Author:
casties
Branch:
default
Message:

deal with special characters in urls.

File:
1 edited

Legend:

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

    r63 r65  
    66
    77import java.io.IOException;
     8import java.io.UnsupportedEncodingException;
     9import java.net.URLDecoder;
    810import java.util.ArrayList;
    911import java.util.List;
     
    5052        setCorsHeaders();
    5153        // id from URI /annotations/{id}
     54        String id = null;
    5255        String jsonId = (String) getRequest().getAttributes().get("id");
    53         String id = decodeJsonId(jsonId);
    54         logger.debug("annotation-id=" + id);
     56        if (jsonId != null) {
     57            // URL decode
     58            try {
     59                jsonId = URLDecoder.decode(jsonId, "UTF-8");
     60            } catch (UnsupportedEncodingException e) {
     61                // this shouldn't happen
     62            }
     63            id = decodeJsonId(jsonId);
     64            logger.debug("annotation-id=" + id);
     65        }
    5566
    5667        // do authentication
     
    8798        AnnotationStore store = getAnnotationStore();
    8899        ArrayList<JSONObject> results = new ArrayList<JSONObject>();
    89        
     100
    90101        // read all annotations
    91102        List<Annotation> annotations = store.getAnnotations(null, null);
    92103        for (Annotation annotation : annotations) {
    93104            // check permission
    94             if (!annotation.isActionAllowed("read", authUser, store)) continue;
     105            if (!annotation.isActionAllowed("read", authUser, store))
     106                continue;
    95107            // add annotation to list
    96108            JSONObject jo = createAnnotatorJson(annotation, false);
     
    102114            JSONObjectComparator.sortAnnotations(results, sortBy);
    103115        }
    104        
     116
    105117        // put in JSON list
    106118        JSONArray rows = new JSONArray();
     
    108120        for (JSONObject result : results) {
    109121            cnt += 1;
    110             if (offset > 0 && cnt < offset) continue;
     122            if (offset > 0 && cnt < offset)
     123                continue;
    111124            rows.put(result);
    112             if (limit > 0 && cnt >= limit) break;
     125            if (limit > 0 && cnt >= limit)
     126                break;
    113127        }
    114128
Note: See TracChangeset for help on using the changeset viewer.