Changeset 5836 for DASISH


Ignore:
Timestamp:
11/18/14 17:52:24 (10 years ago)
Author:
olhsha@mpi.nl
Message:

refactoring. Adding ALL as an access mode.

Location:
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend
Files:
1 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/CHANGES.txt

    r5774 r5836  
    6464sych with the basic authenticated version.
    6565
     66November 7, 2014. This is a package for a basic authenticated annotator, to test a new feature.
     67Namely, a user with "write" access can update annotation as a whole, but if he also sends permission
     68updates they will be ignored.
    6669
     70November 10, 2014. This is a package for a shibboleth authenticated annotator. Now A user with
     71"write"  access can update annotation as a whole, but if he also sends permission updates they will
     72be  ignored.
    6773
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/UPDATE.txt

    r5774 r5836  
    11
    2 Placing tarball: take the tar-ball of the new  version 1.5.4-shibboleth, and follow the
     2Placing tarball: take the tar-ball of the new  version 1.6-basic, and follow the
    33standard MPI deployment procedure. 
    44
    5 This is synchronisation of the shibbolized-authenticated version of the backend
    6 to the basic-authnticated, so both versions are complyiant with the same schema.
     5A new feature: a user with "write" access can update
     6annotation as a whole, but if he also sends permission updates they will be
     7ignored.
    78
    89
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml

    r5774 r5836  
    55    <groupId>eu.dasish.annotation</groupId>
    66    <artifactId>annotator-backend</artifactId>
    7     <version>1.5.4-shibboleth</version>   
     7    <version>1.6-shibboleth</version>   
    88    <packaging>war</packaging>
    99    <name>annotator-backend Jersey Webapp</name>
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/AnnotationDao.java

    r5661 r5836  
    5858     
    5959 
    60     public List<Number> getAnnotationIDsForPermission(Number principalID, Access acess);
    61    
    62     public List<Number> getAnnotationIDsForPublicAccess(Access access);
     60    public List<Number> getAnnotationIDsPermissionAtLeast(Number principalID, Access acess);
     61   
     62   
     63    public List<Number> getAnnotationIDsPublicAtLeast(Access access);
    6364   
    6465   
     
    8586    public List<String> getAnnotationREFs(List<Number> annotationIDs);
    8687   
    87    
    88    
    89    
    90    
    91        /**
    92      *
    93      * @param annotationID
    94      * @return the list of the internal IDs of all the target Targets of "annotationID".
    95      */
    96     //public List<Number> retrieveTargetIDs(Number annotationID);   
    97    
     88 
    9889   
    9990    public Number  getOwner(Number annotationID);
     
    10697     */
    10798    public Access  getAccess(Number annotationID, Number principalID);
     99   
     100    public boolean  hasExplicitAccess(Number annotationID, Number principalID);
    108101   
    109102   
     
    148141     * Sets the "access" for the "principalID" w.r.t. the annotation with "annotationID".
    149142     */
    150     public int addAnnotationPrincipalAccess(Number annotationID, Number principalID, Access access);
     143    public int addPermission(Number annotationID, Number principalID, Access access);
    151144   
    152145   
     
    187180     * Sets the "access" for the "principalID" w.r.t. the annotation with "annotationID".
    188181     */
    189     public int updateAnnotationPrincipalAccess(Number annotationID, Number principalID, Access access);
    190    
    191    
    192     public int updatePublicAttribute(Number annotationID, Access access);
     182    public int updatePermission(Number annotationID, Number principalID, Access access);
     183   
     184   
     185    public int updatePublicAccess(Number annotationID, Access access);
    193186   
    194187   
     
    222215    * @throws SQLException
    223216    */
    224     public int deleteAnnotationPermissions(Number annotationID);
    225    
    226     public int deleteAnnotationPrincipalAccess(Number annotationID, Number principalID);
     217    public int deletePermissions(Number annotationID);
     218   
     219    public int deletePermission(Number annotationID, Number principalID);
    227220   
    228221    public int deleteAnnotationFromAllNotebooks(Number annotationID);
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBDispatcher.java

    r5774 r5836  
    2323import eu.dasish.annotation.backend.PrincipalExists;
    2424import eu.dasish.annotation.backend.Resource;
    25 import eu.dasish.annotation.backend.ResourceAction;
    2625import eu.dasish.annotation.schema.Annotation;
    2726import eu.dasish.annotation.schema.AnnotationBody;
     
    3231import eu.dasish.annotation.schema.NotebookInfoList;
    3332import eu.dasish.annotation.schema.Access;
     33import eu.dasish.annotation.schema.Action;
    3434import eu.dasish.annotation.schema.PermissionList;
    3535import eu.dasish.annotation.schema.ReferenceList;
     
    186186     * access is not given
    187187     */
    188     Access getAccess(Number annotationID, Number principalID);
     188    Access getAccess(Number annotationID, Number principalID) ;
    189189   
    190190    Access getPublicAttribute(Number annotationID);
     
    194194    Principal getDataBaseAdmin() ;
    195195
    196     boolean canDo(ResourceAction action, Number principalID, Number resourceID, Resource resource);
     196    boolean canDo(Access action, Number principalID, Number resourceID, Resource resource);
    197197
    198198   
     
    247247     * "annotationID".
    248248     */
    249     int updateAnnotationPrincipalAccess(Number annotationID, Number principalID, Access access);
     249    int updatePermission(Number annotationID, Number principalID, Access access);
    250250
    251251    /**
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherImlp.java

    r5774 r5836  
    2424import eu.dasish.annotation.backend.PrincipalCannotBeDeleted;
    2525import eu.dasish.annotation.backend.PrincipalExists;
    26 import eu.dasish.annotation.backend.ResourceAction;
    2726import eu.dasish.annotation.backend.dao.AnnotationDao;
    2827import eu.dasish.annotation.backend.dao.CachedRepresentationDao;
     
    121120    }
    122121
    123  
    124122    @Override
    125123    public UUID getResourceExternalIdentifier(Number resourceID, Resource resource) {
     
    127125    }
    128126
    129    
    130127    @Override
    131128    public Annotation getAnnotation(Number annotationID) {
     
    174171
    175172////////////////////////////////////////////////////////////////////////
    176     @Override 
     173    @Override
    177174    public List<Number> getFilteredAnnotationIDs(UUID ownerId, String link, MatchMode matchMode, String text, Number inloggedPrincipalID, String accessMode, String namespace, String after, String before) throws NotInDataBaseException {
    178175
     
    209206                if (!accessMode.equals("owner")) {
    210207                    Access access = Access.fromValue(accessMode);
    211                     List<Number> annotationIDsAccess = annotationDao.getAnnotationIDsForPermission(inloggedPrincipalID, access);
    212                     List<Number> annotationIDsPublic = annotationDao.getAnnotationIDsForPublicAccess(access);
    213                     List<Number> annotationIDsOwned = annotationDao.getFilteredAnnotationIDs(inloggedPrincipalID, text, namespace, after, before);
    214                     int check1 = this.addAllNoRepetitions(annotationIDsAccess, annotationIDsPublic);
    215                     int check2 = this.addAllNoRepetitions(annotationIDsAccess, annotationIDsOwned);
    216                     annotationIDs.retainAll(annotationIDsAccess);// intersection
     208                    if (access.equals(Access.NONE)) {
     209                        List<Number> annotationIDsfiletered = new ArrayList<Number>();
     210                        Access accessCurrent;
     211                        for (Number annotationID : annotationIDs) {
     212                            accessCurrent = annotationDao.getAccess(inloggedPrincipalID, annotationID);
     213                            if (accessCurrent.equals(Access.NONE)) {
     214                                annotationIDsfiletered.add(annotationID);
     215                            }
     216                        }
     217                        annotationIDs = annotationIDsfiletered; // yeaahhh I'm relying on garbage collector here                         
     218                    } else {
     219                        List<Number> annotationIDsAccess = annotationDao.getAnnotationIDsPermissionAtLeast(inloggedPrincipalID, access);
     220                        List<Number> annotationIDsPublic = annotationDao.getAnnotationIDsPublicAtLeast(access);
     221                        List<Number> annotationIDsOwned = annotationDao.getFilteredAnnotationIDs(inloggedPrincipalID, text, namespace, after, before);
     222                        int check1 = this.addAllNoRepetitions(annotationIDsAccess, annotationIDsPublic);
     223                        int check2 = this.addAllNoRepetitions(annotationIDsAccess, annotationIDsOwned);
     224                        annotationIDs.retainAll(annotationIDsAccess);// intersection
     225                    }
    217226                }
    218227            }
     
    263272        return annotationIDs;
    264273    }
    265    
    266     private boolean matchCriterium(String currentString, String pattern, MatchMode matchMode){       
     274
     275    private boolean matchCriterium(String currentString, String pattern, MatchMode matchMode) {
    267276        switch (matchMode) {
    268             case EXACT: return currentString.equals(pattern);
    269             case STARTS_WITH: return currentString.startsWith(pattern);
    270             case ENDS_WITH: return currentString.endsWith(pattern);
    271             case CONTAINS: return currentString.contains(pattern);
    272             default: return false;
     277            case EXACT:
     278                return currentString.equals(pattern);
     279            case STARTS_WITH:
     280                return currentString.startsWith(pattern);
     281            case ENDS_WITH:
     282                return currentString.endsWith(pattern);
     283            case CONTAINS:
     284                return currentString.contains(pattern);
     285            default:
     286                return false;
    273287        }
    274288    }
     
    413427        for (Number siblingID : targetIDs) {
    414428            if (!siblingID.equals(targetID)) {
    415             referenceList.getHref().add(targetDao.getHrefFromInternalID(siblingID));
     429                referenceList.getHref().add(targetDao.getHrefFromInternalID(siblingID));
    416430            }
    417431        }
     
    438452        Access publicAttribute = annotationDao.getPublicAttribute(annotationID);
    439453        Access access = annotationDao.getAccess(annotationID, principalID);
    440         if (access != null) {
    441             if (publicAttribute.equals(Access.NONE)) {
    442                 return access;
     454        if (publicAttribute.equals(Access.NONE)) {
     455            return access;
     456        } else {
     457            if (publicAttribute.equals(Access.READ)) {
     458                if (access.equals(Access.NONE)) {
     459                    return Access.READ;
     460                } else {
     461                    return access;
     462                }
    443463            } else {
    444                 if (publicAttribute.equals(Access.READ)) {
    445                     if (access.equals(Access.NONE)) {
    446                         return Access.READ;
     464                if (publicAttribute.equals(Access.WRITE)) {
     465                    if (access.equals(Access.NONE) || access.equals(Access.READ)) {
     466                        return Access.WRITE;
    447467                    } else {
    448468                        return access;
    449469                    }
    450470                } else {
    451                     return Access.WRITE;
     471                    if (publicAttribute.equals(Access.ALL)) {
     472                        return Access.ALL;
     473                    } else {
     474                        logger.error("Database problem: the value of public attribute is not a proper Access value: " + publicAttribute.value());
     475                        return access;
     476                    }
    452477                }
    453478            }
    454         } else {
    455             return publicAttribute;
    456479        }
    457480    }
     
    466489        return principalDao.getPrincipalInternalIDFromRemoteID(remoteID);
    467490    }
    468    
     491
    469492    @Override
    470493    public UUID getPrincipalExternalIDFromRemoteID(String remoteID) throws NotInDataBaseException {
     
    484507    // !!!so far implemented only for annotations!!!
    485508    @Override
    486     public boolean canDo(ResourceAction action, Number principalID, Number resourceID, Resource resource) {
     509    public boolean canDo(Access action, Number principalID, Number resourceID, Resource resource) {
    487510
    488511        switch (resource) {
     
    509532    }
    510533
    511     private boolean greaterOrEqual(Access access, ResourceAction action) {
    512         if (access.equals(Access.WRITE) && (action.equals(ResourceAction.READ) || action.equals(ResourceAction.WRITE))) {
     534    private boolean greaterOrEqual(Access access, Access action) {
     535
     536        if (access.equals(Access.ALL)) {
    513537            return true;
    514538        }
    515         if (access.equals(Access.READ) && action.equals(ResourceAction.READ)) {
     539
     540        if (access.equals(Access.WRITE) && (action.equals(Access.READ) || action.equals(Access.WRITE))) {
     541            return true;
     542        }
     543        if (access.equals(Access.READ) && action.equals(Access.READ)) {
    516544            return true;
    517545        }
     
    524552    public NotebookInfoList getNotebooks(Number principalID, Access access) {
    525553        NotebookInfoList result = new NotebookInfoList();
    526         if (access.equals(Access.READ) || access.equals(Access.WRITE)) {
     554        if (access.equals(Access.READ) || access.equals(Access.WRITE) || access.equals(Access.ALL)) {
    527555            List<Number> notebookIDs = notebookDao.getNotebookIDs(principalID, access);
    528556            for (Number notebookID : notebookIDs) {
     
    581609        accesss.add(Access.READ);
    582610        accesss.add(Access.WRITE);
     611        accesss.add(Access.ALL);
    583612        for (Access access : accesss) {
    584613            List<Number> principals = principalDao.getPrincipalIDsWithAccessForNotebook(notebookID, access);
     
    642671            default:
    643672                return false;
    644         } 
    645     }
    646    
     673        }
     674    }
     675
    647676    @Override
    648677    public boolean updateAccount(UUID principalExternalID, String account) throws NotInDataBaseException {
     
    651680
    652681    @Override
    653     public int updateAnnotationPrincipalAccess(Number annotationID, Number principalID, Access access) {
     682    public int updatePermission(Number annotationID, Number principalID, Access access) {
    654683        int result;
    655684        if (access != null) {
    656             Access currentAccess = annotationDao.getAccess(annotationID, principalID);
    657             if (currentAccess != null) {
    658                 result = annotationDao.updateAnnotationPrincipalAccess(annotationID, principalID, access);
     685            Boolean checkAccess = annotationDao.hasExplicitAccess(annotationID, principalID);
     686            if (checkAccess) {
     687                result = annotationDao.updatePermission(annotationID, principalID, access);
    659688            } else {
    660                 result = annotationDao.addAnnotationPrincipalAccess(annotationID, principalID, access);
     689                result = annotationDao.addPermission(annotationID, principalID, access);
    661690            }
    662691        } else {
    663             result = annotationDao.deleteAnnotationPrincipalAccess(annotationID, principalID);
     692            result = annotationDao.deletePermission(annotationID, principalID);
    664693        }
    665694        return result;
     
    668697    @Override
    669698    public int updatePublicAttribute(Number annotationID, Access publicAttribute) {
    670         return annotationDao.updatePublicAttribute(annotationID, publicAttribute);
     699        return annotationDao.updatePublicAccess(annotationID, publicAttribute);
    671700    }
    672701
    673702    @Override
    674703    public int updatePermissions(Number annotationID, PermissionList permissionList) throws NotInDataBaseException {
    675         annotationDao.updatePublicAttribute(annotationID, permissionList.getPublic());
     704        annotationDao.updatePublicAccess(annotationID, permissionList.getPublic());
    676705        List<Permission> permissions = permissionList.getPermission();
    677706        int result = 0;
     
    679708            Number principalID = principalDao.getInternalIDFromHref(permission.getPrincipalHref());
    680709            Access access = permission.getLevel();
    681             Access currentAccess = annotationDao.getAccess(annotationID, principalID);
    682             if (currentAccess != null) {
    683                 if (!access.equals(currentAccess)) {
    684                     result = result + annotationDao.updateAnnotationPrincipalAccess(annotationID, principalID, access);
    685                 } else {
    686                     result = 0;
    687                 }
     710            Boolean checkAccess = annotationDao.hasExplicitAccess(annotationID, principalID);
     711            if (checkAccess) {
     712                result = result + annotationDao.updatePermission(annotationID, principalID, access);
    688713            } else {
    689                 result = result + annotationDao.addAnnotationPrincipalAccess(annotationID, principalID, access);
    690             }
    691 
     714                result = result + annotationDao.addPermission(annotationID, principalID, access);
     715            }
    692716        }
    693717        return result;
     
    703727        int deletedTargets = annotationDao.deleteAllAnnotationTarget(annotationID);
    704728        int addedTargets = this.addTargets(annotation, annotationID);
    705        
     729
    706730        Number remoteUserID = principalDao.getPrincipalInternalIDFromRemoteID(remoteUser);
    707        
    708         if (ownerID.equals(remoteUserID)) {
    709             int deletedPrinsipalsAccesss = annotationDao.deleteAnnotationPermissions(annotationID);
     731
     732        if (ownerID.equals(remoteUserID) || (annotationDao.getAccess(annotationID, remoteUserID).equals(Access.ALL))) {
     733            int deletedPrinsipalsAccesss = annotationDao.deletePermissions(annotationID);
    710734            int addedPrincipalsAccesss = this.addPermissions(annotation.getPermissions().getPermission(), annotationID);
    711             int updatedPublicAttribute = annotationDao.updatePublicAttribute(annotationID, annotation.getPermissions().getPublic());
     735            //int updatedPublicAttribute = annotationDao.updatePublicAccess(annotationID, annotation.getPermissions().getPublic());
    712736        };
    713737        return updatedAnnotations;
     
    722746
    723747    @Override
    724     public int updateAnnotationHeadline(Number internalID, String newHeader){
     748    public int updateAnnotationHeadline(Number internalID, String newHeader) {
    725749        return annotationDao.updateAnnotationHeadline(internalID, newHeader);
    726750    }
     
    775799    }
    776800
    777    
    778801    @Override
    779802    public Map<String, String> addTargetsForAnnotation(Number annotationID, List<TargetInfo> targets) throws NotInDataBaseException {
     
    799822        int affectedAnnotRows = this.addTargets(annotation, annotationID);
    800823        int addedPrincipalsAccesss = this.addPermissions(annotation.getPermissions().getPermission(), annotationID);
    801         int updatedPublic = annotationDao.updatePublicAttribute(annotationID, annotation.getPermissions().getPublic());
     824        //int updatedPublic = annotationDao.updatePublicAccess(annotationID, annotation.getPermissions().getPublic());
    802825        return annotationID;
    803826    }
     
    886909    public int[] deleteAnnotation(Number annotationID) {
    887910        int[] result = new int[5];
    888         result[1] = annotationDao.deleteAnnotationPermissions(annotationID);
     911        result[1] = annotationDao.deletePermissions(annotationID);
    889912        List<Number> targetIDs = targetDao.getTargetIDs(annotationID);
    890913        result[2] = annotationDao.deleteAllAnnotationTarget(annotationID);
     
    925948    @Override
    926949    public int deleteAnnotationPrincipalAccess(Number annotationID, Number principalID) {
    927         return annotationDao.deleteAnnotationPrincipalAccess(annotationID, principalID);
     950        return annotationDao.deletePermission(annotationID, principalID);
    928951    }
    929952////////////// HELPERS ////////////////////
     
    9811004        }
    9821005    }
    983    
    984     @Override
    985     public UUID getPrincipalExternalIdFromName(String fullName) throws NotInDataBaseException{
    986        return principalDao.getExternalIdFromName(fullName);
    987     }
    988    
    989     @Override
    990     public List<UUID> getAnnotationExternalIdsFromHeadline(String headline){
     1006
     1007    @Override
     1008    public UUID getPrincipalExternalIdFromName(String fullName) throws NotInDataBaseException {
     1009        return principalDao.getExternalIdFromName(fullName);
     1010    }
     1011
     1012    @Override
     1013    public List<UUID> getAnnotationExternalIdsFromHeadline(String headline) {
    9911014        return annotationDao.getExternalIdFromHeadline(headline);
    9921015    }
    993    
    994     @Override
    995     public List<Number> getAnnotationInternalIDsFromHeadline(String headline){
     1016
     1017    @Override
     1018    public List<Number> getAnnotationInternalIDsFromHeadline(String headline) {
    9961019        return annotationDao.getInternalIDsFromHeadline(headline);
    9971020    }
     
    10321055            int addedPermissions = 0;
    10331056            for (Permission permission : permissions) {
    1034                 addedPermissions = addedPermissions + annotationDao.addAnnotationPrincipalAccess(annotationID, principalDao.getInternalIDFromHref(permission.getPrincipalHref()), permission.getLevel());
     1057                addedPermissions = addedPermissions + annotationDao.addPermission(annotationID, principalDao.getInternalIDFromHref(permission.getPrincipalHref()), permission.getLevel());
    10351058            }
    10361059            return addedPermissions;
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDao.java

    r5661 r5836  
    5757        internalIdName = annotation_id;
    5858        resourceTableName = annotationTableName;
    59 
    6059    }
    6160
     
    7170        StringBuilder sql = new StringBuilder("SELECT ");
    7271        sql.append(principal_id).append(",").append(access).append(" FROM ").append(permissionsTableName).append(" WHERE ").append(annotation_id).append("  = ?");
    73         logger.debug("Parameter " + annotation_id + " := " + annotationID.intValue());
    7472        return this.loggedQuery(sql.toString(), principalsAccesssRowMapper, annotationID);
    7573    }
    76 
    77     @Override
    78     public Access getAccess(Number annotationID, Number principalID) {
    79 
     74   
     75    private List<Access> getAccessHelper(Number annotationID, Number principalID){
    8076        Map<String, Number> params = new HashMap<String, Number>();
    8177        params.put("annotationId", annotationID);
     
    8682                append(annotation_id).append("  =  :annotationId ").append(" AND ").
    8783                append(principal_id).append("  = :principalId").append(" LIMIT 1");
    88         List<Access> result = this.loggedQuery(sql.toString(), accessRowMapper, params);
    89         if (result.isEmpty()) {
    90             return null;
     84        return this.loggedQuery(sql.toString(), accessRowMapper, params);
     85    }
     86   
     87    @Override
     88    public boolean hasExplicitAccess(Number annotationID, Number principalID) {
     89        List<Access> result = this.getAccessHelper(annotationID, principalID);
     90        if (result == null || result.isEmpty()) {
     91            return false;
     92        } else {
     93            return true;
     94        }
     95    }
     96
     97    @Override
     98    public Access getAccess(Number annotationID, Number principalID) {
     99     List<Access> result = this.getAccessHelper(annotationID, principalID);   
     100        if (result == null || result.isEmpty()) {
     101            return Access.NONE;
    91102        } else {
    92103            return result.get(0);
    93104        }
    94105    }
    95     private final RowMapper<Access> accessRowMapper = new RowMapper<Access>() {
    96         @Override
    97         public Access mapRow(ResultSet rs, int rowNumber) throws SQLException {
    98             return Access.fromValue(rs.getString(access));
    99         }
    100     };
    101    
    102    
     106   
    103107
    104108    /////////////////////////////////////////////////////////////////////
     
    109113                append(annotation_id).append("  =  ? ").append(" LIMIT 1");
    110114        List<Access> result = this.loggedQuery(sql.toString(), public_RowMapper, annotationID);
    111         return result.get(0);
    112     }
    113    
    114    
    115     @Override
    116     public List<UUID> getExternalIdFromHeadline(String headline){
     115        if (result == null || result.isEmpty()) {
     116            return Access.NONE;
     117        } else {
     118            return result.get(0);
     119        }
     120
     121    }
     122
     123    @Override
     124    public List<UUID> getExternalIdFromHeadline(String headline) {
    117125        StringBuilder requestDB = new StringBuilder("SELECT ");
    118126        requestDB.append(external_id).append(" FROM ").append(annotationTableName).append(" WHERE ").append("'").append(headline).append("'").append("= ?");
    119         return this.loggedQuery(requestDB.toString(), externalIDRowMapper, headline);       
    120     }
    121    
    122     @Override
    123     public List<Number> getInternalIDsFromHeadline(String headline){
     127        return this.loggedQuery(requestDB.toString(), externalIDRowMapper, headline);
     128    }
     129
     130    @Override
     131    public List<Number> getInternalIDsFromHeadline(String headline) {
    124132        StringBuilder requestDB = new StringBuilder("SELECT ");
    125133        requestDB.append(annotation_id).append(" FROM ").append(annotationTableName).append(" WHERE ").append("'").append(headline).append("'").append("= ?");
    126         return this.loggedQuery(requestDB.toString(), internalIDRowMapper, headline);       
     134        return this.loggedQuery(requestDB.toString(), internalIDRowMapper, headline);
    127135    }
    128136
     
    157165    }
    158166
     167
    159168    ///////////////////////////////////////////////////////////////////////////////////
    160     @Override
    161     public List<Number> getAnnotationIDsForPermission(Number principalID, Access access) {
    162 
     169    //this method does not include all the annotations which are NOT in the pair with principal in this table
     170    // they have all default NONE access
     171    @Override
     172    public List<Number> getAnnotationIDsPermissionAtLeast(Number principalID, Access access) {
    163173        StringBuilder sql = new StringBuilder("SELECT ");
    164174        sql.append(annotation_id).append(" FROM ").append(permissionsTableName).append(" WHERE ").
     
    170180    /// helper ///
    171181    private String sqlAccessConstraint(String column, Access access) {
    172 
    173182        StringBuilder accessConstraint = new StringBuilder();
    174183        if (access.equals(Access.READ)) {
    175184            accessConstraint.append("(").append(column).append("  = '").append(Access.READ.value()).append("'");
    176             accessConstraint.append(" OR ").append(column).append("  = '").append(Access.WRITE.value()).append("')");
     185            accessConstraint.append(" OR ").append(column).append("  = '").append(Access.WRITE.value()).append("'");
     186            accessConstraint.append(" OR ").append(column).append("  = '").append(Access.ALL.value()).append("')");
    177187        } else {
    178             accessConstraint.append(column).append("  = '").append(access.value()).append("'");
    179         }
    180 
     188            if (access.equals(Access.WRITE)) {
     189                accessConstraint.append("(").append(column).append("  = '").append(Access.WRITE.value()).append("'");
     190                accessConstraint.append(" OR ").append(column).append("  = '").append(Access.ALL.value()).append("')");
     191            } else if (access.equals(Access.ALL)) {
     192                accessConstraint.append("(").append(column).append("  = '").append(Access.ALL.value()).append("')");
     193            } else {
     194                accessConstraint.append("(").append(column).append("  = '").append(Access.NONE.value()).append("')");
     195            }
     196        }
    181197        return accessConstraint.toString();
    182198    }
     
    184200    /////////////
    185201    @Override
    186     public List<Number> getAnnotationIDsForPublicAccess(Access access) {
     202    public List<Number> getAnnotationIDsPublicAtLeast(Access access) {
    187203        StringBuilder sql = new StringBuilder("SELECT ");
    188204        sql.append(annotation_id).append(" FROM ").append(annotationTableName).append(" WHERE ").
     
    190206        return this.loggedQuery(sql.toString(), internalIDRowMapper);
    191207    }
    192 
    193    
    194208
    195209    /////////////////////////////////////////
     
    317331            annotation.setTargets(null);
    318332            String externalId = rs.getString(external_id);
    319             annotation.setId(externalId);           
     333            annotation.setId(externalId);
    320334            annotation.setHref(externalIDtoHref(externalId));
    321335            annotation.setLastModified(timeStampToXMLGregorianCalendar(rs.getString(last_modified)));
     
    335349    }
    336350
    337     /////////////////////////////
    338 //    @Override
    339 //    public boolean annotationIsInUse(Number annotationID) {
    340 //        StringBuilder sqlNotebooks = new StringBuilder("SELECT ");
    341 //        sqlNotebooks.append(notebook_id).append(" FROM ").append(notebooksAnnotationsTableName).append(" WHERE ").append(annotation_id).append("= ? LIMIT 1");
    342 //        List<Number> resultNotebooks = this.loggedQuery(sqlNotebooks.toString(), notebookIDRowMapper, annotationID);
    343 //        if (resultNotebooks.size() > 0) {
    344 //            return true;
    345 //        }
    346 //
    347 //        StringBuilder sqlTargets = new StringBuilder("SELECT ");
    348 //        sqlTargets.append(target_id).append(" FROM ").append(annotationsTargetsTableName).append(" WHERE ").append(annotation_id).append("= ? LIMIT 1");
    349 //        List<Number> resultTargets = this.loggedQuery(sqlTargets.toString(), targetIDRowMapper, annotationID);
    350 //        if (resultTargets.size() > 0) {
    351 //            return true;
    352 //        }
    353 //
    354 //        StringBuilder sqlAccesss = new StringBuilder("SELECT ");
    355 //        sqlAccesss.append(principal_id).append(" FROM ").append(permissionsTableName).append(" WHERE ").append(annotation_id).append("= ? LIMIT 1");
    356 //        List<Number> resultAccesss = this.loggedQuery(sqlAccesss.toString(), principalIDRowMapper, annotationID);
    357 //        return (resultAccesss.size() > 0);
    358 //    }
     351   
    359352    @Override
    360353    public List<Number> getAnnotations(Number notebookID) {
     
    395388        return affectedRows;
    396389    }
    397    
    398      @Override
     390
     391    @Override
    399392    public int updateAnnotationHeadline(Number annotationID, String header) {
    400393        Map<String, Object> params = new HashMap<String, Object>();
     
    416409
    417410        String[] body = retrieveBodyComponents(annotation.getBody());
    418                
     411
    419412        Map<String, Object> params = new HashMap<String, Object>();
    420413        params.put("owner", newOwnerID);
     
    423416        params.put("headline", annotation.getHeadline());
    424417        params.put("isXml", annotation.getBody().getXmlBody() != null);
    425         params.put("externalId", annotation.getId());
     418        params.put("externalId", annotation.getId());       
     419        params.put("publicAccess", annotation.getPermissions().getPublic().value());
    426420        params.put("annotationId", annotationID);
    427421
     
    434428                append(last_modified).append("=  default,").
    435429                append(is_xml).append("= :isXml, ").
    436                 append(external_id).append("= :externalId").
    437                 append(" WHERE ").append(annotation_id).append("= :annotationId");
     430                append(external_id).append("= :externalId, ").
     431                append(public_).append("= :publicAccess").
     432                append(" WHERE ").append(annotation_id).append("= :annotationId");
    438433        int affectedRows = this.loggedUpdate(sql.toString(), params);
    439        
     434
    440435        return affectedRows;
    441436    }
    442437
    443438    @Override
    444     public int updateAnnotationPrincipalAccess(Number annotationID, Number principalID, Access access) {
     439    public int updatePermission(Number annotationID, Number principalID, Access access) {
    445440
    446441        Map<String, Object> params = new HashMap<String, Object>();
     
    460455
    461456    @Override
    462     public int updatePublicAttribute(Number annotationID, Access access) {
     457    public int updatePublicAccess(Number annotationID, Access access) {
    463458
    464459        Map<String, Object> params = new HashMap<String, Object>();
     
    486481        params.put("bodyText", body[0]);
    487482        params.put("bodyMimeType", body[1]);
    488         params.put("isXml", annotation.getBody().getXmlBody() != null);
     483        params.put("isXml", annotation.getBody().getXmlBody() != null);               
     484        params.put("publicAccess", annotation.getPermissions().getPublic().value());
    489485
    490486        StringBuilder sql = new StringBuilder("INSERT INTO ");
    491487        sql.append(annotationTableName).append("(").append(external_id).append(",").append(owner_id);
    492         sql.append(",").append(headline).append(",").append(body_text).append(",").append(body_mimetype).append(",").append(is_xml).
    493                 append(" ) VALUES (:externalId, :owner, :headline, :bodyText, :bodyMimeType, :isXml)");
     488        sql.append(",").append(headline).append(",").append(body_text).append(",").append(body_mimetype).append(",").append(is_xml).append(",").append(public_).
     489                append(" ) VALUES (:externalId, :owner, :headline, :bodyText, :bodyMimeType, :isXml, :publicAccess)");
    494490        int affectedRows = this.loggedUpdate(sql.toString(), params);
    495491        return getInternalID(externalID);
     
    509505    /////////////////////////////////////////////////////////////////////////////////////////
    510506    @Override
    511     public int addAnnotationPrincipalAccess(Number annotationID, Number principalID, Access access) {
     507    public int addPermission(Number annotationID, Number principalID, Access access) {
    512508
    513509        Map<String, Object> paramsAccesss = new HashMap<String, Object>();
     
    541537    //////////////////////////////////////////////////////
    542538    @Override
    543     public int deleteAnnotationPermissions(Number annotationID) {
     539    public int deletePermissions(Number annotationID) {
    544540        StringBuilder sqlAccesss = new StringBuilder("DELETE FROM ");
    545541        sqlAccesss.append(permissionsTableName).append(" WHERE ").append(annotation_id).append(" = ?");
    546542        return this.loggedUpdate(sqlAccesss.toString(), annotationID); // removed "access" rows
    547543    }
    548 
    549     ////////////////////////////////////////
    550     @Override
    551     public int deleteAnnotationFromAllNotebooks(Number annotationID) {
    552         StringBuilder sql = new StringBuilder("DELETE FROM ");
    553         sql.append(notebooksAnnotationsTableName).append(" WHERE ").append(annotation_id).append(" = ?");
    554         return this.loggedUpdate(sql.toString(), annotationID); // removed "notebook-annotation" rows
    555 
    556     }
    557 
     544   
    558545    //////////////////////////////////////////////////////
    559546    @Override
    560     public int deleteAnnotationPrincipalAccess(Number annotationID, Number principalID) {
     547    public int deletePermission(Number annotationID, Number principalID) {
    561548        Map<String, Number> params = new HashMap();
    562549        params.put("annotationId", annotationID);
     
    568555
    569556    }
     557
     558    ////////////////////////////////////////
     559    @Override
     560    public int deleteAnnotationFromAllNotebooks(Number annotationID) {
     561        StringBuilder sql = new StringBuilder("DELETE FROM ");
     562        sql.append(notebooksAnnotationsTableName).append(" WHERE ").append(annotation_id).append(" = ?");
     563        return this.loggedUpdate(sql.toString(), annotationID); // removed "notebook-annotation" rows
     564
     565    }
     566
     567   
    570568    /////////////// helpers //////////////////
    571569
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java

    r5468 r5836  
    264264        }
    265265    };
     266    protected final RowMapper<Access> accessRowMapper = new RowMapper<Access>() {
     267        @Override
     268        public Access mapRow(ResultSet rs, int rowNumber) throws SQLException {
     269            Access result =Access.fromValue(rs.getString(access));
     270            return result;
     271        }
     272    };
    266273     protected final RowMapper<Access> public_RowMapper = new RowMapper<Access>() {
    267274        @Override
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java

    r5774 r5836  
    2323import eu.dasish.annotation.backend.NotInDataBaseException;
    2424import eu.dasish.annotation.backend.Resource;
    25 import eu.dasish.annotation.backend.ResourceAction;
    2625import eu.dasish.annotation.backend.dao.ILambda;
    2726import eu.dasish.annotation.schema.Annotation;
     
    9493        Map params = new HashMap();
    9594        try {
    96             Annotation result = (Annotation) (new RequestWrappers(this)).wrapRequestResource(params, new GetAnnotation(), Resource.ANNOTATION, ResourceAction.READ, externalIdentifier);
     95            Annotation result = (Annotation) (new RequestWrappers(this)).wrapRequestResource(params, new GetAnnotation(), Resource.ANNOTATION, Access.READ, externalIdentifier);
    9796            if (result != null) {
    9897                return (new ObjectFactory()).createAnnotation(result);
     
    125124        Map params = new HashMap();
    126125        try {
    127             ReferenceList result = (ReferenceList) (new RequestWrappers(this)).wrapRequestResource(params, new GetTargetList(), Resource.ANNOTATION, ResourceAction.READ, externalIdentifier);
     126            ReferenceList result = (ReferenceList) (new RequestWrappers(this)).wrapRequestResource(params, new GetTargetList(), Resource.ANNOTATION, Access.READ, externalIdentifier);
    128127            if (result != null) {
    129128                return (new ObjectFactory()).createTargetList(result);
     
    244243        Map params = new HashMap();
    245244        try {
    246             PermissionList result = (PermissionList) (new RequestWrappers(this)).wrapRequestResource(params, new GetPermissionList(), Resource.ANNOTATION, ResourceAction.READ, externalIdentifier);
     245            PermissionList result = (PermissionList) (new RequestWrappers(this)).wrapRequestResource(params, new GetPermissionList(), Resource.ANNOTATION, Access.READ, externalIdentifier);
    247246            if (result != null) {
    248247                return (new ObjectFactory()).createPermissionList(result);
     
    273272        Map params = new HashMap();
    274273        try {
    275             int[] result = (int[]) (new RequestWrappers(this)).wrapRequestResource(params, new DeleteAnnotation(), Resource.ANNOTATION, ResourceAction.DELETE, externalIdentifier);
     274            int[] result = (int[]) (new RequestWrappers(this)).wrapRequestResource(params, new DeleteAnnotation(), Resource.ANNOTATION, Access.ALL, externalIdentifier);
    276275            if (result != null) {
    277276                return result[0] + " annotation(s) is(are) deleted.";
     
    344343        }
    345344        try {
    346             Map params = new HashMap();
    347            
     345            Map params = new HashMap();           
    348346            params.put("annotation", annotation);
    349347            params.put("remoteUser",httpServletRequest.getRemoteUser());
    350             ResponseBody result = (ResponseBody) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateAnnotation(), Resource.ANNOTATION, ResourceAction.WRITE, externalId);
     348            ResponseBody result = (ResponseBody) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateAnnotation(), Resource.ANNOTATION, Access.WRITE, externalId);
    351349            if (result != null) {
    352350                return (new ObjectFactory()).createResponseBody(result);
     
    386384        params.put("annotationBody", annotationBody);
    387385        try {
    388             ResponseBody result = (ResponseBody) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateAnnotationBody(), Resource.ANNOTATION, ResourceAction.WRITE, externalIdentifier);
     386            ResponseBody result = (ResponseBody) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateAnnotationBody(), Resource.ANNOTATION, Access.WRITE, externalIdentifier);
    389387            if (result != null) {
    390388                return (new ObjectFactory()).createResponseBody(result);
     
    422420        params.put("headline", newHeadline);
    423421        try {
    424             ResponseBody result = (ResponseBody) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateAnnotationHeadline(), Resource.ANNOTATION, ResourceAction.WRITE, externalIdentifier);
     422            ResponseBody result = (ResponseBody) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateAnnotationHeadline(), Resource.ANNOTATION, Access.WRITE, externalIdentifier);
    425423            if (result != null) {
    426424                return (new ObjectFactory()).createResponseBody(result);
     
    479477                    Map params = new HashMap();
    480478                    params.put("access", accessTyped);
    481                     Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdatePublicAccess(), Resource.ANNOTATION, ResourceAction.WRITE_W_METAINFO, annotationId.toString());
     479                    Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdatePublicAccess(), Resource.ANNOTATION, Access.ALL, annotationId.toString());
    482480                    updatedAnnotations = (result != null) ? updatedAnnotations + result.intValue() : updatedAnnotations;
    483481                }
     
    486484                Map params = new HashMap();
    487485                params.put("access", accessTyped);
    488                 Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdatePublicAccess(), Resource.ANNOTATION, ResourceAction.WRITE_W_METAINFO, annotationDatabaseId);
     486                Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdatePublicAccess(), Resource.ANNOTATION, Access.ALL, annotationDatabaseId);
    489487                if (result != null) {
    490488                    return result + " row(s) is(are) updated.";
     
    517515    @Produces(MediaType.APPLICATION_XML)
    518516    @Path("{annotationid: " + BackendConstants.regExpIdentifier + "}/permissions/{principalid: " + BackendConstants.regExpIdentifier + "}")
    519     public String updateAccess(@PathParam("annotationid") String annotationExternalId,
     517    public String updatePermission(@PathParam("annotationid") String annotationExternalId,
    520518            @PathParam("principalid") String principalExternalId, Access access) throws IOException {
    521519        try {
    522             return this.genericUpdateDeleteAccess(annotationExternalId, principalExternalId, access);
     520            return this.genericUpdateDeletePermission(annotationExternalId, principalExternalId, access);
    523521        } catch (NotInDataBaseException e1) {
    524522            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, e1.getMessage());
     
    569567                String tmp = null;
    570568                for (UUID annotationId : annotationIds) {
    571                     tmp = this.genericUpdateDeleteAccess(annotationId.toString(), principalDatabaseId, Access.fromValue(access));
     569                    tmp = this.genericUpdateDeletePermission(annotationId.toString(), principalDatabaseId, Access.fromValue(access));
    572570                    if (!tmp.startsWith("0")) {
    573571                        count++;
     
    576574                return (count + " row(s) are updated");
    577575            } else {
    578                 return this.genericUpdateDeleteAccess(annotationDatabaseId, principalDatabaseId, Access.fromValue(access));
     576                return this.genericUpdateDeletePermission(annotationDatabaseId, principalDatabaseId, Access.fromValue(access));
    579577            }
    580578
     
    589587
    590588    ////////////////////////////////////////////
    591     private String genericUpdateDeleteAccess(String annotationId, String principalId, Access access) throws IOException, NotInDataBaseException, ForbiddenException {
     589    private String genericUpdateDeletePermission(String annotationId, String principalId, Access access) throws IOException, NotInDataBaseException, ForbiddenException {
    592590        Map params = new HashMap();
    593591        params.put("access", access);
    594592        final Number inputPrincipalID = dbDispatcher.getResourceInternalIdentifier(UUID.fromString(principalId), Resource.PRINCIPAL);
    595593        params.put("inputPrincipalID", inputPrincipalID);
    596         Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdatePrincipalAccess(), Resource.ANNOTATION, ResourceAction.WRITE_W_METAINFO, annotationId);
     594        Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdatePermissionHelper(), Resource.ANNOTATION, Access.ALL, annotationId);
    597595        if (result != null) {
    598596            return result + " row(s) is(are) updated.";
     
    602600    }
    603601
    604     private class UpdatePrincipalAccess implements ILambda<Map, Integer> {
     602    private class UpdatePermissionHelper implements ILambda<Map, Integer> {
    605603
    606604        @Override
     
    609607            Number principalID = (Number) params.get("inputPrincipalID");
    610608            Access access = (Access) params.get("access");
    611             return dbDispatcher.updateAnnotationPrincipalAccess(annotationID, principalID, access);
     609            return dbDispatcher.updatePermission(annotationID, principalID, access);
    612610        }
    613611    }
     
    623621        params.put("permissions", permissions);
    624622        try {
    625             ResponseBody result = (ResponseBody) (new RequestWrappers(this)).wrapRequestResource(params, new UpdatePermissions(), Resource.ANNOTATION, ResourceAction.WRITE_W_METAINFO, annotationExternalId);
     623            ResponseBody result = (ResponseBody) (new RequestWrappers(this)).wrapRequestResource(params, new UpdatePermissions(), Resource.ANNOTATION, Access.ALL, annotationExternalId);
    626624            if (result != null) {
    627625                return new ObjectFactory().createResponseBody(result);
     
    655653    @Produces(MediaType.TEXT_PLAIN)
    656654    @Path("{annotationId: " + BackendConstants.regExpIdentifier + "}/principal/{principalId}/delete")
    657     public String deletePrincipalsAccess(@PathParam("annotationId") String annotationId,
     655    public String deletePermission(@PathParam("annotationId") String annotationId,
    658656            @PathParam("principalId") String principalId) throws IOException {
    659657        try {
    660             return this.genericUpdateDeleteAccess(annotationId, principalId, null);
     658            return this.genericUpdateDeletePermission(annotationId, principalId, null);
    661659        } catch (NotInDataBaseException e1) {
    662660            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, e1.getMessage());
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/CachedRepresentationResource.java

    r5693 r5836  
    2424import eu.dasish.annotation.backend.NotInDataBaseException;
    2525import eu.dasish.annotation.backend.Resource;
    26 import eu.dasish.annotation.backend.ResourceAction;
    2726import eu.dasish.annotation.backend.dao.ILambda;
     27import eu.dasish.annotation.schema.Access;
    2828import eu.dasish.annotation.schema.CachedRepresentationInfo;
    2929import eu.dasish.annotation.schema.ObjectFactory;
     
    7171        Map params = new HashMap();
    7272        try {
    73             CachedRepresentationInfo result = (CachedRepresentationInfo) (new RequestWrappers(this)).wrapRequestResource(params, new GetCachedRepresentationInfo(), Resource.CACHED_REPRESENTATION, ResourceAction.READ, externalId);
     73            CachedRepresentationInfo result = (CachedRepresentationInfo) (new RequestWrappers(this)).wrapRequestResource(params, new GetCachedRepresentationInfo(), Resource.CACHED_REPRESENTATION, Access.READ, externalId);
    7474            if (result != null) {
    7575                return (new ObjectFactory()).createCachedRepresentationInfo(result);
     
    103103        Map params = new HashMap();
    104104        try {
    105             InputStream result = (InputStream) (new RequestWrappers(this)).wrapRequestResource(params, new GetCachedRepresentationInputStream(), Resource.CACHED_REPRESENTATION, ResourceAction.READ, externalId);
     105            InputStream result = (InputStream) (new RequestWrappers(this)).wrapRequestResource(params, new GetCachedRepresentationInputStream(), Resource.CACHED_REPRESENTATION, Access.READ, externalId);
    106106            if (result != null) {
    107107                ImageIO.setUseCache(false);
     
    135135        Map params = new HashMap();
    136136        try {
    137             return (InputStream) (new RequestWrappers(this)).wrapRequestResource(params, new GetCachedRepresentationInputStream(), Resource.CACHED_REPRESENTATION, ResourceAction.READ, externalId);
     137            return (InputStream) (new RequestWrappers(this)).wrapRequestResource(params, new GetCachedRepresentationInputStream(), Resource.CACHED_REPRESENTATION, Access.READ, externalId);
    138138        } catch (NotInDataBaseException e1) {
    139139            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, e1.getMessage());
     
    165165        params.put("stream", bpe.getInputStream());
    166166        try {
    167             Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateCachedBlob(), Resource.CACHED_REPRESENTATION, ResourceAction.WRITE, cachedIdentifier);
     167            Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateCachedBlob(), Resource.CACHED_REPRESENTATION, Access.WRITE, cachedIdentifier);
    168168            if (result != null) {
    169169                return result + "rows are updated";
     
    199199        params.put("stream", input);
    200200        try {
    201             Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateCachedBlob(), Resource.CACHED_REPRESENTATION, ResourceAction.WRITE, cachedIdentifier);
     201            Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateCachedBlob(), Resource.CACHED_REPRESENTATION, Access.WRITE, cachedIdentifier);
    202202            input.close();
    203203            if (result != null) {
     
    240240        params.put("info", cachedInfo);
    241241        try {
    242             Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateCachedMetadata(), Resource.CACHED_REPRESENTATION, ResourceAction.WRITE_W_METAINFO, cachedInfo.getId());
     242            Integer result = (Integer) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateCachedMetadata(), Resource.CACHED_REPRESENTATION, Access.ALL, cachedInfo.getId());
    243243            if (result != null) {
    244244                return result + "rows are updated";
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/RequestWrappers.java

    r5684 r5836  
    2222import eu.dasish.annotation.backend.PrincipalExists;
    2323import eu.dasish.annotation.backend.Resource;
    24 import eu.dasish.annotation.backend.ResourceAction;
    2524import eu.dasish.annotation.backend.dao.ILambda;
    2625import eu.dasish.annotation.backend.dao.ILambdaPrincipal;
     26import eu.dasish.annotation.schema.Access;
    2727import eu.dasish.annotation.schema.ObjectFactory;
    2828import eu.dasish.annotation.schema.Principal;
     
    3030import java.util.Map;
    3131import java.util.UUID;
    32 import javax.servlet.http.HttpServletResponse;
    3332import javax.xml.bind.JAXBElement;
    3433
     
    6261    }
    6362
    64     public T wrapRequestResource(Map params, ILambda<Map, T> dbRequestor, Resource resource, ResourceAction action, String externalId) throws IOException, ForbiddenException, NotInDataBaseException {
     63    public T wrapRequestResource(Map params, ILambda<Map, T> dbRequestor, Resource resource, Access action, String externalId) throws IOException, ForbiddenException, NotInDataBaseException {
    6564        Number principalID = resourceResource.getPrincipalID();
    6665        if (principalID == null) {
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/TargetResource.java

    r5693 r5836  
    2424import eu.dasish.annotation.backend.NotInDataBaseException;
    2525import eu.dasish.annotation.backend.Resource;
    26 import eu.dasish.annotation.backend.ResourceAction;
    2726import eu.dasish.annotation.backend.dao.ILambda;
     27import eu.dasish.annotation.schema.Access;
    2828import eu.dasish.annotation.schema.CachedRepresentationInfo;
    2929import eu.dasish.annotation.schema.ObjectFactory;
    3030import eu.dasish.annotation.schema.ReferenceList;
    31 import eu.dasish.annotation.schema.ResponseBody;
    3231import eu.dasish.annotation.schema.Target;
    3332import java.io.IOException;
     
    8281        Map params = new HashMap();
    8382        try {
    84             Target result = (Target) (new RequestWrappers(this)).wrapRequestResource(params, new GetTarget(), Resource.TARGET, ResourceAction.READ, externalIdentifier);
     83            Target result = (Target) (new RequestWrappers(this)).wrapRequestResource(params, new GetTarget(), Resource.TARGET, Access.READ, externalIdentifier);
    8584            if (result != null) {
    8685                return new ObjectFactory().createTarget(result);
     
    114113        Map params = new HashMap();
    115114        try {
    116             ReferenceList result = (ReferenceList) (new RequestWrappers(this)).wrapRequestResource(params, new GetSiblingTargets(), Resource.TARGET, ResourceAction.READ, externalIdentifier);
     115            ReferenceList result = (ReferenceList) (new RequestWrappers(this)).wrapRequestResource(params, new GetSiblingTargets(), Resource.TARGET, Access.READ, externalIdentifier);
    117116            if (result != null) {
    118117                return new ObjectFactory().createReferenceList(result);
     
    153152        params.put("fragmentDescriptor", fragmentDescriptor);
    154153        try {
    155             CachedRepresentationInfo result = (CachedRepresentationInfo) (new RequestWrappers(this)).wrapRequestResource(params, new PostCached(), Resource.TARGET, ResourceAction.WRITE_W_METAINFO, targetIdentifier);
     154            CachedRepresentationInfo result = (CachedRepresentationInfo) (new RequestWrappers(this)).wrapRequestResource(params, new PostCached(), Resource.TARGET, Access.ALL, targetIdentifier);
    156155            if (result != null) {
    157156                return new ObjectFactory().createCachedRepresentationInfo(result);
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/SCHEMA/DASISH-schema.xsd

    r5755 r5836  
    136136            <xs:enumeration value="write"/>
    137137            <xs:enumeration value="none"/>
     138            <xs:enumeration value="all"/>
    138139        </xs:restriction>
    139140    </xs:simpleType>
     
    153154                <xs:attribute name="public" type="dasish:Access" use="required"/>
    154155            </xs:extension>
     156        </xs:complexContent>
     157    </xs:complexType>
     158   
     159    <xs:complexType name="HistoryRecord">
     160        <xs:sequence>           
     161            <xs:element name="modifiedByHref" type="xs:anyURI"  minOccurs="1" maxOccurs="1"/>           
     162            <xs:element name="modifiedOn" type="xs:dateTime"  minOccurs="1" maxOccurs="1"/>
     163            <xs:element name="mdifiedBody" type="dasish:AnnotationBody" minOccurs="1" maxOccurs="1"/>
     164            <xs:element name="modifiedHeadline" type="xs:string"  minOccurs="1" maxOccurs="1"/>
     165        </xs:sequence>
     166    </xs:complexType>
     167   
     168    <xs:complexType name="HistoryRecordList">
     169        <xs:complexContent>
     170            <xs:extension base="dasish:List">
     171                <xs:sequence>
     172                    <xs:element name="historyRecord" type="dasish:HistoryRecord" minOccurs="0"
     173                        maxOccurs="unbounded"/>
     174                </xs:sequence>
     175            </xs:extension>
    155176        </xs:complexContent>
    156177    </xs:complexType>
     
    166187            <xs:element name="permissions" type="dasish:PermissionList" minOccurs="1"
    167188                        maxOccurs="1"/>
     189            <xs:element name="historyRecords" type="dasish:HistoryRecordList" minOccurs="0" maxOccurs="1"/>
    168190        </xs:sequence>
    169191        <xs:attribute name="href" type="xs:anyURI" use="required"/>
     
    348370
    349371    <xs:element name="targetInfo" type="dasish:TargetInfo"/>
    350 
    351     <xs:element name="targetInfoList" type="dasish:TargetInfoList"/>
     372   
     373    <xs:element name="historyRecord" type="dasish:HistoryRecord"/>
     374
     375    <xs:element name="historyRecordList" type="dasish:HistoryRecordList"/>
    352376
    353377    <xs:element name="targetList" type="dasish:ReferenceList"/>
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherTest.java

    r5774 r5836  
    344344                will(returnValue(mockAnnotationIDs1));
    345345
    346                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.READ);
     346                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.READ);
    347347                will(returnValue(mockAnnotationIDsRead));
    348348
    349                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.READ);
     349                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.READ);
    350350                will(returnValue(mockAnnotationIDsPublicRead));               
    351351
     
    418418                will(returnValue(mockAnnotationIDs1));
    419419
    420                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.READ);
     420                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.READ);
    421421                will(returnValue(mockAnnotationIDsRead));
    422422
    423                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.READ);
     423                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.READ);
    424424                will(returnValue(mockAnnotationIDsPublicRead));               
    425425
     
    491491                will(returnValue(mockAnnotationIDs1));
    492492
    493                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.READ);
     493                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.READ);
    494494                will(returnValue(mockAnnotationIDsRead));
    495495
    496                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.READ);
     496                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.READ);
    497497                will(returnValue(mockAnnotationIDsPublicRead));               
    498498
     
    565565                will(returnValue(mockAnnotationIDs1));
    566566
    567                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.READ);
     567                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.READ);
    568568                will(returnValue(mockAnnotationIDsRead));
    569569
    570                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.READ);
     570                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.READ);
    571571                will(returnValue(mockAnnotationIDsPublicRead));               
    572572
     
    631631                will(returnValue(mockAnnotationIDs1));
    632632
    633                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.WRITE);
     633                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.WRITE);
    634634                will(returnValue(mockAnnotationIDsWrite));
    635635
    636                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.WRITE);
     636                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.WRITE);
    637637                will(returnValue(mockAnnotationIDsPublicWrite));               
    638638
     
    695695                will(returnValue(mockAnnotationIDs1));
    696696
    697                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.WRITE);
     697                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.WRITE);
    698698                will(returnValue(mockAnnotationIDsWrite));
    699699
    700                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.WRITE);
     700                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.WRITE);
    701701                will(returnValue(mockAnnotationIDsPublicWrite));               
    702702
     
    761761                will(returnValue(mockAnnotationIDs1));
    762762
    763                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.WRITE);
     763                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.WRITE);
    764764                will(returnValue(mockAnnotationIDsWrite));
    765765
    766                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.WRITE);
     766                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.WRITE);
    767767                will(returnValue(mockAnnotationIDsPublicWrite));               
    768768
     
    826826                will(returnValue(mockAnnotationIDs1));
    827827
    828                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.WRITE);
     828                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.WRITE);
    829829                will(returnValue(mockAnnotationIDsWrite));
    830830
    831                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.WRITE);
     831                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.WRITE);
    832832                will(returnValue(mockAnnotationIDsPublicWrite));               
    833833
     
    10211021                will(returnValue(mockAnnotationIDs1));
    10221022
    1023                 oneOf(annotationDao).getAnnotationIDsForPermission(loggedIn, Access.READ);
     1023                oneOf(annotationDao).getAnnotationIDsPermissionAtLeast(loggedIn, Access.READ);
    10241024                will(returnValue(mockAnnotationIDsRead));
    10251025
    1026                 oneOf(annotationDao).getAnnotationIDsForPublicAccess(Access.READ);
     1026                oneOf(annotationDao).getAnnotationIDsPublicAtLeast(Access.READ);
    10271027                will(returnValue(mockAnnotationIDsPublicRead));
    10281028             
     
    12581258                will(returnValue(1)); // the DB update will be called at perform anyway, even if the body is not changed (can be optimized)
    12591259
    1260                 oneOf(annotationDao).updatePublicAttribute(5, Access.WRITE);
     1260                oneOf(annotationDao).updatePublicAccess(5, Access.WRITE);
    12611261                will(returnValue(1));
    12621262            }
     
    14141414        mockeryDao.checking(new Expectations() {
    14151415            {
    1416                 oneOf(annotationDao).deleteAnnotationPermissions(2);
     1416                oneOf(annotationDao).deletePermissions(2);
    14171417                will(returnValue(2));
    14181418
     
    17671767                will(returnValue("/api/principals/00000000-0000-0000-0000-000000000113"));
    17681768
    1769 
     1769               oneOf(principalDao).getPrincipalIDsWithAccessForNotebook(2, Access.ALL);
     1770                will(returnValue(new ArrayList<Number>()));
    17701771
    17711772            }
     
    19521953                will(returnValue(1)); // the DB update will be called at perform anyway, even if the body is not changed (can be optimized)
    19531954
    1954                 oneOf(annotationDao).updatePublicAttribute(5, Access.WRITE);
     1955                oneOf(annotationDao).updatePublicAccess(5, Access.WRITE);
    19551956                will(returnValue(1));
    19561957
     
    21102111                will(returnValue(1));
    21112112
    2112                 oneOf(annotationDao).deleteAnnotationPermissions(1);
     2113                oneOf(annotationDao).deletePermissions(1);
    21132114                will(returnValue(3));
    21142115
     
    21442145                will(returnValue(2));
    21452146
    2146                 oneOf(annotationDao).addAnnotationPrincipalAccess(1, 2, Access.WRITE);
     2147                oneOf(annotationDao).addPermission(1, 2, Access.WRITE);
    21472148                will(returnValue(1));
    21482149
     
    21502151                will(returnValue(3));
    21512152
    2152                 oneOf(annotationDao).addAnnotationPrincipalAccess(1, 3, Access.READ);
     2153                oneOf(annotationDao).addPermission(1, 3, Access.READ);
    21532154                will(returnValue(1));
    21542155
     
    21612162                ///
    21622163
    2163                 oneOf(annotationDao).updatePublicAttribute(1, permissions.getPublic());
     2164                oneOf(annotationDao).updatePublicAccess(1, permissions.getPublic());
    21642165                will(returnValue(1));
    21652166
     
    22002201//    }
    22012202    @Test
    2202     public void testUpdateAnnotationPrinciaplAccess() {
     2203    public void testUpdatePermission() {
    22032204        System.out.println("test updateAnnotationPrincipalAccess");
    22042205        mockeryDao.checking(new Expectations() {
    22052206            {
    2206                 oneOf(annotationDao).getAccess(1, 2);
    2207                 will(returnValue(Access.WRITE));
    2208 
    2209                 oneOf(annotationDao).updateAnnotationPrincipalAccess(1, 2, Access.READ);
    2210                 will(returnValue(1));
    2211 
    2212                 oneOf(annotationDao).getAccess(1, 4);
    2213                 will(returnValue(null));
    2214                
    2215                 oneOf(annotationDao).addAnnotationPrincipalAccess(1, 4, Access.WRITE);
    2216                 will(returnValue(1));
    2217 
    2218             }
    2219         });
    2220 
    2221         assertEquals(1, dbDispatcher.updateAnnotationPrincipalAccess(1, 2, Access.READ));
    2222         assertEquals(1, dbDispatcher.updateAnnotationPrincipalAccess(1, 4, Access.WRITE));
     2207                oneOf(annotationDao).hasExplicitAccess(1, 2);
     2208                will(returnValue(true));
     2209
     2210                oneOf(annotationDao).updatePermission(1, 2, Access.READ);
     2211                will(returnValue(1));
     2212
     2213                oneOf(annotationDao).hasExplicitAccess(1, 4);
     2214                will(returnValue(false));
     2215               
     2216                oneOf(annotationDao).addPermission(1, 4, Access.WRITE);
     2217                will(returnValue(1));
     2218
     2219            }
     2220        });
     2221
     2222        assertEquals(1, dbDispatcher.updatePermission(1, 2, Access.READ));
     2223        assertEquals(1, dbDispatcher.updatePermission(1, 4, Access.WRITE));
    22232224    }
    22242225
     
    22492250            {
    22502251                /////
    2251                 oneOf(annotationDao).updatePublicAttribute(1, permissions.getPublic());
     2252                oneOf(annotationDao).updatePublicAccess(1, permissions.getPublic());
    22522253                will(returnValue(1));
    22532254
     
    22552256                will(returnValue(2));
    22562257
    2257                 oneOf(annotationDao).getAccess(1, 2);
    2258                 will(returnValue(Access.WRITE));
     2258                oneOf(annotationDao).hasExplicitAccess(1, 2);
     2259                will(returnValue(true));
    22592260
    22602261                oneOf(principalDao).getInternalIDFromHref(permissions.getPermission().get(1).getPrincipalHref());
    22612262                will(returnValue(3));
    22622263
    2263                 oneOf(annotationDao).getAccess(1, 3);
    2264                 will(returnValue(Access.WRITE));
     2264                oneOf(annotationDao).hasExplicitAccess(1, 3);
     2265                will(returnValue(true));
    22652266               
    22662267                oneOf(principalDao).getInternalIDFromHref(permissions.getPermission().get(2).getPrincipalHref());
    22672268                will(returnValue(4));
    22682269
    2269                 oneOf(annotationDao).getAccess(1, 4);
    2270                 will(returnValue(null));
    2271 
    2272                 oneOf(annotationDao).updateAnnotationPrincipalAccess(1, 3, Access.READ);
    2273                 will(returnValue(1));
    2274                
    2275                 oneOf(annotationDao).addAnnotationPrincipalAccess(1, 4, Access.READ);
    2276                 will(returnValue(1));
    2277 
    2278             }
    2279         });
    2280 
    2281         assertEquals(2, dbDispatcher.updatePermissions(1, permissions));
     2270                oneOf(annotationDao).hasExplicitAccess(1, 4);
     2271                will(returnValue(false));
     2272               
     2273                oneOf(annotationDao).updatePermission(1, 2, Access.WRITE);
     2274                will(returnValue(1));
     2275
     2276                oneOf(annotationDao).updatePermission(1, 3, Access.READ);
     2277                will(returnValue(1));
     2278               
     2279                oneOf(annotationDao).addPermission(1, 4, Access.READ);
     2280                will(returnValue(1));
     2281
     2282            }
     2283        });
     2284
     2285        assertEquals(3, dbDispatcher.updatePermissions(1, permissions));
    22822286
    22832287    }
     
    22932297            {
    22942298                /////
    2295                 oneOf(annotationDao).updatePublicAttribute(1, Access.NONE);
     2299                oneOf(annotationDao).updatePublicAccess(1, Access.NONE);
    22962300                will(returnValue(1));
    22972301
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDaoTest.java

    r5468 r5836  
    114114    public void testDeleteAnnotationPrinciplePermissions() {
    115115        System.out.println("test deleteAllAnnotationTargets");
    116         int result = jdbcAnnotationDao.deleteAnnotationPermissions(1);
     116        int result = jdbcAnnotationDao.deletePermissions(1);
    117117        assertEquals(3, result);
    118         assertEquals(0, jdbcAnnotationDao.deleteAnnotationPermissions(1));
     118        assertEquals(0, jdbcAnnotationDao.deletePermissions(1));
    119119    }
    120120
     
    123123    public void testAddAnnotationPrincipalAccess() {
    124124        System.out.println("test addAnnotationTargets");
    125         int result = jdbcAnnotationDao.addAnnotationPrincipalAccess(1, 1, Access.READ);
     125        int result = jdbcAnnotationDao.addPermission(1, 1, Access.READ);
    126126        assertEquals(1, result);
    127127    }
     
    226226        // to provide integrity, first delete rows in the joint tables
    227227        jdbcAnnotationDao.deleteAllAnnotationTarget(4);
    228         jdbcAnnotationDao.deleteAnnotationPermissions(4);
     228        jdbcAnnotationDao.deletePermissions(4);
    229229
    230230        assertEquals(1, jdbcAnnotationDao.deleteAnnotation(4));
     
    313313    public void testAnnotationIDsForPermission() {
    314314        System.out.println("test getAnnotationIDsForPermission");
    315         List<Number> result = jdbcAnnotationDao.getAnnotationIDsForPermission(1, Access.READ);
     315        List<Number> result = jdbcAnnotationDao.getAnnotationIDsPermissionAtLeast(1, Access.READ);
    316316        assertEquals(3, result.size());
    317317        assertEquals(2, result.get(0));
     
    319319        assertEquals(4, result.get(2));
    320320
    321         List<Number> resultTwo = jdbcAnnotationDao.getAnnotationIDsForPermission(1, Access.WRITE);
     321        List<Number> resultTwo = jdbcAnnotationDao.getAnnotationIDsPermissionAtLeast(1, Access.WRITE);
    322322        assertEquals(1, resultTwo.size());
    323323        assertEquals(4, resultTwo.get(0));
    324324
    325         List<Number> resultThree = jdbcAnnotationDao.getAnnotationIDsForPermission(1, Access.NONE);
     325        List<Number> resultThree = jdbcAnnotationDao.getAnnotationIDsPermissionAtLeast(1, Access.NONE);
    326326        assertEquals(0, resultThree.size());
    327327
     
    332332    public void testAnnotationIDsForPublicAccess() {
    333333        System.out.println("test getAnnotationIDsForPublicAccess");
    334         List<Number> result = jdbcAnnotationDao.getAnnotationIDsForPublicAccess(Access.READ);
     334        List<Number> result = jdbcAnnotationDao.getAnnotationIDsPublicAtLeast(Access.READ);
    335335        assertEquals(2, result.size());
    336336        assertTrue(result.contains(1));
    337337        assertTrue(result.contains(2));
    338338
    339         List<Number> resultTwo = jdbcAnnotationDao.getAnnotationIDsForPublicAccess(Access.WRITE);
     339        List<Number> resultTwo = jdbcAnnotationDao.getAnnotationIDsPublicAtLeast(Access.WRITE);
    340340        assertEquals(1, resultTwo.size());
    341341        assertEquals(1, resultTwo.get(0));
    342342
    343343
    344         List<Number> resultThree = jdbcAnnotationDao.getAnnotationIDsForPublicAccess(Access.NONE);
     344        List<Number> resultThree = jdbcAnnotationDao.getAnnotationIDsPublicAtLeast(Access.NONE);
    345345        assertEquals(2, resultThree.size());
    346346        assertTrue(resultThree.contains(3));
     
    362362        assertEquals(Access.READ, jdbcAnnotationDao.getAccess(1, 3));
    363363        assertEquals(Access.WRITE, jdbcAnnotationDao.getAccess(2, 3));
    364         assertEquals(null, jdbcAnnotationDao.getAccess(3, 3));
     364        assertEquals(Access.NONE, jdbcAnnotationDao.getAccess(3, 3));
    365365    }
    366366
     
    449449        System.out.println("test updateAnntationPrincipalAccess ");
    450450
    451         int result = jdbcAnnotationDao.updateAnnotationPrincipalAccess(1, 2, Access.NONE);
     451        int result = jdbcAnnotationDao.updatePermission(1, 2, Access.NONE);
    452452        assertEquals(1, result);
    453453        assertEquals(Access.NONE, jdbcAnnotationDao.getAccess(1, 2));
     
    458458        System.out.println("test updatePublicAtribute ");
    459459
    460         int result = jdbcAnnotationDao.updatePublicAttribute(1, Access.NONE);
     460        int result = jdbcAnnotationDao.updatePublicAccess(1, Access.NONE);
    461461        assertEquals(1, result);
    462462        assertEquals(Access.NONE, jdbcAnnotationDao.getPublicAttribute(1));
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java

    r5774 r5836  
    2121import eu.dasish.annotation.backend.NotInDataBaseException;
    2222import eu.dasish.annotation.backend.Resource;
    23 import eu.dasish.annotation.backend.ResourceAction;
    2423import eu.dasish.annotation.backend.dao.DBDispatcher;
    2524import eu.dasish.annotation.backend.TestInstances;
     
    107106
    108107
    109                 oneOf(mockDbDispatcher).canDo(ResourceAction.READ, 3, 1, Resource.ANNOTATION);
     108                oneOf(mockDbDispatcher).canDo(Access.READ, 3, 1, Resource.ANNOTATION);
    110109                will(returnValue(true));
    111110
     
    152151                will(returnValue(3));
    153152               
    154                 oneOf(mockDbDispatcher).canDo(ResourceAction.DELETE, 3, 4, Resource.ANNOTATION);
     153                oneOf(mockDbDispatcher).canDo(Access.ALL, 3, 4, Resource.ANNOTATION);
    155154                will(returnValue(true));
    156155
     
    276275                will(returnValue(1));
    277276               
    278                 oneOf(mockDbDispatcher).canDo(ResourceAction.WRITE, 1, 1, Resource.ANNOTATION);
     277                oneOf(mockDbDispatcher).canDo(Access.WRITE, 1, 1, Resource.ANNOTATION);
    279278                will(returnValue(true));
    280279               
     
    344343                will(returnValue(1));
    345344               
    346                 oneOf(mockDbDispatcher).canDo(ResourceAction.WRITE, 1, 1, Resource.ANNOTATION);
     345                oneOf(mockDbDispatcher).canDo(Access.WRITE, 1, 1, Resource.ANNOTATION);
    347346                will(returnValue(true));               
    348347               
     
    397396                will(returnValue(1));
    398397               
    399                 oneOf(mockDbDispatcher).canDo(ResourceAction.WRITE, 1, 1, Resource.ANNOTATION);
     398                oneOf(mockDbDispatcher).canDo(Access.WRITE, 1, 1, Resource.ANNOTATION);
    400399                will(returnValue(true));               
    401400               
Note: See TracChangeset for help on using the changeset viewer.