Hi Jonathan, Are you using NTLM? How big are your documents? We have seen issues with NTLM and documents around 120kb and bigger. The stream is closed on the server side before the content is completely read and leaves you with invalid Base64. The only solution I'm aware of is to avoid NTLM and use basic authentication instead.
Florian ----- Original Message ----- From: "Jonathan Lee" <johnnyho...@gmail.com> To: dev@chemistry.apache.org Sent: Thursday, April 28, 2011 8:07:22 PM GMT +00:00 GMT Britain, Ireland, Portugal Subject: SharePoint Base64 decoding error in OpenCMIS Hi all Currently we are trying to use openCMIS 0.3.0 to mount a SharePoint 2010 Repository. We have run into an issue when trying to get the content stream of the documents. SharePoint 2010 return the stream with Base64 encoding, and I am aware that org.apache.chemistry.opencmis.client.bindings.spi.atompub.HttpUtils returns a Base64.InputStream if the content encoding type is base64. However there is an error when Base64 is trying to decode the stream. Here is the exception, java.lang.ArrayIndexOutOfBoundsException: -19 at org.apache.chemistry.opencmis.commons.impl.Base64.decode4to3(Base64.java:1048) at org.apache.chemistry.opencmis.commons.impl.Base64.access$200(Base64.java:33) at org.apache.chemistry.opencmis.commons.impl.Base64$InputStream.read(Base64.java:1766) at org.apache.chemistry.opencmis.commons.impl.Base64$InputStream.read(Base64.java:1832) at java.io.FilterInputStream.read(Unknown Source) After some debugging I realized the InputStream being decoded is not the correct stream. So instead of using the InputStream I get from calling, *docuemnt.getcontentStream().getStream()* I did my own Http Get Request http:// [Server]/_vti_bin/cmis/rest/81c77da7-2ecd-436a-aadd-3cb01b74d55b?getContentStream&objectID=48-512 and called this to get the InputStream inputStream = new Base64.InputStream(connection.getInputStream()); When I pass the inputStream I acquired through my own method to Base64, The decoding works! I am wondering if document.getContentStream().getStream() is returning the correct stream when retrieving from SharePoint. Can anyone share some insight on this problem? Here are some extra information that I think you might want to know. This is the respond header when we call http://[Server]/_vti_bin/cmis/rest/81c77da7-2ecd-436a-aadd-3cb01b74d55b?getContentStream&objectID=48-512 This Cache-ControlprivateContent-Typetext/plain; charset=utf-8Content-Encoding gzipVaryAccept-EncodingServerMicrosoft-IIS/7.0SPRequestGuid a8bcfa3a-fced-4149-8553-38f40ebad01dSet-CookieWSS_KeepSessionAuthenticated={774a893e-3944-489d-84b1-b861ed338a6f}; path=/X-SharePointHealthScore5Content-Transfer-Encodingbase64 X-AspNet-Version2.0.50727X-Powered-ByASP.NETMicrosoftSharePointTeamSe... 14.0.0.4762DateThu, 28 Apr 2011 18:28:55 GMTContent-Length1546 This is the response body, which is Base64 encoded VGhpcyBpcyBhIFRlc3RpbmcgRG9jdW1lbnQNCg0KVGVzdGluZyBPcGVuQ01JUw0KDQpTaGFyZVBvaW50IDIwMTANCg0KSm9uYXRoYW4gTGVl Any help or insight would be much appreciated! Thanks Jonathan Lee