- Timestamp:
- 09/19/14 09:59:35 (10 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/CHANGES.txt
r5401 r5661 45 45 Moreover, an atribute xml:id is added to the schema for main resource instances. 46 46 47 July 14, 2014. Added 1: api to send an image cached representation as a file, via its path 48 or URI. At least will help in testing because I have problems with turning an image file 49 onto a stream to send it via FF Client in a request body. Added 2: admin can change the external 50 ID (UUID) of a resource. At least will help with testing. 51 52 53 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/UPDATE.txt
r5401 r5661 19 19 This id is already set up in the jsp page, so no changes should be done there. 20 20 21 4. Nothing is to be update in settings (web.xml, context.xml) and the database. 22 21 23 22 24 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml
r5401 r5661 363 363 <netbeans.hint.license>gpl20</netbeans.hint.license> 364 364 <plugin.license.copyrightYear>2013</plugin.license.copyrightYear> 365 <project.version>1.5 </project.version>365 <project.version>1.5.1</project.version> 366 366 <shibboleth.version>1.0.4</shibboleth.version> 367 367 </properties> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/AnnotationDao.java
r5138 r5661 25 25 import java.sql.SQLException; 26 26 import java.util.List; 27 import java.util.UUID; 27 28 28 29 /** … … 40 41 */ 41 42 43 public List<UUID> getExternalIdFromHeadline(String headline); 44 45 public List<Number> getInternalIDsFromHeadline(String headline); 42 46 /** 43 47 * -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBDispatcher.java
r5468 r5661 394 394 395 395 ResponseBody makeAccessResponseEnvelope(Number resourceID, Resource resource); 396 397 UUID getPrincipalExternalIdFromName(String fullName) throws NotInDataBaseException; 398 399 List<UUID> getAnnotationExternalIdsFromHeadline(String headline); 400 401 List<Number> getAnnotationInternalIDsFromHeadline(String headline); 396 402 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/PrincipalDao.java
r5385 r5661 53 53 public UUID getPrincipalExternalIDFromRemoteID(String remoteID) throws NotInDataBaseException; 54 54 55 public UUID getExternalIdFromName(String fullName) throws NotInDataBaseException; 55 56 56 57 public List<Number> getPrincipalIDsWithAccessForNotebook(Number notebookID, Access access); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherImlp.java
r5468 r5661 962 962 } 963 963 } 964 965 @Override 966 public UUID getPrincipalExternalIdFromName(String fullName) throws NotInDataBaseException{ 967 return principalDao.getExternalIdFromName(fullName); 968 } 969 970 @Override 971 public List<UUID> getAnnotationExternalIdsFromHeadline(String headline){ 972 return annotationDao.getExternalIdFromHeadline(headline); 973 } 974 975 @Override 976 public List<Number> getAnnotationInternalIDsFromHeadline(String headline){ 977 return annotationDao.getInternalIDsFromHeadline(headline); 978 } 964 979 965 980 //// privee /// -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDao.java
r5393 r5661 110 110 List<Access> result = this.loggedQuery(sql.toString(), public_RowMapper, annotationID); 111 111 return result.get(0); 112 } 113 114 115 @Override 116 public List<UUID> getExternalIdFromHeadline(String headline){ 117 StringBuilder requestDB = new StringBuilder("SELECT "); 118 requestDB.append(external_id).append(" FROM ").append(annotationTableName).append(" WHERE ").append("'").append(headline).append("'").append("= ?"); 119 return this.loggedQuery(requestDB.toString(), externalIDRowMapper, headline); 120 } 121 122 @Override 123 public List<Number> getInternalIDsFromHeadline(String headline){ 124 StringBuilder requestDB = new StringBuilder("SELECT "); 125 requestDB.append(annotation_id).append(" FROM ").append(annotationTableName).append(" WHERE ").append("'").append(headline).append("'").append("= ?"); 126 return this.loggedQuery(requestDB.toString(), internalIDRowMapper, headline); 112 127 } 113 128 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcPrincipalDao.java
r5393 r5661 157 157 158 158 @Override 159 public UUID getExternalIdFromName(String fullName) throws NotInDataBaseException { 160 StringBuilder requestDB = new StringBuilder("SELECT "); 161 requestDB.append(external_id).append(" FROM ").append(principalTableName).append(" WHERE ").append(principal_name).append("= ? LIMIT 1"); 162 List<UUID> result = this.loggedQuery(requestDB.toString(), externalIDRowMapper, fullName); 163 if (result.isEmpty()) { 164 throw new NotInDataBaseException("principal", "full name", fullName); 165 } 166 return result.get(0); 167 } 168 169 @Override 159 170 public String getTypeOfPrincipalAccount(Number internalID) { 160 171 StringBuilder requestDB = new StringBuilder("SELECT "); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
r5385 r5661 34 34 import java.util.Arrays; 35 35 import java.util.HashMap; 36 import java.util.List; 36 37 import java.util.Map; 37 38 import java.util.UUID; … … 40 41 import javax.ws.rs.Consumes; 41 42 import javax.ws.rs.DELETE; 43 import javax.ws.rs.FormParam; 42 44 import javax.ws.rs.GET; 43 45 import javax.ws.rs.POST; … … 61 63 @Transactional(rollbackFor = {Exception.class}) 62 64 public class AnnotationResource extends ResourceResource { 63 65 64 66 public void setHttpServletResponse(HttpServletResponse httpServletResponse) { 65 67 this.httpServletResponse = httpServletResponse; … … 210 212 public JAXBElement<ResponseBody> createAnnotation(Annotation annotation) throws IOException { 211 213 212 Map params = new HashMap(); 213 params.put("annotation", annotation); 214 ResponseBody result = (ResponseBody) (new RequestWrappers(this)).wrapRequestResource(params, new AddAnnotation()); 215 if (result != null) { 216 return (new ObjectFactory()).createResponseBody(result); 217 } else { 218 return (new ObjectFactory()).createResponseBody(new ResponseBody()); 219 } 220 } 221 222 214 Map params = new HashMap(); 215 params.put("annotation", annotation); 216 ResponseBody result = (ResponseBody) (new RequestWrappers(this)).wrapRequestResource(params, new AddAnnotation()); 217 if (result != null) { 218 return (new ObjectFactory()).createResponseBody(result); 219 } else { 220 return (new ObjectFactory()).createResponseBody(new ResponseBody()); 221 } 222 } 223 223 224 224 private class AddAnnotation implements ILambda<Map, ResponseBody> { … … 327 327 } 328 328 } 329 330 ////////////////////////////////////////// 331 332 ////////////////////////////////////////////// 333 @POST 334 @Consumes(MediaType.APPLICATION_FORM_URLENCODED) 335 @Produces(MediaType.TEXT_PLAIN) 336 @Path("publicaccessform") 337 public String updatePubliAccessFromForm( 338 @FormParam("annotationId") String annotationDatabaseId, 339 @FormParam("annotationHeadline") String annotationHeadline, 340 @FormParam("access") String access) 341 throws IOException { 342 343 if (access.trim().equals("")) { 344 access = "none"; 345 } 346 347 Access accessTyped = Access.fromValue(access); 348 int updatedAnnotations = 0; 349 350 if (annotationDatabaseId == null || annotationDatabaseId.trim().equals("")) { 351 List<Number> annotationIDs = dbDispatcher.getAnnotationInternalIDsFromHeadline(annotationHeadline); 352 if (annotationIDs == null || annotationIDs.isEmpty()) { 353 return "No annotations with this headline have been found"; 354 }; 355 int count = 0; 356 for (Number annotationID : annotationIDs) { 357 count = dbDispatcher.updatePublicAttribute(annotationID, accessTyped);; 358 updatedAnnotations = updatedAnnotations+count; 359 } 360 return (updatedAnnotations + " row(s) are updated"); 361 } else { 362 try { 363 Number annotationID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(annotationDatabaseId), Resource.ANNOTATION); 364 updatedAnnotations= dbDispatcher.updatePublicAttribute(annotationID, accessTyped); 365 } catch (NotInDataBaseException e) { 366 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, e.toString()); 367 } 368 } 369 return (updatedAnnotations + " annotation(s) are updated."); 370 } 371 329 372 //////////////////////////////////////////////////// 330 373 … … 337 380 return this.genericUpdateDeleteAccess(annotationExternalId, principalExternalId, access); 338 381 } 382 383 384 385 ////////////////////////////////////////////// 386 @POST 387 @Consumes(MediaType.APPLICATION_FORM_URLENCODED) 388 @Produces(MediaType.TEXT_PLAIN) 389 @Path("permissionform") 390 public String updatePermissionFromForm(@FormParam("login") String remoteID, 391 @FormParam("fullName") String fullName, 392 @FormParam("userId") String principalDatabaseId, 393 @FormParam("annotationId") String annotationDatabaseId, 394 @FormParam("annotationHeadline") String annotationHeadline, 395 @FormParam("access") String access) 396 throws IOException { 397 398 if (access.trim().equals("")) { 399 access = null; 400 } 401 402 try { 403 if (principalDatabaseId == null || principalDatabaseId.trim().equals("")) { 404 if (remoteID != null && !remoteID.trim().equals("")) { 405 principalDatabaseId = dbDispatcher.getPrincipalExternalIDFromRemoteID(remoteID).toString(); 406 } else { 407 if (fullName != null) { 408 principalDatabaseId = dbDispatcher.getPrincipalExternalIdFromName(fullName).toString(); 409 } else { 410 httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "No user information is given"); 411 } 412 } 413 } 414 } catch (NotInDataBaseException e) { 415 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, e.toString()); 416 } 417 418 if (annotationDatabaseId == null || annotationDatabaseId.trim().equals("")) { 419 List<UUID> annotationIds = dbDispatcher.getAnnotationExternalIdsFromHeadline(annotationHeadline); 420 if (annotationIds == null || annotationIds.isEmpty()) { 421 return "No annotations with this headline found"; 422 }; 423 int count = 0; 424 String tmp = null; 425 for (UUID annotationId : annotationIds) { 426 tmp = this.genericUpdateDeleteAccess(annotationId.toString(), principalDatabaseId, Access.fromValue(access)); 427 if (!tmp.startsWith("0")) { 428 count++; 429 } 430 } 431 return (count + " row(s) are updated"); 432 } else { 433 return this.genericUpdateDeleteAccess(annotationDatabaseId, principalDatabaseId, Access.fromValue(access)); 434 } 435 } 436 339 437 //////////////////////////////////////////// 340 341 438 private String genericUpdateDeleteAccess(String annotationId, String principalId, Access access) throws IOException { 342 439 Map params = new HashMap(); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/index.jsp
r5468 r5661 40 40 <br> 41 41 <a href="api/authentication/logout"> logout</a> <br> 42 <br> 42 43 <br> 44 <a href="changePermissions.html"> Change access mode for a user and an annotation </a><br> 45 <br> 46 <br> 47 <a href="publicAccess.html"> Change public access mode for an annotation </a> <br> 48 <br> 43 49 44 50 <b>Test URI-s</b><br>
Note: See TracChangeset
for help on using the changeset viewer.