Search in sources :

Example 11 with CallContext

use of org.apache.chemistry.opencmis.commons.server.CallContext in project alfresco-repository by Alfresco.

the class AbstractEventsService method getAlfrescoClient.

protected Client getAlfrescoClient(Client knownClientType) {
    // The following is a HACK in order to fix MNT-17302:
    // 
    // "RuleServiceImpl.ExecutedRules" is a resource bond to the transaction by RuleServiceImpl;
    // We can use this information to avoid setting "alfrescoClientId" in this case, otherwise its presence
    // will cause the filtering-out of the events that are generated as a result of a rule execution;
    // 
    // We should find a better, cleaner solution in the future...
    Object noAlfrescoClientIdHint = AlfrescoTransactionSupport.getResource("RuleServiceImpl.ExecutedRules");
    if (noAlfrescoClientIdHint != null) {
        return null;
    }
    CallContext context = AlfrescoCmisServiceCall.get();
    if (context != null) {
        HttpServletRequest request = (HttpServletRequest) context.get(CallContext.HTTP_SERVLET_REQUEST);
        if (request != null) {
            String alfrescoClientId = (String) request.getHeader("alfrescoClientId");
            return new Client(Client.ClientType.cmis, alfrescoClientId);
        }
    }
    return knownClientType;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Client(org.alfresco.sync.repo.Client) CallContext(org.apache.chemistry.opencmis.commons.server.CallContext)

Aggregations

CallContext (org.apache.chemistry.opencmis.commons.server.CallContext)11 CmisService (org.apache.chemistry.opencmis.commons.server.CmisService)5 VersionableAspectTest (org.alfresco.repo.version.VersionableAspectTest)4 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 FileInfo (org.alfresco.service.cmr.model.FileInfo)3 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)3 RepositoryInfo (org.apache.chemistry.opencmis.commons.data.RepositoryInfo)3 UnfileObject (org.apache.chemistry.opencmis.commons.enums.UnfileObject)3 Serializable (java.io.Serializable)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 MimetypeMap (org.alfresco.repo.content.MimetypeMap)2 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)2 QName (org.alfresco.service.namespace.QName)2 Properties (org.apache.chemistry.opencmis.commons.data.Properties)2 BigInteger (java.math.BigInteger)1 HashSet (java.util.HashSet)1