Changeset 5088
- Timestamp:
- 04/28/14 16:01:50 (10 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src
- Files:
-
- 1 deleted
- 13 edited
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBDispatcher.java
r5086 r5088 49 49 * 50 50 */ 51 public interface DB IntegrityService{51 public interface DBDispatcher { 52 52 53 53 void setServiceURI(String serviceURI); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherImlp.java
r5086 r5088 26 26 import eu.dasish.annotation.backend.dao.AnnotationDao; 27 27 import eu.dasish.annotation.backend.dao.CachedRepresentationDao; 28 import eu.dasish.annotation.backend.dao.DB IntegrityService;28 import eu.dasish.annotation.backend.dao.DBDispatcher; 29 29 import eu.dasish.annotation.backend.dao.NotebookDao; 30 30 import eu.dasish.annotation.backend.dao.ResourceDao; … … 70 70 * @author olhsha 71 71 */ 72 public class DB IntegrityServiceImlp implements DBIntegrityService{72 public class DBDispatcherImlp implements DBDispatcher { 73 73 74 74 @Autowired … … 83 83 NotebookDao notebookDao; 84 84 final static protected String admin = "admin"; 85 private static final Logger logger = LoggerFactory.getLogger(DB IntegrityServiceImlp.class);85 private static final Logger logger = LoggerFactory.getLogger(DBDispatcherImlp.class); 86 86 87 87 ////////////////////////////////// -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
r5086 r5088 62 62 @Transactional(rollbackFor = {Exception.class}) 63 63 public class AnnotationResource extends ResourceResource { 64 65 64 66 65 67 public void setUriInfo(UriInfo uriInfo) { … … 100 102 @Override 101 103 public Annotation apply(Map params) throws NotInDataBaseException { 102 return db IntegrityService.getAnnotation((Number) params.get("internalID"));104 return dbDispatcher.getAnnotation((Number) params.get("internalID")); 103 105 } 104 106 } … … 123 125 @Override 124 126 public ReferenceList apply(Map params) throws NotInDataBaseException { 125 return db IntegrityService.getAnnotationTargets((Number) params.get("internalID"));127 return dbDispatcher.getAnnotationTargets((Number) params.get("internalID")); 126 128 } 127 129 } … … 150 152 } 151 153 if (!Arrays.asList(admissibleAccess).contains(access)) { 152 verboseOutput.INVALID_ACCESS_MODE(access);154 this.INVALID_ACCESS_MODE(access); 153 155 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "ivalide mode acess " + access); 154 156 return new ObjectFactory().createAnnotationInfoList(new AnnotationInfoList()); 155 157 } 156 158 try { 157 final AnnotationInfoList annotationInfoList = db IntegrityService.getFilteredAnnotationInfos(ownerExternalUUID, link, text, principalID, access, namespace, after, before);159 final AnnotationInfoList annotationInfoList = dbDispatcher.getFilteredAnnotationInfos(ownerExternalUUID, link, text, principalID, access, namespace, after, before); 158 160 return new ObjectFactory().createAnnotationInfoList(annotationInfoList); 159 161 } catch (NotInDataBaseException e) { … … 183 185 @Override 184 186 public PermissionList apply(Map params) throws NotInDataBaseException { 185 return db IntegrityService.getPermissions((Number) params.get("internalID"), (Resource) params.get("resourceType"));187 return dbDispatcher.getPermissions((Number) params.get("internalID"), (Resource) params.get("resourceType")); 186 188 } 187 189 } … … 204 206 @Override 205 207 public int[] apply(Map params) throws NotInDataBaseException { 206 return db IntegrityService.deleteAnnotation((Number) params.get("internalID"));208 return dbDispatcher.deleteAnnotation((Number) params.get("internalID")); 207 209 } 208 210 } … … 230 232 Number principalID = (Number) params.get("principalID"); 231 233 Annotation annotation = (Annotation) params.get("annotation"); 232 Number annotationID = db IntegrityService.addPrincipalsAnnotation(principalID, annotation);233 return db IntegrityService.makeAnnotationResponseEnvelope(annotationID);234 Number annotationID = dbDispatcher.addPrincipalsAnnotation(principalID, annotation); 235 return dbDispatcher.makeAnnotationResponseEnvelope(annotationID); 234 236 } 235 237 } … … 269 271 Annotation annotation = (Annotation) params.get("annotation"); 270 272 Number annotationID = (Number) params.get("internalID"); 271 int updatedRows = db IntegrityService.updateAnnotation(annotation);272 return db IntegrityService.makeAnnotationResponseEnvelope(annotationID);273 int updatedRows = dbDispatcher.updateAnnotation(annotation); 274 return dbDispatcher.makeAnnotationResponseEnvelope(annotationID); 273 275 } 274 276 } … … 298 300 Number resourceID = (Number) params.get("internalID"); 299 301 AnnotationBody annotationBody = (AnnotationBody) params.get("annotationBody"); 300 int updatedRows = db IntegrityService.updateAnnotationBody(resourceID, annotationBody);301 return db IntegrityService.makeAnnotationResponseEnvelope(resourceID);302 int updatedRows = dbDispatcher.updateAnnotationBody(resourceID, annotationBody); 303 return dbDispatcher.makeAnnotationResponseEnvelope(resourceID); 302 304 } 303 305 } … … 326 328 Number resourceID = (Number) params.get("internalID"); 327 329 String newHeadline = (String) params.get("headline"); 328 int updatedRows = db IntegrityService.updateAnnotationHeadline(resourceID, newHeadline);329 return db IntegrityService.makeAnnotationResponseEnvelope(resourceID);330 int updatedRows = dbDispatcher.updateAnnotationHeadline(resourceID, newHeadline); 331 return dbDispatcher.makeAnnotationResponseEnvelope(resourceID); 330 332 } 331 333 } … … 346 348 params.put("access", access); 347 349 try { 348 final Number inputPrincipalID = db IntegrityService.getResourceInternalIdentifier(UUID.fromString(principalId), Resource.PRINCIPAL);350 final Number inputPrincipalID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(principalId), Resource.PRINCIPAL); 349 351 params.put("inputPrincipalID", inputPrincipalID); 350 352 Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdatePrincipalAccess(), Resource.ANNOTATION, ResourceAction.WRITE_W_METAINFO, annotationId, false); … … 369 371 Number principalID = (Number) params.get("inputPrincipalID"); 370 372 Access access = (Access) params.get("access"); 371 return db IntegrityService.updateAnnotationPrincipalAccess(annotationID, principalID, access);373 return dbDispatcher.updateAnnotationPrincipalAccess(annotationID, principalID, access); 372 374 } 373 375 } … … 400 402 Number annotationID = (Number) params.get("internalID"); 401 403 PermissionList permissions = (PermissionList) params.get("permissions"); 402 int updatedRows = db IntegrityService.updatePermissions(annotationID, permissions);403 return db IntegrityService.makeAccessResponseEnvelope(annotationID, Resource.ANNOTATION);404 int updatedRows = dbDispatcher.updatePermissions(annotationID, permissions); 405 return dbDispatcher.makeAccessResponseEnvelope(annotationID, Resource.ANNOTATION); 404 406 } 405 407 } … … 413 415 return genericUpdateDeleteAccess(annotationId, principalId, null); 414 416 } 417 418 415 419 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AutheticationResource.java
r4995 r5088 50 50 Number principalID = this.getPrincipalID(); 51 51 if (principalID != null) { 52 return new ObjectFactory().createPrincipal(db IntegrityService.getPrincipal(principalID));52 return new ObjectFactory().createPrincipal(dbDispatcher.getPrincipal(principalID)); 53 53 } else { 54 54 return new ObjectFactory().createPrincipal(new Principal()); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/CachedRepresentationResource.java
r5086 r5088 79 79 public CachedRepresentationInfo apply(Map params) throws NotInDataBaseException { 80 80 Number cachedID = (Number) params.get("internalID"); 81 return db IntegrityService.getCachedRepresentationInfo(cachedID);81 return dbDispatcher.getCachedRepresentationInfo(cachedID); 82 82 } 83 83 } … … 122 122 public InputStream apply(Map params) throws NotInDataBaseException { 123 123 Number cachedID = (Number) params.get("internalID"); 124 return db IntegrityService.getCachedRepresentationBlob(cachedID);124 return dbDispatcher.getCachedRepresentationBlob(cachedID); 125 125 } 126 126 } … … 152 152 InputStream stream = (InputStream) params.get("stream"); 153 153 try { 154 return db IntegrityService.updateCachedBlob(cachedID, stream);154 return dbDispatcher.updateCachedBlob(cachedID, stream); 155 155 } catch (IOException e) { 156 156 loggerServer.info(e.toString()); … … 181 181 public Integer apply(Map params) throws NotInDataBaseException { 182 182 CachedRepresentationInfo cachedInfo = (CachedRepresentationInfo) params.get("cachedInfo"); 183 return db IntegrityService.updateCachedMetada(cachedInfo);183 return dbDispatcher.updateCachedMetada(cachedInfo); 184 184 } 185 185 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/DebugResource.java
r4985 r5088 57 57 return new ObjectFactory().createAnnotationInfoList(new AnnotationInfoList()); 58 58 } 59 String typeOfAccount = db IntegrityService.getTypeOfPrincipalAccount(remotePrincipalID);59 String typeOfAccount = dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID); 60 60 if (typeOfAccount.equals(admin) || typeOfAccount.equals(developer)) { 61 final AnnotationInfoList annotationInfoList = db IntegrityService.getAllAnnotationInfos();61 final AnnotationInfoList annotationInfoList = dbDispatcher.getAllAnnotationInfos(); 62 62 return new ObjectFactory().createAnnotationInfoList(annotationInfoList); 63 63 } else { 64 verboseOutput.DEVELOPER_RIGHTS_EXPECTED();64 this.DEVELOPER_RIGHTS_EXPECTED(); 65 65 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 66 66 return new ObjectFactory().createAnnotationInfoList(new AnnotationInfoList()); … … 77 77 return " "; 78 78 } 79 String typeOfAccount = db IntegrityService.getTypeOfPrincipalAccount(remotePrincipalID);79 String typeOfAccount = dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID); 80 80 if (typeOfAccount.equals(admin) || typeOfAccount.equals(developer)) { 81 81 return logFile("eu.dasish.annotation.backend.logDatabaseLocation", n); 82 82 } else { 83 verboseOutput.DEVELOPER_RIGHTS_EXPECTED();83 this.DEVELOPER_RIGHTS_EXPECTED(); 84 84 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 85 85 return "Coucou."; … … 105 105 return " "; 106 106 } 107 String typeOfAccount = db IntegrityService.getTypeOfPrincipalAccount(remotePrincipalID);107 String typeOfAccount = dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID); 108 108 if (typeOfAccount.equals(admin) || typeOfAccount.equals(developer)) { 109 109 return logFile("eu.dasish.annotation.backend.logServerLocation", n); 110 110 } else { 111 verboseOutput.DEVELOPER_RIGHTS_EXPECTED();111 this.DEVELOPER_RIGHTS_EXPECTED(); 112 112 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 113 113 return "Coucou."; … … 125 125 return " "; 126 126 } 127 String typeOfAccount = db IntegrityService.getTypeOfPrincipalAccount(remotePrincipalID);127 String typeOfAccount = dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID); 128 128 if (typeOfAccount.equals(admin)) { 129 129 try { 130 final boolean update = db IntegrityService.updateAccount(UUID.fromString(principalId), account);130 final boolean update = dbDispatcher.updateAccount(UUID.fromString(principalId), account); 131 131 return (update ? "The account is updated" : "The account is not updated, see the log."); 132 132 } catch (NotInDataBaseException e) { … … 135 135 } 136 136 } else { 137 verboseOutput.ADMIN_RIGHTS_EXPECTED(dbIntegrityService.getDataBaseAdmin().getDisplayName(), dbIntegrityService.getDataBaseAdmin().getEMail());137 this.ADMIN_RIGHTS_EXPECTED(); 138 138 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 139 139 return "Coucou."; … … 160 160 return result.toString(); 161 161 } 162 163 private void DEVELOPER_RIGHTS_EXPECTED() throws IOException { 164 loggerServer.debug("The request can be performed only by the principal with the developer's or admin rights. The logged in principal does not have either developer's or admin rights."); 165 } 162 166 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/NotebookResource.java
r4914 r5088 65 65 @Transactional(readOnly = true) 66 66 public JAXBElement<NotebookInfoList> getNotebookInfos(@QueryParam("access") String accessMode) throws IOException { 67 db IntegrityService.setServiceURI(uriInfo.getBaseUri().toString());67 dbDispatcher.setServiceURI(uriInfo.getBaseUri().toString()); 68 68 Number remotePrincipalID = this.getPrincipalID(); 69 69 if (accessMode.equalsIgnoreCase("read") || accessMode.equalsIgnoreCase("write")) { 70 NotebookInfoList notebookInfos = db IntegrityService.getNotebooks(remotePrincipalID, Access.fromValue(accessMode));70 NotebookInfoList notebookInfos = dbDispatcher.getNotebooks(remotePrincipalID, Access.fromValue(accessMode)); 71 71 return new ObjectFactory().createNotebookInfoList(notebookInfos); 72 72 } else { 73 verboseOutput.INVALID_ACCESS_MODE(accessMode);73 this.INVALID_ACCESS_MODE(accessMode); 74 74 httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "ivalide mode acess " + accessMode); 75 75 return new ObjectFactory().createNotebookInfoList(new NotebookInfoList()); … … 86 86 return new ObjectFactory().createReferenceList(new ReferenceList()); 87 87 } 88 ReferenceList references = db IntegrityService.getNotebooksOwnedBy(remotePrincipalID);88 ReferenceList references = dbDispatcher.getNotebooksOwnedBy(remotePrincipalID); 89 89 return new ObjectFactory().createReferenceList(references); 90 90 } … … 100 100 } 101 101 try { 102 Number notebookID = db IntegrityService.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK);103 if (db IntegrityService.hasAccess(notebookID, remotePrincipalID, Access.fromValue("read"))) {104 ReferenceList principals = db IntegrityService.getPrincipals(notebookID, accessMode);102 Number notebookID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK); 103 if (dbDispatcher.hasAccess(notebookID, remotePrincipalID, Access.fromValue("read"))) { 104 ReferenceList principals = dbDispatcher.getPrincipals(notebookID, accessMode); 105 105 return new ObjectFactory().createReferenceList(principals); 106 106 } else { 107 verboseOutput.FORBIDDEN_NOTEBOOK_READING(externalIdentifier, dbIntegrityService.getAnnotationOwner(notebookID).getDisplayName(), dbIntegrityService.getAnnotationOwner(notebookID).getEMail());108 107 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 109 108 return new ObjectFactory().createReferenceList(new ReferenceList()); … … 132 131 } 133 132 try { 134 Number notebookID = db IntegrityService.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK);135 if (db IntegrityService.hasAccess(notebookID, remotePrincipalID, Access.fromValue("read"))) {136 Notebook notebook = db IntegrityService.getNotebook(notebookID);133 Number notebookID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK); 134 if (dbDispatcher.hasAccess(notebookID, remotePrincipalID, Access.fromValue("read"))) { 135 Notebook notebook = dbDispatcher.getNotebook(notebookID); 137 136 return new ObjectFactory().createNotebook(notebook); 138 137 } else { 139 verboseOutput.FORBIDDEN_NOTEBOOK_READING(externalIdentifier, dbIntegrityService.getAnnotationOwner(notebookID).getDisplayName(), dbIntegrityService.getAnnotationOwner(notebookID).getEMail());140 138 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 141 139 return new ObjectFactory().createNotebook(new Notebook()); … … 164 162 } 165 163 try { 166 Number notebookID = db IntegrityService.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK);167 if (db IntegrityService.hasAccess(notebookID, remotePrincipalID, Access.fromValue("read"))) {168 ReferenceList annotations = db IntegrityService.getAnnotationsForNotebook(notebookID, startAnnotations, maximumAnnotations, orderBy, desc);164 Number notebookID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK); 165 if (dbDispatcher.hasAccess(notebookID, remotePrincipalID, Access.fromValue("read"))) { 166 ReferenceList annotations = dbDispatcher.getAnnotationsForNotebook(notebookID, startAnnotations, maximumAnnotations, orderBy, desc); 169 167 return new ObjectFactory().createReferenceList(annotations); 170 168 } else { 171 verboseOutput.FORBIDDEN_NOTEBOOK_READING(externalIdentifier, dbIntegrityService.getAnnotationOwner(notebookID).getDisplayName(), dbIntegrityService.getAnnotationOwner(notebookID).getEMail());172 169 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 173 170 return new ObjectFactory().createReferenceList(new ReferenceList()); … … 194 191 String notebookURI = notebookInfo.getRef(); 195 192 if (!(path + "notebook/" + externalIdentifier).equals(notebookURI)) { 196 verboseOutput.IDENTIFIER_MISMATCH(externalIdentifier);197 193 httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST); 198 194 return new ObjectFactory().createResponseBody(new ResponseBody()); 199 195 }; 200 196 try { 201 final Number notebookID = db IntegrityService.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK);197 final Number notebookID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK); 202 198 try { 203 if (remotePrincipalID.equals(db IntegrityService.getNotebookOwner(notebookID)) || dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {204 boolean success = db IntegrityService.updateNotebookMetadata(notebookID, notebookInfo);199 if (remotePrincipalID.equals(dbDispatcher.getNotebookOwner(notebookID)) || dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) { 200 boolean success = dbDispatcher.updateNotebookMetadata(notebookID, notebookInfo); 205 201 if (success) { 206 return new ObjectFactory().createResponseBody(db IntegrityService.makeNotebookResponseEnvelope(notebookID));202 return new ObjectFactory().createResponseBody(dbDispatcher.makeNotebookResponseEnvelope(notebookID)); 207 203 } else { 208 204 httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); … … 210 206 } 211 207 } else { 212 verboseOutput.FORBIDDEN_ACCESS_CHANGING(externalIdentifier, dbIntegrityService.getAnnotationOwner(notebookID).getDisplayName(), dbIntegrityService.getAnnotationOwner(notebookID).getEMail());213 208 loggerServer.debug(" Ownership changing is the part of the full update of the notebook metadadata."); 214 209 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/PrincipalResource.java
r5086 r5088 83 83 @Override 84 84 public Principal apply(Map params) throws NotInDataBaseException { 85 final Number principalID = db IntegrityService.getResourceInternalIdentifier(UUID.fromString((String) params.get("externalId")), Resource.PRINCIPAL);86 return db IntegrityService.getPrincipal(principalID);85 final Number principalID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString((String) params.get("externalId")), Resource.PRINCIPAL); 86 return dbDispatcher.getPrincipal(principalID); 87 87 } 88 88 } … … 99 99 return " "; 100 100 } 101 return "The admin of the server database " + db IntegrityService.getDataBaseAdmin().getDisplayName() + " is availiable via e-mail " + dbIntegrityService.getDataBaseAdmin().getEMail();101 return "The admin of the server database " + dbDispatcher.getDataBaseAdmin().getDisplayName() + " is availiable via e-mail " + dbDispatcher.getDataBaseAdmin().getEMail(); 102 102 } 103 103 … … 119 119 @Override 120 120 public Principal apply(Map params) throws NotInDataBaseException { 121 return db IntegrityService.getPrincipalByInfo((String) params.get("email"));121 return dbDispatcher.getPrincipalByInfo((String) params.get("email")); 122 122 } 123 123 } … … 140 140 @Override 141 141 public CurrentPrincipalInfo apply(Map params) throws NotInDataBaseException { 142 final Number principalID = db IntegrityService.getResourceInternalIdentifier(UUID.fromString((String) params.get("externalId")), Resource.PRINCIPAL);142 final Number principalID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString((String) params.get("externalId")), Resource.PRINCIPAL); 143 143 final CurrentPrincipalInfo principalInfo = new CurrentPrincipalInfo(); 144 principalInfo.setRef(db IntegrityService.getResourceURI(principalID, Resource.PRINCIPAL));144 principalInfo.setRef(dbDispatcher.getResourceURI(principalID, Resource.PRINCIPAL)); 145 145 principalInfo.setCurrentPrincipal(((PrincipalResource) params.get("resource")).ifLoggedIn(principalID)); 146 146 return principalInfo; … … 158 158 } 159 159 160 if (db IntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {161 int result = db IntegrityService.addSpringUser(remoteId, password, shaStrength, remoteId);160 if (dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) { 161 int result = dbDispatcher.addSpringUser(remoteId, password, shaStrength, remoteId); 162 162 return result + " record(s) has been added. Must be 2: 1 record for the principal, another for the authorities table."; 163 163 } else { 164 verboseOutput.ADMIN_RIGHTS_EXPECTED();164 this.ADMIN_RIGHTS_EXPECTED(); 165 165 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 166 166 return "Nothing is added."; … … 186 186 params.put("newPrincipal", principal); 187 187 188 if (db IntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {188 if (dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) { 189 189 return (new RequestWrappers(this)).wrapAddPrincipalRequest(params, new AddPrincipal()); 190 190 } else { 191 verboseOutput.ADMIN_RIGHTS_EXPECTED();191 this.ADMIN_RIGHTS_EXPECTED(); 192 192 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 193 193 return new ObjectFactory().createPrincipal(new Principal()); … … 200 200 @Override 201 201 public Principal apply(Map params) throws NotInDataBaseException, PrincipalExists { 202 final Number principalID = db IntegrityService.addPrincipal((Principal) params.get("newPrincipal"), (String) params.get("remoteId"));203 return db IntegrityService.getPrincipal(principalID);202 final Number principalID = dbDispatcher.addPrincipal((Principal) params.get("newPrincipal"), (String) params.get("remoteId")); 203 return dbDispatcher.getPrincipal(principalID); 204 204 } 205 205 } … … 225 225 params.put("newPrincipal", newPrincipal); 226 226 227 db IntegrityService.setServiceURI(uriInfo.getBaseUri().toString());227 dbDispatcher.setServiceURI(uriInfo.getBaseUri().toString()); 228 228 return (new RequestWrappers(this)).wrapAddPrincipalRequest(params, new RegisterNonShibbolizedPrincipal()); 229 229 } … … 233 233 @Override 234 234 public Principal apply(Map params) throws NotInDataBaseException, PrincipalExists { 235 final int updatedSpringTables = db IntegrityService.addSpringUser((String) params.get("remoteId"), (String) params.get("password"), (Integer) params.get("shaStrength"), (String) params.get("remoteId"));236 final Number principalID = db IntegrityService.addPrincipal((Principal) params.get("newPrincipal"), (String) params.get("remoteId"));237 return db IntegrityService.getPrincipal(principalID);235 final int updatedSpringTables = dbDispatcher.addSpringUser((String) params.get("remoteId"), (String) params.get("password"), (Integer) params.get("shaStrength"), (String) params.get("remoteId")); 236 final Number principalID = dbDispatcher.addPrincipal((Principal) params.get("newPrincipal"), (String) params.get("remoteId")); 237 return dbDispatcher.getPrincipal(principalID); 238 238 } 239 239 } … … 249 249 @FormParam("remoteId") String remoteId, @FormParam("email") String email) 250 250 throws IOException { 251 db IntegrityService.setServiceURI(uriInfo.getBaseUri().toString());251 dbDispatcher.setServiceURI(uriInfo.getBaseUri().toString()); 252 252 Principal newPrincipal = new Principal(); 253 253 newPrincipal.setDisplayName(name); … … 257 257 params.put("newPrincipal", newPrincipal); 258 258 259 db IntegrityService.setServiceURI(uriInfo.getBaseUri().toString());259 dbDispatcher.setServiceURI(uriInfo.getBaseUri().toString()); 260 260 return (new RequestWrappers(this)).wrapAddPrincipalRequest(params, new AddPrincipal()); 261 261 } … … 269 269 public String registerShibbolizedPrincipalAsNonShibb(@FormParam("remoteId") String remoteId, @FormParam("password") String password) 270 270 throws IOException { 271 int result = db IntegrityService.addSpringUser(remoteId, password, shaStrength, remoteId);271 int result = dbDispatcher.addSpringUser(remoteId, password, shaStrength, remoteId); 272 272 return result + " record(s) has been added. Must be 2: 1 record for the principal, another for the authorities table."; 273 273 … … 283 283 return new ObjectFactory().createPrincipal(new Principal()); 284 284 } 285 if (db IntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {285 if (dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) { 286 286 Map params = new HashMap<String, Object>(); 287 287 params.put("principal", principal); … … 290 290 291 291 } else { 292 verboseOutput.ADMIN_RIGHTS_EXPECTED();292 this.ADMIN_RIGHTS_EXPECTED(); 293 293 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 294 294 return new ObjectFactory().createPrincipal(new Principal()); … … 319 319 Principal principal = (Principal) params.get("newPrincipal"); 320 320 Number principalID = (Number) params.get("principalID"); 321 String uri = db IntegrityService.getResourceURI(principalID, Resource.PRINCIPAL);321 String uri = dbDispatcher.getResourceURI(principalID, Resource.PRINCIPAL); 322 322 principal.setURI(uri); 323 Number principalIDupd = db IntegrityService.updatePrincipal(principal);324 return db IntegrityService.getPrincipal(principalID);323 Number principalIDupd = dbDispatcher.updatePrincipal(principal); 324 return dbDispatcher.getPrincipal(principalID); 325 325 } 326 326 } … … 336 336 return "Nothing is updated."; 337 337 } 338 if (db IntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {338 if (dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) { 339 339 try { 340 final boolean updated = db IntegrityService.updateAccount(UUID.fromString(externalId), accountType);340 final boolean updated = dbDispatcher.updateAccount(UUID.fromString(externalId), accountType); 341 341 if (updated) { 342 return "The account was updated to " + db IntegrityService.getTypeOfPrincipalAccount(dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(externalId), Resource.PRINCIPAL));342 return "The account was updated to " + dbDispatcher.getTypeOfPrincipalAccount(dbDispatcher.getResourceInternalIdentifier(UUID.fromString(externalId), Resource.PRINCIPAL)); 343 343 } else { 344 344 loggerServer.debug("The account is not updated."); … … 352 352 } 353 353 } else { 354 verboseOutput.ADMIN_RIGHTS_EXPECTED();354 this.ADMIN_RIGHTS_EXPECTED(); 355 355 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 356 356 return "Account is not updated."; … … 366 366 return "Nothings is deleted."; 367 367 } 368 if (db IntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {368 if (dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) { 369 369 try { 370 final Number principalID = db IntegrityService.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.PRINCIPAL);370 final Number principalID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.PRINCIPAL); 371 371 try { 372 final int result = db IntegrityService.deletePrincipal(principalID);372 final int result = dbDispatcher.deletePrincipal(principalID); 373 373 return "There is " + result + " row deleted"; 374 374 } catch (PrincipalCannotBeDeleted e2) { … … 383 383 } 384 384 } else { 385 verboseOutput.ADMIN_RIGHTS_EXPECTED();385 this.ADMIN_RIGHTS_EXPECTED(); 386 386 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 387 387 return "Account is not updated."; … … 392 392 // silly because it is trivial. harvest all logged in users via shibboleth!! 393 393 private boolean ifLoggedIn(Number principalID) { 394 return (httpServletRequest.getRemoteUser()).equals(db IntegrityService.getPrincipalRemoteID(principalID));394 return (httpServletRequest.getRemoteUser()).equals(dbDispatcher.getPrincipalRemoteID(principalID)); 395 395 } 396 396 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/RequestWrappers.java
r5086 r5088 77 77 final Number resourceID; 78 78 if (isUri) { 79 resourceID = resourceResource.db IntegrityService.getResourceInternalIdentifierFromURI(externalId, resource);80 params.put(_externalId, resourceResource.db IntegrityService.getResourceExternalIdentifier(resourceID, resource).toString());79 resourceID = resourceResource.dbDispatcher.getResourceInternalIdentifierFromURI(externalId, resource); 80 params.put(_externalId, resourceResource.dbDispatcher.getResourceExternalIdentifier(resourceID, resource).toString()); 81 81 } else { 82 resourceID = resourceResource.db IntegrityService.getResourceInternalIdentifier(UUID.fromString(externalId), resource);82 resourceID = resourceResource.dbDispatcher.getResourceInternalIdentifier(UUID.fromString(externalId), resource); 83 83 params.put(_externalId, externalId); 84 84 } 85 if (resourceResource.db IntegrityService.canDo(action, principalID, resourceID, resource)) {85 if (resourceResource.dbDispatcher.canDo(action, principalID, resourceID, resource)) { 86 86 params.put(_internalID, resourceID); 87 87 params.put(_resourceType, resource); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceResource.java
r5086 r5088 21 21 import eu.dasish.annotation.backend.NotInDataBaseException; 22 22 import eu.dasish.annotation.backend.PrincipalExists; 23 import eu.dasish.annotation.backend.dao.DBIntegrityService; 24 import eu.dasish.annotation.backend.dao.ILambda; 25 import eu.dasish.annotation.schema.ObjectFactory; 23 import eu.dasish.annotation.backend.dao.DBDispatcher; 26 24 import eu.dasish.annotation.schema.Principal; 27 25 import java.io.IOException; 28 import java.util.Map;29 26 import javax.servlet.ServletContext; 30 27 import javax.servlet.http.HttpServletRequest; … … 33 30 import javax.ws.rs.core.UriInfo; 34 31 import javax.ws.rs.ext.Providers; 35 import javax.xml.bind.JAXBElement;36 32 import org.slf4j.Logger; 37 33 import org.slf4j.LoggerFactory; … … 45 41 46 42 @Autowired 47 protected DB IntegrityService dbIntegrityService;43 protected DBDispatcher dbDispatcher; 48 44 @Context 49 45 protected HttpServletRequest httpServletRequest; … … 57 53 protected ServletContext context; 58 54 protected Logger loggerServer = LoggerFactory.getLogger(HttpServletResponse.class); 59 protected VerboseOutput verboseOutput;60 55 protected String admin = "admin"; 61 56 protected String anonym = "anonymous"; 62 57 protected String defaultAccess = "read"; 63 64 58 protected String[] admissibleAccess = {"read", "write", "owner"}; 65 59 66 60 public Number getPrincipalID() throws IOException { 67 db IntegrityService.setServiceURI(uriInfo.getBaseUri().toString());61 dbDispatcher.setServiceURI(uriInfo.getBaseUri().toString()); 68 62 String remotePrincipal = httpServletRequest.getRemoteUser(); 69 verboseOutput = new VerboseOutput(loggerServer);70 63 if (remotePrincipal != null) { 71 64 if (!remotePrincipal.equals("anonymous")) { 72 65 try { 73 return db IntegrityService.getPrincipalInternalIDFromRemoteID(remotePrincipal);66 return dbDispatcher.getPrincipalInternalIDFromRemoteID(remotePrincipal); 74 67 } catch (NotInDataBaseException e) { 75 68 loggerServer.info(e.toString()); … … 78 71 try { 79 72 Principal newPrincipal = Helpers.createPrincipalElement(remotePrincipal, remotePrincipal); 80 return db IntegrityService.addPrincipal(newPrincipal, remotePrincipal);73 return dbDispatcher.addPrincipal(newPrincipal, remotePrincipal); 81 74 } catch (PrincipalExists e2) { 82 75 loggerServer.info(e2.toString()); … … 101 94 } 102 95 } 103 104 96 97 protected void ADMIN_RIGHTS_EXPECTED() throws IOException { 98 loggerServer.debug("The request can be performed only by the principal with the admin rights."); 99 } 100 101 protected void INVALID_ACCESS_MODE(String accessMode) throws IOException { 102 loggerServer.debug(accessMode + " is an invalid access value, which must be either owner, or read, or write."); 103 } 105 104 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/TargetResource.java
r5086 r5088 92 92 public Target apply(Map params) throws NotInDataBaseException { 93 93 Number targetID = (Number) params.get("internalID"); 94 return db IntegrityService.getTarget(targetID);94 return dbDispatcher.getTarget(targetID); 95 95 } 96 96 } … … 116 116 public ReferenceList apply(Map params) throws NotInDataBaseException { 117 117 Number targetID = (Number) params.get("internalID"); 118 return db IntegrityService.getTargetsForTheSameLinkAs(targetID);118 return dbDispatcher.getTargetsForTheSameLinkAs(targetID); 119 119 } 120 120 } … … 152 152 InputStream cachedSource = (InputStream) params.get("cachedBlob"); 153 153 try { 154 final Number[] respondDB = db IntegrityService.addCachedForTarget(targetID, fragmentDescriptor, metadata, cachedSource);155 return db IntegrityService.getCachedRepresentationInfo(respondDB[1]);154 final Number[] respondDB = dbDispatcher.addCachedForTarget(targetID, fragmentDescriptor, metadata, cachedSource); 155 return dbDispatcher.getCachedRepresentationInfo(respondDB[1]); 156 156 } catch (IOException e) { 157 157 loggerServer.info(e.toString()); … … 172 172 } 173 173 try { 174 final Number targetID = db IntegrityService.getResourceInternalIdentifier(UUID.fromString(targetIdentifier), Resource.TARGET);174 final Number targetID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(targetIdentifier), Resource.TARGET); 175 175 try { 176 final Number cachedID = db IntegrityService.getResourceInternalIdentifier(UUID.fromString(cachedIdentifier), Resource.CACHED_REPRESENTATION);177 final int updated = db IntegrityService.updateTargetCachedFragment(targetID, cachedID, fragmentDescriptor);176 final Number cachedID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(cachedIdentifier), Resource.CACHED_REPRESENTATION); 177 final int updated = dbDispatcher.updateTargetCachedFragment(targetID, cachedID, fragmentDescriptor); 178 178 return updated + "rows is/are updated."; 179 179 } catch (NotInDataBaseException e1) { … … 198 198 } 199 199 try { 200 final Number targetID = db IntegrityService.getResourceInternalIdentifier(UUID.fromString(targetExternalIdentifier), Resource.TARGET);200 final Number targetID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(targetExternalIdentifier), Resource.TARGET); 201 201 try { 202 final Number cachedID = db IntegrityService.getResourceInternalIdentifier(UUID.fromString(cachedExternalIdentifier), Resource.CACHED_REPRESENTATION);203 int[] result = db IntegrityService.deleteCachedRepresentationOfTarget(targetID, cachedID);202 final Number cachedID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(cachedExternalIdentifier), Resource.CACHED_REPRESENTATION); 203 int[] result = dbDispatcher.deleteCachedRepresentationOfTarget(targetID, cachedID); 204 204 return result[0] + " pair(s) target-cached deleted."; 205 205 } catch (NotInDataBaseException e) { -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/resources/spring-config/dbDispatcher.xml
r4681 r5088 24 24 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 25 25 "> 26 <bean class="eu.dasish.annotation.backend.dao.impl.DB IntegrityServiceImlp">26 <bean class="eu.dasish.annotation.backend.dao.impl.DBDispatcherImlp"> 27 27 </bean> 28 28 </beans> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/MockObjectsFactoryRest.java
r4603 r5088 18 18 package eu.dasish.annotation.backend; 19 19 20 import eu.dasish.annotation.backend.dao.DB IntegrityService;20 import eu.dasish.annotation.backend.dao.DBDispatcher; 21 21 import javax.servlet.http.HttpServletRequest; 22 22 import javax.servlet.http.HttpServletResponse; … … 39 39 40 40 41 public DB IntegrityService newDBIntegrityService() {42 return context.mock(DB IntegrityService.class);41 public DBDispatcher newDBDispatcher() { 42 return context.mock(DBDispatcher.class); 43 43 } 44 44 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherTest.java
r5086 r5088 76 76 "/spring-test-config/mockPrincipalDao.xml", "/spring-test-config/mockTargetDao.xml", "/spring-test-config/mockCachedRepresentationDao.xml", 77 77 "/spring-test-config/mockNotebookDao.xml", 78 "/spring-config/db IntegrityService.xml"})79 public class DB IntegrityServiceTest {78 "/spring-config/dbDispatcher.xml"}) 79 public class DBDispatcherTest { 80 80 81 81 @Autowired 82 private DB IntegrityServiceImlp dbIntegrityService;82 private DBDispatcherImlp dbDispatcher; 83 83 @Autowired 84 84 private Mockery mockeryDao; … … 95 95 TestInstances testInstances = new TestInstances(TestBackendConstants._TEST_SERVLET_URI); 96 96 97 public DB IntegrityServiceTest() {97 public DBDispatcherTest() { 98 98 } 99 99 … … 114 114 } 115 115 }); 116 assertEquals(1, db IntegrityService.getResourceInternalIdentifier(externalID, Resource.ANNOTATION));116 assertEquals(1, dbDispatcher.getResourceInternalIdentifier(externalID, Resource.ANNOTATION)); 117 117 } 118 118 … … 132 132 } 133 133 }); 134 assertEquals("00000000-0000-0000-0000-000000000021", db IntegrityService.getResourceExternalIdentifier(1, Resource.ANNOTATION).toString());134 assertEquals("00000000-0000-0000-0000-000000000021", dbDispatcher.getResourceExternalIdentifier(1, Resource.ANNOTATION).toString()); 135 135 } 136 136 … … 151 151 } 152 152 }); 153 assertEquals(1, db IntegrityService.getResourceInternalIdentifier(externalID, Resource.PRINCIPAL));153 assertEquals(1, dbDispatcher.getResourceInternalIdentifier(externalID, Resource.PRINCIPAL)); 154 154 } 155 155 … … 169 169 } 170 170 }); 171 assertEquals("00000000-0000-0000-0000-000000000111", db IntegrityService.getResourceExternalIdentifier(1, Resource.PRINCIPAL).toString());171 assertEquals("00000000-0000-0000-0000-000000000111", dbDispatcher.getResourceExternalIdentifier(1, Resource.PRINCIPAL).toString()); 172 172 } 173 173 … … 265 265 }); 266 266 267 Annotation result = db IntegrityService.getAnnotation(1);267 Annotation result = dbDispatcher.getAnnotation(1); 268 268 assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations + "00000000-0000-0000-0000-000000000021", result.getURI()); 269 269 assertEquals("text/plain", result.getBody().getTextBody().getMimeType()); … … 366 366 367 367 368 List result = db IntegrityService.getFilteredAnnotationIDs(null, "nl.wikipedia.org", "some html 1", 3, "read", null, after, before);368 List result = dbDispatcher.getFilteredAnnotationIDs(null, "nl.wikipedia.org", "some html 1", 3, "read", null, after, before); 369 369 assertEquals(1, result.size()); 370 370 assertEquals(1, result.get(0)); … … 440 440 441 441 442 List result = db IntegrityService.getFilteredAnnotationIDs(null, "nl.wikipedia.org", "some html 1", 3, "write", null, after, before);442 List result = dbDispatcher.getFilteredAnnotationIDs(null, "nl.wikipedia.org", "some html 1", 3, "write", null, after, before); 443 443 assertEquals(1, result.size()); 444 444 assertEquals(1, result.get(0)); … … 482 482 483 483 484 List result = db IntegrityService.getFilteredAnnotationIDs(null, "nl.wikipedia.org", "some html 1", 3, "owner", null, after, before);484 List result = dbDispatcher.getFilteredAnnotationIDs(null, "nl.wikipedia.org", "some html 1", 3, "owner", null, after, before); 485 485 assertEquals(0, result.size()); 486 486 } … … 518 518 519 519 520 List result = db IntegrityService.getFilteredAnnotationIDs(UUID.fromString("00000000-0000-0000-0000-000000000111"), "nl.wikipedia.org", "some html 1", 3, "owner", null, after, before);520 List result = dbDispatcher.getFilteredAnnotationIDs(UUID.fromString("00000000-0000-0000-0000-000000000111"), "nl.wikipedia.org", "some html 1", 3, "owner", null, after, before); 521 521 assertEquals(0, result.size()); 522 522 } … … 542 542 }); 543 543 544 ReferenceList result = db IntegrityService.getAnnotationTargets(1);544 ReferenceList result = dbDispatcher.getAnnotationTargets(1); 545 545 assertEquals(2, result.getRef().size()); 546 546 assertEquals(TestBackendConstants._TEST_SERVLET_URI_targets + "00000000-0000-0000-0000-000000000031", result.getRef().get(0)); … … 663 663 664 664 665 AnnotationInfoList result = db IntegrityService.getFilteredAnnotationInfos(ownerUUID, "nl.wikipedia.org", "some html 1", 3, "read", null, after, before);665 AnnotationInfoList result = dbDispatcher.getFilteredAnnotationInfos(ownerUUID, "nl.wikipedia.org", "some html 1", 3, "read", null, after, before); 666 666 assertEquals(1, result.getAnnotationInfo().size()); 667 667 AnnotationInfo resultAnnotInfo = result.getAnnotationInfo().get(0); … … 705 705 }); 706 706 707 List<String> result = db IntegrityService.getTargetsWithNoCachedRepresentation(3);707 List<String> result = dbDispatcher.getTargetsWithNoCachedRepresentation(3); 708 708 assertEquals(1, result.size()); 709 709 assertEquals("00000000-0000-0000-0000-000000000037", result.get(0)); // Target number 7 has no cached … … 747 747 748 748 749 Number[] result = db IntegrityService.addCachedForTarget(1, "#(1,2)", newCachedInfo, newCachedBlob);749 Number[] result = dbDispatcher.addCachedForTarget(1, "#(1,2)", newCachedInfo, newCachedBlob); 750 750 assertEquals(2, result.length); 751 751 assertEquals(1, result[0]); … … 784 784 }); 785 785 786 Map<String, String> result = db IntegrityService.addTargetsForAnnotation(4, mockTargetListOne);786 Map<String, String> result = dbDispatcher.addTargetsForAnnotation(4, mockTargetListOne); 787 787 assertEquals(0, result.size()); 788 788 … … 819 819 }); 820 820 821 Map<String, String> resultTwo = db IntegrityService.addTargetsForAnnotation(1, mockTargetListTwo);821 Map<String, String> resultTwo = dbDispatcher.addTargetsForAnnotation(1, mockTargetListTwo); 822 822 assertEquals(1, resultTwo.size()); 823 823 assertEquals(mockNewTargetUUID.toString(), resultTwo.get(tempTargetID)); … … 857 857 }); 858 858 859 Number result = db IntegrityService.addPrincipalsAnnotation(3, testAnnotation);859 Number result = dbDispatcher.addPrincipalsAnnotation(3, testAnnotation); 860 860 assertEquals(5, result); 861 861 … … 888 888 889 889 890 assertEquals(11, db IntegrityService.addPrincipal(freshPrincipal, "guisil@mpi.nl").intValue());890 assertEquals(11, dbDispatcher.addPrincipal(freshPrincipal, "guisil@mpi.nl").intValue()); 891 891 892 892 /// principal already exists … … 904 904 PrincipalExists ex = null; 905 905 try { 906 db IntegrityService.addPrincipal(principal, "olhsha@mpi.nl");906 dbDispatcher.addPrincipal(principal, "olhsha@mpi.nl"); 907 907 } catch (PrincipalExists e) { 908 908 ex = e; … … 930 930 }); 931 931 932 assertEquals(0, db IntegrityService.deletePrincipal(1));933 assertEquals(0, db IntegrityService.deletePrincipal(3));934 assertEquals(1, db IntegrityService.deletePrincipal(10));932 assertEquals(0, dbDispatcher.deletePrincipal(1)); 933 assertEquals(0, dbDispatcher.deletePrincipal(3)); 934 assertEquals(1, dbDispatcher.deletePrincipal(10)); 935 935 } 936 936 … … 952 952 }); 953 953 954 int[] result = db IntegrityService.deleteCachedRepresentationOfTarget(5, 7);954 int[] result = dbDispatcher.deleteCachedRepresentationOfTarget(5, 7); 955 955 assertEquals(2, result.length); 956 956 assertEquals(1, result[0]); … … 986 986 }); 987 987 988 int[] result = db IntegrityService.deleteAllCachedRepresentationsOfTarget(1);988 int[] result = dbDispatcher.deleteAllCachedRepresentationsOfTarget(1); 989 989 assertEquals(2, result[0]); // # affected rows in Targets_cacheds 990 990 assertEquals(2, result[1]); // # affected rows in cacheds … … 1041 1041 } 1042 1042 }); 1043 int[] result = db IntegrityService.deleteAnnotation(2);// the Target will be deleted because it is not referred by any annotation1043 int[] result = dbDispatcher.deleteAnnotation(2);// the Target will be deleted because it is not referred by any annotation 1044 1044 assertEquals(5, result.length); 1045 1045 assertEquals(1, result[0]); // annotation 3 is deleted … … 1071 1071 }); 1072 1072 1073 assertEquals(1, db IntegrityService.getResourceInternalIdentifier(mockUUID, Resource.NOTEBOOK));1073 assertEquals(1, dbDispatcher.getResourceInternalIdentifier(mockUUID, Resource.NOTEBOOK)); 1074 1074 1075 1075 } … … 1127 1127 }); 1128 1128 1129 NotebookInfoList result = db IntegrityService.getNotebooks(3, Access.READ);1129 NotebookInfoList result = dbDispatcher.getNotebooks(3, Access.READ); 1130 1130 assertEquals("00000000-0000-0000-0000-000000000011", result.getNotebookInfo().get(0).getRef()); 1131 1131 assertEquals("00000000-0000-0000-0000-000000000111", result.getNotebookInfo().get(0).getOwnerRef()); … … 1206 1206 }); 1207 1207 1208 ReferenceList result = db IntegrityService.getNotebooksOwnedBy(3);1208 ReferenceList result = dbDispatcher.getNotebooksOwnedBy(3); 1209 1209 assertEquals(2, result.getRef().size()); 1210 1210 assertEquals(TestBackendConstants._TEST_SERVLET_URI_notebooks + "00000000-0000-0000-0000-000000000013", result.getRef().get(0)); … … 1239 1239 }); 1240 1240 1241 assertTrue(db IntegrityService.hasAccess(4, 2, write));1242 assertFalse(db IntegrityService.hasAccess(5, 2, write));1241 assertTrue(dbDispatcher.hasAccess(4, 2, write)); 1242 assertFalse(dbDispatcher.hasAccess(5, 2, write)); 1243 1243 } 1244 1244 … … 1275 1275 }); 1276 1276 1277 ReferenceList result = db IntegrityService.getPrincipals(1, "write");1277 ReferenceList result = dbDispatcher.getPrincipals(1, "write"); 1278 1278 assertEquals("serviceURI/principals/00000000-0000-0000-0000-000000000112", result.getRef().get(0).toString()); 1279 1279 assertEquals("serviceURI/principals/00000000-0000-0000-0000-000000000114", result.getRef().get(1).toString()); … … 1364 1364 }); 1365 1365 1366 Notebook result = db IntegrityService.getNotebook(2);1366 Notebook result = dbDispatcher.getNotebook(2); 1367 1367 assertEquals("serviceURI/notebooks/00000000-0000-0000-0000-000000000012", result.getURI()); 1368 1368 assertEquals("serviceURI/principals/00000000-0000-0000-0000-000000000112", result.getOwnerRef()); … … 1404 1404 }); 1405 1405 1406 ReferenceList result = db IntegrityService.getAnnotationsForNotebook(1, -1, 3, "last_modified", true);1406 ReferenceList result = dbDispatcher.getAnnotationsForNotebook(1, -1, 3, "last_modified", true); 1407 1407 assertEquals(2, result.getRef().size()); 1408 1408 assertEquals("serviceURI/annotations/00000000-0000-0000-0000-000000000021", result.getRef().get(0).toString()); … … 1435 1435 }); 1436 1436 1437 boolean result = db IntegrityService.updateNotebookMetadata(1, mockNotebookInfo);1437 boolean result = dbDispatcher.updateNotebookMetadata(1, mockNotebookInfo); 1438 1438 assertTrue(result); 1439 1439 } … … 1454 1454 }); 1455 1455 1456 assertTrue(db IntegrityService.addAnnotationToNotebook(1, 3));1456 assertTrue(dbDispatcher.addAnnotationToNotebook(1, 3)); 1457 1457 } 1458 1458 … … 1513 1513 }); 1514 1514 1515 Number result = db IntegrityService.createNotebook(notebook, 1);1515 Number result = dbDispatcher.createNotebook(notebook, 1); 1516 1516 assertEquals(5, result); 1517 1517 … … 1552 1552 }); 1553 1553 1554 assertTrue(db IntegrityService.createAnnotationInNotebook(1, testAnnotation, 3));1554 assertTrue(dbDispatcher.createAnnotationInNotebook(1, testAnnotation, 3)); 1555 1555 1556 1556 } … … 1584 1584 }); 1585 1585 1586 assertTrue(db IntegrityService.deleteNotebook(1));1586 assertTrue(dbDispatcher.deleteNotebook(1)); 1587 1587 } 1588 1588 … … 1603 1603 }); 1604 1604 1605 assertEquals(Access.WRITE, db IntegrityService.getAccess(1, 3));1605 assertEquals(Access.WRITE, dbDispatcher.getAccess(1, 3)); 1606 1606 1607 1607 ////// … … 1617 1617 } 1618 1618 }); 1619 assertEquals(Access.READ, db IntegrityService.getAccess(2, 3));1619 assertEquals(Access.READ, dbDispatcher.getAccess(2, 3)); 1620 1620 1621 1621 ////// … … 1631 1631 } 1632 1632 }); 1633 assertEquals(Access.NONE, db IntegrityService.getAccess(3, 3));1633 assertEquals(Access.NONE, dbDispatcher.getAccess(3, 3)); 1634 1634 1635 1635 ////// … … 1647 1647 } 1648 1648 }); 1649 assertEquals(Access.READ, db IntegrityService.getPublicAttribute(2));1649 assertEquals(Access.READ, dbDispatcher.getPublicAttribute(2)); 1650 1650 } 1651 1651 … … 1755 1755 } 1756 1756 }); 1757 assertEquals(1, db IntegrityService.updateAnnotation(annotation));1757 assertEquals(1, dbDispatcher.updateAnnotation(annotation)); 1758 1758 } 1759 1759 … … 1781 1781 } 1782 1782 }); 1783 assertEquals(1, db IntegrityService.updateAnnotationHeadline(1, "new Headline"));1783 assertEquals(1, dbDispatcher.updateAnnotationHeadline(1, "new Headline")); 1784 1784 } 1785 1785 … … 1822 1822 }); 1823 1823 1824 assertEquals(1, db IntegrityService.updateAnnotationPrincipalAccess(1, 2, Access.READ));1825 assertEquals(1, db IntegrityService.updateAnnotationPrincipalAccess(1, 4, Access.WRITE));1824 assertEquals(1, dbDispatcher.updateAnnotationPrincipalAccess(1, 2, Access.READ)); 1825 assertEquals(1, dbDispatcher.updateAnnotationPrincipalAccess(1, 4, Access.WRITE)); 1826 1826 } 1827 1827 … … 1858 1858 }); 1859 1859 1860 assertEquals(1, db IntegrityService.updatePermissions(1, permissions));1860 assertEquals(1, dbDispatcher.updatePermissions(1, permissions)); 1861 1861 1862 1862 } … … 1894 1894 }); 1895 1895 1896 assertEquals(1, db IntegrityService.updatePermissions(1, permissions));1896 assertEquals(1, dbDispatcher.updatePermissions(1, permissions)); 1897 1897 1898 1898 } … … 1913 1913 }); 1914 1914 1915 assertEquals(1, db IntegrityService.updatePublicAttribute(1, Access.NONE));1915 assertEquals(1, dbDispatcher.updatePublicAttribute(1, Access.NONE)); 1916 1916 1917 1917 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java
r5086 r5088 21 21 import eu.dasish.annotation.backend.Resource; 22 22 import eu.dasish.annotation.backend.ResourceAction; 23 import eu.dasish.annotation.backend.dao.DB IntegrityService;23 import eu.dasish.annotation.backend.dao.DBDispatcher; 24 24 import eu.dasish.annotation.backend.TestBackendConstants; 25 25 import eu.dasish.annotation.backend.TestInstances; … … 53 53 */ 54 54 @RunWith(value = SpringJUnit4ClassRunner.class) 55 @ContextConfiguration(locations = {"/spring-test-config/mockeryRest.xml", "/spring-test-config/mockDB IntegrityService.xml",55 @ContextConfiguration(locations = {"/spring-test-config/mockeryRest.xml", "/spring-test-config/mockDBDispatcher.xml", 56 56 "/spring-test-config/mockUriInfo.xml", 57 57 "/spring-config/jaxbMarshallerFactory.xml"}) … … 61 61 private Mockery mockeryRest; 62 62 @Autowired 63 private DB IntegrityService mockDbIntegrityService;63 private DBDispatcher mockDbDispatcher; 64 64 @Autowired 65 65 UriInfo mockUriInfo; … … 107 107 will(returnValue(baseUri)); 108 108 109 oneOf(mockDb IntegrityService).setServiceURI(baseUri.toString());110 111 oneOf(mockDb IntegrityService).getPrincipalInternalIDFromRemoteID("olhsha@mpi.nl");109 oneOf(mockDbDispatcher).setServiceURI(baseUri.toString()); 110 111 oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("olhsha@mpi.nl"); 112 112 will(returnValue(3)); 113 113 114 oneOf(mockDb IntegrityService).getResourceInternalIdentifier(with(aNonNull(UUID.class)), with(aNonNull((Resource.class))));115 will(returnValue(1)); 116 117 118 oneOf(mockDb IntegrityService).canDo(ResourceAction.READ, 3, 1, Resource.ANNOTATION);114 oneOf(mockDbDispatcher).getResourceInternalIdentifier(with(aNonNull(UUID.class)), with(aNonNull((Resource.class)))); 115 will(returnValue(1)); 116 117 118 oneOf(mockDbDispatcher).canDo(ResourceAction.READ, 3, 1, Resource.ANNOTATION); 119 119 will(returnValue(true)); 120 120 121 oneOf(mockDb IntegrityService).getAnnotation(1);121 oneOf(mockDbDispatcher).getAnnotation(1); 122 122 will(returnValue(expectedAnnotation)); 123 123 } … … 154 154 will(returnValue(baseUri)); 155 155 156 oneOf(mockDb IntegrityService).setServiceURI(baseUri.toString());157 158 oneOf(mockDb IntegrityService).getPrincipalInternalIDFromRemoteID("olhsha@mpi.nl");156 oneOf(mockDbDispatcher).setServiceURI(baseUri.toString()); 157 158 oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("olhsha@mpi.nl"); 159 159 will(returnValue(3)); 160 160 161 oneOf(mockDb IntegrityService).getResourceInternalIdentifier(with(aNonNull(UUID.class)), with(aNonNull((Resource.class))));161 oneOf(mockDbDispatcher).getResourceInternalIdentifier(with(aNonNull(UUID.class)), with(aNonNull((Resource.class)))); 162 162 will(returnValue(4)); 163 163 164 164 165 oneOf(mockDb IntegrityService).getAnnotationOwnerID(4);165 oneOf(mockDbDispatcher).getAnnotationOwnerID(4); 166 166 will(returnValue(3)); 167 167 168 oneOf(mockDb IntegrityService).canDo(ResourceAction.DELETE, 3, 4, Resource.ANNOTATION);168 oneOf(mockDbDispatcher).canDo(ResourceAction.DELETE, 3, 4, Resource.ANNOTATION); 169 169 will(returnValue(true)); 170 170 171 oneOf(mockDb IntegrityService).deleteAnnotation(4);171 oneOf(mockDbDispatcher).deleteAnnotation(4); 172 172 will(returnValue(mockDelete)); 173 173 } … … 216 216 will(returnValue(baseUri)); 217 217 218 oneOf(mockDb IntegrityService).setServiceURI(baseUri.toString());219 220 oneOf(mockDb IntegrityService).getPrincipalInternalIDFromRemoteID("olhsha@mpi.nl");218 oneOf(mockDbDispatcher).setServiceURI(baseUri.toString()); 219 220 oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("olhsha@mpi.nl"); 221 221 will(returnValue(3)); 222 222 223 oneOf(mockDb IntegrityService).addPrincipalsAnnotation(3, annotationToAdd);223 oneOf(mockDbDispatcher).addPrincipalsAnnotation(3, annotationToAdd); 224 224 will(returnValue(newAnnotationID)); 225 225 226 oneOf(mockDb IntegrityService).getAnnotation(newAnnotationID);226 oneOf(mockDbDispatcher).getAnnotation(newAnnotationID); 227 227 will(returnValue(addedAnnotation)); 228 228 229 oneOf(mockDb IntegrityService).makeAnnotationResponseEnvelope(newAnnotationID);229 oneOf(mockDbDispatcher).makeAnnotationResponseEnvelope(newAnnotationID); 230 230 will(returnValue(mockEnvelope)); 231 231 … … 286 286 will(returnValue(baseUri)); 287 287 288 oneOf(mockDb IntegrityService).setServiceURI(baseUri.toString());289 290 oneOf(mockDb IntegrityService).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl");291 will(returnValue(1)); 292 293 oneOf(mockUriInfo).getBaseUri(); 294 will(returnValue(baseUri)); 295 296 oneOf(mockDb IntegrityService).getResourceInternalIdentifier(externalId, Resource.ANNOTATION);297 will(returnValue(1)); 298 299 oneOf(mockDb IntegrityService).getAnnotationOwnerID(1);300 will(returnValue(1)); 301 302 oneOf(mockDb IntegrityService).canDo(ResourceAction.WRITE_W_METAINFO, 1, 1, Resource.ANNOTATION);288 oneOf(mockDbDispatcher).setServiceURI(baseUri.toString()); 289 290 oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl"); 291 will(returnValue(1)); 292 293 oneOf(mockUriInfo).getBaseUri(); 294 will(returnValue(baseUri)); 295 296 oneOf(mockDbDispatcher).getResourceInternalIdentifier(externalId, Resource.ANNOTATION); 297 will(returnValue(1)); 298 299 oneOf(mockDbDispatcher).getAnnotationOwnerID(1); 300 will(returnValue(1)); 301 302 oneOf(mockDbDispatcher).canDo(ResourceAction.WRITE_W_METAINFO, 1, 1, Resource.ANNOTATION); 303 303 will(returnValue(true)); 304 304 305 oneOf(mockDb IntegrityService).updateAnnotation(annotation);305 oneOf(mockDbDispatcher).updateAnnotation(annotation); 306 306 will(returnValue(1)); 307 307 308 oneOf(mockDb IntegrityService).makeAnnotationResponseEnvelope(1);308 oneOf(mockDbDispatcher).makeAnnotationResponseEnvelope(1); 309 309 will(returnValue(mockEnvelope)); 310 310 … … 361 361 will(returnValue(baseUri)); 362 362 363 oneOf(mockDb IntegrityService).setServiceURI(baseUri.toString());364 365 oneOf(mockDb IntegrityService).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl");363 oneOf(mockDbDispatcher).setServiceURI(baseUri.toString()); 364 365 oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl"); 366 366 will(returnValue(1)); 367 367 368 368 369 oneOf(mockDb IntegrityService).getResourceInternalIdentifier(externalId, Resource.ANNOTATION);370 will(returnValue(1)); 371 372 oneOf(mockDb IntegrityService).canDo(ResourceAction.WRITE, 1, 1, Resource.ANNOTATION);369 oneOf(mockDbDispatcher).getResourceInternalIdentifier(externalId, Resource.ANNOTATION); 370 will(returnValue(1)); 371 372 oneOf(mockDbDispatcher).canDo(ResourceAction.WRITE, 1, 1, Resource.ANNOTATION); 373 373 will(returnValue(true)); 374 374 375 375 376 oneOf(mockDb IntegrityService).updateAnnotationBody(1, ab);376 oneOf(mockDbDispatcher).updateAnnotationBody(1, ab); 377 377 will(returnValue(1)); 378 378 379 oneOf(mockDb IntegrityService).makeAnnotationResponseEnvelope(1);379 oneOf(mockDbDispatcher).makeAnnotationResponseEnvelope(1); 380 380 will(returnValue(mockEnvelope)); 381 381 … … 418 418 will(returnValue(baseUri)); 419 419 420 oneOf(mockDb IntegrityService).setServiceURI(baseUri.toString());421 422 oneOf(mockDb IntegrityService).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl");420 oneOf(mockDbDispatcher).setServiceURI(baseUri.toString()); 421 422 oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl"); 423 423 will(returnValue(1)); 424 424 425 425 426 oneOf(mockDb IntegrityService).getResourceInternalIdentifier(externalId, Resource.ANNOTATION);427 will(returnValue(1)); 428 429 oneOf(mockDb IntegrityService).canDo(ResourceAction.WRITE, 1, 1, Resource.ANNOTATION);426 oneOf(mockDbDispatcher).getResourceInternalIdentifier(externalId, Resource.ANNOTATION); 427 will(returnValue(1)); 428 429 oneOf(mockDbDispatcher).canDo(ResourceAction.WRITE, 1, 1, Resource.ANNOTATION); 430 430 will(returnValue(true)); 431 431 432 432 433 oneOf(mockDb IntegrityService).updateAnnotationHeadline(1, newHeadline);433 oneOf(mockDbDispatcher).updateAnnotationHeadline(1, newHeadline); 434 434 will(returnValue(1)); 435 435 436 oneOf(mockDb IntegrityService).makeAnnotationResponseEnvelope(1);436 oneOf(mockDbDispatcher).makeAnnotationResponseEnvelope(1); 437 437 will(returnValue(mockEnvelope)); 438 438 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationsTest.java
r5086 r5088 87 87 // sorry for the duplication, but JerseyTest is not aware of 88 88 // @ContextConfiguration 89 return "classpath:spring-config/componentscan.xml, classpath:spring-config/notebookDao.xml, classpath:spring-config/annotationDao.xml, classpath:spring-config/principalDao.xml, classpath:spring-config/targetDao.xml, classpath:spring-config/cachedRepresentationDao.xml, classpath:spring-config/db IntegrityService.xml, classpath:spring-config/jaxbMarshallerFactory.xml, classpath:spring-test-config/dataSource.xml";89 return "classpath:spring-config/componentscan.xml, classpath:spring-config/notebookDao.xml, classpath:spring-config/annotationDao.xml, classpath:spring-config/principalDao.xml, classpath:spring-config/targetDao.xml, classpath:spring-config/cachedRepresentationDao.xml, classpath:spring-config/dbDispatcher.xml, classpath:spring-config/jaxbMarshallerFactory.xml, classpath:spring-test-config/dataSource.xml"; 90 90 } 91 91 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/NotebookResourceTest.java
r4800 r5088 18 18 package eu.dasish.annotation.backend.rest; 19 19 20 import eu.dasish.annotation.backend.dao.DB IntegrityService;20 import eu.dasish.annotation.backend.dao.DBDispatcher; 21 21 import org.jmock.Mockery; 22 22 import org.junit.Test; … … 31 31 */ 32 32 @RunWith(value = SpringJUnit4ClassRunner.class) 33 @ContextConfiguration(locations = {"/spring-test-config/mockeryRest.xml", "/spring-test-config/mockDB IntegrityService.xml", "/spring-config/jaxbMarshallerFactory.xml",33 @ContextConfiguration(locations = {"/spring-test-config/mockeryRest.xml", "/spring-test-config/mockDBDispatcher.xml", "/spring-config/jaxbMarshallerFactory.xml", 34 34 "/spring-test-config/mockUriInfo.xml"}) 35 35 public class NotebookResourceTest { … … 38 38 private Mockery mockeryRest; 39 39 @Autowired 40 private DB IntegrityServicedaoDispatcher;40 private DBDispatcher daoDispatcher; 41 41 @Autowired 42 42 private NotebookResource notebookResource; -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/resources/spring-test-config/mockDBDispatcher.xml
r4681 r5088 29 29 30 30 <!-- Mocked dispatcher --> 31 <bean id="dbIntegrityService" factory-bean="mockObjectsFactoryRest" factory-method="newDB IntegrityService" />31 <bean id="dbIntegrityService" factory-bean="mockObjectsFactoryRest" factory-method="newDBDispatcher" /> 32 32 33 33 </beans>
Note: See TracChangeset
for help on using the changeset viewer.