You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Mark Streit <mc...@gmail.com> on 2019/01/31 15:04:28 UTC

Is it possible to set/send a custom HTTP Header using OpenCMIS Java client library

Hello

We have a document management solution built on around the CMIS standards
that uses OpenCMIS Java and interacts w/ Alfresco 5.2.3 Enterprise.  This
question may not be new but given the following:


   - OpenCMIS client api version 0.14.0
   - CMIS Browser binding
   - The application is written entirely in Java and uses
   the org.apache.chemistry.opencmis.client.api.Session along w/ other
   library class imports:

import org.apache.chemistry.opencmis.client.api.OperationContext;

import org.apache.chemistry.opencmis.client.api.Repository;

import org.apache.chemistry.opencmis.client.api.Session;

import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;

import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;

import org.apache.chemistry.opencmis.commons.PropertyIds;

import org.apache.chemistry.opencmis.commons.SessionParameter;

import org.apache.chemistry.opencmis.commons.enums.BindingType;


We generate a unique transaction ID value that is logged on our client
application side logs via a Java logging library and this works fine.

What we are trying to ascertain is whether or not there is a way to:


   - Send that transaction ID as a header (not part of the Document
   model/metadata) in the client API call (say when adding a
   cmis:Document object to a cmis:Folder)
   - Add some type of interceptor on the Alfresco server side (which
   implements the OpenCMIS server libraries)
   - Be able to write that transaction ID to the logs on the Alfresco
   server side


( I realize that this may be more specific to the Alfresco server-side code
and we may need to reach out to them, but first need to confirm if getting
this type of custom header value over the wire via CMIS protocol is even
possible)

Thanks

Mark

Re: Is it possible to set/send a custom HTTP Header using OpenCMIS Java client library

Posted by Florian Müller <fm...@apache.org>.
Hi Mark,

You can set HTTP headers per session in the session parameter like so:

parameters.put(SessionParameter.HEADER + ".0", "header0:value0");
parameters.put(SessionParameter.HEADER + ".1", "header1:value1");
parameters.put(SessionParameter.HEADER + ".2", "header2:value2");

But there is no easy way to set a HTTP header per operation. You would 
need to implement your own AuthenticationProvider for that.


- Florian


> Hello
> 
> We have a document management solution built on around the CMIS 
> standards
> that uses OpenCMIS Java and interacts w/ Alfresco 5.2.3 Enterprise.  
> This
> question may not be new but given the following:
> 
> 
>    - OpenCMIS client api version 0.14.0
>    - CMIS Browser binding
>    - The application is written entirely in Java and uses
>    the org.apache.chemistry.opencmis.client.api.Session along w/ other
>    library class imports:
> 
> import org.apache.chemistry.opencmis.client.api.OperationContext;
> 
> import org.apache.chemistry.opencmis.client.api.Repository;
> 
> import org.apache.chemistry.opencmis.client.api.Session;
> 
> import 
> org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;
> 
> import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
> 
> import org.apache.chemistry.opencmis.commons.PropertyIds;
> 
> import org.apache.chemistry.opencmis.commons.SessionParameter;
> 
> import org.apache.chemistry.opencmis.commons.enums.BindingType;
> 
> 
> We generate a unique transaction ID value that is logged on our client
> application side logs via a Java logging library and this works fine.
> 
> What we are trying to ascertain is whether or not there is a way to:
> 
> 
>    - Send that transaction ID as a header (not part of the Document
>    model/metadata) in the client API call (say when adding a
>    cmis:Document object to a cmis:Folder)
>    - Add some type of interceptor on the Alfresco server side (which
>    implements the OpenCMIS server libraries)
>    - Be able to write that transaction ID to the logs on the Alfresco
>    server side
> 
> 
> ( I realize that this may be more specific to the Alfresco server-side 
> code
> and we may need to reach out to them, but first need to confirm if 
> getting
> this type of custom header value over the wire via CMIS protocol is 
> even
> possible)
> 
> Thanks
> 
> Mark