You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Paul Santa Maria <pa...@yahoo.com.INVALID> on 2015/12/04 21:11:16 UTC
Unable to update a custom integer property in DotCMIS
I have a DotCMIS 0.7 app talking to a FileNet P8 5.2 repository. I'm able to read and write most custom properties (String, Float, DateTime, etc.) ... but not "Integer".
I can *read* the custom integer property ("RGBInteger"), but when I try to update it (to an existing document), or add it (to a new document), it's always set to "null" in the repository.
SAMPLE CODE: Public Sub TestIntegerProp(ByVal docName As String, ByVal propName As String)
' Perform query
Dim strSQL = "select * from RGBClass2 where cmis:name like '" & docName & "%'"
Dim queryResults As IItemEnumerable(Of IQueryResult) = m_Session.Query(strSQL, False)
' Fetch document
Dim qr As IQueryResult = queryResults(0)
<= POST /fncmis/resources/RGBOS/Query HTTP/1.1
Dim docId As String = qr.GetPropertyValueByQueryName("cmis:objectId").ToString()
Dim cmisDoc As IDocument = m_Session.GetObject(docId)
<= GET /fncmis/resources/RGBOS/Content/idd_4EA639AB-5973-4750-ABC2-B2742AFCDFEB?filter=&includeAllowableActions=true&includeACL=false HTTP/1.1
GET /fncmis/resources/RGBOS/Type/RGBClass2 HTTP/1.1
' Read property
Dim cmisProp As IProperty = FindProperty(propName, cmisDoc.Properties)
<= OK: the property is "100"
' Update property
Dim cmisProperties As IDictionary(Of String, Object) = New Dictionary(Of String, Object)
cmisProperties.Add(propName, 12345)
' Update document
Dim cmisObj As IObjectId = cmisDoc.UpdateProperties(cmisProperties)
<= PUT /fncmis/resources/RGBOS/Content/idd_4EA639AB-5973-4750-ABC2-B2742AFCDFEB?changeToken=9 HTTP/1.1
GET /fncmis/resources/RGBOS/Content/idd_4EA639AB-5973-4750-ABC2-B2742AFCDFEB?filter=&includeAllowableActions=true&includeACL=false HTTP/1.1
<= No error: but this sets the property to "Nothing" (???)
This is the XML when I query the document: RGBInteger =>
...
<cmis:propertyInteger propertyDefinitionId="RGBInteger" localName="RGBInteger" displayName="RGBInteger" queryName="RGBInteger">
<cmis:value>100</cmis:value>
</cmis:propertyInteger>
<= READ - GOOD! See correct value of "100"
But this is the XML when I try to update the document:
RGBInteger =>
...
<cmis:propertyInteger propertyDefinitionId="RGBInteger" localName="RGBInteger" displayName="RGBInteger" queryName="RGBInteger"/>
The problem occurs for *all* integer custom properties I try to update: either single-valued (like above) or multi-valued.
The problem seems similar to this post:
https://forums.alfresco.com/forum/developer-discussions/alfresco-api/dotcmis-custom-type-property-fails-integers-08202014-2009
<= Unfortunately, no resolution...
Q: Any suggestions what might be going wrong?
Thank you in advance
Re: Unable to update a custom integer property in DotCMIS
Posted by Paul Santa Maria <pa...@yahoo.com.INVALID>.
Worked like a charm! Specifically:
1. I already had a generic "DocumentProperty" class for different custom property types for different repositories (including CMIS).
2. I had a "docPropertyToCmis()" method to convert to a simple .Net "object", to include it in the CMIS properties list I pass to "document.Update()".
3. All I needed to do was cast to "long":
' Copy DocumentProperty object to a new CMIS propertyData object
Private Function docPropertyToCmis(ByVal docProp As DocumentProperty) As Object
... Select Case docProp.Type Case DocumentProperty.propType.TYPE_BOOLEAN
Return Boolean.Parse(docProp.Value)
Case DocumentProperty.propType.TYPE_DATETIME
Return DateTime.Parse(docProp.Value)
Case DocumentProperty.propType.TYPE_FLOAT
Return Decimal.Parse(docProp.Value)
Case DocumentProperty.propType.TYPE_INTEGER
Return Long.Parse(docProp.Value)
Case Else
Return docProp.Value
End Select
Anyway - it's working great now. Thank you!
From: Florian Müller <fm...@apache.org>
To: dev@chemistry.apache.org; paulsm1021@yahoo.com
Sent: Friday, December 4, 2015 2:30 PM
Subject: Re: Unable to update a custom integer property in DotCMIS
Hi Paul,
Please you try setting a long instead of an int:
cmisProperties.Add(propName, 12345L)
The DotCMIS is not very tolerant. Something that should be changed...
- Florian
> I have a DotCMIS 0.7 app talking to a FileNet P8 5.2 repository. I'm able to read and write most custom properties (String, Float, DateTime, etc.) ... but not "Integer".
> I can *read* the custom integer property ("RGBInteger"), but when I try to update it (to an existing document), or add it (to a new document), it's always set to "null" in the repository.
> SAMPLE CODE: Public Sub TestIntegerProp(ByVal docName As String, ByVal propName As String)
>
> ' Perform query
> Dim strSQL = "select * from RGBClass2 where cmis:name like '" & docName & "%'"
> Dim queryResults As IItemEnumerable(Of IQueryResult) = m_Session.Query(strSQL, False)
>
> ' Fetch document
> Dim qr As IQueryResult = queryResults(0)
> <= POST /fncmis/resources/RGBOS/Query HTTP/1.1
> Dim docId As String = qr.GetPropertyValueByQueryName("cmis:objectId").ToString()
> Dim cmisDoc As IDocument = m_Session.GetObject(docId)
> <= GET /fncmis/resources/RGBOS/Content/idd_4EA639AB-5973-4750-ABC2-B2742AFCDFEB?filter=&includeAllowableActions=true&includeACL=false HTTP/1.1
> GET /fncmis/resources/RGBOS/Type/RGBClass2 HTTP/1.1
>
> ' Read property
> Dim cmisProp As IProperty = FindProperty(propName, cmisDoc.Properties)
> <= OK: the property is "100"
>
> ' Update property
> Dim cmisProperties As IDictionary(Of String, Object) = New Dictionary(Of String, Object)
> cmisProperties.Add(propName, 12345)
>
> ' Update document
> Dim cmisObj As IObjectId = cmisDoc.UpdateProperties(cmisProperties)
> <= PUT /fncmis/resources/RGBOS/Content/idd_4EA639AB-5973-4750-ABC2-B2742AFCDFEB?changeToken=9 HTTP/1.1
> GET /fncmis/resources/RGBOS/Content/idd_4EA639AB-5973-4750-ABC2-B2742AFCDFEB?filter=&includeAllowableActions=true&includeACL=false HTTP/1.1
> <= No error: but this sets the property to "Nothing" (???)
>
> This is the XML when I query the document: RGBInteger =>
> ...
> <cmis:propertyInteger propertyDefinitionId="RGBInteger" localName="RGBInteger" displayName="RGBInteger" queryName="RGBInteger">
> <cmis:value>100</cmis:value>
> </cmis:propertyInteger>
> <= READ - GOOD! See correct value of "100"
> But this is the XML when I try to update the document:
> RGBInteger =>
> ...
> <cmis:propertyInteger propertyDefinitionId="RGBInteger" localName="RGBInteger" displayName="RGBInteger" queryName="RGBInteger"/>
>
> The problem occurs for *all* integer custom properties I try to update: either single-valued (like above) or multi-valued.
> The problem seems similar to this post:
> https://forums.alfresco.com/forum/developer-discussions/alfresco-api/dotcmis-custom-type-property-fails-integers-08202014-2009
> <= Unfortunately, no resolution...
> Q: Any suggestions what might be going wrong?
> Thank you in advance
>
>
>
>
Re: Unable to update a custom integer property in DotCMIS
Posted by Florian Müller <fm...@apache.org>.
Hi Paul,
Please you try setting a long instead of an int:
cmisProperties.Add(propName, 12345L)
The DotCMIS is not very tolerant. Something that should be changed...
- Florian
> I have a DotCMIS 0.7 app talking to a FileNet P8 5.2 repository. I'm able to read and write most custom properties (String, Float, DateTime, etc.) ... but not "Integer".
> I can *read* the custom integer property ("RGBInteger"), but when I try to update it (to an existing document), or add it (to a new document), it's always set to "null" in the repository.
> SAMPLE CODE: Public Sub TestIntegerProp(ByVal docName As String, ByVal propName As String)
>
> ' Perform query
> Dim strSQL = "select * from RGBClass2 where cmis:name like '" & docName & "%'"
> Dim queryResults As IItemEnumerable(Of IQueryResult) = m_Session.Query(strSQL, False)
>
> ' Fetch document
> Dim qr As IQueryResult = queryResults(0)
> <= POST /fncmis/resources/RGBOS/Query HTTP/1.1
> Dim docId As String = qr.GetPropertyValueByQueryName("cmis:objectId").ToString()
> Dim cmisDoc As IDocument = m_Session.GetObject(docId)
> <= GET /fncmis/resources/RGBOS/Content/idd_4EA639AB-5973-4750-ABC2-B2742AFCDFEB?filter=&includeAllowableActions=true&includeACL=false HTTP/1.1
> GET /fncmis/resources/RGBOS/Type/RGBClass2 HTTP/1.1
>
> ' Read property
> Dim cmisProp As IProperty = FindProperty(propName, cmisDoc.Properties)
> <= OK: the property is "100"
>
> ' Update property
> Dim cmisProperties As IDictionary(Of String, Object) = New Dictionary(Of String, Object)
> cmisProperties.Add(propName, 12345)
>
> ' Update document
> Dim cmisObj As IObjectId = cmisDoc.UpdateProperties(cmisProperties)
> <= PUT /fncmis/resources/RGBOS/Content/idd_4EA639AB-5973-4750-ABC2-B2742AFCDFEB?changeToken=9 HTTP/1.1
> GET /fncmis/resources/RGBOS/Content/idd_4EA639AB-5973-4750-ABC2-B2742AFCDFEB?filter=&includeAllowableActions=true&includeACL=false HTTP/1.1
> <= No error: but this sets the property to "Nothing" (???)
>
> This is the XML when I query the document: RGBInteger =>
> ...
> <cmis:propertyInteger propertyDefinitionId="RGBInteger" localName="RGBInteger" displayName="RGBInteger" queryName="RGBInteger">
> <cmis:value>100</cmis:value>
> </cmis:propertyInteger>
> <= READ - GOOD! See correct value of "100"
> But this is the XML when I try to update the document:
> RGBInteger =>
> ...
> <cmis:propertyInteger propertyDefinitionId="RGBInteger" localName="RGBInteger" displayName="RGBInteger" queryName="RGBInteger"/>
>
> The problem occurs for *all* integer custom properties I try to update: either single-valued (like above) or multi-valued.
> The problem seems similar to this post:
> https://forums.alfresco.com/forum/developer-discussions/alfresco-api/dotcmis-custom-type-property-fails-integers-08202014-2009
> <= Unfortunately, no resolution...
> Q: Any suggestions what might be going wrong?
> Thank you in advance
>
>
>
>