001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Florent Guillaume 018 */ 019package org.nuxeo.ecm.core.opencmis.impl.client; 020 021import org.apache.chemistry.opencmis.commons.enums.BindingType; 022import org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl; 023import org.apache.chemistry.opencmis.commons.server.CmisService; 024import org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider; 025import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory; 026import org.apache.chemistry.opencmis.commons.spi.CmisBinding; 027import org.nuxeo.ecm.core.api.CoreSession; 028import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoCmisService; 029 030/** 031 * Local CMIS binding to the services. 032 */ 033public class NuxeoBinding implements CmisBinding { 034 035 private static final BindingsObjectFactory OBJECT_FACTORY = new BindingsObjectFactoryImpl(); 036 037 public final CmisService service; 038 039 private NuxeoCmisService nuxeoCmisService; 040 041 public NuxeoBinding(CmisService service) { 042 this.service = service; 043 } 044 045 @Override 046 public void close() { 047 service.close(); 048 } 049 050 @Override 051 public CmisService getRepositoryService() { 052 return service; 053 } 054 055 @Override 056 public CmisService getNavigationService() { 057 return service; 058 } 059 060 @Override 061 public CmisService getObjectService() { 062 return service; 063 } 064 065 @Override 066 public CmisService getDiscoveryService() { 067 return service; 068 } 069 070 @Override 071 public CmisService getRelationshipService() { 072 return service; 073 } 074 075 @Override 076 public CmisService getVersioningService() { 077 return service; 078 } 079 080 @Override 081 public CmisService getAclService() { 082 return service; 083 } 084 085 @Override 086 public CmisService getMultiFilingService() { 087 return service; 088 } 089 090 @Override 091 public CmisService getPolicyService() { 092 return service; 093 } 094 095 @Override 096 public BindingsObjectFactory getObjectFactory() { 097 return OBJECT_FACTORY; 098 } 099 100 @Override 101 public AuthenticationProvider getAuthenticationProvider() { 102 return null; // no provider 103 } 104 105 @Override 106 public void clearAllCaches() { 107 // TODO Auto-generated method stub 108 throw new UnsupportedOperationException(); 109 } 110 111 @Override 112 public void clearRepositoryCache(String repositoryId) { 113 // TODO Auto-generated method stub 114 throw new UnsupportedOperationException(); 115 } 116 117 @Override 118 public String getSessionId() { 119 // TODO Auto-generated method stub 120 throw new UnsupportedOperationException(); 121 } 122 123 @Override 124 public BindingType getBindingType() { 125 // TODO Auto-generated method stub 126 throw new UnsupportedOperationException(); 127 } 128 129 public CoreSession getCoreSession() { 130 return getNuxeoCmisService() == null ? null : nuxeoCmisService.getCoreSession(); 131 } 132 133 /** 134 * Gets the potentially wrapped NuxeoCmisService. 135 */ 136 public NuxeoCmisService getNuxeoCmisService() { 137 if (nuxeoCmisService == null) { 138 nuxeoCmisService = NuxeoCmisService.extractFromCmisService(service); 139 } 140 return nuxeoCmisService; 141 } 142 143}