001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Florent Guillaume
011 */
012package org.nuxeo.ecm.core.opencmis.impl.client;
013
014import org.apache.chemistry.opencmis.commons.enums.BindingType;
015import org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl;
016import org.apache.chemistry.opencmis.commons.server.CmisService;
017import org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider;
018import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
019import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
020import org.nuxeo.ecm.core.api.CoreSession;
021import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoCmisService;
022
023/**
024 * Local CMIS binding to the services.
025 */
026public class NuxeoBinding implements CmisBinding {
027
028    private static final BindingsObjectFactory OBJECT_FACTORY = new BindingsObjectFactoryImpl();
029
030    public final CmisService service;
031
032    private NuxeoCmisService nuxeoCmisService;
033
034    public NuxeoBinding(CmisService service) {
035        this.service = service;
036    }
037
038    @Override
039    public void close() {
040        service.close();
041    }
042
043    @Override
044    public CmisService getRepositoryService() {
045        return service;
046    }
047
048    @Override
049    public CmisService getNavigationService() {
050        return service;
051    }
052
053    @Override
054    public CmisService getObjectService() {
055        return service;
056    }
057
058    @Override
059    public CmisService getDiscoveryService() {
060        return service;
061    }
062
063    @Override
064    public CmisService getRelationshipService() {
065        return service;
066    }
067
068    @Override
069    public CmisService getVersioningService() {
070        return service;
071    }
072
073    @Override
074    public CmisService getAclService() {
075        return service;
076    }
077
078    @Override
079    public CmisService getMultiFilingService() {
080        return service;
081    }
082
083    @Override
084    public CmisService getPolicyService() {
085        return service;
086    }
087
088    @Override
089    public BindingsObjectFactory getObjectFactory() {
090        return OBJECT_FACTORY;
091    }
092
093    @Override
094    public AuthenticationProvider getAuthenticationProvider() {
095        return null; // no provider
096    }
097
098    @Override
099    public void clearAllCaches() {
100        // TODO Auto-generated method stub
101        throw new UnsupportedOperationException();
102    }
103
104    @Override
105    public void clearRepositoryCache(String repositoryId) {
106        // TODO Auto-generated method stub
107        throw new UnsupportedOperationException();
108    }
109
110    @Override
111    public String getSessionId() {
112        // TODO Auto-generated method stub
113        throw new UnsupportedOperationException();
114    }
115
116    @Override
117    public BindingType getBindingType() {
118        // TODO Auto-generated method stub
119        throw new UnsupportedOperationException();
120    }
121
122    public CoreSession getCoreSession() {
123        return getNuxeoCmisService() == null ? null : nuxeoCmisService.getCoreSession();
124    }
125
126    /**
127     * Gets the potentially wrapped NuxeoCmisService.
128     */
129    public NuxeoCmisService getNuxeoCmisService() {
130        if (nuxeoCmisService == null) {
131            nuxeoCmisService = NuxeoCmisService.extractFromCmisService(service);
132        }
133        return nuxeoCmisService;
134    }
135
136}