Changeset 4264
- Timestamp:
- 01/15/14 13:13:21 (10 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/AnnotationDao.java
r4262 r4264 68 68 public List<Number> getFilteredAnnotationIDs(List<Number> annotationIDs, String text, String namespace, Timestamp after, Timestamp before); 69 69 70 public List<Number> getAllAnnotationIDs(); 71 70 72 /** 71 73 * unit test is missing -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBIntegrityService.java
r4262 r4264 89 89 List<Number> getFilteredAnnotationIDs(String link, String text, Number inloggedUserID, String[] accessModes, String namespace, Timestamp after, Timestamp before); 90 90 91 91 AnnotationInfoList getAllAnnotationInfos(); 92 92 93 93 /** … … 233 233 234 234 235 public boolean userHasAdminRights(Number userID);235 public String getTypeOfUserAccount(Number userID); 236 236 237 237 /** -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/UserDao.java
r4260 r4264 38 38 public boolean userExists(User user); 39 39 40 public boolean hasAdminRights(Number internalID);40 public String getTypeOfUserAccount(Number internalID); 41 41 42 42 public String getRemoteID(Number internalID); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java
r4263 r4264 275 275 return null; 276 276 } 277 277 } 278 279 @Override 280 public AnnotationInfoList getAllAnnotationInfos() { 281 List<Number> annotationIDs = annotationDao.getAllAnnotationIDs(); 282 if (annotationIDs != null) { 283 AnnotationInfoList result = new AnnotationInfoList(); 284 for (Number annotationID : annotationIDs) { 285 Number ownerID = annotationDao.getOwner(annotationID); 286 ReferenceList targets = getAnnotationTargets(annotationID); 287 AnnotationInfo annotationInfo = annotationDao.getAnnotationInfoWithoutTargets(annotationID); 288 annotationInfo.setTargets(targets); 289 if (ownerID != null){ 290 annotationInfo.setOwnerRef(userDao.getURIFromInternalID(ownerID));} 291 else { 292 annotationInfo.setOwnerRef("ACHTUNG: This annotation does not have an owner in the DB!!!!"); 293 } 294 result.getAnnotationInfo().add(annotationInfo); 295 } 296 297 return result; 298 } else { 299 return null; 300 } 278 301 } 279 302 … … 343 366 344 367 @Override 345 public boolean userHasAdminRights(Number userID) {346 return userDao. hasAdminRights(userID);368 public String getTypeOfUserAccount(Number userID) { 369 return userDao.getTypeOfUserAccount(userID); 347 370 } 348 371 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDao.java
r4262 r4264 180 180 181 181 return getSimpleJdbcTemplate().query(sql.toString(), internalIDRowMapper, params); 182 } 183 184 ///////////////////////////////////////// 185 186 @Override 187 public List<Number> getAllAnnotationIDs(){ 188 StringBuilder sql = new StringBuilder("SELECT "); 189 sql.append(annotation_id).append(" , ").append(last_modified).append(" FROM ").append(annotationTableName).append(" ORDER BY ").append(last_modified).append(" DESC"); 190 return getSimpleJdbcTemplate().query(sql.toString(), internalIDRowMapper); 182 191 } 183 192 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java
r4262 r4264 50 50 final static protected String targetsCachedRepresentationsTableName = "targets_cached_representations"; 51 51 // base string constants: field Names 52 final static protected String a dmin_rights = "admin_rights";52 final static protected String account = "account"; 53 53 final static protected String annotation_id = "annotation_id"; 54 54 final static protected String notebook_id = "notebook_id"; -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcUserDao.java
r4262 r4264 132 132 133 133 @Override 134 public boolean hasAdminRights(Number internalID){134 public String getTypeOfUserAccount(Number internalID){ 135 135 StringBuilder requestDB = new StringBuilder("SELECT "); 136 requestDB.append(a dmin_rights).append(" FROM ").append(principalTableName).append(" WHERE ").append(principal_id).append("= ? LIMIT 1");137 List< Boolean> result = getSimpleJdbcTemplate().query(requestDB.toString(), adminRightsRowMapper, internalID);138 return (result.size() > 0) ? result.get(0) .booleanValue() :false;136 requestDB.append(account).append(" FROM ").append(principalTableName).append(" WHERE ").append(principal_id).append("= ? LIMIT 1"); 137 List<String> result = getSimpleJdbcTemplate().query(requestDB.toString(), adminRightsRowMapper, internalID); 138 return (result.size() > 0) ? result.get(0) :null; 139 139 } 140 private final RowMapper< Boolean> adminRightsRowMapper = new RowMapper<Boolean>() {140 private final RowMapper<String> adminRightsRowMapper = new RowMapper<String>() { 141 141 @Override 142 public BooleanmapRow(ResultSet rs, int rowNumber) throws SQLException {143 return new Boolean(rs.getBoolean(admin_rights));142 public String mapRow(ResultSet rs, int rowNumber) throws SQLException { 143 return rs.getString(account); 144 144 } 145 145 }; -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
r4263 r4264 81 81 private Providers providers; 82 82 final String default_permission = "reader"; 83 private static final Logger logger = LoggerFactory.getLogger(AnnotationResource.class); 83 private final Logger logger = LoggerFactory.getLogger(AnnotationResource.class); 84 private final String admin = "admin"; 85 private final String developer = "developer"; 84 86 85 87 public void setUriInfo(UriInfo uriInfo) { … … 100 102 101 103 public AnnotationResource() { 104 } 105 106 @GET 107 @Produces(MediaType.TEXT_XML) 108 @Path("/all/debug") 109 @Transactional(readOnly = true) 110 public JAXBElement<AnnotationInfoList> getAllAnnotations() throws IOException { 111 dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString()); 112 Number userID = dbIntegrityService.getUserInternalIDFromRemoteID(httpServletRequest.getRemoteUser()); 113 if (userID != null) { 114 String typeOfAccount = dbIntegrityService.getTypeOfUserAccount(userID); 115 if (typeOfAccount.equals(admin) || typeOfAccount.equals(developer)) { 116 final AnnotationInfoList annotationInfoList = dbIntegrityService.getAllAnnotationInfos(); 117 return new ObjectFactory().createAnnotationInfoList(annotationInfoList); 118 } else { 119 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "The logged in user is neither developer nor admin, and therefore cannot perform this request."); 120 return null; 121 } 122 } else { 123 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The logged in user is not found in the database"); 124 return null; 125 } 126 102 127 } 103 128 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/UserResource.java
r4262 r4264 63 63 @Context 64 64 private UriInfo uriInfo; 65 65 66 final private String admin = "admin"; 67 66 68 public void setHttpRequest(HttpServletRequest request) { 67 69 this.httpServletRequest = request; … … 145 147 final Number remoteUserID = dbIntegrityService.getUserInternalIDFromRemoteID(httpServletRequest.getRemoteUser()); 146 148 if (remoteUserID != null) { 147 if (dbIntegrityService. userHasAdminRights(remoteUserID)) {149 if (dbIntegrityService.getTypeOfUserAccount(remoteUserID).equals(admin)) { 148 150 dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString()); 149 151 final Number userID = dbIntegrityService.addUser(user, remoteId); … … 172 174 final Number remoteUserID = dbIntegrityService.getUserInternalIDFromRemoteID(httpServletRequest.getRemoteUser()); 173 175 if (remoteUserID != null) { 174 if (dbIntegrityService. userHasAdminRights(remoteUserID)) {176 if (dbIntegrityService.getTypeOfUserAccount(remoteUserID).equals(admin)) { 175 177 dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString()); 176 178 final Number userID = dbIntegrityService.updateUser(user); … … 197 199 final Number remoteUserID = dbIntegrityService.getUserInternalIDFromRemoteID(httpServletRequest.getRemoteUser()); 198 200 if (remoteUserID != null) { 199 if (dbIntegrityService. userHasAdminRights(remoteUserID)) {201 if (dbIntegrityService.getTypeOfUserAccount(remoteUserID).equals(admin)) { 200 202 dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString()); 201 203 final Number userID = dbIntegrityService.getUserInternalIdentifier(UUID.fromString(externalIdentifier)); … … 223 225 final Number remoteUserID = dbIntegrityService.getUserInternalIDFromRemoteID(httpServletRequest.getRemoteUser()); 224 226 if (remoteUserID != null) { 225 if (dbIntegrityService. userHasAdminRights(remoteUserID)) {227 if (dbIntegrityService.getTypeOfUserAccount(remoteUserID).equals(admin)) { 226 228 dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString()); 227 229 final Number userID = dbIntegrityService.getUserInternalIdentifier(UUID.fromString(externalIdentifier)); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/index.jsp
r4245 r4264 58 58 GET <a href="api/targets/00000000-0000-0000-0000-000000000032/versions">api/targets/00000000-0000-0000-0000-000000000032/versions</a> <br> 59 59 GET <a href="api/cached/00000000-0000-0000-0000-000000000051/metadata">api/cached/00000000-0000-0000-0000-000000000051/metadata</a><br> 60 GET <a href="api/cached/00000000-0000-0000-0000-000000000051/content">api/cached/00000000-0000-0000-0000-000000000051/content></a> !Problem: works only on image.jpeg, end maps png-blobs to jpegs. 61 </body> 60 GET <a href="api/cached/00000000-0000-0000-0000-000000000051/content">api/cached/00000000-0000-0000-0000-000000000051/content</a> !Problem: works only on image.jpeg, end maps png-blobs to jpegs. 61 <br> 62 <br> 63 <b>Debugging URI's (only for developers)</b><br> 64 GET <a href="api/annotations/all/debug">api/annotations/all/debug</a> 65 </body> 62 66 </html>
Note: See TracChangeset
for help on using the changeset viewer.