diff src/main/java/de/mpiwg/itgroup/annotations/Annotation.java @ 50:64aa756c60cc

annotations ui can show and delete annotations now.
author casties
date Thu, 27 Sep 2012 17:12:08 +0200
parents 0e00bf8e27fb
children 2b1e6df5e21a
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/annotations/Annotation.java	Thu Sep 27 12:39:15 2012 +0200
+++ b/src/main/java/de/mpiwg/itgroup/annotations/Annotation.java	Thu Sep 27 17:12:08 2012 +0200
@@ -3,8 +3,11 @@
  */
 package de.mpiwg.itgroup.annotations;
 
+import java.io.UnsupportedEncodingException;
 import java.util.Set;
 
+import org.apache.commons.codec.binary.Base64;
+
 import de.mpiwg.itgroup.annotations.neo4j.AnnotationStore;
 
 /**
@@ -160,6 +163,29 @@
     }
 
     /**
+     * Returns an URL-compatible id.
+     * Currently the uri as base64 encoded string.
+     * @return
+     */
+    public String getUrlId() {
+        if (uri == null) return null;
+        try {
+            return Base64.encodeBase64URLSafeString(uri.getBytes("UTF-8"));
+        } catch (UnsupportedEncodingException e) {
+            return null;
+        }
+    }
+
+    public static String decodeId(String id) {
+        if (id == null) return null;
+        try {
+            return new String(Base64.decodeBase64(id), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            return null;
+        }
+    }
+
+    /**
      * @return the bodyText
      */
     public String getBodyText() {