Changeset 4263
- Timestamp:
- 01/14/14 18:06:27 (10 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java
r4262 r4263 386 386 int addedTargets = addTargets(annotation, annotationID); 387 387 int addedPrincipalsPermissions = addPrincipalsPermissions(annotation.getPermissions().getUserWithPermission(), annotationID); 388 int addedOwner = annotationDao.addAnnotationPrincipalPermission(annotationID, userID, Permission.OWNER);389 388 return updatedAnnotations; 390 389 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
r4262 r4263 101 101 public AnnotationResource() { 102 102 } 103 104 105 103 106 104 @GET … … 167 165 // TODO Unit test 168 166 169 170 171 172 167 @GET 173 168 @Produces(MediaType.TEXT_XML) … … 255 250 } 256 251 } 257 252 258 253 // TODO: how to return the status code? 259 260 261 254 /////////////////////////////////////////////////////// 262 263 255 @POST 264 256 @Consumes(MediaType.APPLICATION_XML) … … 288 280 dbIntegrityService.setServiceURI(path); 289 281 String annotationURI = annotation.getURI(); 290 282 291 283 if (!(path + "annotations/" + externalIdentifier).equals(annotationURI)) { 292 284 httpServletResponse.sendError(HttpServletResponse.SC_CONFLICT, "Wrong request: the external annotation ID and the annotation ID from the request body do not match. Correct the request and resend."); 293 285 return null; 294 286 } 295 287 296 288 List<UserWithPermission> permissions = annotation.getPermissions().getUserWithPermission(); 297 298 289 String ownerURI = annotation.getOwnerRef(); 290 if (!ownerIsListed(ownerURI, permissions)) { 291 httpServletResponse.sendError(HttpServletResponse.SC_CONFLICT, "Wrong request body: the owner URI's is not listed in the list of permissions as 'owner'. Correct the request and resend."); 292 return null; 293 } 294 295 299 296 final Number annotationID = dbIntegrityService.getAnnotationInternalIdentifier(UUID.fromString(externalIdentifier)); 300 297 if (annotationID != null) { … … 518 515 } 519 516 } 520 521 517 518 private boolean ownerIsListed(String uri, List<UserWithPermission> permissions) { 519 for (UserWithPermission permissionPair : permissions) { 520 if (permissionPair.getRef().equals(uri) && permissionPair.getPermission().equals(Permission.OWNER)) { 521 return true; 522 } 523 } 524 return false; 525 } 522 526 }
Note: See TracChangeset
for help on using the changeset viewer.