Changeset 4532 for DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
- Timestamp:
- 02/18/14 15:12:30 (10 years ago)
- 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
r4529 r4532 122 122 return new ObjectFactory().createAnnotation(annotation); 123 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); 124 verboseOutput.FORBIDDEN_ANNOTATION_READING(externalIdentifier); 125 } 126 } else { 127 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser); 128 } 129 } else { 130 verboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier); 131 } 132 } catch (IllegalArgumentException e) { 133 verboseOutput.ILLEGAL_UUID(externalIdentifier); 135 134 } 136 135 return new ObjectFactory().createAnnotation(new Annotation()); … … 154 153 return new ObjectFactory().createTargetList(TargetList); 155 154 } else { 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);155 verboseOutput.FORBIDDEN_ANNOTATION_READING(externalIdentifier); 156 } 157 } else { 158 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser); 159 160 } 161 } else { 162 verboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier); 163 164 } 165 } catch (IllegalArgumentException e) { 166 verboseOutput.ILLEGAL_UUID(externalIdentifier); 168 167 } 169 168 return new ObjectFactory().createTargetList(new ReferenceList()); … … 193 192 return new ObjectFactory().createAnnotationInfoList(annotationInfoList); 194 193 } catch (IllegalArgumentException e) { 195 verboseOutput. sendFailureMessage(VerboseOutput.ILLEGAL_UUID(ownerExternalId), HttpServletResponse.SC_BAD_REQUEST);194 verboseOutput.ILLEGAL_UUID(ownerExternalId); 196 195 } 197 196 } else { 198 verboseOutput. sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);197 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser); 199 198 200 199 } … … 219 218 return new ObjectFactory().createPermissionList(permissionList); 220 219 } else { 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);220 verboseOutput.FORBIDDEN_ANNOTATION_READING(externalIdentifier); 221 } 222 } else { 223 verboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier); 224 } 225 } else { 226 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser); 227 228 } 229 } catch (IllegalArgumentException e) { 230 verboseOutput.ILLEGAL_UUID(externalIdentifier); 232 231 } 233 232 return new ObjectFactory().createUserWithPermissionList(new UserWithPermissionList()); … … 251 250 return result + " annotation(s) deleted."; 252 251 } else { 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);252 verboseOutput.FORBIDDEN_ANNOTATION_WRITING(externalIdentifier); 253 254 } 255 } else { 256 verboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier); 257 } 258 259 } else { 260 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser); 261 262 } 263 } catch (IllegalArgumentException e) { 264 verboseOutput.ILLEGAL_UUID(externalIdentifier); 266 265 } 267 266 … … 283 282 return new ObjectFactory().createResponseBody(makeAnnotationResponseEnvelope(annotationID)); 284 283 } else { 285 verboseOutput. sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);284 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser); 286 285 287 286 } … … 301 300 302 301 if (!(path + "annotations/" + externalIdentifier).equals(annotationURI)) { 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);302 verboseOutput.IDENTIFIER_MISMATCH(externalIdentifier); 304 303 return new ObjectFactory().createResponseBody(new ResponseBody()); 305 304 } … … 316 315 return new ObjectFactory().createResponseBody(makeAnnotationResponseEnvelope(annotationID)); 317 316 } 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); 317 verboseOutput.FORBIDDEN_PERMISSION_CHANGING(externalIdentifier); 318 loggerServer.debug(" Permission changing is the part of the full update of the annotation."); 319 } 320 } else { 321 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser); 322 } 323 } else { 324 verboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier); 325 } 326 } catch (IllegalArgumentException e) { 327 verboseOutput.ILLEGAL_UUID(externalIdentifier); 328 328 } 329 329 return new ObjectFactory().createResponseBody(new ResponseBody()); … … 347 347 return new ObjectFactory().createResponseBody(makeAnnotationResponseEnvelope(annotationID)); 348 348 } else { 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);349 verboseOutput.FORBIDDEN_ANNOTATION_WRITING(externalIdentifier); 350 } 351 } else { 352 verboseOutput.ANNOTATION_NOT_FOUND(externalIdentifier); 353 } 354 } else { 355 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser); 356 357 } 358 } catch (IllegalArgumentException e) { 359 verboseOutput.ILLEGAL_UUID(externalIdentifier); 360 360 } 361 361 return new ObjectFactory().createResponseBody(new ResponseBody()); … … 385 385 386 386 } else { 387 verboseOutput. sendFailureMessage(VerboseOutput.FORBIDDEN_PERMISSION_CHANGING(annotationExternalId), HttpServletResponse.SC_FORBIDDEN);387 verboseOutput.FORBIDDEN_PERMISSION_CHANGING(annotationExternalId); 388 388 } 389 389 } else { 390 verboseOutput. sendFailureMessage(VerboseOutput.ANNOTATION_NOT_FOUND(annotationExternalId), HttpServletResponse.SC_NOT_FOUND);390 verboseOutput.ANNOTATION_NOT_FOUND(annotationExternalId); 391 391 } 392 392 } catch (IllegalArgumentException e) { 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);393 verboseOutput.ILLEGAL_UUID(annotationExternalId); 394 } 395 } else { 396 verboseOutput.PRINCIPAL_NOT_FOUND(userExternalId); 397 397 } 398 398 } catch (IllegalArgumentException e) { 399 verboseOutput. sendFailureMessage(VerboseOutput.ILLEGAL_UUID(userExternalId), HttpServletResponse.SC_BAD_REQUEST);399 verboseOutput.ILLEGAL_UUID(userExternalId); 400 400 } 401 401 402 402 } else { 403 verboseOutput. sendFailureMessage(VerboseOutput.REMOTE_PRINCIPAL_NOT_FOUND, httpServletResponse.SC_NOT_FOUND);403 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser); 404 404 405 405 } … … 423 423 return new ObjectFactory().createResponseBody(makePermissionResponseEnvelope(annotationID)); 424 424 } else { 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);425 verboseOutput.FORBIDDEN_PERMISSION_CHANGING(annotationExternalId); 426 } 427 } else { 428 verboseOutput.ANNOTATION_NOT_FOUND(annotationExternalId); 429 } 430 } else { 431 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser); 432 432 433 433 } … … 435 435 436 436 } catch (IllegalArgumentException e) { 437 verboseOutput. sendFailureMessage(VerboseOutput.ILLEGAL_UUID(annotationExternalId), HttpServletResponse.SC_BAD_REQUEST);437 verboseOutput.ILLEGAL_UUID(annotationExternalId); 438 438 return new ObjectFactory().createResponseBody(new ResponseBody()); 439 439 … … 459 459 460 460 } else { 461 verboseOutput. sendFailureMessage(VerboseOutput.PRINCIPAL_NOT_FOUND(userId), HttpServletResponse.SC_NOT_FOUND);461 verboseOutput.PRINCIPAL_NOT_FOUND(userId); 462 462 } 463 463 } else { 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);464 verboseOutput.FORBIDDEN_PERMISSION_CHANGING(annotationId); 465 466 } 467 } else { 468 verboseOutput.ANNOTATION_NOT_FOUND(annotationId); 469 } 470 } else { 471 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser); 472 473 } 474 } catch (IllegalArgumentException e) { 475 verboseOutput.ILLEGAL_UUID(annotationId); 476 476 } 477 477 return (deletedRows + " is deleted.");
Note: See TracChangeset
for help on using the changeset viewer.