svn commit: r492850 - in /ofbiz/trunk/applications/content: config/content.properties script/org/ofbiz/content/content/ContentServices.xml servicedef/secas.xml servicedef/services.xml

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

svn commit: r492850 - in /ofbiz/trunk/applications/content: config/content.properties script/org/ofbiz/content/content/ContentServices.xml servicedef/secas.xml servicedef/services.xml

jaz-3
Author: jaz
Date: Thu Jan  4 18:18:29 2007
New Revision: 492850

URL: http://svn.apache.org/viewvc?view=rev&rev=492850
Log:
moved upload content code to the content component (from party); made more generic and added speedy services for creating uploaded content; also added service for text content (not yet tested)

Modified:
    ofbiz/trunk/applications/content/config/content.properties
    ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml
    ofbiz/trunk/applications/content/servicedef/secas.xml
    ofbiz/trunk/applications/content/servicedef/services.xml

Modified: ofbiz/trunk/applications/content/config/content.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/config/content.properties?view=diff&rev=492850&r1=492849&r2=492850
==============================================================================
--- ofbiz/trunk/applications/content/config/content.properties (original)
+++ ofbiz/trunk/applications/content/config/content.properties Thu Jan  4 18:18:29 2007
@@ -27,5 +27,5 @@
 freemarker.templateIdPrefix=[system]
 
 # user level content uploading (relative to ofbiz.home)
-content.upload.path.prefix=/uploads
+content.upload.path.prefix=/applications/content/uploads
 content.upload.max.files=250

Modified: ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml?view=diff&rev=492850&r1=492849&r2=492850
==============================================================================
--- ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml (original)
+++ ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml Thu Jan  4 18:18:29 2007
@@ -789,7 +789,56 @@
         <create-value value-name="content"/>
     </simple-method>
 
- <!-- This method first creates Content, DataResource and ElectronicText, ImageDataResource, etc. entities (if needed)
+    <!-- This method will accept an uploaded file stream and create a generic Content/DataResource record -->
+    <simple-method method-name="createUploadedLocalFileContent" short-description="Creates a Local File Content from an uploaded stream">
+        <!-- check for the uploaded file name and information -->
+        <if-not-empty field-name="_uploadedFile_fileName" map-name="parameters">
+            <call-class-method class-name="org.ofbiz.content.data.DataResourceWorker" method-name="getDataResourceContentUploadPath" ret-field-name="uploadPath"/>
+            <log level="info" message="[createUploadedLocalFileContent] - Found Subdir : ${uploadPath}"/>
+
+            <!-- locate the file extension to use based on mime-type -->
+            <set from-field="parameters._uploadedFile_contentType" field="extenLookup.mimeTypeId"/>
+            <find-by-and entity-name="FileExtension" map-name="extenLookup" list-name="extensions"/>
+            <first-from-list entry-name="extension" list-name="extensions"/>
+            <set-service-fields service-name="createDataResource" map-name="parameters" to-map-name="dataResource"/>
+
+            <!-- obtain a data resource id (needed in advance for the raw file name -->
+            <sequenced-id-to-env sequence-name="DataResource" env-name="dataResourceId"/>
+            <set from-field="dataResourceId" field="dataResource.dataResourceId"/>
+            
+            <!-- create the data resource object -->
+            <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-name="extension">
+                <set value="${uploadPath}/${dataResource.dataResourceId}.${extension.fileExtensionId}" field="dataResource.objectInfo"/>
+            </if-not-empty>
+            <set value="LOCAL_FILE" field="dataResource.dataResourceTypeId"/>
+            <call-service service-name="createDataResource" in-map-name="dataResource" break-on-error="false">
+                <result-to-field result-name="dataResourceId" field-name="dataResourceId"/>
+                <result-to-field result-name="dataResource" field-name="dataResourceMap"/>
+            </call-service>
+
+            <!-- create the content record -->
+            <set-service-fields service-name="createContent" map-name="parameters" to-map-name="createContentMap"/>
+            <set from-field="parameters._uploadedFile_fileName" field="createContentMap.contentName"/>
+            <set from-field="parameters._uploadedFile_contentType" field="createContentMap.mimeTypeId"/>
+            <set from-field="dataResourceId" field="createContentMap.dataResourceId"/>
+            <call-service service-name="createContent" in-map-name="createContentMap" break-on-error="false">
+                <result-to-field result-name="contentId" field-name="contentId"/>
+            </call-service>
+
+            <!-- store the file -->
+            <set-service-fields service-name="createAnonFile" map-name="dataResourceMap" to-map-name="fileCtx"/>
+            <set from-field="parameters.uploadedFile" field="fileCtx.binData"/>
+            <set from-field="dataResourceMap" field="fileCtx.dataResource"/>
+            <call-service service-name="createAnonFile" in-map-name="fileCtx" include-user-login="true"/>
+            
+            <field-to-result field-name="contentId" />
+       </if-not-empty>
+    </simple-method>
+
+    <!-- This method first creates Content, DataResource and ElectronicText, ImageDataResource, etc. entities (if needed)
  by calling persistContentAndAssoc.
 
  It then takes the contentId coming out of that service, the passed in communicationEventId

Modified: ofbiz/trunk/applications/content/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/secas.xml?view=diff&rev=492850&r1=492849&r2=492850
==============================================================================
--- ofbiz/trunk/applications/content/servicedef/secas.xml (original)
+++ ofbiz/trunk/applications/content/servicedef/secas.xml Thu Jan  4 18:18:29 2007
@@ -34,4 +34,21 @@
         <action service="storeEmailAsCommunication" mode="sync"/>
     </eca>
 
+    <!-- create content events -->
+    <eca service="createContent" event="commit">
+        <condition field-name="partyId" operator="is-not-empty"/>
+        <condition field-name="roleTypeId" operator="is-not-empty"/>
+        <action service="createContentRole" mode="sync"/>
+    </eca>
+
+    <eca service="createTextContent" event="invoke">
+        <action service="createDataResource" mode="sync"/>
+        <action service="createContent" mode="sync"/>
+    </eca>
+
+    <eca service="updateTextContent" event="invoke">
+        <action service="updateDataResource" mode="sync"/>
+        <action service="updateContent" mode="sync"/>
+    </eca>
+
 </service-eca>

Modified: ofbiz/trunk/applications/content/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/services.xml?view=diff&rev=492850&r1=492849&r2=492850
==============================================================================
--- ofbiz/trunk/applications/content/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/content/servicedef/services.xml Thu Jan  4 18:18:29 2007
@@ -80,9 +80,10 @@
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <attribute mode="OUT" name="resultData" optional="true" type="java.util.Map"/>
     </service>
-    
+
+    <!-- create content services -->
     <service name="createContent" default-entity-name="Content" engine="java"
-        location="org.ofbiz.content.content.ContentServices" invoke="createContent" transaction-timeout="72000" auth="true">
+        location="org.ofbiz.content.content.ContentServices" invoke="createContent" transaction-timeout="300" auth="true">
         <description>Create a Content</description>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
         <attribute mode="IN" name="targetOperationList" optional="true" type="List"/>
@@ -93,15 +94,40 @@
         <attribute mode="IN" name="userLogin" optional="true" type="GenericValue"/>
         <attribute mode="IN" name="skipPermissionCheck" optional="true" type="String"/>
         <attribute mode="IN" name="displayFailCond" optional="true" type="Boolean"/>
+        <attribute mode="IN" name="partyId" optional="true" type="String"/>
+        <attribute mode="IN" name="roleTypeId" optional="true" type="String"/>
         <attribute mode="INOUT" name="roleTypeList" optional="true" type="List"/>
         <attribute mode="INOUT" name="contentId" optional="true" type="String"/>
         <override name="contentTypeId" optional="false"/>
     </service>
+
+    <service name="createTextContent" engine="route" transaction-timeout="300" auth="true">
+        <description>Creates a Text Document DataResource and Content Records</description>
+        <implements service="createDataResource" optional="false"/>
+        <implements service="createContent" optional="false"/>
+    </service>
+
+    <service name="createLocalFileContentFromStream" default-entity-name="Content" engine="simple" transaction-timeout="300"
+             location="org/ofbiz/content/content/ContentServices.xml" invoke="createUploadedLocalFileContent">
+        <description>Creates a local file, data resource and content records for an uploaded file</description>
+        <auto-attributes mode="IN" include="nonpk" optional="true"/>
+        <attribute name="uploadedFile" type="org.ofbiz.entity.util.ByteWrapper" mode="IN" optional="true"/>
+        <attribute name="_uploadedFile_fileName" type="String" mode="IN" optional="true"/>
+        <attribute name="_uploadedFile_contentType" type="String" mode="IN" optional="false"/>
+        <attribute name="dataCategoryId" type="String" mode="IN" optional="true"/>
+        <attribute name="statusId" type="String" mode="IN" optional="false"/>
+        <attribute name="partyId" type="String" mode="IN" optional="true"/>
+        <attribute name="contentId" type="String" mode="OUT" optional="false"/>
+        <override name="contentTypeId" optional="false"/>
+    </service>
+
     <service name="copyContentAndElectronicTextandAssoc" default-entity-name="Content" engine="simple"
         location="org/ofbiz/content/content/ContentServices.xml" invoke="copyContentAndElectronicTextandAssoc" transaction-timeout="72000" auth="true" >
         <description>Copy a Content, e;ectronic text and assocs</description>
         <auto-attributes include="pk" mode="INOUT" optional="false"/>
     </service>
+
+    <!-- update content services -->
     <service name="updateContent" default-entity-name="Content" engine="java"
         location="org.ofbiz.content.content.ContentServices" invoke="updateContent" auth="true">
         <description>Update a Content</description>
@@ -114,6 +140,13 @@
         <attribute mode="IN" name="displayFailCond" optional="true" type="Boolean"/>
         <attribute mode="INOUT" name="roleTypeList" optional="true" type="List"/>
     </service>
+
+    <service name="updateTextContent" engine="route" transaction-timeout="300" auth="true">
+        <description>Updates a Text Document DataResource and Content Records</description>
+        <implements service="updateDataResource" optional="false"/>
+        <implements service="updateContent" optional="false"/>
+    </service>
+    
     <service name="removeContent" default-entity-name="Content" engine="simple"
         location="org/ofbiz/content/content/ContentServices.xml" invoke="deleteContent" auth="true">
         <description>Remove Content</description>
@@ -166,6 +199,19 @@
         <attribute mode="OUT" name="contentList" optional="false" type="List"/>
     </service>
 
+    <service name="createLocalFileContentFromStream" default-entity-name="Content" engine="simple" transaction-timeout="300"
+             location="org/ofbiz/content/content/ContentServices.xml" invoke="createUploadedLocalFileContent">
+        <description>Creates a local file, data resource and content records for an uploaded file</description>
+        <auto-attributes mode="IN" include="nonpk" optional="true"/>
+        <attribute name="uploadedFile" type="org.ofbiz.entity.util.ByteWrapper" mode="IN" optional="true"/>
+        <attribute name="_uploadedFile_fileName" type="String" mode="IN" optional="true"/>
+        <attribute name="_uploadedFile_contentType" type="String" mode="IN" optional="false"/>
+        <attribute name="dataCategoryId" type="String" mode="IN" optional="true"/>
+        <attribute name="statusId" type="String" mode="IN" optional="false"/>
+        <attribute name="partyId" type="String" mode="IN" optional="true"/>
+        <attribute name="contentId" type="String" mode="OUT" optional="false"/>
+        <override name="contentTypeId" optional="false"/>        
+    </service>
 
     <!--Content Assoc services.-->
     <service name="checkAssocPermission"