Party Services bug - Please review

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

Party Services bug - Please review

Chris Juettner-2
I believe I have found and corrected a bug in these simple methods named "createPartyContent" and "updatePartyContent" located in PartyServices.xml.  
 
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.
 
Please review for accuracy and make the change if appropriate.
 
Thanks
 
Chris Juettner
Integral Business Solutions
 
 
File: PartyServices.xml

createPartyContent
Original code:
 
           <!-- 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>          
 
 
Fixed code:

           <!-- 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-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"/>
 
 
updatePartyContent
Original code:
 
               <!-- 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>    
 
Fixed code:

               <!-- 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"/>

Reply | Threaded
Open this post in threaded view
|

Re: Party Services bug - Please review

Jacques Le Roux
Administrator
Chris,

This makes sense indeed. Could you please open a Jira issue and attach a patch?

TIA

Jacques

From: "Chris Juettner" <[hidden email]>

>I believe I have found and corrected a bug in these simple methods named "createPartyContent" and "updatePartyContent" located in
>PartyServices.xml.
>
> 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.
>
> Please review for accuracy and make the change if appropriate.
>
> Thanks
>
> Chris Juettner
> Integral Business Solutions
>
>
> File: PartyServices.xml
>
> createPartyContent
> Original code:
>
>           <!-- 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>
>
>
> Fixed code:
>
>           <!-- 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-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"/>
>
>
> updatePartyContent
> Original code:
>
>               <!-- 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>
>
> Fixed code:
>
>               <!-- 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"/>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Party Services bug - Please review

Jacques Le Roux
Administrator
In reply to this post by Chris Juettner-2
Thanks Chris,

I finally commited your changes without a patch : see trunk rev. 614945 release4.0 614946

Jacques

From: "Jacques Le Roux" <[hidden email]>

> Chris,
>
> This makes sense indeed. Could you please open a Jira issue and attach a patch?
>
> TIA
>
> Jacques
>
> From: "Chris Juettner" <[hidden email]>
>>I believe I have found and corrected a bug in these simple methods named "createPartyContent" and "updatePartyContent" located in
>>PartyServices.xml.
>>
>> 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.
>>
>> Please review for accuracy and make the change if appropriate.
>>
>> Thanks
>>
>> Chris Juettner
>> Integral Business Solutions
>>
>>
>> File: PartyServices.xml
>>
>> createPartyContent
>> Original code:
>>
>>           <!-- 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>
>>
>>
>> Fixed code:
>>
>>           <!-- 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-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"/>
>>
>>
>> updatePartyContent
>> Original code:
>>
>>               <!-- 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>
>>
>> Fixed code:
>>
>>               <!-- 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"/>
>>
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

RE: Party Services bug - Please review

Chris Juettner-2
Thanks Jacques.
I had it on my TODO list but just didn't get to it.
Looks good.



-----Original Message-----
From: Jacques Le Roux [mailto:[hidden email]]
Sent: Thursday, January 24, 2008 12:06 PM
To: [hidden email]
Subject: Re: Party Services bug - Please review

Thanks Chris,

I finally commited your changes without a patch : see trunk rev. 614945
release4.0 614946

Jacques

From: "Jacques Le Roux" <[hidden email]>
> Chris,
>
> This makes sense indeed. Could you please open a Jira issue and attach
a patch?
>
> TIA
>
> Jacques
>
> From: "Chris Juettner" <[hidden email]>
>>I believe I have found and corrected a bug in these simple methods
named "createPartyContent" and "updatePartyContent" located in
>>PartyServices.xml.
>>
>> 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\.d
oc
>>
>> So I added a call to the updateDataResource service following the
createDataResource because the dataResourceId is now available.

>>
>> Please review for accuracy and make the change if appropriate.
>>
>> Thanks
>>
>> Chris Juettner
>> Integral Business Solutions
>>
>>
>> File: PartyServices.xml
>>
>> createPartyContent
>> Original code:
>>
>>           <!-- 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.fileExte
nsionId}"
>> 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>
>>
>>
>> Fixed code:
>>
>>           <!-- 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-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"/>
>>
>>
>> updatePartyContent
>> Original code:
>>
>>               <!-- 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.fileExte
nsionId}"
>> 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>
>>
>> Fixed code:
>>
>>               <!-- 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"/>
>>
>>
>>
>