Changeset 5203


Ignore:
Timestamp:
05/15/14 17:35:14 (10 years ago)
Author:
olhsha@mpi.nl
Message:

Fixing small bug: url-encoding with omitting /. Optimisation of filtered annotation search

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

Legend:

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

    r4956 r5203  
    2525April 7/04. 1) Added automated generation of the default record for a shibollized principal, if his/her record not in DB yet. However, to customise the record, the principal has to ask the database admin.  2) Added attribute “public” to permission lists. The database is changed so that the column “public” is added to the table annotation. 3) Attribute and element banes, and the names of their values are simplified.  The corresponding tables and columns are renamed. 4) Using “null” as the intended value when a resource is not found is replaced with throwing an exception.
    2626
    27 April 11 2014. fixed bug: posting cached representations did now work. Added features: updating blob of the cached, updating its metadata, updating fragment connecting a target and its cached.
     27April 11 2014. fixed bug: posting cached representations did now work. Added features: updating blob of the cached, updating its metadata,
     28updating fragment connecting a target and its cached.
     29
     30May 15, 2014. Added validation (via the schem on SCHEMAcat) of the xmls sent by client. Refactoring.
     31fixing busg with escape symbols and URL encoding of them.
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/UPDATE.txt

    r4956 r5203  
    1 1. Placing tarball: as always, take the tar-ball of the new  version 1.3.2, and follow the
     11. Placing tarball: as always, take the tar-ball of the new  version 1.4, and follow the
    22standard MPI deployment procedure.  Consult the instructions from INSTALL.txt
    33about placing war file if you have forgotten.
    44
    5 2. Adjusting shhaa.xml, database, web.xml this time are not necessary this time. It was just an urgent bug fix in some posting request.
     52. Adjusting shhaa.xml, database, web.xml this time are not necessary. OR if you want to reuse
     6this tarball to deploy shibbolized version you need to change web.xml
     7
     82.1. Comment  <filter>
     9        <filter-name>AAIFilter</filter-name>
     10        <filter-class>de.mpg.aai.shhaa.AuthFilter</filter-class>
     11    </filter>
     12    <filter-mapping>
     13        <filter-name>AAIFilter</filter-name>
     14        <url-pattern>/*</url-pattern>
     15    </filter-mapping>
     16   
     17    and uncomment
     18   
     19     <filter>
     20        <filter-name>springSecurityFilterChain</filter-name>
     21        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
     22    </filter>
     23    <filter-mapping>
     24        <filter-name>springSecurityFilterChain</filter-name>
     25        <url-pattern>/*</url-pattern>
     26    </filter-mapping>
     27   
     28   
     29    2.2. Comment  <param-value>/ds/webannotator/j_spring_security_logout</param-value> and uncomment
     30    <param-value>/ds/webannotator?shhaaDo=lO</param-value>
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml

    r5174 r5203  
    363363        <netbeans.hint.license>gpl20</netbeans.hint.license> 
    364364        <plugin.license.copyrightYear>2013</plugin.license.copyrightYear>
    365         <project.version>1.3.5</project.version>
     365        <project.version>1.4</project.version>
    366366        <shibboleth.version>1.0.4</shibboleth.version>
    367367    </properties>
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherImlp.java

    r5186 r5203  
    211211
    212212
    213         // Filetring on accessMode
     213        // Filetring on accessMode, the junction table
    214214        if (annotationIDs != null) {
    215215            if (!annotationIDs.isEmpty()) {
     
    218218                    List<Number> annotationIDsAccess = annotationDao.getAnnotationIDsForPermission(inloggedPrincipalID, access);
    219219                    List<Number> annotationIDsPublic = annotationDao.getAnnotationIDsForPublicAccess(access);
    220                     List<Number> annotationIDsOwned = annotationDao.getFilteredAnnotationIDs(inloggedPrincipalID, null, null, null, null);
     220                    List<Number> annotationIDsOwned = annotationDao.getFilteredAnnotationIDs(inloggedPrincipalID, text, namespace, after, before);
    221221                    int check1 = this.addAllNoRepetitions(annotationIDsAccess, annotationIDsPublic);
    222222                    int check2 = this.addAllNoRepetitions(annotationIDsAccess, annotationIDsOwned);
    223                     annotationIDs.retainAll(annotationIDsAccess);
     223                    annotationIDs.retainAll(annotationIDsAccess);// intersection
    224224                }
    225225            }
     
    238238            if (!linkSubstring.isEmpty()) {
    239239                if (annotationIDs != null) {
     240                    String partiallyEncoded = this.encodeURLNoSlashEncoded(linkSubstring);
     241                    String urlEncoded = null;
     242                    try {
     243                        urlEncoded = URLEncoder.encode(linkSubstring, "UTF-8");
     244                    } catch (UnsupportedEncodingException e) {
     245                        logger.debug(e.toString());
     246                    }
     247
    240248                    List<Number> result = new ArrayList();
    241249                    for (Number annotationID : annotationIDs) {
     
    244252                            if (!result.contains(annotationID)) {
    245253                                String link = targetDao.getLink(targetID);
    246                                 if (link.contains(linkSubstring)) {
     254                                if (link.contains(linkSubstring) || link.contains(partiallyEncoded)) {
    247255                                    result.add(annotationID);
    248256                                } else {
    249                                     try {
    250                                         String urlEncoded = URLEncoder.encode(linkSubstring, "UTF-8");
     257                                    if (urlEncoded != null) {
    251258                                        if (link.contains(urlEncoded)) {
    252259                                            result.add(annotationID);
    253260                                        }
    254                                     } catch (UnsupportedEncodingException e) {
    255                                         logger.debug(e.toString());
    256261                                    }
    257262                                }
     
    284289        }
    285290        return result;
     291    }
     292
     293    private String encodeURLNoSlashEncoded(String string) {
     294        String[] split = string.split("/");
     295        StringBuilder result = new StringBuilder(split[0]);
     296        for (int i = 1; i < split.length; i++) {
     297            try {
     298                result.append("/").append(URLEncoder.encode(split[i], "UTF-8"));
     299            } catch (UnsupportedEncodingException e) {
     300                result.append("/").append(split[i]);
     301                logger.debug(e.toString());
     302            }
     303        }
     304        return result.toString();
    286305    }
    287306
     
    648667// TODO: optimize (not chnanged targets should not be deleted)
    649668// TODO: unit test
     669
    650670    @Override
    651671    public int updateAnnotation(Annotation annotation) throws NotInDataBaseException {
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcTargetDao.java

    r5138 r5203  
    2222import eu.dasish.annotation.schema.Target;
    2323import eu.dasish.annotation.schema.TargetInfo;
    24 import java.io.UnsupportedEncodingException;
    25 import java.net.URLEncoder;
    2624import java.sql.ResultSet;
    2725import java.sql.SQLException;
     
    4442
    4543    private final Logger loggerTargetDao = LoggerFactory.getLogger(JdbcTargetDao.class);
    46     private final String encoding = "ISO-8859-1";
    47 
     44   
    4845    public JdbcTargetDao(DataSource dataTarget) {
    4946        setDataSource(dataTarget);
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/web.xml

    r5174 r5203  
    4747        <param-name>eu.dasish.annotation.backend.logout</param-name>
    4848<!--        <param-value>/ds/webannotator?shhaaDo=lO</param-value>-->
    49 <!--       <param-value>/ds/webannotator/j_spring_security_logout</param-value>-->
    50          <param-value>/annotator-backend/j_spring_security_logout</param-value>
     49        <param-value>/ds/webannotator/j_spring_security_logout</param-value>
     50 <!--       <param-value>/annotator-backend/j_spring_security_logout</param-value> -->
    5151    </context-param>
    5252   
     
    107107    </security-role> -->
    108108   
    109  <!-- Spring security -->
     109    <!-- Spring security -->
    110110    <filter>
    111111        <filter-name>springSecurityFilterChain</filter-name>
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBDispatcherTest.java

    r5186 r5203  
    305305     
    306306        final List<Number> mockAnnotationIDsOwned = new ArrayList<Number>();
    307         mockAnnotationIDsOwned.add(3);
     307        //mockAnnotationIDsOwned.add(3);
    308308
    309309        final List<Number> mockAnnotationIDsRead = new ArrayList<Number>();
     
    342342                will(returnValue(mockAnnotationIDsPublicRead));               
    343343
    344                 oneOf(annotationDao).getFilteredAnnotationIDs(loggedIn, null, null, null, null);
     344                oneOf(annotationDao).getFilteredAnnotationIDs(loggedIn, "some html 1", null, after, before);
    345345                will(returnValue(mockAnnotationIDsOwned));
    346346               
     
    374374     
    375375        final List<Number> mockAnnotationIDsOwned = new ArrayList<Number>();
    376         mockAnnotationIDsOwned.add(3);
     376        //mockAnnotationIDsOwned.add(3);
    377377
    378378        final List<Number> mockAnnotationIDsWrite = new ArrayList<Number>();
     
    409409                will(returnValue(mockAnnotationIDsPublicWrite));               
    410410
    411                 oneOf(annotationDao).getFilteredAnnotationIDs(loggedIn, null, null, null, null);
     411                oneOf(annotationDao).getFilteredAnnotationIDs(loggedIn, "some html 1", null, after, before);
    412412                will(returnValue(mockAnnotationIDsOwned));
    413413               
     
    538538
    539539        final List<Number> mockAnnotationIDsOwned = new ArrayList<Number>();
    540         mockAnnotationIDsOwned.add(3);
     540        //mockAnnotationIDsOwned.add(3);
    541541
    542542        final List<Number> mockAnnotationIDsRead = new ArrayList<Number>();
     
    578578
    579579             
    580 
    581580                oneOf(annotationDao).getFilteredAnnotationIDs(1, "some html 1", null, after, before);
    582581                will(returnValue(mockAnnotationIDs1));
     
    589588             
    590589
    591                 oneOf(annotationDao).getFilteredAnnotationIDs(loggedIn, null, null, null, null);
     590                oneOf(annotationDao).getFilteredAnnotationIDs(3, "some html 1", null, after, before);
    592591                will(returnValue(mockAnnotationIDsOwned));
    593592
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationsTest.java

    r5174 r5203  
    182182     */
    183183    @Test
    184     @Ignore
    185184    public void testCreateAnnotation() throws NotInDataBaseException, IOException{
    186185       
Note: See TracChangeset for help on using the changeset viewer.