Changeset 5774 for DASISH


Ignore:
Timestamp:
11/05/14 14:32:51 (10 years ago)
Author:
olhsha@mpi.nl
Message:

updating annotations: if the current user is not owner then the permission part is ignored

Location:
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend
Files:
13 edited

Legend:

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

    r5755 r5774  
    6161class is corrected (cachedRepresentatinons --> cachedRepresentations).
    6262
     63October 31, 2014. This is a package for webannotator of shibbolized version for lux17,
     64sych with the basic authenticated version.
    6365
     66
     67
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/UPDATE.txt

    r5755 r5774  
    11
    2 Placing tarball: take the tar-ball of the new  version 1.5.4-basic, and follow the
     2Placing tarball: take the tar-ball of the new  version 1.5.4-shibboleth, and follow the
    33standard MPI deployment procedure. 
    44
    5 This is is a simple update due to fixing a spelling error in the DASISHschema.
     5This is synchronisation of the shibbolized-authenticated version of the backend
     6to the basic-authnticated, so both versions are complyiant with the same schema.
     7
     8
    69
    710
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml

    r5755 r5774  
    55    <groupId>eu.dasish.annotation</groupId>
    66    <artifactId>annotator-backend</artifactId>
    7     <version>1.5.4-basic</version>   
     7    <version>1.5.4-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/Helpers.java

    r5393 r5774  
    106106                + remoteID + ".<br>"
    107107                + "<h3>Welcome to DASISH Webannotator (DWAN)</h3><br>"
    108                 + "<a href=\"" + baseUri + "\"> To DWAN's test jsp page</a>"
     108                + "<a href=\"" + baseUri + "\"> To DWAN REST overview page</a>"
    109109                + "</body>";
    110110        return welcome;
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DBDispatcher.java

    r5686 r5774  
    226226     * @return 1 of the annotation if it is updated
    227227     */
    228     int updateAnnotation(Annotation annotation) throws NotInDataBaseException;
     228    int updateAnnotation(Annotation annotation, String remoteUser) throws NotInDataBaseException;
    229229
    230230    /**
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherImlp.java

    r5755 r5774  
    697697
    698698    @Override
    699     public int updateAnnotation(Annotation annotation) throws NotInDataBaseException {
     699    public int updateAnnotation(Annotation annotation, String remoteUser) throws NotInDataBaseException {
    700700        Number annotationID = annotationDao.getInternalID(UUID.fromString(annotation.getId()));
    701         int updatedAnnotations = annotationDao.updateAnnotation(annotation, annotationID, principalDao.getInternalIDFromHref(annotation.getOwnerHref()));
     701        Number ownerID = principalDao.getInternalIDFromHref(annotation.getOwnerHref());
     702        int updatedAnnotations = annotationDao.updateAnnotation(annotation, annotationID, ownerID);
    702703        int deletedTargets = annotationDao.deleteAllAnnotationTarget(annotationID);
    703         int deletedPrinsipalsAccesss = annotationDao.deleteAnnotationPermissions(annotationID);
    704704        int addedTargets = this.addTargets(annotation, annotationID);
    705         int addedPrincipalsAccesss = this.addPermissions(annotation.getPermissions().getPermission(), annotationID);
    706         int updatedPublicAttribute = annotationDao.updatePublicAttribute(annotationID, annotation.getPermissions().getPublic());
     705       
     706        Number remoteUserID = principalDao.getPrincipalInternalIDFromRemoteID(remoteUser);
     707       
     708        if (ownerID.equals(remoteUserID)) {
     709            int deletedPrinsipalsAccesss = annotationDao.deleteAnnotationPermissions(annotationID);
     710            int addedPrincipalsAccesss = this.addPermissions(annotation.getPermissions().getPermission(), annotationID);
     711            int updatedPublicAttribute = annotationDao.updatePublicAttribute(annotationID, annotation.getPermissions().getPublic());
     712        };
    707713        return updatedAnnotations;
    708714    }
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java

    r5686 r5774  
    345345        try {
    346346            Map params = new HashMap();
     347           
    347348            params.put("annotation", annotation);
    348             ResponseBody result = (ResponseBody) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateAnnotation(), Resource.ANNOTATION, ResourceAction.WRITE_W_METAINFO, externalId);
     349            params.put("remoteUser",httpServletRequest.getRemoteUser());
     350            ResponseBody result = (ResponseBody) (new RequestWrappers(this)).wrapRequestResource(params, new UpdateAnnotation(), Resource.ANNOTATION, ResourceAction.WRITE, externalId);
    349351            if (result != null) {
    350352                return (new ObjectFactory()).createResponseBody(result);
    351             } else {
     353            }
     354            else {
    352355                return (new ObjectFactory()).createResponseBody(new ResponseBody());
    353356            }
     
    368371            Annotation annotation = (Annotation) params.get("annotation");
    369372            Number annotationID = (Number) params.get("internalID");
    370             int updatedRows = dbDispatcher.updateAnnotation(annotation);
     373            String remoteUser = (String) params.get("remoteUser");
     374            int updatedRows = dbDispatcher.updateAnnotation(annotation, remoteUser);
    371375            return dbDispatcher.makeAnnotationResponseEnvelope(annotationID);
    372376        }
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AutheticationResource.java

    r5385 r5774  
    8181        httpServletRequest.getSession().invalidate();
    8282        boolean isShibboleth = Boolean.parseBoolean(context.getInitParameter("eu.dasish.annotation.backend.isShibbolethSession"));
    83         String redirect = isShibboleth ? context.getInitParameter("eu.dasish.annotation.backend.logout") :
    84                 httpServletRequest.getContextPath() + context.getInitParameter("eu.dasish.annotation.backend.logout");       
     83        String redirect = isShibboleth ? context.getInitParameter("eu.dasish.annotation.backend.logout.shibboleth") :
     84                httpServletRequest.getContextPath() + context.getInitParameter("eu.dasish.annotation.backend.logout.basic");       
    8585        httpServletResponse.sendRedirect(redirect);
    8686    }
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/shhaa.xml

    r4969 r5774  
    3838                <username>anonymous</username>
    3939            </fallback>
    40             <sso action="lI">https://lux16.mpi.nl/Shibboleth.sso/Login</sso>
    41             <slo action="lO">https://lux16.mpi.nl/Shibboleth.sso/Logout</slo>
     40            <sso action="lI">https://lux17.mpi.nl/Shibboleth.sso/Login</sso>
     41            <slo action="lO">https://lux17.mpi.nl/Shibboleth.sso/Logout</slo>
    4242        </authentication>
    4343       
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/web.xml

    r5755 r5774  
    4040    <context-param>
    4141        <param-name>eu.dasish.annotation.backend.isShibbolethSession</param-name>
    42         <param-value>false</param-value>
     42        <param-value>true</param-value>
    4343    </context-param>
    4444    <context-param>
    45         <param-name>eu.dasish.annotation.backend.logout</param-name>
     45        <param-name>eu.dasish.annotation.backend.logout.basic</param-name>
    4646        <param-value>/j_spring_security_logout</param-value>
    4747    </context-param>
    48    
     48    <context-param>
     49        <param-name>eu.dasish.annotation.backend.logout.shibboleth</param-name>
     50        <param-value>https://lux17.mpi.nl/Shibboleth.sso/Logout</param-value>
     51    </context-param>
    4952   
    5053    <listener>
     
    108111   
    109112    <!-- Spring security -->
    110      <filter>
     113     <!-- <filter>
    111114        <filter-name>springSecurityFilterChain</filter-name>
    112115        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
     
    115118        <filter-name>springSecurityFilterChain</filter-name>
    116119        <url-pattern>/*</url-pattern>
    117     </filter-mapping>
     120    </filter-mapping> -->
    118121   
    119      <!--  Shibboleth filter -->
    120    <!--<filter>
     122    <!--  Shibboleth filter -->
     123   <filter>
    121124        <filter-name>AAIFilter</filter-name>
    122125        <filter-class>de.mpg.aai.shhaa.AuthFilter</filter-class>
     
    125128        <filter-name>AAIFilter</filter-name>
    126129        <url-pattern>/*</url-pattern>
    127     </filter-mapping> -->
     130    </filter-mapping>
    128131   
    129132  </web-app> 
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherTest.java

    r5686 r5774  
    21142114
    21152115
    2116                 /// adding the first target, nt foind in the DB
     2116                /// adding the first target, not found in the DB
    21172117
    21182118                oneOf(targetDao).getInternalIDFromHref(annotation.getTargets().getTargetInfo().get(0).getHref());
     
    21342134                oneOf(annotationDao).addAnnotationTarget(1, 2);
    21352135                will(returnValue(1));
     2136               
     2137                /////
     2138               
     2139                oneOf(principalDao).getPrincipalInternalIDFromRemoteID("userello");
     2140                will(returnValue(1));
    21362141
    21372142                /////
     
    21622167            }
    21632168        });
    2164         assertEquals(1, dbDispatcher.updateAnnotation(annotation));
     2169        assertEquals(1, dbDispatcher.updateAnnotation(annotation, "userello"));
    21652170    }
    21662171
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java

    r5685 r5774  
    276276                will(returnValue(1));
    277277               
    278                 oneOf(mockDbDispatcher).canDo(ResourceAction.WRITE_W_METAINFO, 1, 1, Resource.ANNOTATION);
     278                oneOf(mockDbDispatcher).canDo(ResourceAction.WRITE, 1, 1, Resource.ANNOTATION);
    279279                will(returnValue(true));
    280280               
    281                 oneOf(mockDbDispatcher).updateAnnotation(annotation);
     281                oneOf(mockDbDispatcher).updateAnnotation(annotation, "twagoo@mpi.nl");
    282282                will(returnValue(1));
    283283               
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationsTest.java

    r5385 r5774  
    252252        assertEquals("text/plain", entityA.getBody().getTextBody().getMimeType());
    253253        assertEquals("updated annotation 1", entityA.getHeadline());
    254         assertEquals(2, entityA.getPermissions().getPermission().size());
    255         assertEquals(Access.READ, entityA.getPermissions().getPublic());
    256         assertEquals(_relativePath + "/principals/00000000-0000-0000-0000-000000000111", entityA.getOwnerHref());
    257         assertEquals("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#de_Opdracht", entityA.getTargets().getTargetInfo().get(0).getLink());
    258         assertEquals(_relativePath+ "/targets/00000000-0000-0000-0000-000000000031", entityA.getTargets().getTargetInfo().get(0).getHref());
    259        
     254        assertEquals(3, entityA.getPermissions().getPermission().size());
     255//        assertEquals(Access.READ, entityA.getPermissions().getPublic());
     256//        assertEquals(_relativePath + "/principals/00000000-0000-0000-0000-000000000111", entityA.getOwnerHref());
     257//        assertEquals("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#de_Opdracht", entityA.getTargets().getTargetInfo().get(0).getLink());
     258//        assertEquals(_relativePath+ "/targets/00000000-0000-0000-0000-000000000031", entityA.getTargets().getTargetInfo().get(0).getHref());
     259//       
    260260    }
    261261   
Note: See TracChangeset for help on using the changeset viewer.