Changeset 5088


Ignore:
Timestamp:
04/28/14 16:01:50 (10 years ago)
Author:
olhsha@mpi.nl
Message:

removing redundant "VerboseOutput?"

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  
    4949 *
    5050 */
    51 public interface DBIntegrityService {
     51public interface DBDispatcher {
    5252
    5353    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  
    2626import eu.dasish.annotation.backend.dao.AnnotationDao;
    2727import eu.dasish.annotation.backend.dao.CachedRepresentationDao;
    28 import eu.dasish.annotation.backend.dao.DBIntegrityService;
     28import eu.dasish.annotation.backend.dao.DBDispatcher;
    2929import eu.dasish.annotation.backend.dao.NotebookDao;
    3030import eu.dasish.annotation.backend.dao.ResourceDao;
     
    7070 * @author olhsha
    7171 */
    72 public class DBIntegrityServiceImlp implements DBIntegrityService {
     72public class DBDispatcherImlp implements DBDispatcher {
    7373
    7474    @Autowired
     
    8383    NotebookDao notebookDao;
    8484    final static protected String admin = "admin";
    85     private static final Logger logger = LoggerFactory.getLogger(DBIntegrityServiceImlp.class);
     85    private static final Logger logger = LoggerFactory.getLogger(DBDispatcherImlp.class);
    8686
    8787    //////////////////////////////////
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java

    r5086 r5088  
    6262@Transactional(rollbackFor = {Exception.class})
    6363public class AnnotationResource extends ResourceResource {
     64   
     65   
    6466
    6567    public void setUriInfo(UriInfo uriInfo) {
     
    100102        @Override
    101103        public Annotation apply(Map params) throws NotInDataBaseException {
    102             return dbIntegrityService.getAnnotation((Number) params.get("internalID"));
     104            return dbDispatcher.getAnnotation((Number) params.get("internalID"));
    103105        }
    104106    }
     
    123125        @Override
    124126        public ReferenceList apply(Map params) throws NotInDataBaseException {
    125             return dbIntegrityService.getAnnotationTargets((Number) params.get("internalID"));
     127            return dbDispatcher.getAnnotationTargets((Number) params.get("internalID"));
    126128        }
    127129    }
     
    150152        }
    151153        if (!Arrays.asList(admissibleAccess).contains(access)) {
    152             verboseOutput.INVALID_ACCESS_MODE(access);
     154            this.INVALID_ACCESS_MODE(access);
    153155            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "ivalide mode acess " + access);
    154156            return new ObjectFactory().createAnnotationInfoList(new AnnotationInfoList());
    155157        }
    156158        try {
    157             final AnnotationInfoList annotationInfoList = dbIntegrityService.getFilteredAnnotationInfos(ownerExternalUUID, link, text, principalID, access, namespace, after, before);
     159            final AnnotationInfoList annotationInfoList = dbDispatcher.getFilteredAnnotationInfos(ownerExternalUUID, link, text, principalID, access, namespace, after, before);
    158160            return new ObjectFactory().createAnnotationInfoList(annotationInfoList);
    159161        } catch (NotInDataBaseException e) {
     
    183185        @Override
    184186        public PermissionList apply(Map params) throws NotInDataBaseException {
    185             return dbIntegrityService.getPermissions((Number) params.get("internalID"), (Resource) params.get("resourceType"));
     187            return dbDispatcher.getPermissions((Number) params.get("internalID"), (Resource) params.get("resourceType"));
    186188        }
    187189    }
     
    204206        @Override
    205207        public int[] apply(Map params) throws NotInDataBaseException {
    206             return dbIntegrityService.deleteAnnotation((Number) params.get("internalID"));
     208            return dbDispatcher.deleteAnnotation((Number) params.get("internalID"));
    207209        }
    208210    }
     
    230232            Number principalID = (Number) params.get("principalID");
    231233            Annotation annotation = (Annotation) params.get("annotation");
    232             Number annotationID = dbIntegrityService.addPrincipalsAnnotation(principalID, annotation);
    233             return dbIntegrityService.makeAnnotationResponseEnvelope(annotationID);
     234            Number annotationID = dbDispatcher.addPrincipalsAnnotation(principalID, annotation);
     235            return dbDispatcher.makeAnnotationResponseEnvelope(annotationID);
    234236        }
    235237    }
     
    269271            Annotation annotation = (Annotation) params.get("annotation");
    270272            Number annotationID = (Number) params.get("internalID");
    271             int updatedRows = dbIntegrityService.updateAnnotation(annotation);
    272             return dbIntegrityService.makeAnnotationResponseEnvelope(annotationID);
     273            int updatedRows = dbDispatcher.updateAnnotation(annotation);
     274            return dbDispatcher.makeAnnotationResponseEnvelope(annotationID);
    273275        }
    274276    }
     
    298300            Number resourceID = (Number) params.get("internalID");
    299301            AnnotationBody annotationBody = (AnnotationBody) params.get("annotationBody");
    300             int updatedRows = dbIntegrityService.updateAnnotationBody(resourceID, annotationBody);
    301             return dbIntegrityService.makeAnnotationResponseEnvelope(resourceID);
     302            int updatedRows = dbDispatcher.updateAnnotationBody(resourceID, annotationBody);
     303            return dbDispatcher.makeAnnotationResponseEnvelope(resourceID);
    302304        }
    303305    }
     
    326328            Number resourceID = (Number) params.get("internalID");
    327329            String newHeadline = (String) params.get("headline");
    328             int updatedRows = dbIntegrityService.updateAnnotationHeadline(resourceID, newHeadline);
    329             return dbIntegrityService.makeAnnotationResponseEnvelope(resourceID);
     330            int updatedRows = dbDispatcher.updateAnnotationHeadline(resourceID, newHeadline);
     331            return dbDispatcher.makeAnnotationResponseEnvelope(resourceID);
    330332        }
    331333    }
     
    346348        params.put("access", access);
    347349        try {
    348             final Number inputPrincipalID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(principalId), Resource.PRINCIPAL);
     350            final Number inputPrincipalID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(principalId), Resource.PRINCIPAL);
    349351            params.put("inputPrincipalID", inputPrincipalID);
    350352            Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdatePrincipalAccess(), Resource.ANNOTATION, ResourceAction.WRITE_W_METAINFO, annotationId, false);
     
    369371            Number principalID = (Number) params.get("inputPrincipalID");
    370372            Access access = (Access) params.get("access");
    371             return dbIntegrityService.updateAnnotationPrincipalAccess(annotationID, principalID, access);
     373            return dbDispatcher.updateAnnotationPrincipalAccess(annotationID, principalID, access);
    372374        }
    373375    }
     
    400402            Number annotationID = (Number) params.get("internalID");
    401403            PermissionList permissions = (PermissionList) params.get("permissions");
    402             int updatedRows = dbIntegrityService.updatePermissions(annotationID, permissions);
    403             return dbIntegrityService.makeAccessResponseEnvelope(annotationID, Resource.ANNOTATION);
     404            int updatedRows = dbDispatcher.updatePermissions(annotationID, permissions);
     405            return dbDispatcher.makeAccessResponseEnvelope(annotationID, Resource.ANNOTATION);
    404406        }
    405407    }
     
    413415        return genericUpdateDeleteAccess(annotationId, principalId, null);
    414416    }
     417   
     418   
    415419}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AutheticationResource.java

    r4995 r5088  
    5050        Number principalID = this.getPrincipalID();
    5151        if (principalID != null) {
    52             return new ObjectFactory().createPrincipal(dbIntegrityService.getPrincipal(principalID));
     52            return new ObjectFactory().createPrincipal(dbDispatcher.getPrincipal(principalID));
    5353        } else {
    5454            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  
    7979        public CachedRepresentationInfo apply(Map params) throws NotInDataBaseException {
    8080            Number cachedID = (Number) params.get("internalID");
    81             return dbIntegrityService.getCachedRepresentationInfo(cachedID);
     81            return dbDispatcher.getCachedRepresentationInfo(cachedID);
    8282        }
    8383    }
     
    122122        public InputStream apply(Map params) throws NotInDataBaseException {
    123123            Number cachedID = (Number) params.get("internalID");
    124             return dbIntegrityService.getCachedRepresentationBlob(cachedID);
     124            return dbDispatcher.getCachedRepresentationBlob(cachedID);
    125125        }
    126126    }
     
    152152            InputStream stream = (InputStream) params.get("stream");
    153153            try {
    154                 return dbIntegrityService.updateCachedBlob(cachedID, stream);
     154                return dbDispatcher.updateCachedBlob(cachedID, stream);
    155155            } catch (IOException e) {
    156156                loggerServer.info(e.toString());
     
    181181        public Integer apply(Map params) throws NotInDataBaseException {
    182182            CachedRepresentationInfo cachedInfo = (CachedRepresentationInfo) params.get("cachedInfo");
    183             return dbIntegrityService.updateCachedMetada(cachedInfo);
     183            return dbDispatcher.updateCachedMetada(cachedInfo);
    184184        }
    185185    }
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/DebugResource.java

    r4985 r5088  
    5757            return new ObjectFactory().createAnnotationInfoList(new AnnotationInfoList());
    5858        }
    59         String typeOfAccount = dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID);
     59        String typeOfAccount = dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID);
    6060        if (typeOfAccount.equals(admin) || typeOfAccount.equals(developer)) {
    61             final AnnotationInfoList annotationInfoList = dbIntegrityService.getAllAnnotationInfos();
     61            final AnnotationInfoList annotationInfoList = dbDispatcher.getAllAnnotationInfos();
    6262            return new ObjectFactory().createAnnotationInfoList(annotationInfoList);
    6363        } else {
    64             verboseOutput.DEVELOPER_RIGHTS_EXPECTED();
     64            this.DEVELOPER_RIGHTS_EXPECTED();
    6565            httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
    6666            return new ObjectFactory().createAnnotationInfoList(new AnnotationInfoList());
     
    7777            return " ";
    7878        }
    79         String typeOfAccount = dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID);
     79        String typeOfAccount = dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID);
    8080        if (typeOfAccount.equals(admin) || typeOfAccount.equals(developer)) {
    8181            return logFile("eu.dasish.annotation.backend.logDatabaseLocation", n);
    8282        } else {
    83             verboseOutput.DEVELOPER_RIGHTS_EXPECTED();
     83            this.DEVELOPER_RIGHTS_EXPECTED();
    8484            httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
    8585            return "Coucou.";
     
    105105            return " ";
    106106        }
    107         String typeOfAccount = dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID);
     107        String typeOfAccount = dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID);
    108108        if (typeOfAccount.equals(admin) || typeOfAccount.equals(developer)) {
    109109            return logFile("eu.dasish.annotation.backend.logServerLocation", n);
    110110        } else {
    111             verboseOutput.DEVELOPER_RIGHTS_EXPECTED();
     111            this.DEVELOPER_RIGHTS_EXPECTED();
    112112            httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
    113113            return "Coucou.";
     
    125125            return " ";
    126126        }
    127         String typeOfAccount = dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID);
     127        String typeOfAccount = dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID);
    128128        if (typeOfAccount.equals(admin)) {
    129129            try {
    130                 final boolean update = dbIntegrityService.updateAccount(UUID.fromString(principalId), account);
     130                final boolean update = dbDispatcher.updateAccount(UUID.fromString(principalId), account);
    131131                return (update ? "The account is updated" : "The account is not updated, see the log.");
    132132            } catch (NotInDataBaseException e) {
     
    135135            }
    136136        } else {
    137             verboseOutput.ADMIN_RIGHTS_EXPECTED(dbIntegrityService.getDataBaseAdmin().getDisplayName(), dbIntegrityService.getDataBaseAdmin().getEMail());
     137            this.ADMIN_RIGHTS_EXPECTED();
    138138            httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
    139139            return "Coucou.";
     
    160160        return result.toString();
    161161    }
     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    }
    162166}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/NotebookResource.java

    r4914 r5088  
    6565    @Transactional(readOnly = true)
    6666    public JAXBElement<NotebookInfoList> getNotebookInfos(@QueryParam("access") String accessMode) throws IOException {
    67         dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
     67        dbDispatcher.setServiceURI(uriInfo.getBaseUri().toString());
    6868        Number remotePrincipalID = this.getPrincipalID();
    6969        if (accessMode.equalsIgnoreCase("read") || accessMode.equalsIgnoreCase("write")) {
    70             NotebookInfoList notebookInfos = dbIntegrityService.getNotebooks(remotePrincipalID, Access.fromValue(accessMode));
     70            NotebookInfoList notebookInfos = dbDispatcher.getNotebooks(remotePrincipalID, Access.fromValue(accessMode));
    7171            return new ObjectFactory().createNotebookInfoList(notebookInfos);
    7272        } else {
    73             verboseOutput.INVALID_ACCESS_MODE(accessMode);
     73            this.INVALID_ACCESS_MODE(accessMode);
    7474            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "ivalide mode acess " + accessMode);
    7575            return new ObjectFactory().createNotebookInfoList(new NotebookInfoList());
     
    8686            return new ObjectFactory().createReferenceList(new ReferenceList());
    8787        }
    88         ReferenceList references = dbIntegrityService.getNotebooksOwnedBy(remotePrincipalID);
     88        ReferenceList references = dbDispatcher.getNotebooksOwnedBy(remotePrincipalID);
    8989        return new ObjectFactory().createReferenceList(references);
    9090    }
     
    100100        }
    101101        try {
    102             Number notebookID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK);
    103             if (dbIntegrityService.hasAccess(notebookID, remotePrincipalID, Access.fromValue("read"))) {
    104                 ReferenceList principals = dbIntegrityService.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);
    105105                return new ObjectFactory().createReferenceList(principals);
    106106            } else {
    107                 verboseOutput.FORBIDDEN_NOTEBOOK_READING(externalIdentifier, dbIntegrityService.getAnnotationOwner(notebookID).getDisplayName(), dbIntegrityService.getAnnotationOwner(notebookID).getEMail());
    108107                httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
    109108                return new ObjectFactory().createReferenceList(new ReferenceList());
     
    132131        }
    133132        try {
    134             Number notebookID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK);
    135             if (dbIntegrityService.hasAccess(notebookID, remotePrincipalID, Access.fromValue("read"))) {
    136                 Notebook notebook = dbIntegrityService.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);
    137136                return new ObjectFactory().createNotebook(notebook);
    138137            } else {
    139                 verboseOutput.FORBIDDEN_NOTEBOOK_READING(externalIdentifier, dbIntegrityService.getAnnotationOwner(notebookID).getDisplayName(), dbIntegrityService.getAnnotationOwner(notebookID).getEMail());
    140138                httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
    141139                return new ObjectFactory().createNotebook(new Notebook());
     
    164162        }
    165163        try {
    166             Number notebookID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK);
    167             if (dbIntegrityService.hasAccess(notebookID, remotePrincipalID, Access.fromValue("read"))) {
    168                 ReferenceList annotations = dbIntegrityService.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);
    169167                return new ObjectFactory().createReferenceList(annotations);
    170168            } else {
    171                 verboseOutput.FORBIDDEN_NOTEBOOK_READING(externalIdentifier, dbIntegrityService.getAnnotationOwner(notebookID).getDisplayName(), dbIntegrityService.getAnnotationOwner(notebookID).getEMail());
    172169                httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
    173170                return new ObjectFactory().createReferenceList(new ReferenceList());
     
    194191        String notebookURI = notebookInfo.getRef();
    195192        if (!(path + "notebook/" + externalIdentifier).equals(notebookURI)) {
    196             verboseOutput.IDENTIFIER_MISMATCH(externalIdentifier);
    197193            httpServletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST);
    198194            return new ObjectFactory().createResponseBody(new ResponseBody());
    199195        };
    200196        try {
    201             final Number notebookID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK);
     197            final Number notebookID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.NOTEBOOK);
    202198            try {
    203                 if (remotePrincipalID.equals(dbIntegrityService.getNotebookOwner(notebookID)) || dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
    204                     boolean success = dbIntegrityService.updateNotebookMetadata(notebookID, notebookInfo);
     199                if (remotePrincipalID.equals(dbDispatcher.getNotebookOwner(notebookID)) || dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
     200                    boolean success = dbDispatcher.updateNotebookMetadata(notebookID, notebookInfo);
    205201                    if (success) {
    206                         return new ObjectFactory().createResponseBody(dbIntegrityService.makeNotebookResponseEnvelope(notebookID));
     202                        return new ObjectFactory().createResponseBody(dbDispatcher.makeNotebookResponseEnvelope(notebookID));
    207203                    } else {
    208204                        httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
     
    210206                    }
    211207                } else {
    212                     verboseOutput.FORBIDDEN_ACCESS_CHANGING(externalIdentifier, dbIntegrityService.getAnnotationOwner(notebookID).getDisplayName(), dbIntegrityService.getAnnotationOwner(notebookID).getEMail());
    213208                    loggerServer.debug(" Ownership changing is the part of the full update of the notebook metadadata.");
    214209                    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  
    8383        @Override
    8484        public Principal apply(Map params) throws NotInDataBaseException {
    85             final Number principalID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString((String) params.get("externalId")), Resource.PRINCIPAL);
    86             return dbIntegrityService.getPrincipal(principalID);
     85            final Number principalID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString((String) params.get("externalId")), Resource.PRINCIPAL);
     86            return dbDispatcher.getPrincipal(principalID);
    8787        }
    8888    }
     
    9999            return " ";
    100100        }
    101         return "The admin of the server database " + dbIntegrityService.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();
    102102    }
    103103   
     
    119119        @Override
    120120        public Principal apply(Map params) throws NotInDataBaseException {
    121             return dbIntegrityService.getPrincipalByInfo((String) params.get("email"));
     121            return dbDispatcher.getPrincipalByInfo((String) params.get("email"));
    122122        }
    123123    }
     
    140140        @Override
    141141        public CurrentPrincipalInfo apply(Map params) throws NotInDataBaseException {
    142             final Number principalID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString((String) params.get("externalId")), Resource.PRINCIPAL);
     142            final Number principalID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString((String) params.get("externalId")), Resource.PRINCIPAL);
    143143            final CurrentPrincipalInfo principalInfo = new CurrentPrincipalInfo();
    144             principalInfo.setRef(dbIntegrityService.getResourceURI(principalID, Resource.PRINCIPAL));
     144            principalInfo.setRef(dbDispatcher.getResourceURI(principalID, Resource.PRINCIPAL));
    145145            principalInfo.setCurrentPrincipal(((PrincipalResource) params.get("resource")).ifLoggedIn(principalID));
    146146            return principalInfo;
     
    158158        }
    159159
    160         if (dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
    161             int result = dbIntegrityService.addSpringUser(remoteId, password, shaStrength, remoteId);
     160        if (dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
     161            int result = dbDispatcher.addSpringUser(remoteId, password, shaStrength, remoteId);
    162162            return result + " record(s) has been added. Must be 2: 1 record for the principal, another for the authorities table.";
    163163        } else {
    164             verboseOutput.ADMIN_RIGHTS_EXPECTED();
     164            this.ADMIN_RIGHTS_EXPECTED();
    165165            httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
    166166            return "Nothing is added.";
     
    186186        params.put("newPrincipal", principal);
    187187
    188         if (dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
     188        if (dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
    189189            return (new RequestWrappers(this)).wrapAddPrincipalRequest(params, new AddPrincipal());
    190190        } else {
    191             verboseOutput.ADMIN_RIGHTS_EXPECTED();
     191            this.ADMIN_RIGHTS_EXPECTED();
    192192            httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
    193193            return new ObjectFactory().createPrincipal(new Principal());
     
    200200        @Override
    201201        public Principal apply(Map params) throws NotInDataBaseException, PrincipalExists {
    202             final Number principalID = dbIntegrityService.addPrincipal((Principal) params.get("newPrincipal"), (String) params.get("remoteId"));
    203             return dbIntegrityService.getPrincipal(principalID);
     202            final Number principalID = dbDispatcher.addPrincipal((Principal) params.get("newPrincipal"), (String) params.get("remoteId"));
     203            return dbDispatcher.getPrincipal(principalID);
    204204        }
    205205    }
     
    225225        params.put("newPrincipal", newPrincipal);
    226226
    227         dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
     227        dbDispatcher.setServiceURI(uriInfo.getBaseUri().toString());
    228228        return (new RequestWrappers(this)).wrapAddPrincipalRequest(params, new RegisterNonShibbolizedPrincipal());
    229229    }
     
    233233        @Override
    234234        public Principal apply(Map params) throws NotInDataBaseException, PrincipalExists {
    235             final int updatedSpringTables = dbIntegrityService.addSpringUser((String) params.get("remoteId"), (String) params.get("password"), (Integer) params.get("shaStrength"), (String) params.get("remoteId"));
    236             final Number principalID = dbIntegrityService.addPrincipal((Principal) params.get("newPrincipal"), (String) params.get("remoteId"));
    237             return dbIntegrityService.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);
    238238        }
    239239    }
     
    249249            @FormParam("remoteId") String remoteId, @FormParam("email") String email)
    250250            throws IOException {
    251         dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
     251        dbDispatcher.setServiceURI(uriInfo.getBaseUri().toString());
    252252        Principal newPrincipal = new Principal();
    253253        newPrincipal.setDisplayName(name);
     
    257257        params.put("newPrincipal", newPrincipal);
    258258
    259         dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
     259        dbDispatcher.setServiceURI(uriInfo.getBaseUri().toString());
    260260        return (new RequestWrappers(this)).wrapAddPrincipalRequest(params, new AddPrincipal());
    261261    }
     
    269269    public String registerShibbolizedPrincipalAsNonShibb(@FormParam("remoteId") String remoteId, @FormParam("password") String password)
    270270            throws IOException {
    271         int result = dbIntegrityService.addSpringUser(remoteId, password, shaStrength, remoteId);
     271        int result = dbDispatcher.addSpringUser(remoteId, password, shaStrength, remoteId);
    272272        return result + " record(s) has been added. Must be 2: 1 record for the principal, another for the authorities table.";
    273273
     
    283283            return new ObjectFactory().createPrincipal(new Principal());
    284284        }
    285         if (dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
     285        if (dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
    286286            Map params = new HashMap<String, Object>();
    287287            params.put("principal", principal);
     
    290290
    291291        } else {
    292             verboseOutput.ADMIN_RIGHTS_EXPECTED();
     292            this.ADMIN_RIGHTS_EXPECTED();
    293293            httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
    294294            return new ObjectFactory().createPrincipal(new Principal());
     
    319319            Principal principal = (Principal) params.get("newPrincipal");
    320320            Number principalID = (Number) params.get("principalID");           
    321             String uri = dbIntegrityService.getResourceURI(principalID, Resource.PRINCIPAL);
     321            String uri = dbDispatcher.getResourceURI(principalID, Resource.PRINCIPAL);
    322322            principal.setURI(uri);
    323             Number principalIDupd = dbIntegrityService.updatePrincipal(principal);
    324             return dbIntegrityService.getPrincipal(principalID);
     323            Number principalIDupd = dbDispatcher.updatePrincipal(principal);
     324            return dbDispatcher.getPrincipal(principalID);
    325325        }
    326326    }
     
    336336            return "Nothing is updated.";
    337337        }
    338         if (dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
     338        if (dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
    339339            try {
    340                 final boolean updated = dbIntegrityService.updateAccount(UUID.fromString(externalId), accountType);
     340                final boolean updated = dbDispatcher.updateAccount(UUID.fromString(externalId), accountType);
    341341                if (updated) {
    342                     return "The account was updated to " + dbIntegrityService.getTypeOfPrincipalAccount(dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(externalId), Resource.PRINCIPAL));
     342                    return "The account was updated to " + dbDispatcher.getTypeOfPrincipalAccount(dbDispatcher.getResourceInternalIdentifier(UUID.fromString(externalId), Resource.PRINCIPAL));
    343343                } else {
    344344                    loggerServer.debug("The account is not updated.");
     
    352352            }
    353353        } else {
    354             verboseOutput.ADMIN_RIGHTS_EXPECTED();
     354            this.ADMIN_RIGHTS_EXPECTED();
    355355            httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
    356356            return "Account is not updated.";
     
    366366            return "Nothings is deleted.";
    367367        }
    368         if (dbIntegrityService.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
     368        if (dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID).equals(admin)) {
    369369            try {
    370                 final Number principalID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.PRINCIPAL);
     370                final Number principalID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(externalIdentifier), Resource.PRINCIPAL);
    371371                try {
    372                     final int result = dbIntegrityService.deletePrincipal(principalID);
     372                    final int result = dbDispatcher.deletePrincipal(principalID);
    373373                    return "There is " + result + " row deleted";
    374374                } catch (PrincipalCannotBeDeleted e2) {
     
    383383            }
    384384        } else {
    385             verboseOutput.ADMIN_RIGHTS_EXPECTED();
     385            this.ADMIN_RIGHTS_EXPECTED();
    386386            httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
    387387            return "Account is not updated.";
     
    392392    // silly because it is trivial. harvest all logged in users via shibboleth!!
    393393    private boolean ifLoggedIn(Number principalID) {
    394         return (httpServletRequest.getRemoteUser()).equals(dbIntegrityService.getPrincipalRemoteID(principalID));
     394        return (httpServletRequest.getRemoteUser()).equals(dbDispatcher.getPrincipalRemoteID(principalID));
    395395    }
    396396
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/RequestWrappers.java

    r5086 r5088  
    7777            final Number resourceID;
    7878            if (isUri) {
    79                 resourceID = resourceResource.dbIntegrityService.getResourceInternalIdentifierFromURI(externalId, resource);
    80                 params.put(_externalId,  resourceResource.dbIntegrityService.getResourceExternalIdentifier(resourceID, resource).toString());
     79                resourceID = resourceResource.dbDispatcher.getResourceInternalIdentifierFromURI(externalId, resource);
     80                params.put(_externalId,  resourceResource.dbDispatcher.getResourceExternalIdentifier(resourceID, resource).toString());
    8181            } else {
    82                 resourceID = resourceResource.dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(externalId), resource);
     82                resourceID = resourceResource.dbDispatcher.getResourceInternalIdentifier(UUID.fromString(externalId), resource);
    8383                params.put(_externalId, externalId);
    8484            }
    85             if (resourceResource.dbIntegrityService.canDo(action, principalID, resourceID, resource)) {
     85            if (resourceResource.dbDispatcher.canDo(action, principalID, resourceID, resource)) {
    8686                params.put(_internalID, resourceID);
    8787                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  
    2121import eu.dasish.annotation.backend.NotInDataBaseException;
    2222import 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;
     23import eu.dasish.annotation.backend.dao.DBDispatcher;
    2624import eu.dasish.annotation.schema.Principal;
    2725import java.io.IOException;
    28 import java.util.Map;
    2926import javax.servlet.ServletContext;
    3027import javax.servlet.http.HttpServletRequest;
     
    3330import javax.ws.rs.core.UriInfo;
    3431import javax.ws.rs.ext.Providers;
    35 import javax.xml.bind.JAXBElement;
    3632import org.slf4j.Logger;
    3733import org.slf4j.LoggerFactory;
     
    4541
    4642    @Autowired
    47     protected DBIntegrityService dbIntegrityService;
     43    protected DBDispatcher dbDispatcher;
    4844    @Context
    4945    protected HttpServletRequest httpServletRequest;
     
    5753    protected ServletContext context;
    5854    protected Logger loggerServer = LoggerFactory.getLogger(HttpServletResponse.class);
    59     protected VerboseOutput verboseOutput;
    6055    protected String admin = "admin";
    6156    protected String anonym = "anonymous";
    6257    protected String defaultAccess = "read";
    63    
    6458    protected String[] admissibleAccess = {"read", "write", "owner"};
    6559
    6660    public Number getPrincipalID() throws IOException {
    67         dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
     61        dbDispatcher.setServiceURI(uriInfo.getBaseUri().toString());
    6862        String remotePrincipal = httpServletRequest.getRemoteUser();
    69         verboseOutput = new VerboseOutput(loggerServer);
    7063        if (remotePrincipal != null) {
    7164            if (!remotePrincipal.equals("anonymous")) {
    7265                try {
    73                     return dbIntegrityService.getPrincipalInternalIDFromRemoteID(remotePrincipal);
     66                    return dbDispatcher.getPrincipalInternalIDFromRemoteID(remotePrincipal);
    7467                } catch (NotInDataBaseException e) {
    7568                    loggerServer.info(e.toString());
     
    7871                        try {
    7972                            Principal newPrincipal = Helpers.createPrincipalElement(remotePrincipal, remotePrincipal);
    80                             return dbIntegrityService.addPrincipal(newPrincipal, remotePrincipal);
     73                            return dbDispatcher.addPrincipal(newPrincipal, remotePrincipal);
    8174                        } catch (PrincipalExists e2) {
    8275                            loggerServer.info(e2.toString());
     
    10194        }
    10295    }
    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    }
    105104}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/TargetResource.java

    r5086 r5088  
    9292        public Target apply(Map params) throws NotInDataBaseException {
    9393            Number targetID = (Number) params.get("internalID");
    94             return dbIntegrityService.getTarget(targetID);
     94            return dbDispatcher.getTarget(targetID);
    9595        }
    9696    }
     
    116116        public ReferenceList apply(Map params) throws NotInDataBaseException {
    117117            Number targetID = (Number) params.get("internalID");
    118             return dbIntegrityService.getTargetsForTheSameLinkAs(targetID);
     118            return dbDispatcher.getTargetsForTheSameLinkAs(targetID);
    119119        }
    120120    }
     
    152152            InputStream cachedSource = (InputStream) params.get("cachedBlob");
    153153            try {
    154             final Number[] respondDB = dbIntegrityService.addCachedForTarget(targetID, fragmentDescriptor, metadata, cachedSource);
    155             return dbIntegrityService.getCachedRepresentationInfo(respondDB[1]);
     154            final Number[] respondDB = dbDispatcher.addCachedForTarget(targetID, fragmentDescriptor, metadata, cachedSource);
     155            return dbDispatcher.getCachedRepresentationInfo(respondDB[1]);
    156156            } catch (IOException e) {
    157157                loggerServer.info(e.toString());
     
    172172        }
    173173        try {
    174             final Number targetID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(targetIdentifier), Resource.TARGET);
     174            final Number targetID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(targetIdentifier), Resource.TARGET);
    175175            try {
    176                 final Number cachedID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(cachedIdentifier), Resource.CACHED_REPRESENTATION);
    177                 final int updated = dbIntegrityService.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);
    178178                return updated + "rows is/are updated.";
    179179            } catch (NotInDataBaseException e1) {
     
    198198        }
    199199        try {
    200             final Number targetID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(targetExternalIdentifier), Resource.TARGET);
     200            final Number targetID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(targetExternalIdentifier), Resource.TARGET);
    201201            try {
    202                 final Number cachedID = dbIntegrityService.getResourceInternalIdentifier(UUID.fromString(cachedExternalIdentifier), Resource.CACHED_REPRESENTATION);
    203                 int[] result = dbIntegrityService.deleteCachedRepresentationOfTarget(targetID, cachedID);
     202                final Number cachedID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(cachedExternalIdentifier), Resource.CACHED_REPRESENTATION);
     203                int[] result = dbDispatcher.deleteCachedRepresentationOfTarget(targetID, cachedID);
    204204                return result[0] + " pair(s) target-cached deleted.";
    205205            } catch (NotInDataBaseException e) {
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/resources/spring-config/dbDispatcher.xml

    r4681 r5088  
    2424       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    2525">
    26     <bean class="eu.dasish.annotation.backend.dao.impl.DBIntegrityServiceImlp">
     26    <bean class="eu.dasish.annotation.backend.dao.impl.DBDispatcherImlp">
    2727    </bean>
    2828</beans>
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/MockObjectsFactoryRest.java

    r4603 r5088  
    1818package eu.dasish.annotation.backend;
    1919
    20 import eu.dasish.annotation.backend.dao.DBIntegrityService;
     20import eu.dasish.annotation.backend.dao.DBDispatcher;
    2121import javax.servlet.http.HttpServletRequest;
    2222import javax.servlet.http.HttpServletResponse;
     
    3939
    4040   
    41     public DBIntegrityService newDBIntegrityService() {
    42         return context.mock(DBIntegrityService.class);
     41    public DBDispatcher newDBDispatcher() {
     42        return context.mock(DBDispatcher.class);
    4343    }
    4444   
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherTest.java

    r5086 r5088  
    7676    "/spring-test-config/mockPrincipalDao.xml", "/spring-test-config/mockTargetDao.xml", "/spring-test-config/mockCachedRepresentationDao.xml",
    7777    "/spring-test-config/mockNotebookDao.xml",
    78     "/spring-config/dbIntegrityService.xml"})
    79 public class DBIntegrityServiceTest {
     78    "/spring-config/dbDispatcher.xml"})
     79public class DBDispatcherTest {
    8080
    8181    @Autowired
    82     private DBIntegrityServiceImlp dbIntegrityService;
     82    private DBDispatcherImlp dbDispatcher;
    8383    @Autowired
    8484    private Mockery mockeryDao;
     
    9595    TestInstances testInstances = new TestInstances(TestBackendConstants._TEST_SERVLET_URI);
    9696
    97     public DBIntegrityServiceTest() {
     97    public DBDispatcherTest() {
    9898    }
    9999
     
    114114            }
    115115        });
    116         assertEquals(1, dbIntegrityService.getResourceInternalIdentifier(externalID, Resource.ANNOTATION));
     116        assertEquals(1, dbDispatcher.getResourceInternalIdentifier(externalID, Resource.ANNOTATION));
    117117    }
    118118
     
    132132            }
    133133        });
    134         assertEquals("00000000-0000-0000-0000-000000000021", dbIntegrityService.getResourceExternalIdentifier(1, Resource.ANNOTATION).toString());
     134        assertEquals("00000000-0000-0000-0000-000000000021", dbDispatcher.getResourceExternalIdentifier(1, Resource.ANNOTATION).toString());
    135135    }
    136136
     
    151151            }
    152152        });
    153         assertEquals(1, dbIntegrityService.getResourceInternalIdentifier(externalID, Resource.PRINCIPAL));
     153        assertEquals(1, dbDispatcher.getResourceInternalIdentifier(externalID, Resource.PRINCIPAL));
    154154    }
    155155
     
    169169            }
    170170        });
    171         assertEquals("00000000-0000-0000-0000-000000000111", dbIntegrityService.getResourceExternalIdentifier(1, Resource.PRINCIPAL).toString());
     171        assertEquals("00000000-0000-0000-0000-000000000111", dbDispatcher.getResourceExternalIdentifier(1, Resource.PRINCIPAL).toString());
    172172    }
    173173
     
    265265        });
    266266
    267         Annotation result = dbIntegrityService.getAnnotation(1);
     267        Annotation result = dbDispatcher.getAnnotation(1);
    268268        assertEquals(TestBackendConstants._TEST_SERVLET_URI_annotations + "00000000-0000-0000-0000-000000000021", result.getURI());
    269269        assertEquals("text/plain", result.getBody().getTextBody().getMimeType());
     
    366366
    367367
    368         List result = dbIntegrityService.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);
    369369        assertEquals(1, result.size());
    370370        assertEquals(1, result.get(0));
     
    440440
    441441
    442         List result = dbIntegrityService.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);
    443443        assertEquals(1, result.size());
    444444        assertEquals(1, result.get(0));
     
    482482
    483483
    484         List result = dbIntegrityService.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);
    485485        assertEquals(0, result.size());
    486486    }
     
    518518
    519519
    520         List result = dbIntegrityService.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);
    521521        assertEquals(0, result.size());
    522522    }
     
    542542        });
    543543
    544         ReferenceList result = dbIntegrityService.getAnnotationTargets(1);
     544        ReferenceList result = dbDispatcher.getAnnotationTargets(1);
    545545        assertEquals(2, result.getRef().size());
    546546        assertEquals(TestBackendConstants._TEST_SERVLET_URI_targets + "00000000-0000-0000-0000-000000000031", result.getRef().get(0));
     
    663663
    664664
    665         AnnotationInfoList result = dbIntegrityService.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);
    666666        assertEquals(1, result.getAnnotationInfo().size());
    667667        AnnotationInfo resultAnnotInfo = result.getAnnotationInfo().get(0);
     
    705705        });
    706706
    707         List<String> result = dbIntegrityService.getTargetsWithNoCachedRepresentation(3);
     707        List<String> result = dbDispatcher.getTargetsWithNoCachedRepresentation(3);
    708708        assertEquals(1, result.size());
    709709        assertEquals("00000000-0000-0000-0000-000000000037", result.get(0)); // Target number 7 has no cached
     
    747747
    748748
    749         Number[] result = dbIntegrityService.addCachedForTarget(1, "#(1,2)", newCachedInfo, newCachedBlob);
     749        Number[] result = dbDispatcher.addCachedForTarget(1, "#(1,2)", newCachedInfo, newCachedBlob);
    750750        assertEquals(2, result.length);
    751751        assertEquals(1, result[0]);
     
    784784        });
    785785
    786         Map<String, String> result = dbIntegrityService.addTargetsForAnnotation(4, mockTargetListOne);
     786        Map<String, String> result = dbDispatcher.addTargetsForAnnotation(4, mockTargetListOne);
    787787        assertEquals(0, result.size());
    788788
     
    819819        });
    820820
    821         Map<String, String> resultTwo = dbIntegrityService.addTargetsForAnnotation(1, mockTargetListTwo);
     821        Map<String, String> resultTwo = dbDispatcher.addTargetsForAnnotation(1, mockTargetListTwo);
    822822        assertEquals(1, resultTwo.size());
    823823        assertEquals(mockNewTargetUUID.toString(), resultTwo.get(tempTargetID));
     
    857857        });
    858858
    859         Number result = dbIntegrityService.addPrincipalsAnnotation(3, testAnnotation);
     859        Number result = dbDispatcher.addPrincipalsAnnotation(3, testAnnotation);
    860860        assertEquals(5, result);
    861861
     
    888888
    889889
    890         assertEquals(11, dbIntegrityService.addPrincipal(freshPrincipal, "guisil@mpi.nl").intValue());
     890        assertEquals(11, dbDispatcher.addPrincipal(freshPrincipal, "guisil@mpi.nl").intValue());
    891891
    892892        /// principal already exists
     
    904904        PrincipalExists ex = null;
    905905        try {
    906             dbIntegrityService.addPrincipal(principal, "olhsha@mpi.nl");
     906            dbDispatcher.addPrincipal(principal, "olhsha@mpi.nl");
    907907        } catch (PrincipalExists e) {
    908908            ex = e;
     
    930930        });
    931931
    932         assertEquals(0, dbIntegrityService.deletePrincipal(1));
    933         assertEquals(0, dbIntegrityService.deletePrincipal(3));
    934         assertEquals(1, dbIntegrityService.deletePrincipal(10));
     932        assertEquals(0, dbDispatcher.deletePrincipal(1));
     933        assertEquals(0, dbDispatcher.deletePrincipal(3));
     934        assertEquals(1, dbDispatcher.deletePrincipal(10));
    935935    }
    936936
     
    952952        });
    953953
    954         int[] result = dbIntegrityService.deleteCachedRepresentationOfTarget(5, 7);
     954        int[] result = dbDispatcher.deleteCachedRepresentationOfTarget(5, 7);
    955955        assertEquals(2, result.length);
    956956        assertEquals(1, result[0]);
     
    986986        });
    987987
    988         int[] result = dbIntegrityService.deleteAllCachedRepresentationsOfTarget(1);
     988        int[] result = dbDispatcher.deleteAllCachedRepresentationsOfTarget(1);
    989989        assertEquals(2, result[0]); // # affected rows in Targets_cacheds
    990990        assertEquals(2, result[1]); // # affected rows in cacheds
     
    10411041            }
    10421042        });
    1043         int[] result = dbIntegrityService.deleteAnnotation(2);// the Target will be deleted because it is not referred by any annotation
     1043        int[] result = dbDispatcher.deleteAnnotation(2);// the Target will be deleted because it is not referred by any annotation
    10441044        assertEquals(5, result.length);
    10451045        assertEquals(1, result[0]); // annotation 3 is deleted
     
    10711071        });
    10721072
    1073         assertEquals(1, dbIntegrityService.getResourceInternalIdentifier(mockUUID, Resource.NOTEBOOK));
     1073        assertEquals(1, dbDispatcher.getResourceInternalIdentifier(mockUUID, Resource.NOTEBOOK));
    10741074
    10751075    }
     
    11271127        });
    11281128
    1129         NotebookInfoList result = dbIntegrityService.getNotebooks(3, Access.READ);
     1129        NotebookInfoList result = dbDispatcher.getNotebooks(3, Access.READ);
    11301130        assertEquals("00000000-0000-0000-0000-000000000011", result.getNotebookInfo().get(0).getRef());
    11311131        assertEquals("00000000-0000-0000-0000-000000000111", result.getNotebookInfo().get(0).getOwnerRef());
     
    12061206        });
    12071207
    1208         ReferenceList result = dbIntegrityService.getNotebooksOwnedBy(3);
     1208        ReferenceList result = dbDispatcher.getNotebooksOwnedBy(3);
    12091209        assertEquals(2, result.getRef().size());
    12101210        assertEquals(TestBackendConstants._TEST_SERVLET_URI_notebooks + "00000000-0000-0000-0000-000000000013", result.getRef().get(0));
     
    12391239        });
    12401240
    1241         assertTrue(dbIntegrityService.hasAccess(4, 2, write));
    1242         assertFalse(dbIntegrityService.hasAccess(5, 2, write));
     1241        assertTrue(dbDispatcher.hasAccess(4, 2, write));
     1242        assertFalse(dbDispatcher.hasAccess(5, 2, write));
    12431243    }
    12441244
     
    12751275        });
    12761276
    1277         ReferenceList result = dbIntegrityService.getPrincipals(1, "write");
     1277        ReferenceList result = dbDispatcher.getPrincipals(1, "write");
    12781278        assertEquals("serviceURI/principals/00000000-0000-0000-0000-000000000112", result.getRef().get(0).toString());
    12791279        assertEquals("serviceURI/principals/00000000-0000-0000-0000-000000000114", result.getRef().get(1).toString());
     
    13641364        });
    13651365
    1366         Notebook result = dbIntegrityService.getNotebook(2);
     1366        Notebook result = dbDispatcher.getNotebook(2);
    13671367        assertEquals("serviceURI/notebooks/00000000-0000-0000-0000-000000000012", result.getURI());
    13681368        assertEquals("serviceURI/principals/00000000-0000-0000-0000-000000000112", result.getOwnerRef());
     
    14041404        });
    14051405
    1406         ReferenceList result = dbIntegrityService.getAnnotationsForNotebook(1, -1, 3, "last_modified", true);
     1406        ReferenceList result = dbDispatcher.getAnnotationsForNotebook(1, -1, 3, "last_modified", true);
    14071407        assertEquals(2, result.getRef().size());
    14081408        assertEquals("serviceURI/annotations/00000000-0000-0000-0000-000000000021", result.getRef().get(0).toString());
     
    14351435        });
    14361436
    1437         boolean result = dbIntegrityService.updateNotebookMetadata(1, mockNotebookInfo);
     1437        boolean result = dbDispatcher.updateNotebookMetadata(1, mockNotebookInfo);
    14381438        assertTrue(result);
    14391439    }
     
    14541454        });
    14551455
    1456         assertTrue(dbIntegrityService.addAnnotationToNotebook(1, 3));
     1456        assertTrue(dbDispatcher.addAnnotationToNotebook(1, 3));
    14571457    }
    14581458
     
    15131513        });
    15141514
    1515         Number result = dbIntegrityService.createNotebook(notebook, 1);
     1515        Number result = dbDispatcher.createNotebook(notebook, 1);
    15161516        assertEquals(5, result);
    15171517
     
    15521552        });
    15531553
    1554         assertTrue(dbIntegrityService.createAnnotationInNotebook(1, testAnnotation, 3));
     1554        assertTrue(dbDispatcher.createAnnotationInNotebook(1, testAnnotation, 3));
    15551555
    15561556    }
     
    15841584        });
    15851585
    1586         assertTrue(dbIntegrityService.deleteNotebook(1));
     1586        assertTrue(dbDispatcher.deleteNotebook(1));
    15871587    }
    15881588
     
    16031603        });
    16041604
    1605         assertEquals(Access.WRITE, dbIntegrityService.getAccess(1, 3));
     1605        assertEquals(Access.WRITE, dbDispatcher.getAccess(1, 3));
    16061606
    16071607        //////
     
    16171617            }
    16181618        });
    1619         assertEquals(Access.READ, dbIntegrityService.getAccess(2, 3));
     1619        assertEquals(Access.READ, dbDispatcher.getAccess(2, 3));
    16201620
    16211621        //////
     
    16311631            }
    16321632        });
    1633         assertEquals(Access.NONE, dbIntegrityService.getAccess(3, 3));
     1633        assertEquals(Access.NONE, dbDispatcher.getAccess(3, 3));
    16341634
    16351635        //////
     
    16471647            }
    16481648        });
    1649         assertEquals(Access.READ, dbIntegrityService.getPublicAttribute(2));
     1649        assertEquals(Access.READ, dbDispatcher.getPublicAttribute(2));
    16501650    }
    16511651
     
    17551755            }
    17561756        });
    1757         assertEquals(1, dbIntegrityService.updateAnnotation(annotation));
     1757        assertEquals(1, dbDispatcher.updateAnnotation(annotation));
    17581758    }
    17591759
     
    17811781            }
    17821782        });
    1783         assertEquals(1, dbIntegrityService.updateAnnotationHeadline(1, "new Headline"));
     1783        assertEquals(1, dbDispatcher.updateAnnotationHeadline(1, "new Headline"));
    17841784    }
    17851785   
     
    18221822        });
    18231823
    1824         assertEquals(1, dbIntegrityService.updateAnnotationPrincipalAccess(1, 2, Access.READ));
    1825         assertEquals(1, dbIntegrityService.updateAnnotationPrincipalAccess(1, 4, Access.WRITE));
     1824        assertEquals(1, dbDispatcher.updateAnnotationPrincipalAccess(1, 2, Access.READ));
     1825        assertEquals(1, dbDispatcher.updateAnnotationPrincipalAccess(1, 4, Access.WRITE));
    18261826    }
    18271827
     
    18581858        });
    18591859
    1860         assertEquals(1, dbIntegrityService.updatePermissions(1, permissions));
     1860        assertEquals(1, dbDispatcher.updatePermissions(1, permissions));
    18611861
    18621862    }
     
    18941894        });
    18951895
    1896         assertEquals(1, dbIntegrityService.updatePermissions(1, permissions));
     1896        assertEquals(1, dbDispatcher.updatePermissions(1, permissions));
    18971897
    18981898    }
     
    19131913        });
    19141914
    1915         assertEquals(1, dbIntegrityService.updatePublicAttribute(1, Access.NONE));
     1915        assertEquals(1, dbDispatcher.updatePublicAttribute(1, Access.NONE));
    19161916
    19171917    }
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java

    r5086 r5088  
    2121import eu.dasish.annotation.backend.Resource;
    2222import eu.dasish.annotation.backend.ResourceAction;
    23 import eu.dasish.annotation.backend.dao.DBIntegrityService;
     23import eu.dasish.annotation.backend.dao.DBDispatcher;
    2424import eu.dasish.annotation.backend.TestBackendConstants;
    2525import eu.dasish.annotation.backend.TestInstances;
     
    5353 */
    5454@RunWith(value = SpringJUnit4ClassRunner.class)
    55 @ContextConfiguration(locations = {"/spring-test-config/mockeryRest.xml", "/spring-test-config/mockDBIntegrityService.xml",
     55@ContextConfiguration(locations = {"/spring-test-config/mockeryRest.xml", "/spring-test-config/mockDBDispatcher.xml",
    5656    "/spring-test-config/mockUriInfo.xml",
    5757    "/spring-config/jaxbMarshallerFactory.xml"})
     
    6161    private Mockery mockeryRest;
    6262    @Autowired
    63     private DBIntegrityService mockDbIntegrityService;
     63    private DBDispatcher mockDbDispatcher;
    6464    @Autowired
    6565    UriInfo mockUriInfo;
     
    107107                will(returnValue(baseUri));
    108108
    109                 oneOf(mockDbIntegrityService).setServiceURI(baseUri.toString());
    110 
    111                 oneOf(mockDbIntegrityService).getPrincipalInternalIDFromRemoteID("olhsha@mpi.nl");
     109                oneOf(mockDbDispatcher).setServiceURI(baseUri.toString());
     110
     111                oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("olhsha@mpi.nl");
    112112                will(returnValue(3));
    113113
    114                 oneOf(mockDbIntegrityService).getResourceInternalIdentifier(with(aNonNull(UUID.class)), with(aNonNull((Resource.class))));
    115                 will(returnValue(1));
    116 
    117 
    118                 oneOf(mockDbIntegrityService).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);
    119119                will(returnValue(true));
    120120
    121                 oneOf(mockDbIntegrityService).getAnnotation(1);
     121                oneOf(mockDbDispatcher).getAnnotation(1);
    122122                will(returnValue(expectedAnnotation));
    123123            }
     
    154154                will(returnValue(baseUri));
    155155
    156                 oneOf(mockDbIntegrityService).setServiceURI(baseUri.toString());
    157 
    158                 oneOf(mockDbIntegrityService).getPrincipalInternalIDFromRemoteID("olhsha@mpi.nl");
     156                oneOf(mockDbDispatcher).setServiceURI(baseUri.toString());
     157
     158                oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("olhsha@mpi.nl");
    159159                will(returnValue(3));
    160160
    161                 oneOf(mockDbIntegrityService).getResourceInternalIdentifier(with(aNonNull(UUID.class)), with(aNonNull((Resource.class))));
     161                oneOf(mockDbDispatcher).getResourceInternalIdentifier(with(aNonNull(UUID.class)), with(aNonNull((Resource.class))));
    162162                will(returnValue(4));
    163163
    164164
    165                 oneOf(mockDbIntegrityService).getAnnotationOwnerID(4);
     165                oneOf(mockDbDispatcher).getAnnotationOwnerID(4);
    166166                will(returnValue(3));
    167167               
    168                 oneOf(mockDbIntegrityService).canDo(ResourceAction.DELETE, 3, 4, Resource.ANNOTATION);
     168                oneOf(mockDbDispatcher).canDo(ResourceAction.DELETE, 3, 4, Resource.ANNOTATION);
    169169                will(returnValue(true));
    170170
    171                 oneOf(mockDbIntegrityService).deleteAnnotation(4);
     171                oneOf(mockDbDispatcher).deleteAnnotation(4);
    172172                will(returnValue(mockDelete));
    173173            }
     
    216216                will(returnValue(baseUri));
    217217
    218                 oneOf(mockDbIntegrityService).setServiceURI(baseUri.toString());
    219 
    220                 oneOf(mockDbIntegrityService).getPrincipalInternalIDFromRemoteID("olhsha@mpi.nl");
     218                oneOf(mockDbDispatcher).setServiceURI(baseUri.toString());
     219
     220                oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("olhsha@mpi.nl");
    221221                will(returnValue(3));
    222222
    223                 oneOf(mockDbIntegrityService).addPrincipalsAnnotation(3, annotationToAdd);
     223                oneOf(mockDbDispatcher).addPrincipalsAnnotation(3, annotationToAdd);
    224224                will(returnValue(newAnnotationID));
    225225
    226                 oneOf(mockDbIntegrityService).getAnnotation(newAnnotationID);
     226                oneOf(mockDbDispatcher).getAnnotation(newAnnotationID);
    227227                will(returnValue(addedAnnotation));
    228228               
    229                 oneOf(mockDbIntegrityService).makeAnnotationResponseEnvelope(newAnnotationID);
     229                oneOf(mockDbDispatcher).makeAnnotationResponseEnvelope(newAnnotationID);
    230230                will(returnValue(mockEnvelope));
    231231
     
    286286                will(returnValue(baseUri));
    287287
    288                 oneOf(mockDbIntegrityService).setServiceURI(baseUri.toString());
    289 
    290                 oneOf(mockDbIntegrityService).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl");
    291                 will(returnValue(1));
    292                
    293                 oneOf(mockUriInfo).getBaseUri();
    294                 will(returnValue(baseUri));
    295 
    296                 oneOf(mockDbIntegrityService).getResourceInternalIdentifier(externalId, Resource.ANNOTATION);
    297                 will(returnValue(1));
    298                
    299                 oneOf(mockDbIntegrityService).getAnnotationOwnerID(1);
    300                 will(returnValue(1));
    301                
    302                 oneOf(mockDbIntegrityService).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);
    303303                will(returnValue(true));
    304304               
    305                 oneOf(mockDbIntegrityService).updateAnnotation(annotation);
     305                oneOf(mockDbDispatcher).updateAnnotation(annotation);
    306306                will(returnValue(1));
    307307               
    308                 oneOf(mockDbIntegrityService).makeAnnotationResponseEnvelope(1);
     308                oneOf(mockDbDispatcher).makeAnnotationResponseEnvelope(1);
    309309                will(returnValue(mockEnvelope));
    310310
     
    361361                will(returnValue(baseUri));
    362362
    363                 oneOf(mockDbIntegrityService).setServiceURI(baseUri.toString());
    364 
    365                 oneOf(mockDbIntegrityService).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl");
     363                oneOf(mockDbDispatcher).setServiceURI(baseUri.toString());
     364
     365                oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl");
    366366                will(returnValue(1));
    367367               
    368368               
    369                 oneOf(mockDbIntegrityService).getResourceInternalIdentifier(externalId, Resource.ANNOTATION);
    370                 will(returnValue(1));
    371                
    372                 oneOf(mockDbIntegrityService).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);
    373373                will(returnValue(true));               
    374374               
    375375               
    376                 oneOf(mockDbIntegrityService).updateAnnotationBody(1, ab);
     376                oneOf(mockDbDispatcher).updateAnnotationBody(1, ab);
    377377                will(returnValue(1));
    378378               
    379                 oneOf(mockDbIntegrityService).makeAnnotationResponseEnvelope(1);
     379                oneOf(mockDbDispatcher).makeAnnotationResponseEnvelope(1);
    380380                will(returnValue(mockEnvelope));
    381381
     
    418418                will(returnValue(baseUri));
    419419
    420                 oneOf(mockDbIntegrityService).setServiceURI(baseUri.toString());
    421 
    422                 oneOf(mockDbIntegrityService).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl");
     420                oneOf(mockDbDispatcher).setServiceURI(baseUri.toString());
     421
     422                oneOf(mockDbDispatcher).getPrincipalInternalIDFromRemoteID("twagoo@mpi.nl");
    423423                will(returnValue(1));
    424424               
    425425               
    426                 oneOf(mockDbIntegrityService).getResourceInternalIdentifier(externalId, Resource.ANNOTATION);
    427                 will(returnValue(1));
    428                
    429                 oneOf(mockDbIntegrityService).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);
    430430                will(returnValue(true));               
    431431               
    432432               
    433                 oneOf(mockDbIntegrityService).updateAnnotationHeadline(1, newHeadline);
     433                oneOf(mockDbDispatcher).updateAnnotationHeadline(1, newHeadline);
    434434                will(returnValue(1));
    435435               
    436                 oneOf(mockDbIntegrityService).makeAnnotationResponseEnvelope(1);
     436                oneOf(mockDbDispatcher).makeAnnotationResponseEnvelope(1);
    437437                will(returnValue(mockEnvelope));
    438438
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationsTest.java

    r5086 r5088  
    8787        // sorry for the duplication, but JerseyTest is not aware of
    8888        // @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/dbIntegrityService.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";
    9090    }
    9191   
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/NotebookResourceTest.java

    r4800 r5088  
    1818package eu.dasish.annotation.backend.rest;
    1919
    20 import eu.dasish.annotation.backend.dao.DBIntegrityService;
     20import eu.dasish.annotation.backend.dao.DBDispatcher;
    2121import org.jmock.Mockery;
    2222import org.junit.Test;
     
    3131 */
    3232@RunWith(value = SpringJUnit4ClassRunner.class)
    33 @ContextConfiguration(locations = {"/spring-test-config/mockeryRest.xml", "/spring-test-config/mockDBIntegrityService.xml", "/spring-config/jaxbMarshallerFactory.xml",
     33@ContextConfiguration(locations = {"/spring-test-config/mockeryRest.xml", "/spring-test-config/mockDBDispatcher.xml", "/spring-config/jaxbMarshallerFactory.xml",
    3434    "/spring-test-config/mockUriInfo.xml"})
    3535public class NotebookResourceTest {
     
    3838    private Mockery mockeryRest;
    3939    @Autowired
    40     private DBIntegrityService daoDispatcher;
     40    private DBDispatcher daoDispatcher;
    4141    @Autowired
    4242    private NotebookResource notebookResource;
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/resources/spring-test-config/mockDBDispatcher.xml

    r4681 r5088  
    2929           
    3030    <!-- Mocked dispatcher -->
    31     <bean id="dbIntegrityService" factory-bean="mockObjectsFactoryRest" factory-method="newDBIntegrityService" />
     31    <bean id="dbIntegrityService" factory-bean="mockObjectsFactoryRest" factory-method="newDBDispatcher" />
    3232   
    3333</beans>
Note: See TracChangeset for help on using the changeset viewer.