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
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1081848 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+9
-1
@@ -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"/>
|
||||
|
||||
@@ -153,8 +153,16 @@ ofbiz/trunk/framework/webslinger/lib/webslinger-extension-template-20091211-3897
|
||||
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
|
||||
|
||||
@@ -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">
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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"/>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -50,6 +50,13 @@ import org.apache.commons.fileupload.FileItem;
|
||||
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.ScreenFactory;
|
||||
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 implements org.ofbiz.widget.DataResourceWorkerI
|
||||
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;
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user