svn commit: r614945 - /ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartyServices.xml

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

svn commit: r614945 - /ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartyServices.xml

jleroux@apache.org
Author: jleroux
Date: Thu Jan 24 10:01:29 2008
New Revision: 614945

URL: http://svn.apache.org/viewvc?rev=614945&view=rev
Log:
A patch submitted by Chris Juettner in dev ML :

What is happening is the method is setting the dataResourceId in the map prior to the DataResource row being created. This is a problem because the dataResourceId doesn't exist yet. The result is that the uploaded file name is persisted with just the path and extension.  
 
For example:    
C:\eclipse\workspace\ofbiz\applications\content\uploads\1200348109149\.doc
 
So I added a call to the updateDataResource service following the createDataResource because the dataResourceId is now available.

Modified:
    ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartyServices.xml

Modified: ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartyServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartyServices.xml?rev=614945&r1=614944&r2=614945&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartyServices.xml (original)
+++ ofbiz/trunk/applications/party/script/org/ofbiz/party/party/PartyServices.xml Thu Jan 24 10:01:29 2008
@@ -321,15 +321,16 @@
            <!-- 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>          
+           </call-service>
+          
+           <set-service-fields service-name="updateDataResource" map-name="dataResource" to-map-name="dataResource"/>          
+           <set from-field="dataResourceId" field="dataResource.dataResourceId"/>
+           <call-service service-name="updateDataResource" in-map-name="dataResource" break-on-error="false" />
+           <set from-field="dataResource.dataResourceId" field="lookup.dataResourceId"/>
+           <find-by-primary-key use-cache="true" entity-name="DataResource" value-name="dataResourceMap" map-name="lookup"/>
        </if-not-empty>
         
        <set-service-fields service-name="createContent" map-name="parameters" to-map-name="createContentMap"/>
@@ -408,17 +409,22 @@
                <first-from-list entry-name="extension" list-name="extensions"/>
                <set-service-fields service-name="createDataResource" map-name="parameters" to-map-name="dataResource"/>
                <!-- 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 data resource object -->
+                <set from-field="parameters._uploadedFile_fileName" field="dataResource.dataResourceName"/>
+                <set from-field="parameters._uploadedFile_contentType" field="dataResource.mimeTypeId"/>
+                <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"/>
+                </call-service>
+                <set value="${uploadPath}/${dataResourceId}" field="dataResource.objectInfo"/>
+                <if-not-empty field-name="extension">
+                    <set value="${uploadPath}/${dataResourceId}.${extension.fileExtensionId}" field="dataResource.objectInfo"/>
+                </if-not-empty>
+                <set-service-fields service-name="updateDataResource" map-name="dataResource" to-map-name="dataResource"/>          
+                <set from-field="dataResourceId" field="dataResource.dataResourceId"/>
+                <call-service service-name="updateDataResource" in-map-name="dataResource" break-on-error="false" />
+                <set from-field="dataResource.dataResourceId" field="lookup.dataResourceId"/>
+                <find-by-primary-key use-cache="true" entity-name="DataResource" value-name="dataResourceMap" map-name="lookup"/>
             </else>  
            </if-not-empty>          
        </if-not-empty>