svn commit: r1081848 - in /ofbiz/trunk: ./ applications/content/entitydef/ applications/content/lib/ applications/content/script/org/ofbiz/content/data/ applications/content/servicedef/ applications/content/src/org/ofbiz/content/data/ applications/part...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1081848 - in /ofbiz/trunk: ./ applications/content/entitydef/ applications/content/lib/ applications/content/script/org/ofbiz/content/data/ applications/content/servicedef/ applications/content/src/org/ofbiz/content/data/ applications/part...

erwan
Author: erwan
Date: Tue Mar 15 16:43:09 2011
New Revision: 1081848

URL: http://svn.apache.org/viewvc?rev=1081848&view=rev
Log:
mime-type is now auto detected with Apache Tika when uploading a new file to a profile. I also had to change the mimeTypeId field to vlong, as there are now mimetypes with a length > 60 characters

Added:
    ofbiz/trunk/applications/content/lib/fontbox-1.4.0.jar   (with props)
    ofbiz/trunk/applications/content/lib/jempbox-1.4.0.jar   (with props)
    ofbiz/trunk/applications/content/lib/metadata-extractor-2.4.0-beta-1.jar   (with props)
    ofbiz/trunk/applications/content/lib/pdfbox-1.4.0.jar   (with props)
    ofbiz/trunk/applications/content/lib/poi-3.7.jar   (with props)
    ofbiz/trunk/applications/content/lib/poi-ooxml-3.7.jar   (with props)
    ofbiz/trunk/applications/content/lib/poi-ooxml-schemas-3.7.jar   (with props)
    ofbiz/trunk/applications/content/lib/poi-scratchpad-3.7.jar   (with props)
    ofbiz/trunk/applications/content/lib/tika-core-0.9.jar   (with props)
    ofbiz/trunk/applications/content/lib/tika-parsers-0.9.jar   (with props)
Removed:
    ofbiz/trunk/applications/content/lib/poi-3.2-FINAL-20081019.jar
Modified:
    ofbiz/trunk/.classpath
    ofbiz/trunk/LICENSE
    ofbiz/trunk/applications/content/entitydef/entitymodel.xml
    ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml
    ofbiz/trunk/applications/content/servicedef/services_content.xml
    ofbiz/trunk/applications/content/servicedef/services_data.xml
    ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java
    ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Content.ftl

Modified: ofbiz/trunk/.classpath
URL: http://svn.apache.org/viewvc/ofbiz/trunk/.classpath?rev=1081848&r1=1081847&r2=1081848&view=diff
==============================================================================
--- ofbiz/trunk/.classpath (original)
+++ ofbiz/trunk/.classpath Tue Mar 15 16:43:09 2011
@@ -2,8 +2,16 @@
 <classpath>
     <classpathentry kind="con" path="GROOVY_SUPPORT" exported="true"/>
     <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+    <classpathentry kind="lib" path="applications/content/lib/fontbox-1.4.0.jar"/>
+    <classpathentry kind="lib" path="applications/content/lib/jempbox-1.4.0.jar"/>
     <classpathentry kind="lib" path="applications/content/lib/lucene-core-3.0.3.jar"/>
-    <classpathentry kind="lib" path="applications/content/lib/poi-3.2-FINAL-20081019.jar"/>
+    <classpathentry kind="lib" path="applications/content/lib/metadata-extractor-2.4.0.jar"/>
+    <classpathentry kind="lib" path="applications/content/lib/pdfbox-1.4.0.jar"/>
+    <classpathentry kind="lib" path="applications/content/lib/poi-3.7.jar"/>
+    <classpathentry kind="lib" path="applications/content/lib/poi-ooxml-3.7.jar"/>
+    <classpathentry kind="lib" path="applications/content/lib/poi-scratchpad-3.7.jar"/>
+    <classpathentry kind="lib" path="applications/content/lib/tika-core-0.9.jar"/>
+    <classpathentry kind="lib" path="applications/content/lib/tika-parsers-0.9.jar"/>
     <classpathentry kind="lib" path="applications/product/lib/watermarker-0.0.4.jar"/>
     <classpathentry kind="lib" path="applications/product/lib/dozer-4.2.1.jar"/>
     <classpathentry kind="lib" path="framework/base/lib/ant-1.7.1.jar"/>

Modified: ofbiz/trunk/LICENSE
URL: http://svn.apache.org/viewvc/ofbiz/trunk/LICENSE?rev=1081848&r1=1081847&r2=1081848&view=diff
==============================================================================
--- ofbiz/trunk/LICENSE (original)
+++ ofbiz/trunk/LICENSE Tue Mar 15 16:43:09 2011
@@ -153,8 +153,16 @@ ofbiz/trunk/framework/webslinger/lib/web
 ofbiz/trunk/framework/webslinger/lib/webslinger-extension-velocity-20091211-3897-7ab22baea4b6.jar
 ofbiz/trunk/framework/webslinger/lib/webslinger-extension-wiki-20091211-3897-7ab22baea4b6.jar
 ofbiz/trunk/framework/webslinger/lib/webslinger-launcher-20091211-3897-7ab22baea4b6.jar
+ofbiz/trunk/applications/content/lib/fontbox-1.4.0.jar
+ofbiz/trunk/applications/content/lib/jempbox-1.4.0.jar
 ofbiz/trunk/applications/content/lib/lucene-core-3.0.3.jar
-ofbiz/trunk/applications/content/lib/poi-3.2-FINAL-20081019.jar
+ofbiz/trunk/applications/content/lib/metadata-extractor-2.4.0.jar
+ofbiz/trunk/applications/content/lib/pdfbox-1.4.0.jar
+ofbiz/trunk/applications/content/lib/poi-3.7.jar
+ofbiz/trunk/applications/content/lib/poi-ooxml-3.7.jar
+ofbiz/trunk/applications/content/lib/poi-scratchpad-3.7.jar
+ofbiz/trunk/applications/content/lib/tika-core-0.9.jar
+ofbiz/trunk/applications/content/lib/tika-parsers-0.9.jar
 ofbiz/trunk/applications/product/lib/dozer-4.2.1.jar
 ofbiz/trunk/applications/product/lib/watermarker-0.0.4.jar
 ofbiz/trunk/specialpurpose/googlecheckout/lib/checkout-sdk-0.8.8.jar

Modified: ofbiz/trunk/applications/content/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/entitydef/entitymodel.xml?rev=1081848&r1=1081847&r2=1081848&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/content/entitydef/entitymodel.xml Tue Mar 15 16:43:09 2011
@@ -163,7 +163,7 @@ under the License.
       <field name="contentName" type="name"></field>
       <field name="description" type="description"></field>
       <field name="localeString" type="very-short"></field>
-      <field name="mimeTypeId" type="id-long"></field>
+      <field name="mimeTypeId" type="id-vlong"></field>
       <field name="characterSetId" type="id-long"></field>
       <field name="childLeafCount" type="numeric"/>
       <field name="childBranchCount" type="numeric"/>
@@ -763,7 +763,7 @@ under the License.
       <field name="statusId" type="id"></field>
       <field name="dataResourceName" type="name"></field>
       <field name="localeString" type="very-short"></field>
-      <field name="mimeTypeId" type="id-long"></field>
+      <field name="mimeTypeId" type="id-vlong"></field>
       <field name="characterSetId" type="id-long"></field>
       <field name="objectInfo" type="long-varchar"><description>For Short Text the text goes here.</description></field>
       <field name="surveyId" type="id"></field>
@@ -988,7 +988,7 @@ under the License.
             package-name="org.ofbiz.content.data"
             title="File Extension Entity">
       <field name="fileExtensionId" type="id-long-ne"></field>
-      <field name="mimeTypeId" type="id-long-ne"></field>
+      <field name="mimeTypeId" type="id-vlong-ne"></field>
       <prim-key field="fileExtensionId"/>
       <relation type="one" fk-name="FILEEXT_MMTYP" rel-entity-name="MimeType">
         <key-map field-name="mimeTypeId"/>
@@ -1016,7 +1016,7 @@ under the License.
             package-name="org.ofbiz.content.data"
             default-resource-name="ContentEntityLabels"
             title="Mime Type Entity">
-      <field name="mimeTypeId" type="id-long-ne"></field>
+      <field name="mimeTypeId" type="id-vlong-ne"></field>
       <field name="description" type="description"></field>
       <prim-key field="mimeTypeId"/>
     </entity>
@@ -1024,7 +1024,7 @@ under the License.
             package-name="org.ofbiz.content.data"
             default-resource-name="ContentEntityLabels"
             title="Mime Text Template Entity">
-      <field name="mimeTypeId" type="id-long-ne"></field>
+      <field name="mimeTypeId" type="id-vlong-ne"></field>
       <field name="templateLocation" type="long-varchar"></field>
       <prim-key field="mimeTypeId"/>
       <relation type="one" fk-name="MIMETYPE_TPL_MT" rel-entity-name="MimeType">

Added: ofbiz/trunk/applications/content/lib/fontbox-1.4.0.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/fontbox-1.4.0.jar?rev=1081848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/applications/content/lib/fontbox-1.4.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ofbiz/trunk/applications/content/lib/jempbox-1.4.0.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/jempbox-1.4.0.jar?rev=1081848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/applications/content/lib/jempbox-1.4.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ofbiz/trunk/applications/content/lib/metadata-extractor-2.4.0-beta-1.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/metadata-extractor-2.4.0-beta-1.jar?rev=1081848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/applications/content/lib/metadata-extractor-2.4.0-beta-1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ofbiz/trunk/applications/content/lib/pdfbox-1.4.0.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/pdfbox-1.4.0.jar?rev=1081848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/applications/content/lib/pdfbox-1.4.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ofbiz/trunk/applications/content/lib/poi-3.7.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/poi-3.7.jar?rev=1081848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/applications/content/lib/poi-3.7.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ofbiz/trunk/applications/content/lib/poi-ooxml-3.7.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/poi-ooxml-3.7.jar?rev=1081848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/applications/content/lib/poi-ooxml-3.7.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ofbiz/trunk/applications/content/lib/poi-ooxml-schemas-3.7.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/poi-ooxml-schemas-3.7.jar?rev=1081848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/applications/content/lib/poi-ooxml-schemas-3.7.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ofbiz/trunk/applications/content/lib/poi-scratchpad-3.7.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/poi-scratchpad-3.7.jar?rev=1081848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/applications/content/lib/poi-scratchpad-3.7.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ofbiz/trunk/applications/content/lib/tika-core-0.9.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/tika-core-0.9.jar?rev=1081848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/applications/content/lib/tika-core-0.9.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ofbiz/trunk/applications/content/lib/tika-parsers-0.9.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/lib/tika-parsers-0.9.jar?rev=1081848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/applications/content/lib/tika-parsers-0.9.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml?rev=1081848&r1=1081847&r2=1081848&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml (original)
+++ ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml Tue Mar 15 16:43:09 2011
@@ -51,8 +51,8 @@ under the License.
         </if-empty>
 
         <if-empty field="newEntity.mimeTypeId">
-            <call-class-method class-name="org.ofbiz.content.data.DataResourceWorker" method-name="getMimeType" ret-field="newEntity.mimeTypeId">
-                <field field="newEntity" type="GenericValue"/>
+            <call-class-method class-name="org.ofbiz.content.data.DataResourceWorker" method-name="getMimeTypeWithByteBuffer" ret-field="newEntity.mimeTypeId">
+                <field field="parameters.uploadedFile" type="java.nio.ByteBuffer"/>
             </call-class-method>
         </if-empty>
 
@@ -752,7 +752,6 @@ under the License.
         <first-from-list entry="extension" list="extensions"/>
 
         <set from-field="parameters._uploadedFile_fileName" field="dataResource.dataResourceName"/>
-        <set from-field="parameters._uploadedFile_contentType" field="dataResource.mimeTypeId"/>
         <set value="${uploadPath}/${dataResource.dataResourceId}" field="dataResource.objectInfo"/>
         <if-not-empty field="extension">
             <set value="${uploadPath}/${dataResource.dataResourceId}.${extension.fileExtensionId}" field="dataResource.objectInfo"/>

Modified: ofbiz/trunk/applications/content/servicedef/services_content.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/services_content.xml?rev=1081848&r1=1081847&r2=1081848&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/servicedef/services_content.xml (original)
+++ ofbiz/trunk/applications/content/servicedef/services_content.xml Tue Mar 15 16:43:09 2011
@@ -74,6 +74,7 @@
         <implements service="createContent" optional="true"/>
         <attribute name="dataResourceId" type="String" mode="IN" optional="false"/>
         <attribute name="contentId" type="String" mode="OUT" optional="false"/>
+        <attribute name="uploadedFile" type="java.nio.ByteBuffer" mode="IN" optional="true"/>
     </service>
 
     <service name="attachUploadToDataResource" engine="simple" transaction-timeout="300"

Modified: ofbiz/trunk/applications/content/servicedef/services_data.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/services_data.xml?rev=1081848&r1=1081847&r2=1081848&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/servicedef/services_data.xml (original)
+++ ofbiz/trunk/applications/content/servicedef/services_data.xml Tue Mar 15 16:43:09 2011
@@ -36,6 +36,7 @@
         <attribute name="partyId" type="String" mode="IN" optional="true"/>
         <attribute name="dataResourceId" type="String" mode="OUT" optional="false"/>
         <attribute name="dataResource" type="org.ofbiz.entity.GenericValue" mode="OUT" optional="true"/>
+        <attribute name="uploadedFile" type="java.nio.ByteBuffer" mode="IN" optional="true"/>
         <override name="objectInfo" allow-html="safe"/>
     </service>
     <service name="createDataResourceAndAssocToContent" default-entity-name="DataResource" engine="simple"

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java?rev=1081848&r1=1081847&r2=1081848&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Tue Mar 15 16:43:09 2011
@@ -50,6 +50,13 @@ import org.apache.commons.fileupload.Fil
 import org.apache.commons.fileupload.FileUploadException;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.tika.Tika;
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.AutoDetectParser;
+import org.apache.tika.parser.ParseContext;
+import org.apache.tika.parser.Parser;
 import org.ofbiz.base.location.FlexibleLocation;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.FileUtil;
@@ -77,7 +84,9 @@ import org.ofbiz.widget.screen.ScreenFac
 import org.ofbiz.widget.screen.ScreenRenderer;
 import org.ofbiz.widget.screen.ScreenStringRenderer;
 import org.w3c.dom.Document;
+import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
 
 import freemarker.template.Template;
 import freemarker.template.TemplateException;
@@ -381,6 +390,13 @@ public class DataResourceWorker  impleme
         return mimeTypeId;
     }
 
+    public static String getMimeTypeWithByteBuffer(java.nio.ByteBuffer buffer) throws IOException {
+        byte[] b = buffer.array();
+
+        Tika tika = new Tika();
+        return tika.detect(b);
+    }
+
     public static String buildRequestPrefix(Delegator delegator, Locale locale, String webSiteId, String https) {
         Map<String, Object> prefixValues = FastMap.newInstance();
         String prefix;

Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Content.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Content.ftl?rev=1081848&r1=1081847&r2=1081848&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Content.ftl (original)
+++ ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Content.ftl Tue Mar 15 16:43:09 2011
@@ -50,12 +50,6 @@ under the License.
             <option value="${role.roleTypeId}" <#if role.roleTypeId == "_NA_">selected="selected"</#if>>${role.get("description", locale)?default(role.roleTypeId)}</option>
           </#list>
         </select>
-        <select name="mimeTypeId">
-          <option value="">${uiLabelMap.PartySelectMimeType}</option>
-          <#list mimeTypes as mimeType>
-            <option value="${mimeType.mimeTypeId}">${mimeType.get("description", locale)?default(mimeType.mimeTypeId)}</option>
-          </#list>
-        </select>
         <input type="submit" value="${uiLabelMap.CommonUpload}"/>
       </form>
       <div id='progress_bar'><div></div></div>