Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBIntegrityService.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBIntegrityService.java	(revision 4528)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBIntegrityService.java	(revision 4529)
@@ -245,4 +245,6 @@
     public NotebookInfoList getNotebooks(Number prinipalID, String permission);
     
+    boolean hasAccess(Number notebookID, Number principalID, Permission permission);    
+    
     public ReferenceList getNotebooksOwnedBy(Number principalID);
 
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/NotebookDao.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/NotebookDao.java	(revision 4528)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/NotebookDao.java	(revision 4529)
@@ -43,4 +43,6 @@
     
     Number getOwner(Number notebookID);
+    
+    
     
     List<Number> getNotebookIDs(Number principalID, Permission acessMode);
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java	(revision 4528)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java	(revision 4529)
@@ -471,4 +471,14 @@
 
     @Override
+    public boolean hasAccess(Number notebookID, Number principalID, Permission permission){
+        List<Number> notebookIDs = notebookDao.getNotebookIDs(principalID, permission);
+        if (notebookIDs == null) {
+            return false;
+        } 
+        return notebookIDs.contains(notebookID);
+    }
+    
+    
+    @Override
     public ReferenceList getNotebooksOwnedBy(Number principalID) {
         ReferenceList result = new ReferenceList();
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcNotebookDao.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcNotebookDao.java	(revision 4528)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcNotebookDao.java	(revision 4529)
@@ -24,5 +24,4 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.List;
@@ -31,7 +30,4 @@
 import javax.sql.DataSource;
 import org.springframework.jdbc.core.RowMapper;
-import javax.xml.datatype.DatatypeConfigurationException;
-import javax.xml.datatype.DatatypeFactory;
-import javax.xml.datatype.XMLGregorianCalendar;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -72,4 +68,6 @@
         }
     }
+    
+  
 
     @Override
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java	(revision 4528)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java	(revision 4529)
@@ -83,7 +83,6 @@
     @Context
     private ServletContext context;
-    
-    private final Logger logger = LoggerFactory.getLogger(AnnotationResource.class);
     public static final Logger loggerServer = LoggerFactory.getLogger(HttpServletResponse.class);
+    private final VerboseOutput verboseOutput = new VerboseOutput(httpServletResponse, loggerServer);
     final private String admin = "admin";
 
@@ -112,9 +111,5 @@
     @Transactional(readOnly = true)
     public JAXBElement<Annotation> getAnnotation(@PathParam("annotationid") String externalIdentifier) throws IOException {
-
-        URI baseURI = uriInfo.getBaseUri();
-        String baseURIstr = baseURI.toString();
-        dbIntegrityService.setServiceURI(baseURIstr);
-
+        dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
         try {
             final Number annotationID = dbIntegrityService.getAnnotationInternalIdentifier(UUID.fromString(externalIdentifier));
@@ -125,27 +120,19 @@
                     if (dbIntegrityService.canRead(userID, annotationID)) {
                         final Annotation annotation = dbIntegrityService.getAnnotation(annotationID);
-                        JAXBElement<Annotation> rootElement = new ObjectFactory().createAnnotation(annotation);
-                        return rootElement;
-                    } else {
-                        loggerServer.debug(httpServletResponse.SC_FORBIDDEN + ": The logged-in user cannot read the annotation.");
-                        httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "The logged-in user cannot read the annotation.");
-                        return null;
-                    }
-                } else {
-                    loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-                    httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database");
-                    return null;
-                }
-            } else {
-                loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + externalIdentifier + " is not found in the database");
-                httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id " + externalIdentifier + " is not found in the database");
-                return null;
-            }
-        } catch (IllegalArgumentException e) {
-            loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + externalIdentifier);
-            httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + externalIdentifier);
-            return null;
-        }
-
+                        return new ObjectFactory().createAnnotation(annotation);
+                    } else {
+                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_ANNOTATION_READING(externalIdentifier), HttpServletResponse.SC_FORBIDDEN);
+                    }
+                } else {
+                    verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+
+                }
+            } else {
+                verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
+            }
+        } catch (IllegalArgumentException e) {
+            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(externalIdentifier), HttpServletResponse.SC_BAD_REQUEST);
+        }
+        return new ObjectFactory().createAnnotation(new Annotation());
     }
 
@@ -157,5 +144,4 @@
     public JAXBElement<ReferenceList> getAnnotationTargets(@PathParam("annotationid") String externalIdentifier) throws IOException {
         dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
-
         try {
             final Number annotationID = dbIntegrityService.getAnnotationInternalIdentifier(UUID.fromString(externalIdentifier));
@@ -166,26 +152,20 @@
                     if (dbIntegrityService.canRead(userID, annotationID)) {
                         final ReferenceList TargetList = dbIntegrityService.getAnnotationTargets(annotationID);
-                        logger.info("getAnnotationTargets method: OK");
                         return new ObjectFactory().createTargetList(TargetList);
                     } else {
-                        loggerServer.debug(httpServletResponse.SC_FORBIDDEN + ": The logged-in user cannot read the annotation.");
-                        httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "The logged-in user cannot read the annotation.");
-                        return null;
-                    }
-                } else {
-                    loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-                    httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database");
-                    return null;
-                }
-            } else {
-                loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + externalIdentifier + " is not found in the database");
-                httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id " + externalIdentifier + " is not found in the database");
-                return null;
-            }
-        } catch (IllegalArgumentException e) {
-            loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + externalIdentifier);
-            httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + externalIdentifier);
-            return null;
-        }
+                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_ANNOTATION_READING(externalIdentifier), HttpServletResponse.SC_FORBIDDEN);
+                    }
+                } else {
+                    verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+
+                }
+            } else {
+                verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
+
+            }
+        } catch (IllegalArgumentException e) {
+            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(externalIdentifier), HttpServletResponse.SC_BAD_REQUEST);
+        }
+        return new ObjectFactory().createTargetList(new ReferenceList());
     }
 // TODO Unit test 
@@ -209,18 +189,15 @@
             try {
                 UUID ownerExternalUUID = (ownerExternalId != null) ? UUID.fromString(ownerExternalId) : null;
-                
+
                 final AnnotationInfoList annotationInfoList = dbIntegrityService.getFilteredAnnotationInfos(ownerExternalUUID, link, text, userID, access, namespace, after, before);
                 return new ObjectFactory().createAnnotationInfoList(annotationInfoList);
             } catch (IllegalArgumentException e) {
-                loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + ownerExternalId);
-                httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + ownerExternalId);
-                return null;
+                verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(ownerExternalId), HttpServletResponse.SC_BAD_REQUEST);
             }
         } else {
-            loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database");
-            return null;
-        }
-
+            verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+
+        }
+        return new ObjectFactory().createAnnotationInfoList(new AnnotationInfoList());
     }
 
@@ -240,26 +217,19 @@
                     if (dbIntegrityService.canRead(userID, annotationID)) {
                         final UserWithPermissionList permissionList = dbIntegrityService.getPermissionsForAnnotation(annotationID);
-                        logger.debug("getAnnotationPermissions method: OK");
                         return new ObjectFactory().createPermissionList(permissionList);
                     } else {
-                        loggerServer.debug(httpServletResponse.SC_FORBIDDEN + ": The logged-in user cannot read the annotation.");
-                        httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "The logged-in user cannot read the annotation.");
-                        return null;
-                    }
-                } else {
-                    loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + externalIdentifier + " is not found in the database");
-                    httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id " + externalIdentifier + " is not found in the database");
-                    return null;
-                }
-            } else {
-                loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-                httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database");
-                return null;
-            }
-        } catch (IllegalArgumentException e) {
-            loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + externalIdentifier);
-            httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + externalIdentifier);
-            return null;
-        }
+                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_ANNOTATION_READING(externalIdentifier), HttpServletResponse.SC_FORBIDDEN);
+                    }
+                } else {
+                    verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
+                }
+            } else {
+                verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+
+            }
+        } catch (IllegalArgumentException e) {
+            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(externalIdentifier), HttpServletResponse.SC_BAD_REQUEST);
+        }
+        return new ObjectFactory().createUserWithPermissionList(new UserWithPermissionList());
     }
 ///////////////////////////////////////////////////////
@@ -279,27 +249,22 @@
                         int[] resultDelete = dbIntegrityService.deleteAnnotation(annotationID);
                         String result = Integer.toString(resultDelete[0]);
-                        logger.info("deleteAnnotation method: OK");
                         return result + " annotation(s) deleted.";
                     } else {
-                        loggerServer.debug(httpServletResponse.SC_FORBIDDEN + ": The logged-in user cannot delete the annotation. Only the owner can delete the annotation.");
-                        httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "The logged-in user cannot delete the annotation. Only the owner can delete the annotation.");
-                        return null;
-                    }
-                } else {
-                    loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + externalIdentifier + " is not found in the database");
-                    httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id  " + externalIdentifier + " is not found in the database.");
-                    return null;
-                }
-
-            } else {
-                loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database.");
-                httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
-                return null;
-            }
-        } catch (IllegalArgumentException e) {
-            loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + externalIdentifier);
-            httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + externalIdentifier);
-            return null;
-        }
+                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_ANNOTATION_WRITING(externalIdentifier) + " Only a principal with 'owner' access can delete the annotation.", HttpServletResponse.SC_FORBIDDEN);
+
+                    }
+                } else {
+                    verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
+                }
+
+            } else {
+                verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+
+            }
+        } catch (IllegalArgumentException e) {
+            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(externalIdentifier), HttpServletResponse.SC_BAD_REQUEST);
+        }
+
+        return "Due to the failure no annotation is deleted.";
     }
 
@@ -318,8 +283,8 @@
             return new ObjectFactory().createResponseBody(makeAnnotationResponseEnvelope(annotationID));
         } else {
-            loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
-            return null;
-        }
+            verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+
+        }
+        return new ObjectFactory().createResponseBody(new ResponseBody());
     }
 ///////////////////////////////////////////////////////
@@ -336,7 +301,6 @@
 
         if (!(path + "annotations/" + externalIdentifier).equals(annotationURI)) {
-            loggerServer.debug(httpServletResponse.SC_CONFLICT + "Wrong request: the annotation identifier   " + externalIdentifier + " and the annotation ID from the request body do not match. Correct the request and resend.");
-            httpServletResponse.sendError(HttpServletResponse.SC_CONFLICT, "Wrong request: the annotation identifier   " + externalIdentifier + " and the annotation ID from the request body do not match. Correct the request and resend.");
-            return null;
+            verboseOutput.sendFailureMessage("Wrong request: the annotation identifier   " + externalIdentifier + " and the annotation ID from the request body do not match. Correct the request and resend.", HttpServletResponse.SC_CONFLICT);
+            return new ObjectFactory().createResponseBody(new ResponseBody());
         }
 
@@ -351,25 +315,17 @@
                         int updatedRows = dbIntegrityService.updateAnnotation(annotation);
                         return new ObjectFactory().createResponseBody(makeAnnotationResponseEnvelope(annotationID));
-
-                    } else {
-                        loggerServer.debug(httpServletResponse.SC_UNAUTHORIZED + "Only the owner can update the annotation fully (incl. permissions). Only writer can update the annotation's body.");
-                        httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Only the owner can update the annotation fully (incl. permissions). Only writer can update the annotation's body.");
-                        return null;
-                    }
-                } else {
-                    loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-                    httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
-                    return null;
-                }
-            } else {
-                loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + externalIdentifier + " is not found in the database");
-                httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id   " + externalIdentifier + " is not found in the database.");
-                return null;
-            }
-        } catch (IllegalArgumentException e) {
-            loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + externalIdentifier);
-            httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + externalIdentifier);
-            return null;
-        }
+                    } else {
+                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_PERMISSION_CHANGING(externalIdentifier) + " Permission changing is the part of the full update of the annotation.", HttpServletResponse.SC_FORBIDDEN);
+                    }
+                } else {
+                    verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+                }
+            } else {
+                verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
+            }
+        } catch (IllegalArgumentException e) {
+            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(externalIdentifier), HttpServletResponse.SC_BAD_REQUEST);
+        }
+        return new ObjectFactory().createResponseBody(new ResponseBody());
     }
 
@@ -391,23 +347,17 @@
                         return new ObjectFactory().createResponseBody(makeAnnotationResponseEnvelope(annotationID));
                     } else {
-                        loggerServer.debug(httpServletResponse.SC_UNAUTHORIZED + "The logged-in user cannot change the body of this annotation because (s)he is  not its 'writer'.");
-                        httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The logged-in user cannot change the body of this annotation because (s)he is  not its 'writer'.");
-                        return null;
-                    }
-                } else {
-                    loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + externalIdentifier + " is not found in the database");
-                    httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id   " + externalIdentifier + " is not found in the database.");
-                    return null;
-                }
-            } else {
-                loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-                httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
-                return null;
-            }
-        } catch (IllegalArgumentException e) {
-            loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + externalIdentifier);
-            httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + externalIdentifier);
-            return null;
-        }
+                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_ANNOTATION_WRITING(externalIdentifier), HttpServletResponse.SC_FORBIDDEN);
+                    }
+                } else {
+                    verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
+                }
+            } else {
+                verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+
+            }
+        } catch (IllegalArgumentException e) {
+            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(externalIdentifier), HttpServletResponse.SC_BAD_REQUEST);
+        }
+        return new ObjectFactory().createResponseBody(new ResponseBody());
     }
 
@@ -432,38 +382,27 @@
                                         ? dbIntegrityService.updateAnnotationPrincipalPermission(annotationID, userID, permission)
                                         : dbIntegrityService.addAnnotationPrincipalPermission(annotationID, userID, permission);
-                                logger.info("updatePermission method: OK");
                                 return result + " rows are updated/added";
 
                             } else {
-                                loggerServer.debug(httpServletResponse.SC_UNAUTHORIZED + "The logged-in user cannot change the body of this annotation because (s)he is  not its 'writer'.");
-                                httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The logged-in user cannot change the rights on this annotation because (s)he is  not its owner.");
-                                return null;
+                                verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_PERMISSION_CHANGING(annotationExternalId), HttpServletResponse.SC_FORBIDDEN);
                             }
                         } else {
-                            loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + annotationExternalId + " is not found in the database");
-                            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id  " + annotationExternalId + "  is not found in the database.");
-                            return null;
+                            verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(annotationExternalId), HttpServletResponse.SC_NOT_FOUND);
                         }
                     } catch (IllegalArgumentException e) {
-                        loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + annotationExternalId);
-                        httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + annotationExternalId);
-                        return null;
-                    }
-                } else {
-                    loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The user with the given id   " + userExternalId + " is not found in the database");
-                    httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The user with the given id   " + userExternalId + " is not found in the database.");
-                    return null;
+                        verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(annotationExternalId), HttpServletResponse.SC_BAD_REQUEST);
+                    }
+                } else {
+                    verboseOutput.sendFailureMessage(VerboseOutput.PRINCIPAL_NOT_FOUND(userExternalId), HttpServletResponse.SC_NOT_FOUND);
                 }
             } catch (IllegalArgumentException e) {
-                loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + userExternalId);
-                httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + userExternalId);
-                return null;
+                verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(userExternalId), HttpServletResponse.SC_BAD_REQUEST);
             }
 
         } else {
-            loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
-            return null;
-        }
+            verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+
+        }
+        return "Due to the failure no permissionis updated.";
     }
 
@@ -484,22 +423,19 @@
                         return new ObjectFactory().createResponseBody(makePermissionResponseEnvelope(annotationID));
                     } else {
-                        loggerServer.debug(httpServletResponse.SC_UNAUTHORIZED + "The logged-in user cannot change the access rights on this annotation because (s)he is  not its owner.");
-                        httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The logged-in user cannot change the access rights on this annotation because (s)he is  not its owner.");
-                        return null;
-                    }
-                } else {
-                    loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + annotationExternalId + " is not found in the database");
-                    httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id  " + annotationExternalId + "  is not found in the database.");
-                    return null;
-                }
-            } else {
-                loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-                httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
-                return null;
-            }
-        } catch (IllegalArgumentException e) {
-            loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + annotationExternalId);
-            httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + annotationExternalId);
-            return null;
+                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_PERMISSION_CHANGING(annotationExternalId), HttpServletResponse.SC_FORBIDDEN);
+                    }
+                } else {
+                    verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(annotationExternalId), HttpServletResponse.SC_NOT_FOUND);
+                }
+            } else {
+                verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+
+            }
+            return new ObjectFactory().createResponseBody(new ResponseBody());
+
+        } catch (IllegalArgumentException e) {
+            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(annotationExternalId), HttpServletResponse.SC_BAD_REQUEST);
+            return new ObjectFactory().createResponseBody(new ResponseBody());
+
         }
     }
@@ -523,27 +459,19 @@
 
                         } else {
-                            loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the user external identifier " + userId + " is not found the the databse.");
-                            httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The user external identifier " + userId + " is not found the the databse.");
-
+                            verboseOutput.sendFailureMessage(VerboseOutput.PRINCIPAL_NOT_FOUND(userId), HttpServletResponse.SC_NOT_FOUND);
                         }
                     } else {
-                        loggerServer.debug(httpServletResponse.SC_UNAUTHORIZED + "The logged-in user cannot change the access rights on this annotation because (s)he is  not its owner.");
-                        httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The logged-in user cannot change the access rights on this annotation because (s)he is  not its owner.");
-
-                    }
-                } else {
-                    loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + annotationId + " is not found in the database");
-                    httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id  " + annotationId + "  is not found in the database.");
-
-                }
-            } else {
-                loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-                httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
-
-            }
-        } catch (IllegalArgumentException e) {
-            loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + annotationId);
-            httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + annotationId);
-
+                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_PERMISSION_CHANGING(annotationId), HttpServletResponse.SC_FORBIDDEN);
+
+                    }
+                } else {
+                    verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(annotationId), HttpServletResponse.SC_NOT_FOUND);
+                }
+            } else {
+                verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+
+            }
+        } catch (IllegalArgumentException e) {
+            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(annotationId), HttpServletResponse.SC_BAD_REQUEST);
         }
         return (deletedRows + " is deleted.");
@@ -595,4 +523,3 @@
         }
     }
-
 }
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/NotebookResource.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/NotebookResource.java	(revision 4528)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/NotebookResource.java	(revision 4529)
@@ -23,4 +23,5 @@
 import eu.dasish.annotation.schema.NotebookInfoList;
 import eu.dasish.annotation.schema.ObjectFactory;
+import eu.dasish.annotation.schema.Permission;
 import eu.dasish.annotation.schema.ReferenceList;
 import java.io.IOException;
@@ -67,10 +68,11 @@
     @Context
     protected Providers providers;
-    private final Logger logger = LoggerFactory.getLogger(AnnotationResource.class);
     private final Logger loggerServer = LoggerFactory.getLogger(HttpServletResponse.class);
+    private final VerboseOutput verboseOutput = new VerboseOutput(httpServletResponse, loggerServer);
 
     public NotebookResource() {
     }
 
+    // changed w.r.t.the spec, query parameter persmission is added
     @GET
     @Produces(MediaType.APPLICATION_XML)
@@ -78,25 +80,18 @@
     @Transactional(readOnly = true)
     public JAXBElement<NotebookInfoList> getNotebookInfos(@QueryParam("permission") String permissionMode) throws IOException {
-
-        URI baseURI = uriInfo.getBaseUri();
-        String baseURIstr = baseURI.toString();
-        dbIntegrityService.setServiceURI(baseURIstr);
-
-        String remoteUser = httpServletRequest.getRemoteUser();
-        final Number userID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser);
-        if (userID != null) {
+        dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
+        String remoteUser = httpServletRequest.getRemoteUser();
+        final Number principalID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser);
+        if (principalID != null) {
             if (permissionMode.equalsIgnoreCase("reader") || permissionMode.equalsIgnoreCase("writer") || permissionMode.equalsIgnoreCase("owner")) {
-                NotebookInfoList notebookInfos = dbIntegrityService.getNotebooks(userID, permissionMode);
+                NotebookInfoList notebookInfos = dbIntegrityService.getNotebooks(principalID, permissionMode);
                 return new ObjectFactory().createNotebookInfoList(notebookInfos);
             } else {
-                loggerServer.debug(httpServletResponse.SC_BAD_REQUEST + ": '" + permissionMode + "' is an invalid permission value, which must be either owner, or reader, or writer.");
-                httpServletResponse.sendError(httpServletResponse.SC_BAD_REQUEST, permissionMode + "' is an invalid permission value, which must be either owner, or reader, or writer.");
-                return null;
-            }
-        } else {
-            loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database");
-            return null;
-        }
+                verboseOutput.sendFailureMessage(VerboseOutput.INVALID_PERMISSION_MODE(permissionMode), httpServletResponse.SC_BAD_REQUEST);
+            }
+        } else {
+            verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+        }
+        return (new ObjectFactory()).createNotebookInfoList(new NotebookInfoList());
     }
 
@@ -107,7 +102,5 @@
     public JAXBElement<ReferenceList> getOwnedNotebooks() throws IOException {
 
-        URI baseURI = uriInfo.getBaseUri();
-        String baseURIstr = baseURI.toString();
-        dbIntegrityService.setServiceURI(baseURIstr);
+        dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
 
         String remoteUser = httpServletRequest.getRemoteUser();
@@ -117,37 +110,99 @@
             return new ObjectFactory().createReferenceList(references);
         } else {
-            loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database");
-            return null;
-        }
-    }
-
-    @GET
-    @Produces(MediaType.APPLICATION_XML)
-    @Path("{notebookid: " + BackendConstants.regExpIdentifier + "}/targets")
-    @Transactional(readOnly = true)
-    public JAXBElement<Notebook> getNotebook(@PathParam("notebookid") String externalIdentifier) throws IOException {
-
-        URI baseURI = uriInfo.getBaseUri();
-        String baseURIstr = baseURI.toString();
-        dbIntegrityService.setServiceURI(baseURIstr);
-
-        String remoteUser = httpServletRequest.getRemoteUser();
-        final Number userID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser);
-        if (userID != null) {
+            verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
+        }
+        return new ObjectFactory().createReferenceList(new ReferenceList());
+    }
+
+    @GET
+    @Produces(MediaType.APPLICATION_XML)
+    @Path("{notebookid: " + BackendConstants.regExpIdentifier + "}/{permission}")
+    @Transactional(readOnly = true)
+    public JAXBElement<ReferenceList> getPrincipals(@PathParam("notebookid") String externalIdentifier, @PathParam("permission") String permissionMode) throws IOException {
+
+        dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
+
+        String remoteUser = httpServletRequest.getRemoteUser();
+        final Number principalID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser);
+        if (principalID != null) {
             Number notebookID = dbIntegrityService.getNotebookInternalIdentifier(UUID.fromString(externalIdentifier));
             if (notebookID != null) {
-                Notebook notebook = dbIntegrityService.getNotebook(notebookID);
-                return new ObjectFactory().createNotebook(notebook);
-            } else {
-                loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The notebook with the given id " + externalIdentifier + " is not found in the database");
-                httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The notebook with the given id " + externalIdentifier + " is not found in the database");
-                return null;
-            }
-        } else {
-            loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
-            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database");
-            return null;
-        }
+                if (dbIntegrityService.hasAccess(notebookID, principalID, Permission.fromValue("reader"))) {
+                    ReferenceList principals = dbIntegrityService.getPrincipals(notebookID, permissionMode);
+                    return new ObjectFactory().createReferenceList(principals);
+                } else {
+                    verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_NOTEBOOK_READING(externalIdentifier), HttpServletResponse.SC_FORBIDDEN);
+                }
+            } else {
+                verboseOutput.sendFailureMessage(VerboseOutput.NOTEBOOK_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
+            }
+        } else {
+            verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, HttpServletResponse.SC_NOT_FOUND);
+        }
+
+        return new ObjectFactory().createReferenceList(new ReferenceList());
+    }
+
+    // Notebook and NotebookInfo (metadata) schemata may be changed
+    // 1) we do not have information "private notebook" directly in the xml, but we have readers and writers in the schema
+    //so if both are empty then we see that it is private for the owner
+    // or shall we change the scheme? for notebooks
+    // 2) d we need to include the reference list of annotations in teh metadata of the notebook
+    @GET
+    @Produces(MediaType.APPLICATION_XML)
+    @Path("{notebookid: " + BackendConstants.regExpIdentifier + "}/metadata")
+    @Transactional(readOnly = true)
+    public JAXBElement<Notebook> getNotebook(@PathParam("notebookid") String externalIdentifier) throws IOException {
+        dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
+        String remoteUser = httpServletRequest.getRemoteUser();
+        final Number principalID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser);
+        if (principalID != null) {
+            Number notebookID = dbIntegrityService.getNotebookInternalIdentifier(UUID.fromString(externalIdentifier));
+            if (notebookID != null) {
+                if (dbIntegrityService.hasAccess(notebookID, principalID, Permission.fromValue("reader"))) {
+                    Notebook notebook = dbIntegrityService.getNotebook(notebookID);
+                    return new ObjectFactory().createNotebook(notebook);
+                } else {
+                    verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_NOTEBOOK_READING(externalIdentifier), HttpServletResponse.SC_FORBIDDEN);
+                }
+            } else {
+                verboseOutput.sendFailureMessage(VerboseOutput.NOTEBOOK_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
+            }
+        } else {
+            verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, HttpServletResponse.SC_NOT_FOUND);
+        }
+        return new ObjectFactory().createNotebook(new Notebook());
+    }
+
+    @GET
+    @Produces(MediaType.APPLICATION_XML)
+    @Path("{notebookid: " + BackendConstants.regExpIdentifier + "}")
+    @Transactional(readOnly = true)
+    public JAXBElement<ReferenceList> getNotebookAnnotations(@PathParam("notebookid") String externalIdentifier,
+            @QueryParam("maximumAnnotations") int maximumAnnotations,
+            @QueryParam("startAnnotation") int startAnnotations,
+            @QueryParam("orderBy") String orderBy,
+            @QueryParam("descending") boolean desc) throws IOException {
+
+        dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
+
+        String remoteUser = httpServletRequest.getRemoteUser();
+        final Number principalID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser);
+        if (principalID != null) {
+            Number notebookID = dbIntegrityService.getNotebookInternalIdentifier(UUID.fromString(externalIdentifier));
+            if (notebookID != null) {
+                if (dbIntegrityService.hasAccess(notebookID, principalID, Permission.fromValue("reader"))) {
+                    ReferenceList annotations = dbIntegrityService.getAnnotationsForNotebook(notebookID, startAnnotations, maximumAnnotations, orderBy, desc);
+                    return new ObjectFactory().createReferenceList(annotations);
+                } else {
+                    verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_NOTEBOOK_READING(externalIdentifier), HttpServletResponse.SC_FORBIDDEN);
+                }
+            } else {
+                verboseOutput.sendFailureMessage(VerboseOutput.NOTEBOOK_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
+            }
+        } else {
+            verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, HttpServletResponse.SC_NOT_FOUND);
+        }
+        return new ObjectFactory().createReferenceList(new ReferenceList());
     }
 }
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/VerboseOutput.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/VerboseOutput.java	(revision 4529)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/VerboseOutput.java	(revision 4529)
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2013 DASISH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+package eu.dasish.annotation.backend.rest;
+
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import org.slf4j.Logger;
+
+/**
+ *
+ * @author olhsha
+ */
+public class VerboseOutput {
+    
+    private HttpServletResponse httpServletResponse;
+    private  Logger logger;
+
+    final static public String REMOTE_PRINCIPAL_NOT_FOUND = "The logged-in principal is not found in the database";
+    
+    public VerboseOutput(HttpServletResponse httpServletResponse, Logger logger) {
+        this.httpServletResponse = httpServletResponse;
+        this.logger = logger;
+    }
+    
+    static public String FORBIDDEN_NOTEBOOK_READING(String identifier) {
+        return " The logged-in principal cannot read the notebook with the identifier " + identifier;
+    }
+    
+    static public String FORBIDDEN_NOTEBOOK_WRITING(String identifier) {
+        return " The logged-in principal cannot write in the notebook with the identifier " + identifier;
+    }
+    
+     static public String FORBIDDEN_ANNOTATION_READING(String identifier) {
+        return " The logged-in principal cannot read the annotation with the identifier " + identifier;
+    }
+    
+    static public String FORBIDDEN_ANNOTATION_WRITING(String identifier) {
+        return " The logged-in principal cannot write in the annotation with the identifier " + identifier;
+    }
+    
+     static public String FORBIDDEN_PERMISSION_CHANGING(String identifier) {
+        return " The logged-in principal cannot change the permission of the resource with with the identifier " + identifier+". Only the owner of the resource is allowed to chnange permissions.";
+    }
+
+    static public String ILLEGAL_UUID(String identifier) {
+        return ("The string '" + identifier + "' is not a valid UUID.");
+    }
+
+    static private String resourceNotFound(String externalIdentifier, String resourceType) {
+        return ("A(n) " + resourceType + " with the indentifier " + externalIdentifier + " is not found in the database.");
+    }
+
+    static public String PRINCIPAL_NOT_FOUND(String externalIdentifier) {
+        return resourceNotFound(externalIdentifier, "principal");
+    }
+
+    static public String ANNOTATION_NOT_FOUND(String externalIdentifier) {
+        return resourceNotFound(externalIdentifier, "annotation");
+    }
+
+    static public String NOTEBOOK_NOT_FOUND(String externalIdentifier) {
+        return resourceNotFound(externalIdentifier, "notebook");
+    }
+
+    static public String TARGET_NOT_FOUND(String externalIdentifier) {
+        return resourceNotFound(externalIdentifier, "target");
+    }
+
+    static public String CACHED_REPRESENTATION_NOT_FOUND(String externalIdentifier) {
+        return resourceNotFound(externalIdentifier, "cached representation");
+    }
+
+    static public String INVALID_PERMISSION_MODE(String permissionMode) {
+        return permissionMode + " is an invalid permission value, which must be either owner, or reader, or writer.";
+    }
+
+    public void sendFailureMessage(String message, int responseCode) throws IOException {
+        logger.debug(responseCode + ": " + message);
+        httpServletResponse.sendError(responseCode, message);
+    }
+}
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceTest.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceTest.java	(revision 4528)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceTest.java	(revision 4529)
@@ -985,5 +985,37 @@
         assertEquals(TestBackendConstants._TEST_SERVLET_URI_notebooks + "00000000-0000-0000-0000-000000000014", result.getRef().get(1));
     }
-
+    
+ /*      public boolean hasAccess(Number notebookID, Number principalID, Permission permission){
+        List<Number> notebookIDs = notebookDao.getNotebookIDs(principalID, permission);
+        if (notebookIDs == null) {
+            return false;
+        } 
+        return notebookIDs.contains(notebookID);
+    } */
+    
+    @Test
+    public void testHasAccess() {
+
+        
+        final Permission writer = Permission.fromValue("writer"); 
+        final List<Number> mockNotebookIDwriter = new ArrayList<Number>();
+        mockNotebookIDwriter.add(1);
+        mockNotebookIDwriter.add(4);
+
+        mockeryDao.checking(new Expectations() {
+            {
+                oneOf(notebookDao).getNotebookIDs(2, writer);
+                will(returnValue(mockNotebookIDwriter));
+                
+                oneOf(notebookDao).getNotebookIDs(2, writer);
+                will(returnValue(mockNotebookIDwriter));
+
+            }
+        });
+
+        assertTrue(dbIntegrityService.hasAccess(4, 2, writer));
+        assertFalse(dbIntegrityService.hasAccess(5, 2, writer));
+    }
+    
     /*
      public ReferenceList getPrincipals(Number notebookID, String permission) {
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java	(revision 4528)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java	(revision 4529)
@@ -68,6 +68,4 @@
     private Mockery mockeryRest;     
     @Autowired
-    private MockObjectsFactoryRest mockObjectFactory;
-    @Autowired
     private DBIntegrityService mockDbIntegrityService;
     @Autowired
@@ -81,4 +79,5 @@
         mockRequest = new MockHttpServletRequest();
         mockRequest.setRemoteUser("olhsha@mpi.nl");
+        
         
     }
