chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Florian Müller <florian.muel...@alfresco.com>
Subject Re: SharePoint Base64 decoding error in OpenCMIS
Date Fri, 29 Apr 2011 11:29:27 GMT
Hi Jonathan,

There are a couple of things going on here.

First of all, the headers you have sent in your first email contain "Content-Encoding: gzip".
That is, OpenCMIS tries to unzip it. 
SharePoint should only send compressed content if it is requested by the client. Are you setting
the compression flag in the OpenCMIS session parameters? If so, please remove that for now
and try again.

Secondly, there is a bug that prevents OpenCMIS from handling gzip AND base64 encoded content
at the same time. I have just fixed that for OpenCMIS 0.4.0.
Could you try OpenCMIS 0.4.0? I don't have access to a Sharepoint server at the moment and
cannot verify it.


Thanks for pointing that out!

Florian



On 28/04/2011 23:10, Jonathan Lee wrote:
> Hi Florian,
> 
> I am using BASIC authentication right now and the file size is only 81 
> bytes. Its a text file with some text in it.
> 
> I see it in the HttpUtils that it will perform gunzip and base64 if the 
> response header C/ontent-Encoding/ is /gzip /and 
> Content-Transfer-Encoding is |/base64/|
> |/
> /|
> However when I implement my own method the response from SharePoint is 
> not gzipped and  I didn't perform the gunzip. And with this method The 
> Base64 decoder will decode without error.
> 
>   Here is my code.
> 
> //SAME URL that OpenCMIS is requesting
> /URL url = new 
> URL("http://[server]/_vti_bin/cmis/rest/81c77da7-2ecd-436a-aadd-3cb01b74d55b?getContentStream&objectID=51-512");/
> /String method = "GET";/
> /HttpURLConnection connection = (HttpURLConnection)url.openConnection();/
> /connection.setRequestMethod(method);/
> //
> /// write auth header/
> /BASE64Encoder encoder = new BASE64Encoder();/
> /String encodedCredential = encoder.encode( ("user" + ":" + 
> "password").getBytes() );/
> /connection.setRequestProperty("Authorization", "BASIC " + 
> encodedCredential);/
> //
> /return new Base64.InputStream(connection.getInputStream());/
> /
> /
> But when I called document.getContentStream(). the same response is 
> however gzipped. Therefore gzipped is preformed, and then a bad stream 
> is passed to the Base64 decoder?
> 
> That is the only difference I can notice right now. I have a feeling the 
> response from SharePoint is actually not gzipped. Could that be a 
> problem? I don't understand why two of the same request will return two 
> different responses. One has C/ontent-Encoding/ is /gzip, /and one does not
> 
> Thank you so much for your response.
> 
> Jonathan Lee
> 
> 
> On Thu, Apr 28, 2011 at 12:25 PM, Florian Müller 
> <florian.mueller@alfresco.com <mailto:florian.mueller@alfresco.com>> wrote:
> 
>     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" <johnnyhowey@gmail.com
>     <mailto:johnnyhowey@gmail.com>>
>     To: dev@chemistry.apache.org <mailto: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-38
>     <tel:4149-8553-38>f40ebad01dSet-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
> 
> 


Mime
View raw message