Ignore:
Timestamp:
02/17/14 17:19:07 (10 years ago)
Author:
olhsha
Message:

refactoring verbose server output.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java

    r4491 r4529  
    8383    @Context
    8484    private ServletContext context;
    85    
    86     private final Logger logger = LoggerFactory.getLogger(AnnotationResource.class);
    8785    public static final Logger loggerServer = LoggerFactory.getLogger(HttpServletResponse.class);
     86    private final VerboseOutput verboseOutput = new VerboseOutput(httpServletResponse, loggerServer);
    8887    final private String admin = "admin";
    8988
     
    112111    @Transactional(readOnly = true)
    113112    public JAXBElement<Annotation> getAnnotation(@PathParam("annotationid") String externalIdentifier) throws IOException {
    114 
    115         URI baseURI = uriInfo.getBaseUri();
    116         String baseURIstr = baseURI.toString();
    117         dbIntegrityService.setServiceURI(baseURIstr);
    118 
     113        dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
    119114        try {
    120115            final Number annotationID = dbIntegrityService.getAnnotationInternalIdentifier(UUID.fromString(externalIdentifier));
     
    125120                    if (dbIntegrityService.canRead(userID, annotationID)) {
    126121                        final Annotation annotation = dbIntegrityService.getAnnotation(annotationID);
    127                         JAXBElement<Annotation> rootElement = new ObjectFactory().createAnnotation(annotation);
    128                         return rootElement;
    129                     } else {
    130                         loggerServer.debug(httpServletResponse.SC_FORBIDDEN + ": The logged-in user cannot read the annotation.");
    131                         httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "The logged-in user cannot read the annotation.");
    132                         return null;
    133                     }
    134                 } else {
    135                     loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
    136                     httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database");
    137                     return null;
    138                 }
    139             } else {
    140                 loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + externalIdentifier + " is not found in the database");
    141                 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id " + externalIdentifier + " is not found in the database");
    142                 return null;
    143             }
    144         } catch (IllegalArgumentException e) {
    145             loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + externalIdentifier);
    146             httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + externalIdentifier);
    147             return null;
    148         }
    149 
     122                        return new ObjectFactory().createAnnotation(annotation);
     123                    } else {
     124                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_ANNOTATION_READING(externalIdentifier), HttpServletResponse.SC_FORBIDDEN);
     125                    }
     126                } else {
     127                    verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
     128
     129                }
     130            } else {
     131                verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
     132            }
     133        } catch (IllegalArgumentException e) {
     134            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(externalIdentifier), HttpServletResponse.SC_BAD_REQUEST);
     135        }
     136        return new ObjectFactory().createAnnotation(new Annotation());
    150137    }
    151138
     
    157144    public JAXBElement<ReferenceList> getAnnotationTargets(@PathParam("annotationid") String externalIdentifier) throws IOException {
    158145        dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
    159 
    160146        try {
    161147            final Number annotationID = dbIntegrityService.getAnnotationInternalIdentifier(UUID.fromString(externalIdentifier));
     
    166152                    if (dbIntegrityService.canRead(userID, annotationID)) {
    167153                        final ReferenceList TargetList = dbIntegrityService.getAnnotationTargets(annotationID);
    168                         logger.info("getAnnotationTargets method: OK");
    169154                        return new ObjectFactory().createTargetList(TargetList);
    170155                    } else {
    171                         loggerServer.debug(httpServletResponse.SC_FORBIDDEN + ": The logged-in user cannot read the annotation.");
    172                         httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "The logged-in user cannot read the annotation.");
    173                         return null;
    174                     }
    175                 } else {
    176                     loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
    177                     httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database");
    178                     return null;
    179                 }
    180             } else {
    181                 loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + externalIdentifier + " is not found in the database");
    182                 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id " + externalIdentifier + " is not found in the database");
    183                 return null;
    184             }
    185         } catch (IllegalArgumentException e) {
    186             loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + externalIdentifier);
    187             httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + externalIdentifier);
    188             return null;
    189         }
     156                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_ANNOTATION_READING(externalIdentifier), HttpServletResponse.SC_FORBIDDEN);
     157                    }
     158                } else {
     159                    verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
     160
     161                }
     162            } else {
     163                verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
     164
     165            }
     166        } catch (IllegalArgumentException e) {
     167            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(externalIdentifier), HttpServletResponse.SC_BAD_REQUEST);
     168        }
     169        return new ObjectFactory().createTargetList(new ReferenceList());
    190170    }
    191171// TODO Unit test
     
    209189            try {
    210190                UUID ownerExternalUUID = (ownerExternalId != null) ? UUID.fromString(ownerExternalId) : null;
    211                
     191
    212192                final AnnotationInfoList annotationInfoList = dbIntegrityService.getFilteredAnnotationInfos(ownerExternalUUID, link, text, userID, access, namespace, after, before);
    213193                return new ObjectFactory().createAnnotationInfoList(annotationInfoList);
    214194            } catch (IllegalArgumentException e) {
    215                 loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + ownerExternalId);
    216                 httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + ownerExternalId);
    217                 return null;
     195                verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(ownerExternalId), HttpServletResponse.SC_BAD_REQUEST);
    218196            }
    219197        } else {
    220             loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
    221             httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database");
    222             return null;
    223         }
    224 
     198            verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
     199
     200        }
     201        return new ObjectFactory().createAnnotationInfoList(new AnnotationInfoList());
    225202    }
    226203
     
    240217                    if (dbIntegrityService.canRead(userID, annotationID)) {
    241218                        final UserWithPermissionList permissionList = dbIntegrityService.getPermissionsForAnnotation(annotationID);
    242                         logger.debug("getAnnotationPermissions method: OK");
    243219                        return new ObjectFactory().createPermissionList(permissionList);
    244220                    } else {
    245                         loggerServer.debug(httpServletResponse.SC_FORBIDDEN + ": The logged-in user cannot read the annotation.");
    246                         httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "The logged-in user cannot read the annotation.");
    247                         return null;
    248                     }
    249                 } else {
    250                     loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + externalIdentifier + " is not found in the database");
    251                     httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id " + externalIdentifier + " is not found in the database");
    252                     return null;
    253                 }
    254             } else {
    255                 loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
    256                 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database");
    257                 return null;
    258             }
    259         } catch (IllegalArgumentException e) {
    260             loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + externalIdentifier);
    261             httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + externalIdentifier);
    262             return null;
    263         }
     221                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_ANNOTATION_READING(externalIdentifier), HttpServletResponse.SC_FORBIDDEN);
     222                    }
     223                } else {
     224                    verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
     225                }
     226            } else {
     227                verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
     228
     229            }
     230        } catch (IllegalArgumentException e) {
     231            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(externalIdentifier), HttpServletResponse.SC_BAD_REQUEST);
     232        }
     233        return new ObjectFactory().createUserWithPermissionList(new UserWithPermissionList());
    264234    }
    265235///////////////////////////////////////////////////////
     
    279249                        int[] resultDelete = dbIntegrityService.deleteAnnotation(annotationID);
    280250                        String result = Integer.toString(resultDelete[0]);
    281                         logger.info("deleteAnnotation method: OK");
    282251                        return result + " annotation(s) deleted.";
    283252                    } else {
    284                         loggerServer.debug(httpServletResponse.SC_FORBIDDEN + ": The logged-in user cannot delete the annotation. Only the owner can delete the annotation.");
    285                         httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "The logged-in user cannot delete the annotation. Only the owner can delete the annotation.");
    286                         return null;
    287                     }
    288                 } else {
    289                     loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + externalIdentifier + " is not found in the database");
    290                     httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id  " + externalIdentifier + " is not found in the database.");
    291                     return null;
    292                 }
    293 
    294             } else {
    295                 loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database.");
    296                 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
    297                 return null;
    298             }
    299         } catch (IllegalArgumentException e) {
    300             loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + externalIdentifier);
    301             httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + externalIdentifier);
    302             return null;
    303         }
     253                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_ANNOTATION_WRITING(externalIdentifier) + " Only a principal with 'owner' access can delete the annotation.", HttpServletResponse.SC_FORBIDDEN);
     254
     255                    }
     256                } else {
     257                    verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
     258                }
     259
     260            } else {
     261                verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
     262
     263            }
     264        } catch (IllegalArgumentException e) {
     265            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(externalIdentifier), HttpServletResponse.SC_BAD_REQUEST);
     266        }
     267
     268        return "Due to the failure no annotation is deleted.";
    304269    }
    305270
     
    318283            return new ObjectFactory().createResponseBody(makeAnnotationResponseEnvelope(annotationID));
    319284        } else {
    320             loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
    321             httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
    322             return null;
    323         }
     285            verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
     286
     287        }
     288        return new ObjectFactory().createResponseBody(new ResponseBody());
    324289    }
    325290///////////////////////////////////////////////////////
     
    336301
    337302        if (!(path + "annotations/" + externalIdentifier).equals(annotationURI)) {
    338             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.");
    339             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.");
    340             return null;
     303            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);
     304            return new ObjectFactory().createResponseBody(new ResponseBody());
    341305        }
    342306
     
    351315                        int updatedRows = dbIntegrityService.updateAnnotation(annotation);
    352316                        return new ObjectFactory().createResponseBody(makeAnnotationResponseEnvelope(annotationID));
    353 
    354                     } else {
    355                         loggerServer.debug(httpServletResponse.SC_UNAUTHORIZED + "Only the owner can update the annotation fully (incl. permissions). Only writer can update the annotation's body.");
    356                         httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Only the owner can update the annotation fully (incl. permissions). Only writer can update the annotation's body.");
    357                         return null;
    358                     }
    359                 } else {
    360                     loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
    361                     httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
    362                     return null;
    363                 }
    364             } else {
    365                 loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + externalIdentifier + " is not found in the database");
    366                 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id   " + externalIdentifier + " is not found in the database.");
    367                 return null;
    368             }
    369         } catch (IllegalArgumentException e) {
    370             loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + externalIdentifier);
    371             httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + externalIdentifier);
    372             return null;
    373         }
     317                    } else {
     318                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_PERMISSION_CHANGING(externalIdentifier) + " Permission changing is the part of the full update of the annotation.", HttpServletResponse.SC_FORBIDDEN);
     319                    }
     320                } else {
     321                    verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
     322                }
     323            } else {
     324                verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
     325            }
     326        } catch (IllegalArgumentException e) {
     327            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(externalIdentifier), HttpServletResponse.SC_BAD_REQUEST);
     328        }
     329        return new ObjectFactory().createResponseBody(new ResponseBody());
    374330    }
    375331
     
    391347                        return new ObjectFactory().createResponseBody(makeAnnotationResponseEnvelope(annotationID));
    392348                    } else {
    393                         loggerServer.debug(httpServletResponse.SC_UNAUTHORIZED + "The logged-in user cannot change the body of this annotation because (s)he is  not its 'writer'.");
    394                         httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The logged-in user cannot change the body of this annotation because (s)he is  not its 'writer'.");
    395                         return null;
    396                     }
    397                 } else {
    398                     loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + externalIdentifier + " is not found in the database");
    399                     httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id   " + externalIdentifier + " is not found in the database.");
    400                     return null;
    401                 }
    402             } else {
    403                 loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
    404                 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
    405                 return null;
    406             }
    407         } catch (IllegalArgumentException e) {
    408             loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + externalIdentifier);
    409             httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + externalIdentifier);
    410             return null;
    411         }
     349                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_ANNOTATION_WRITING(externalIdentifier), HttpServletResponse.SC_FORBIDDEN);
     350                    }
     351                } else {
     352                    verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier), HttpServletResponse.SC_NOT_FOUND);
     353                }
     354            } else {
     355                verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
     356
     357            }
     358        } catch (IllegalArgumentException e) {
     359            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(externalIdentifier), HttpServletResponse.SC_BAD_REQUEST);
     360        }
     361        return new ObjectFactory().createResponseBody(new ResponseBody());
    412362    }
    413363
     
    432382                                        ? dbIntegrityService.updateAnnotationPrincipalPermission(annotationID, userID, permission)
    433383                                        : dbIntegrityService.addAnnotationPrincipalPermission(annotationID, userID, permission);
    434                                 logger.info("updatePermission method: OK");
    435384                                return result + " rows are updated/added";
    436385
    437386                            } else {
    438                                 loggerServer.debug(httpServletResponse.SC_UNAUTHORIZED + "The logged-in user cannot change the body of this annotation because (s)he is  not its 'writer'.");
    439                                 httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The logged-in user cannot change the rights on this annotation because (s)he is  not its owner.");
    440                                 return null;
     387                                verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_PERMISSION_CHANGING(annotationExternalId), HttpServletResponse.SC_FORBIDDEN);
    441388                            }
    442389                        } else {
    443                             loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + annotationExternalId + " is not found in the database");
    444                             httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id  " + annotationExternalId + "  is not found in the database.");
    445                             return null;
     390                            verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(annotationExternalId), HttpServletResponse.SC_NOT_FOUND);
    446391                        }
    447392                    } catch (IllegalArgumentException e) {
    448                         loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + annotationExternalId);
    449                         httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + annotationExternalId);
    450                         return null;
    451                     }
    452                 } else {
    453                     loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The user with the given id   " + userExternalId + " is not found in the database");
    454                     httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The user with the given id   " + userExternalId + " is not found in the database.");
    455                     return null;
     393                        verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(annotationExternalId), HttpServletResponse.SC_BAD_REQUEST);
     394                    }
     395                } else {
     396                    verboseOutput.sendFailureMessage(VerboseOutput.PRINCIPAL_NOT_FOUND(userExternalId), HttpServletResponse.SC_NOT_FOUND);
    456397                }
    457398            } catch (IllegalArgumentException e) {
    458                 loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + userExternalId);
    459                 httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + userExternalId);
    460                 return null;
     399                verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(userExternalId), HttpServletResponse.SC_BAD_REQUEST);
    461400            }
    462401
    463402        } else {
    464             loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
    465             httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
    466             return null;
    467         }
     403            verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
     404
     405        }
     406        return "Due to the failure no permissionis updated.";
    468407    }
    469408
     
    484423                        return new ObjectFactory().createResponseBody(makePermissionResponseEnvelope(annotationID));
    485424                    } else {
    486                         loggerServer.debug(httpServletResponse.SC_UNAUTHORIZED + "The logged-in user cannot change the access rights on this annotation because (s)he is  not its owner.");
    487                         httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The logged-in user cannot change the access rights on this annotation because (s)he is  not its owner.");
    488                         return null;
    489                     }
    490                 } else {
    491                     loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + annotationExternalId + " is not found in the database");
    492                     httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id  " + annotationExternalId + "  is not found in the database.");
    493                     return null;
    494                 }
    495             } else {
    496                 loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
    497                 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
    498                 return null;
    499             }
    500         } catch (IllegalArgumentException e) {
    501             loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + annotationExternalId);
    502             httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + annotationExternalId);
    503             return null;
     425                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_PERMISSION_CHANGING(annotationExternalId), HttpServletResponse.SC_FORBIDDEN);
     426                    }
     427                } else {
     428                    verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(annotationExternalId), HttpServletResponse.SC_NOT_FOUND);
     429                }
     430            } else {
     431                verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
     432
     433            }
     434            return new ObjectFactory().createResponseBody(new ResponseBody());
     435
     436        } catch (IllegalArgumentException e) {
     437            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(annotationExternalId), HttpServletResponse.SC_BAD_REQUEST);
     438            return new ObjectFactory().createResponseBody(new ResponseBody());
     439
    504440        }
    505441    }
     
    523459
    524460                        } else {
    525                             loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the user external identifier " + userId + " is not found the the databse.");
    526                             httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The user external identifier " + userId + " is not found the the databse.");
    527 
     461                            verboseOutput.sendFailureMessage(VerboseOutput.PRINCIPAL_NOT_FOUND(userId), HttpServletResponse.SC_NOT_FOUND);
    528462                        }
    529463                    } else {
    530                         loggerServer.debug(httpServletResponse.SC_UNAUTHORIZED + "The logged-in user cannot change the access rights on this annotation because (s)he is  not its owner.");
    531                         httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The logged-in user cannot change the access rights on this annotation because (s)he is  not its owner.");
    532 
    533                     }
    534                 } else {
    535                     loggerServer.debug(HttpServletResponse.SC_NOT_FOUND + ": The annotation with the given id " + annotationId + " is not found in the database");
    536                     httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The annotation with the given id  " + annotationId + "  is not found in the database.");
    537 
    538                 }
    539             } else {
    540                 loggerServer.debug(httpServletResponse.SC_NOT_FOUND + ": the logged-in user is not found in the database");
    541                 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged-in user is not found in the database.");
    542 
    543             }
    544         } catch (IllegalArgumentException e) {
    545             loggerServer.debug(HttpServletResponse.SC_BAD_REQUEST + ": Illegal argument UUID " + annotationId);
    546             httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Illegal argument UUID " + annotationId);
    547 
     464                        verboseOutput.sendFailureMessage(VerboseOutput.FORBIDDEN_PERMISSION_CHANGING(annotationId), HttpServletResponse.SC_FORBIDDEN);
     465
     466                    }
     467                } else {
     468                    verboseOutput.sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(annotationId), HttpServletResponse.SC_NOT_FOUND);
     469                }
     470            } else {
     471                verboseOutput.sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);
     472
     473            }
     474        } catch (IllegalArgumentException e) {
     475            verboseOutput.sendFailureMessage(VerboseOutput.ILLEGAL_UUID(annotationId), HttpServletResponse.SC_BAD_REQUEST);
    548476        }
    549477        return (deletedRows + " is deleted.");
     
    595523        }
    596524    }
    597 
    598525}
Note: See TracChangeset for help on using the changeset viewer.