You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2012/04/19 20:37:00 UTC
svn commit: r1328072 -
/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/mapper/PropertyMapperTika.java
Author: jens
Date: Thu Apr 19 18:37:00 2012
New Revision: 1328072
URL: http://svn.apache.org/viewvc?rev=1328072&view=rev
Log:
add a workaround for a tika bug when parsing MP3 tags
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/mapper/PropertyMapperTika.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/mapper/PropertyMapperTika.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/mapper/PropertyMapperTika.java?rev=1328072&r1=1328071&r2=1328072&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/mapper/PropertyMapperTika.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/mapper/PropertyMapperTika.java Thu Apr 19 18:37:00 2012
@@ -63,18 +63,30 @@ public class PropertyMapperTika extends
return propId;
}
- public Object convertValue(String key, PropertyDefinition<?> propDef, final String strValue) {
+ public Object convertValue(String key, PropertyDefinition<?> propDef, String strValue) {
Object value = null;
PropertyType pt = propDef.getPropertyType();
if (null == pt)
value = null;
- else {
+ else if (null != strValue && strValue.length() > 0) {
+ // Tika has a bug and sometimes fails to parse MP3 tags, then generates '\0' in String
+ // see https://issues.apache.org/jira/browse/TIKA-887
+ int lastIllegalPos = -1;
+ for (int i=0; i<strValue.length(); i++) {
+ int c = strValue.codePointAt(i);
+ if (Character.isISOControl(c))
+ lastIllegalPos = i;
+ }
+ if (lastIllegalPos >= 0)
+ strValue = strValue.substring(lastIllegalPos+1); // use remaining part after illegal char
+
switch (pt) {
case STRING:
case HTML:
case URI:
case ID:
+
if (propDef.getCardinality() == Cardinality.SINGLE)
value = strValue;
else {