chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1387308 - in /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools: scripts/ src/main/java/org/apache/chemistry/opencmis/tools/filecopy/ src/main/java/org/apache/chemistry/opencmis/tools/mapper/ src/main/java/org/...
Date Tue, 18 Sep 2012 18:35:12 GMT
Author: jens
Date: Tue Sep 18 18:35:11 2012
New Revision: 1387308

URL: http://svn.apache.org/viewvc?rev=1387308&view=rev
Log:
cmis test tool: couple of minor bug fixes in property mapper 

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/scripts/testtool.classpath.sh
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/filecopy/FileCopier.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/AbstractMetadataParser.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParser.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParserExif.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParserTika.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/scripts/testtool.classpath.sh
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/scripts/testtool.classpath.sh?rev=1387308&r1=1387307&r2=1387308&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/scripts/testtool.classpath.sh
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/scripts/testtool.classpath.sh
Tue Sep 18 18:35:11 2012
@@ -18,19 +18,20 @@ $M2_REPO/org/apache/chemistry/opencmis/c
 $M2_REPO/org/apache/chemistry/opencmis/chemistry-opencmis-commons-api/$VER/chemistry-opencmis-commons-api-$VER.jar:\
 $M2_REPO/org/apache/chemistry/opencmis/chemistry-opencmis-commons-impl/$VER/chemistry-opencmis-commons-impl-$VER.jar:\
 $M2_REPO/org/apache/chemistry/opencmis/chemistry-opencmis-test-util/$VER/chemistry-opencmis-test-util-$VER.jar:\
+$M2_REPO/org/apache/chemistry/opencmis/chemistry-opencmis-test-tools/$VER/chemistry-opencmis-test-tools-$VER.jar:\
 $M2_REPO/commons-codec/commons-codec/1.5/commons-codec-1.5.jar:\
-$M2_REPO/org/apache/commons/commons-compress/1.3/commons-compress-1.3.jar:\
+$M2_REPO/org/apache/commons/commons-compress/1.4.1/commons-compress-1.4.1.jar:\
 $M2_REPO/commons-io/commons-io/2.0.1/commons-io-2.0.1.jar:\
 $M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:\
 $M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:\
-$M2_REPO/org/apache/pdfbox/fontbox/1.6.0/fontbox-1.6.0.jar:\
+$M2_REPO/org/apache/pdfbox/fontbox/1.7.0/fontbox-1.7.0.jar:\
 $M2_REPO/org/apache/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1.jar:\
-$M2_REPO/com/googlecode/mp4parser/isoparser/1.0-beta-5/isoparser-1.0-beta-5.jar:\
+$M2_REPO/com/googlecode/mp4parser/isoparser/1.0-RC-1/isoparser-1.0-RC-1.jar:\
 $M2_REPO/javassist/javassist/3.6.0.GA/javassist-3.6.0.GA.jar:\
 $M2_REPO/com/sun/xml/bind/jaxb-impl/2.1.11/jaxb-impl-2.1.11.jar:\
 $M2_REPO/com/sun/xml/ws/jaxws-rt/2.1.7/jaxws-rt-2.1.7.jar:\
 $M2_REPO/jdom/jdom/1.0/jdom-1.0.jar:\
-$M2_REPO/org/apache/pdfbox/jempbox/1.6.0/jempbox-1.6.0.jar:\
+$M2_REPO/org/apache/pdfbox/jempbox/1.7.0/jempbox-1.7.0.jar:\
 $M2_REPO/net/sf/jopt-simple/jopt-simple/3.2/jopt-simple-3.2.jar:\
 $M2_REPO/junit/junit/4.7/junit-4.7.jar:\
 $M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16.jar:\
@@ -38,25 +39,27 @@ $M2_REPO/com/drewnoakes/metadata-extract
 $M2_REPO/org/jvnet/mimepull/1.3/mimepull-1.3.jar:\
 $M2_REPO/edu/ucar/netcdf/4.2-min/netcdf-4.2-min.jar:\
 $M2_REPO/org/apache/felix/org.osgi.core/1.0.0/org.osgi.core-1.0.0.jar:\
-$M2_REPO/org/apache/pdfbox/pdfbox/1.6.0/pdfbox-1.6.0.jar:\
-$M2_REPO/org/apache/poi/poi/3.8-beta5/poi-3.8-beta5.jar:\
-$M2_REPO/org/apache/poi/poi-ooxml/3.8-beta5/poi-ooxml-3.8-beta5.jar:\
-$M2_REPO/org/apache/poi/poi-ooxml-schemas/3.8-beta5/poi-ooxml-schemas-3.8-beta5.jar:\
-$M2_REPO/org/apache/poi/poi-scratchpad/3.8-beta5/poi-scratchpad-3.8-beta5.jar:\
+$M2_REPO/org/apache/pdfbox/pdfbox/1.7.0/pdfbox-1.7.0.jar:\
+$M2_REPO/org/apache/poi/poi/3.8/poi-3.8.jar:\
+$M2_REPO/org/apache/poi/poi-ooxml/3.8/poi-ooxml-3.8.jar:\
+$M2_REPO/org/apache/poi/poi-ooxml-schemas/3.8/poi-ooxml-schemas-3.8.jar:\
+$M2_REPO/org/apache/poi/poi-scratchpad/3.8/poi-scratchpad-3.8.jar:\
 $M2_REPO/com/sun/org/apache/xml/internal/resolver/20050927/resolver-20050927.jar:\
 $M2_REPO/rome/rome/0.9/rome-0.9.jar:\
 $M2_REPO/com/sun/xml/messaging/saaj/saaj-impl/1.3.3/saaj-impl-1.3.3.jar:\
 $M2_REPO/net/sf/scannotation/scannotation/1.0.2/scannotation-1.0.2.jar:\
-$M2_REPO/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4.jar:\
-$M2_REPO/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4.jar:\
+$M2_REPO/org/slf4j/slf4j-api/1.6.6/slf4j-api-1.6.6.jar:\
+$M2_REPO/org/slf4j/slf4j-log4j12/1.6.6/slf4j-log4j12-1.6.6.jar:\
 $M2_REPO/stax/stax-api/1.0.1/stax-api-1.0.1.jar:\
 $M2_REPO/org/jvnet/staxex/stax-ex/1.2/stax-ex-1.2.jar:\
 $M2_REPO/com/sun/xml/stream/buffer/streambuffer/0.9/streambuffer-0.9.jar:\
 $M2_REPO/org/ccil/cowan/tagsoup/tagsoup/1.2.1/tagsoup-1.2.1.jar:\
-$M2_REPO/org/apache/tika/tika-core/1.1/tika-core-1.1.jar:\
-$M2_REPO/org/apache/tika/tika-parsers/1.1/tika-parsers-1.1.jar:\
+$M2_REPO/org/apache/tika/tika-core/1.2/tika-core-1.2.jar:\
+$M2_REPO/org/apache/tika/tika-parsers/1.2/tika-parsers-1.2.jar:\
 $M2_REPO/org/gagravarr/vorbis-java-core/0.1/vorbis-java-core-0.1-tests.jar:\
+$M2_REPO/org/aspectj/aspectjrt/1.6.11/aspectjrt-1.6.11.jar:\
 $M2_REPO/org/gagravarr/vorbis-java-core/0.1/vorbis-java-core-0.1.jar:\
 $M2_REPO/org/gagravarr/vorbis-java-tika/0.1/vorbis-java-tika-0.1.jar:\
 $M2_REPO/org/codehaus/woodstox/wstx-asl/3.2.3/wstx-asl-3.2.3.jar:\
-$M2_REPO/org/apache/xmlbeans/xmlbeans/2.3.0/xmlbeans-2.3.0.jar"
+$M2_REPO/org/apache/xmlbeans/xmlbeans/2.3.0/xmlbeans-2.3.0.jar:\
+$M2_REPO/org/tukaani/xz/1.0/xz-1.0.jar"
\ No newline at end of file

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/filecopy/FileCopier.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/filecopy/FileCopier.java?rev=1387308&r1=1387307&r2=1387308&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/filecopy/FileCopier.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/filecopy/FileCopier.java
Tue Sep 18 18:35:11 2012
@@ -26,7 +26,6 @@ import java.util.Map;
 
 import org.apache.chemistry.opencmis.client.api.Document;
 import org.apache.chemistry.opencmis.client.api.Folder;
-import org.apache.chemistry.opencmis.client.api.ObjectId;
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.client.api.SessionFactory;
 import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
@@ -39,15 +38,16 @@ import org.apache.chemistry.opencmis.too
 import org.apache.chemistry.opencmis.tools.mapper.PropertyMapper;
 import org.apache.chemistry.opencmis.tools.parser.MetadataParser;
 import org.apache.chemistry.opencmis.tools.parser.MetadataParserTika;
+import org.apache.tika.Tika;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.tika.Tika;
     
 public class FileCopier {
     
     private static final Logger LOG = LoggerFactory.getLogger(FileCopier.class.getName());
     // initialize configurator to get parsers and property mappings
     private static final Configurator CFG = Configurator.getInstance(); 
+    private static int TOTAL_NUM = 0;
     
     private Session session;
     
@@ -122,7 +122,7 @@ public class FileCopier {
                     throw new MapperException("CMIS type " + typeId + " does not exist on
server.");
 
                 LOG.info("Detected MIME type: "+ mimeType + " is mapped to CMIS type id:
" + td.getId());
-                parser.extractMetadata(f, td);
+                parser.extractMetadata(f, td, session);
                 properties = parser.getCmisProperties();
             }
                         
@@ -146,6 +146,7 @@ public class FileCopier {
             
             id = doc.getId();
             LOG.info("New document created with id: " + id + ", name: " +  properties.get(PropertyIds.NAME)
+ " in folder: " + parentFolder.getId());
+            LOG.debug("total number of creations : " + ++TOTAL_NUM);
         } catch (Exception e) {
             LOG.error("Failed to create CMIS document.", e);
         } finally {
@@ -215,7 +216,7 @@ public class FileCopier {
                     	LOG.info("Detected MIME type: "+ mimeType + " is mapped to CMIS type
id: " + td.getId());
                 }
                 
-                parser.extractMetadata(f, td);
+                parser.extractMetadata(f, td, session);
                 Map<String, Object> properties = parser.getCmisProperties();
                 for (String key : properties.keySet()) {
                     LOG.info("Found metadata tag " + key + "mapped to " + properties.get(key));

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java?rev=1387308&r1=1387307&r2=1387308&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/mapper/PropertyMapperExif.java
Tue Sep 18 18:35:11 2012
@@ -152,12 +152,12 @@ public class PropertyMapperExif extends 
         if (GpsDirectory.class.equals(dir.getClass())) {
             // first check for those tags that need special consideration:
             if ( GpsDirectory.TAG_GPS_LONGITUDE == tag.getTagType()) {
-                Object ref = dir.getObject(GpsDirectory.TAG_GPS_DEST_LONGITUDE_REF);
-                boolean mustInv = ref != null && ref.equals('W');
+                Object ref = dir.getObject(GpsDirectory.TAG_GPS_LONGITUDE_REF);
+                boolean mustInv = ref != null && ref.equals("W");
                 return convertGps(tag, dir, mustInv);
             } else if ( GpsDirectory.TAG_GPS_LATITUDE == tag.getTagType()) {
-                Object ref = dir.getObject(GpsDirectory.TAG_GPS_DEST_LONGITUDE_REF);
-                boolean mustInv = ref != null && ref.equals('S');
+                Object ref = dir.getObject(GpsDirectory.TAG_GPS_LONGITUDE_REF);
+                boolean mustInv = ref != null && ref.equals("S");
                 return convertGps(tag, dir, mustInv);
             } else {
                 String propId = propMapGps.get(hexStr);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/AbstractMetadataParser.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/AbstractMetadataParser.java?rev=1387308&r1=1387307&r2=1387308&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/AbstractMetadataParser.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/AbstractMetadataParser.java
Tue Sep 18 18:35:11 2012
@@ -21,6 +21,7 @@ package org.apache.chemistry.opencmis.to
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.tools.mapper.MapperException;
 import org.apache.chemistry.opencmis.tools.mapper.PropertyMapper;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParser.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParser.java?rev=1387308&r1=1387307&r2=1387308&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParser.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParser.java
Tue Sep 18 18:35:11 2012
@@ -21,6 +21,7 @@ package org.apache.chemistry.opencmis.to
 import java.io.File;
 import java.util.Map;
 
+import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.tools.mapper.MapperException;
 import org.apache.chemistry.opencmis.tools.mapper.PropertyMapper;
@@ -57,7 +58,7 @@ public interface MetadataParser {
      *      file to parse
      * @throws MapperException
      */
-    void extractMetadata(File f, TypeDefinition td) throws MapperException;
+    void extractMetadata(File f, TypeDefinition td, Session session) throws MapperException;
     
     /**
      * Return all found metadata, called after parsing is completed.

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParserExif.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParserExif.java?rev=1387308&r1=1387307&r2=1387308&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParserExif.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParserExif.java
Tue Sep 18 18:35:11 2012
@@ -22,6 +22,7 @@ import java.io.File;
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.tools.mapper.MapperException;
 import org.apache.chemistry.opencmis.tools.mapper.PropertyMapperExif;
@@ -44,7 +45,7 @@ public class MetadataParserExif extends 
 
     private static final Logger LOG = LoggerFactory.getLogger(MetadataParserExif.class.getName());
     
-    public void extractMetadata(File f, TypeDefinition td) throws MapperException {
+    public void extractMetadata(File f, TypeDefinition td, Session session) throws MapperException
{
         
         reset();
         

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParserTika.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParserTika.java?rev=1387308&r1=1387307&r2=1387308&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParserTika.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/parser/MetadataParserTika.java
Tue Sep 18 18:35:11 2012
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
+import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.PropertyType;
@@ -43,11 +44,12 @@ import org.xml.sax.helpers.DefaultHandle
 public class MetadataParserTika extends AbstractMetadataParser {
 
     private static final Logger LOG = LoggerFactory.getLogger(MetadataParserTika.class.getName());
+    private Session session;
 
-    public MetadataParserTika() {        
+    public MetadataParserTika() {
     }
     
-    public void extractMetadata(File f, TypeDefinition td) throws MapperException {
+    public void extractMetadata(File f, TypeDefinition td, Session session) throws MapperException
{
         try {
             InputStream stream = new FileInputStream(f);
             Metadata metadata = new Metadata();
@@ -65,10 +67,7 @@ public class MetadataParserTika extends 
                     String propertyId = mapper.getMappedPropertyId(key);
                     if (null != propertyId && null != val) {
                         if (td != null) {
-                            PropertyDefinition<?> propDef = td.getPropertyDefinitions().get(propertyId);
-                            if (null == propDef)
-                                throw new MapperException("Mapping error: unknown property
"+ propertyId + " in type definition " + td.getId());
-                            PropertyType propertyType = propDef.getPropertyType();
+                            PropertyDefinition<?> propDef = getMappedPropertyDefinition(td.getId(),
propertyId, session);                            
                             Object convVal = mapper.convertValue(propertyId, propDef, val);
                             if (null != convVal)
                                 cmisProperties.put(propertyId, convVal);
@@ -82,6 +81,18 @@ public class MetadataParserTika extends 
             LOG.error(e.toString(), e);
             throw new MapperException("Extracting metadata failed for file " + f.getAbsolutePath(),
e);
         }
+    }
+
+    private PropertyDefinition<?> getMappedPropertyDefinition(String typeId, String
propertyId, Session session) {
+        String typeIdOrg = typeId;
+        while (null != typeId) {
+            TypeDefinition td = session.getTypeDefinition(typeId);
+            PropertyDefinition<?> propDef = td.getPropertyDefinitions().get(propertyId);
+            if (null != propDef)
+                return propDef;
+            typeId = td.getParentTypeId();
+        }
+        throw new MapperException("Mapping error: unknown property "+ propertyId + " in type
definition " + typeIdOrg);
     }    
     
     public void listMetadata(File f) throws MapperException {



Mime
View raw message