Index: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/Helpers.java
===================================================================
--- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/Helpers.java	(revision 5022)
+++ DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/Helpers.java	(revision 5030)
@@ -45,5 +45,9 @@
         String result = (new StringBuilder(text)).toString();
         for (String tempTarget : pairs.keySet()) {
-            result = result.replaceAll(tempTarget, pairs.get(tempTarget));
+            if (tempTarget != null) {
+                if (!tempTarget.trim().equals("")) {
+                    result = result.replaceAll(tempTarget, pairs.get(tempTarget));
+                }
+            }
         }
         return result;
@@ -65,5 +69,5 @@
         return result;
     }
-    
+
     public static String welcomeString(String baseUri) {
         String welcome = "<!DOCTYPE html><body>"
@@ -74,5 +78,5 @@
         return welcome;
     }
-    
+
     public static Principal createPrincipalElement(String name, String e_mail) {
         Principal result = new Principal();
@@ -81,8 +85,8 @@
         return result;
     }
-    
+
     public static String hashPswd(String pswd, int strength, String salt) {
-    ShaPasswordEncoder encoder = new ShaPasswordEncoder(strength);
-    return encoder.encodePassword(pswd, salt);
+        ShaPasswordEncoder encoder = new ShaPasswordEncoder(strength);
+        return encoder.encodePassword(pswd, salt);
     }
 }
Index: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/PrincipalResource.java
===================================================================
--- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/PrincipalResource.java	(revision 5022)
+++ DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/PrincipalResource.java	(revision 5030)
@@ -74,10 +74,5 @@
         Map params = new HashMap<String, String>();
         params.put("externalId", externalIdentifier);
-        Principal principal = (Principal) this.wrapGetResource(params, new GetPrincipal());
-        if (principal != null) {
-            return new ObjectFactory().createPrincipal(principal);
-        } else {
-            return new ObjectFactory().createPrincipal(new Principal());
-        }
+        return this.wrapPrincipalRequest(params, new GetPrincipal());
     }
 
@@ -101,11 +96,5 @@
         Map params = new HashMap<String, String>();
         params.put("email", email);
-        Principal principal = (Principal) this.wrapGetResource(params, new GetPrincipalByInfo());
-        if (principal != null) {
-            return new ObjectFactory().createPrincipal(principal);
-        } else {
-            return new ObjectFactory().createPrincipal(new Principal());
-        }
-
+        return this.wrapPrincipalRequest(params, new GetPrincipalByInfo());
     }
 
@@ -118,10 +107,6 @@
         params.put("externalId", externalIdentifier);
         params.put("resource", this);
-        CurrentPrincipalInfo result = (CurrentPrincipalInfo) this.wrapGetResource(params, new GetCurrentPrincipalInfo());
-        if (result != null) {
-            return new ObjectFactory().createCurrentPrincipalInfo(result);
-        } else {
-            return new ObjectFactory().createCurrentPrincipalInfo(new CurrentPrincipalInfo());
-        }
+        return this.wrapCurrentPrincipalInfoRequest(params, new GetCurrentPrincipalInfo());
+        
     }
 
@@ -162,5 +147,5 @@
 
         if (dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
-            return this.wrapAddOrUpdatePrincipal(params, new AddPrincipal());
+            return this.wrapPrincipalRequest(params, new AddPrincipal());
         } else {
             verboseOutput.ADMIN_RIGHTS_EXPECTED();
@@ -190,5 +175,5 @@
         dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
 
-        return this.wrapAddOrUpdatePrincipal(params, new RegisterNonShibbolizedPrincipal());
+        return this.wrapPrincipalRequest(params, new RegisterNonShibbolizedPrincipal());
 
     }
@@ -209,5 +194,5 @@
         params.put("newPrincipal", newPrincipal);
 
-        return this.wrapAddOrUpdatePrincipal(params, new AddPrincipal());
+        return this.wrapPrincipalRequest(params, new AddPrincipal());
     }
 
@@ -236,5 +221,5 @@
 
         if (dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
-            return this.wrapAddOrUpdatePrincipal(params, new UpdatePrincipal());
+            return this.wrapPrincipalRequest(params, new UpdatePrincipal());
         } else {
             verboseOutput.ADMIN_RIGHTS_EXPECTED();
@@ -264,5 +249,5 @@
         params.put("newPrincipal", newPrincipal);
 
-        return this.wrapAddOrUpdatePrincipal(params, new UpdatePrincipal());
+        return this.wrapPrincipalRequest(params, new UpdatePrincipal());
     }
 
@@ -366,18 +351,18 @@
 
    
-    private class GetPrincipal implements ILambda<Map<String, String>, Principal> {
-
-        @Override
-        public Principal apply(Map<String, String> params) throws NotInDataBaseException, PrincipalExists {
-            final Number principalID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(params.get("externalId")), Resource.PRINCIPAL);
+    private class GetPrincipal implements ILambda<Map, Principal> {
+
+        @Override
+        public Principal apply(Map params) throws NotInDataBaseException, PrincipalExists {
+            final Number principalID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString((String) params.get("externalId")), Resource.PRINCIPAL);
             return dbIntegrityService.getPrincipal(principalID);
         }
     }
 
-    private class GetPrincipalByInfo implements ILambda<Map<String, String>, Principal> {
-
-        @Override
-        public Principal apply(Map<String, String> params) throws NotInDataBaseException, PrincipalExists {
-            return dbIntegrityService.getPrincipalByInfo(params.get("email"));
+    private class GetPrincipalByInfo implements ILambda<Map, Principal> {
+
+        @Override
+        public Principal apply(Map params) throws NotInDataBaseException, PrincipalExists {
+            return dbIntegrityService.getPrincipalByInfo((String) params.get("email"));
         }
     }
@@ -396,5 +381,9 @@
 
     //// wrappers that map main working methods into exception handling ////
-    private JAXBElement<Principal> wrapAddOrUpdatePrincipal(Map params, ILambda<Map, Principal> changer) throws IOException {
+    
+    
+    
+    
+    private JAXBElement<Principal> wrapPrincipalRequest(Map params, ILambda<Map, Principal> dbRequestor) throws IOException {
         Number remotePrincipalID = this.getPrincipalID();
         if (remotePrincipalID == null) {
@@ -403,5 +392,5 @@
         try {
             try {
-                return new ObjectFactory().createPrincipal(changer.apply(params));
+                return new ObjectFactory().createPrincipal(dbRequestor.apply(params));
             } catch (NotInDataBaseException e1) {
                 loggerServer.debug(e1.toString());
@@ -416,3 +405,24 @@
 
     }
+    
+     private JAXBElement<CurrentPrincipalInfo> wrapCurrentPrincipalInfoRequest(Map params, ILambda<Map, CurrentPrincipalInfo> dbRequestor) throws IOException {
+        Number remotePrincipalID = this.getPrincipalID();
+        if (remotePrincipalID == null) {
+            return new ObjectFactory().createCurrentPrincipalInfo(new CurrentPrincipalInfo());
+        }
+        try {
+            try {
+                return new ObjectFactory().createCurrentPrincipalInfo(dbRequestor.apply(params));
+            } catch (NotInDataBaseException e1) {
+                loggerServer.debug(e1.toString());
+                httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e1.toString());
+                return new ObjectFactory().createCurrentPrincipalInfo(new CurrentPrincipalInfo());
+            }
+        } catch (PrincipalExists e) {
+            loggerServer.debug(e.toString());
+            httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
+            return new ObjectFactory().createCurrentPrincipalInfo(new CurrentPrincipalInfo());
+        }
+
+    }
 }
Index: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceResource.java
===================================================================
--- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceResource.java	(revision 5022)
+++ DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceResource.java	(revision 5030)
@@ -101,23 +101,4 @@
     }
     
-    protected T wrapGetResource(Map params, ILambda<Map, T> getter) throws IOException {
-        Number remotePrincipalID = this.getPrincipalID();
-        if (remotePrincipalID == null) {
-            return null;
-        }
-        try {
-            try {
-                return getter.apply(params);
-            } catch (NotInDataBaseException e1) {
-                loggerServer.debug(e1.toString());
-                httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e1.toString());
-                return null;
-            }
-        } catch (PrincipalExists e) {
-            loggerServer.debug(e.toString());
-            httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
-            return null;
-        }
-
-    }
+    
 }
