Return-Path: Delivered-To: apmail-incubator-chemistry-commits-archive@minotaur.apache.org Received: (qmail 27058 invoked from network); 29 Jul 2010 16:47:14 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 29 Jul 2010 16:47:14 -0000 Received: (qmail 89441 invoked by uid 500); 29 Jul 2010 16:47:14 -0000 Delivered-To: apmail-incubator-chemistry-commits-archive@incubator.apache.org Received: (qmail 89382 invoked by uid 500); 29 Jul 2010 16:47:14 -0000 Mailing-List: contact chemistry-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: chemistry-dev@incubator.apache.org Delivered-To: mailing list chemistry-commits@incubator.apache.org Received: (qmail 89374 invoked by uid 99); 29 Jul 2010 16:47:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Jul 2010 16:47:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Jul 2010 16:47:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D210023889B3; Thu, 29 Jul 2010 16:45:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r980504 [1/5] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-client: chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/ chemistry-opencmis-client-bindings/src/main/java/org/apache/ch... Date: Thu, 29 Jul 2010 16:45:50 -0000 To: chemistry-commits@incubator.apache.org From: fguillaume@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100729164550.D210023889B3@eris.apache.org> Author: fguillaume Date: Thu Jul 29 16:45:49 2010 New Revision: 980504 URL: http://svn.apache.org/viewvc?rev=980504&view=rev Log: CMIS-225: proper svn eol-style on text files (native except for *.bat) Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AclServiceImpl.java (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/CmisLocalSpi.java (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/DiscoveryServiceImpl.java (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/MultiFilingServiceImpl.java (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/NavigationServiceImpl.java (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/ObjectServiceImpl.java (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/PolicyServiceImpl.java (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/RelationshipServiceImpl.java (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/RepositoryServiceImpl.java (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/VersioningServiceImpl.java (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/assembly/client-with-dependencies-assembly.xml (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/osgi/Activator.java (props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentDocumentImpl.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentFolderImpl.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentPolicyImpl.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentPropertyImpl.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentRelationshipImpl.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentSessionImpl.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/Cache.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/CacheImpl.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java (contents, props changed) incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CmisObjectMock.java (contents, props changed) Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java?rev=980504&r1=980503&r2=980504&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java Thu Jul 29 16:45:49 2010 @@ -1,204 +1,204 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.chemistry.opencmis.client.bindings; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingImpl; -import org.apache.chemistry.opencmis.commons.SessionParameter; -import org.apache.chemistry.opencmis.commons.spi.CmisBinding; - -/** - * Default factory for a CMIS binding instance. - */ -public final class CmisBindingFactory { - - /** Default CMIS AtomPub binding SPI implementation */ - public static final String BINDING_SPI_ATOMPUB = "org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubSpi"; - /** Default CMIS Web Services binding SPI implementation */ - public static final String BINDING_SPI_WEBSERVICES = "org.apache.chemistry.opencmis.client.bindings.spi.webservices.CmisWebServicesSpi"; - /** Default CMIS local binding SPI implementation */ - public static final String BINDING_SPI_LOCAL = "org.apache.chemistry.opencmis.client.bindings.spi.local.CmisLocalSpi"; - - /** Standard authentication provider class */ - public static final String STANDARD_AUTHENTICATION_PROVIDER = "org.apache.chemistry.opencmis.client.bindings.spi.StandardAuthenticationProvider"; - - private Map defaults; - - /** - * Private constructor -- it's a factory. - */ - private CmisBindingFactory() { - defaults = createNewDefaultParameters(); - } - - /** - * Creates a new factory instance. - */ - public static CmisBindingFactory newInstance() { - return new CmisBindingFactory(); - } - - /** - * Returns the default session parameters. - */ - public Map getDefaultSessionParameters() { - return defaults; - } - - /** - * Sets the default session parameters. - */ - public void setDefaultSessionParameters(Map sessionParameters) { - if (sessionParameters == null) { - defaults = createNewDefaultParameters(); - } else { - defaults = sessionParameters; - } - } - - /** - * Creates a CMIS binding instance. A binding class has to be provided in - * the session parameters. - */ - public CmisBinding createCmisBinding(Map sessionParameters) { - checkSessionParameters(sessionParameters, true); - - addDefaultParameters(sessionParameters); - - return new CmisBindingImpl(sessionParameters); - } - - /** - * Creates a default CMIS AtomPub binding instance. - */ - public CmisBinding createCmisAtomPubBinding(Map sessionParameters) { - checkSessionParameters(sessionParameters, false); - - sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_ATOMPUB); - if (!sessionParameters.containsKey(SessionParameter.AUTHENTICATION_PROVIDER_CLASS)) { - sessionParameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, STANDARD_AUTHENTICATION_PROVIDER); - } - sessionParameters.put(SessionParameter.AUTH_HTTP_BASIC, "true"); - sessionParameters.put(SessionParameter.AUTH_SOAP_USERNAMETOKEN, "false"); - addDefaultParameters(sessionParameters); - - check(sessionParameters, SessionParameter.ATOMPUB_URL); - - return new CmisBindingImpl(sessionParameters); - } - - /** - * Creates a default CMIS Web Services binding instance. - */ - public CmisBinding createCmisWebServicesBinding(Map sessionParameters) { - checkSessionParameters(sessionParameters, false); - - sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_WEBSERVICES); - if (!sessionParameters.containsKey(SessionParameter.AUTHENTICATION_PROVIDER_CLASS)) { - sessionParameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, STANDARD_AUTHENTICATION_PROVIDER); - } - sessionParameters.put(SessionParameter.AUTH_HTTP_BASIC, "true"); - sessionParameters.put(SessionParameter.AUTH_SOAP_USERNAMETOKEN, "true"); - addDefaultParameters(sessionParameters); - - check(sessionParameters, SessionParameter.WEBSERVICES_ACL_SERVICE); - check(sessionParameters, SessionParameter.WEBSERVICES_DISCOVERY_SERVICE); - check(sessionParameters, SessionParameter.WEBSERVICES_MULTIFILING_SERVICE); - check(sessionParameters, SessionParameter.WEBSERVICES_NAVIGATION_SERVICE); - check(sessionParameters, SessionParameter.WEBSERVICES_OBJECT_SERVICE); - check(sessionParameters, SessionParameter.WEBSERVICES_POLICY_SERVICE); - check(sessionParameters, SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE); - check(sessionParameters, SessionParameter.WEBSERVICES_REPOSITORY_SERVICE); - check(sessionParameters, SessionParameter.WEBSERVICES_VERSIONING_SERVICE); - - return new CmisBindingImpl(sessionParameters); - } - - /** - * Creates a default CMIS local binding instance. - */ - public CmisBinding createCmisLocalBinding(Map sessionParameters) { - checkSessionParameters(sessionParameters, false); - - sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_LOCAL); - addDefaultParameters(sessionParameters); - - check(sessionParameters, SessionParameter.LOCAL_FACTORY); - - return new CmisBindingImpl(sessionParameters); - } - - // ---- internal ---- - - /** - * Checks the passed session parameters. - */ - private void checkSessionParameters(Map sessionParameters, boolean mustContainSPI) { - // don't accept null - if (sessionParameters == null) { - throw new IllegalArgumentException("Session parameter map not set!"); - } - - // check binding entry - String SPIClass = sessionParameters.get(SessionParameter.BINDING_SPI_CLASS); - if (mustContainSPI) { - if ((SPIClass == null) || (SPIClass.trim().length() == 0)) { - throw new IllegalArgumentException("SPI class entry (" + SessionParameter.BINDING_SPI_CLASS - + ") is missing!"); - } - } - } - - /** - * Checks if the given parameter is present. If not, throw an - * IllegalArgumentException. - */ - private void check(Map sessionParameters, String parameter) { - if (!sessionParameters.containsKey(parameter)) { - throw new IllegalArgumentException("Parameter '" + parameter + "' is missing!"); - } - } - - /** - * Add the default session parameters to the given map without override - * existing entries. - */ - private void addDefaultParameters(Map sessionParameters) { - for (String key : defaults.keySet()) { - if (!sessionParameters.containsKey(key)) { - sessionParameters.put(key, defaults.get(key)); - } - } - } - - /** - * Creates a default session parameters map with some reasonable defaults. - */ - private Map createNewDefaultParameters() { - Map result = new HashMap(); - - result.put(SessionParameter.CACHE_SIZE_REPOSITORIES, "10"); - result.put(SessionParameter.CACHE_SIZE_TYPES, "100"); - result.put(SessionParameter.CACHE_SIZE_OBJECTS, "400"); - - return result; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.client.bindings; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingImpl; +import org.apache.chemistry.opencmis.commons.SessionParameter; +import org.apache.chemistry.opencmis.commons.spi.CmisBinding; + +/** + * Default factory for a CMIS binding instance. + */ +public final class CmisBindingFactory { + + /** Default CMIS AtomPub binding SPI implementation */ + public static final String BINDING_SPI_ATOMPUB = "org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubSpi"; + /** Default CMIS Web Services binding SPI implementation */ + public static final String BINDING_SPI_WEBSERVICES = "org.apache.chemistry.opencmis.client.bindings.spi.webservices.CmisWebServicesSpi"; + /** Default CMIS local binding SPI implementation */ + public static final String BINDING_SPI_LOCAL = "org.apache.chemistry.opencmis.client.bindings.spi.local.CmisLocalSpi"; + + /** Standard authentication provider class */ + public static final String STANDARD_AUTHENTICATION_PROVIDER = "org.apache.chemistry.opencmis.client.bindings.spi.StandardAuthenticationProvider"; + + private Map defaults; + + /** + * Private constructor -- it's a factory. + */ + private CmisBindingFactory() { + defaults = createNewDefaultParameters(); + } + + /** + * Creates a new factory instance. + */ + public static CmisBindingFactory newInstance() { + return new CmisBindingFactory(); + } + + /** + * Returns the default session parameters. + */ + public Map getDefaultSessionParameters() { + return defaults; + } + + /** + * Sets the default session parameters. + */ + public void setDefaultSessionParameters(Map sessionParameters) { + if (sessionParameters == null) { + defaults = createNewDefaultParameters(); + } else { + defaults = sessionParameters; + } + } + + /** + * Creates a CMIS binding instance. A binding class has to be provided in + * the session parameters. + */ + public CmisBinding createCmisBinding(Map sessionParameters) { + checkSessionParameters(sessionParameters, true); + + addDefaultParameters(sessionParameters); + + return new CmisBindingImpl(sessionParameters); + } + + /** + * Creates a default CMIS AtomPub binding instance. + */ + public CmisBinding createCmisAtomPubBinding(Map sessionParameters) { + checkSessionParameters(sessionParameters, false); + + sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_ATOMPUB); + if (!sessionParameters.containsKey(SessionParameter.AUTHENTICATION_PROVIDER_CLASS)) { + sessionParameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, STANDARD_AUTHENTICATION_PROVIDER); + } + sessionParameters.put(SessionParameter.AUTH_HTTP_BASIC, "true"); + sessionParameters.put(SessionParameter.AUTH_SOAP_USERNAMETOKEN, "false"); + addDefaultParameters(sessionParameters); + + check(sessionParameters, SessionParameter.ATOMPUB_URL); + + return new CmisBindingImpl(sessionParameters); + } + + /** + * Creates a default CMIS Web Services binding instance. + */ + public CmisBinding createCmisWebServicesBinding(Map sessionParameters) { + checkSessionParameters(sessionParameters, false); + + sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_WEBSERVICES); + if (!sessionParameters.containsKey(SessionParameter.AUTHENTICATION_PROVIDER_CLASS)) { + sessionParameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, STANDARD_AUTHENTICATION_PROVIDER); + } + sessionParameters.put(SessionParameter.AUTH_HTTP_BASIC, "true"); + sessionParameters.put(SessionParameter.AUTH_SOAP_USERNAMETOKEN, "true"); + addDefaultParameters(sessionParameters); + + check(sessionParameters, SessionParameter.WEBSERVICES_ACL_SERVICE); + check(sessionParameters, SessionParameter.WEBSERVICES_DISCOVERY_SERVICE); + check(sessionParameters, SessionParameter.WEBSERVICES_MULTIFILING_SERVICE); + check(sessionParameters, SessionParameter.WEBSERVICES_NAVIGATION_SERVICE); + check(sessionParameters, SessionParameter.WEBSERVICES_OBJECT_SERVICE); + check(sessionParameters, SessionParameter.WEBSERVICES_POLICY_SERVICE); + check(sessionParameters, SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE); + check(sessionParameters, SessionParameter.WEBSERVICES_REPOSITORY_SERVICE); + check(sessionParameters, SessionParameter.WEBSERVICES_VERSIONING_SERVICE); + + return new CmisBindingImpl(sessionParameters); + } + + /** + * Creates a default CMIS local binding instance. + */ + public CmisBinding createCmisLocalBinding(Map sessionParameters) { + checkSessionParameters(sessionParameters, false); + + sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_LOCAL); + addDefaultParameters(sessionParameters); + + check(sessionParameters, SessionParameter.LOCAL_FACTORY); + + return new CmisBindingImpl(sessionParameters); + } + + // ---- internal ---- + + /** + * Checks the passed session parameters. + */ + private void checkSessionParameters(Map sessionParameters, boolean mustContainSPI) { + // don't accept null + if (sessionParameters == null) { + throw new IllegalArgumentException("Session parameter map not set!"); + } + + // check binding entry + String SPIClass = sessionParameters.get(SessionParameter.BINDING_SPI_CLASS); + if (mustContainSPI) { + if ((SPIClass == null) || (SPIClass.trim().length() == 0)) { + throw new IllegalArgumentException("SPI class entry (" + SessionParameter.BINDING_SPI_CLASS + + ") is missing!"); + } + } + } + + /** + * Checks if the given parameter is present. If not, throw an + * IllegalArgumentException. + */ + private void check(Map sessionParameters, String parameter) { + if (!sessionParameters.containsKey(parameter)) { + throw new IllegalArgumentException("Parameter '" + parameter + "' is missing!"); + } + } + + /** + * Add the default session parameters to the given map without override + * existing entries. + */ + private void addDefaultParameters(Map sessionParameters) { + for (String key : defaults.keySet()) { + if (!sessionParameters.containsKey(key)) { + sessionParameters.put(key, defaults.get(key)); + } + } + } + + /** + * Creates a default session parameters map with some reasonable defaults. + */ + private Map createNewDefaultParameters() { + Map result = new HashMap(); + + result.put(SessionParameter.CACHE_SIZE_REPOSITORIES, "10"); + result.put(SessionParameter.CACHE_SIZE_TYPES, "100"); + result.put(SessionParameter.CACHE_SIZE_OBJECTS, "400"); + + return result; + } +} Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AclServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/CmisLocalSpi.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/DiscoveryServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/MultiFilingServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/NavigationServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/ObjectServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/PolicyServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/RelationshipServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/RepositoryServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/VersioningServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/assembly/client-with-dependencies-assembly.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/osgi/Activator.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java?rev=980504&r1=980503&r2=980504&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java Thu Jul 29 16:45:49 2010 @@ -1,88 +1,88 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.chemistry.opencmis.client.runtime; - -import java.util.Map; - -import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory; -import org.apache.chemistry.opencmis.commons.SessionParameter; -import org.apache.chemistry.opencmis.commons.enums.BindingType; -import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; -import org.apache.chemistry.opencmis.commons.spi.CmisBinding; - -/** - * Helper methods for binding handling. - */ -public class CmisBindingHelper { - /** - * Creates a {@link CmisProvider} object. - */ - public static CmisBinding createProvider(Map parameters) { - if (parameters == null || parameters.isEmpty()) { - throw new CmisRuntimeException("Session parameter not set!"); - } - - if (!parameters.containsKey(SessionParameter.BINDING_TYPE)) { - parameters.put(SessionParameter.BINDING_TYPE, BindingType.CUSTOM.value()); - } - - BindingType bt = BindingType.fromValue(parameters.get(SessionParameter.BINDING_TYPE)); - - switch (bt) { - case ATOMPUB: - return createAtomPubBinding(parameters); - case WEBSERVICES: - return createWebServiceBinding(parameters); - case CUSTOM: - return createCustomBinding(parameters); - default: - throw new CmisRuntimeException("Ambiguous session parameter: " + parameters); - } - } - - /** - * Creates a provider with custom parameters. - */ - private static CmisBinding createCustomBinding(Map parameters) { - CmisBindingFactory factory = CmisBindingFactory.newInstance(); - CmisBinding binding = factory.createCmisBinding(parameters); - - return binding; - } - - /** - * Creates a Web Services provider. - */ - private static CmisBinding createWebServiceBinding(Map parameters) { - CmisBindingFactory factory = CmisBindingFactory.newInstance(); - CmisBinding binding = factory.createCmisWebServicesBinding(parameters); - - return binding; - } - - /** - * Creates an AtomPub provider. - */ - private static CmisBinding createAtomPubBinding(Map parameters) { - CmisBindingFactory factory = CmisBindingFactory.newInstance(); - CmisBinding binding = factory.createCmisAtomPubBinding(parameters); - - return binding; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.client.runtime; + +import java.util.Map; + +import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory; +import org.apache.chemistry.opencmis.commons.SessionParameter; +import org.apache.chemistry.opencmis.commons.enums.BindingType; +import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; +import org.apache.chemistry.opencmis.commons.spi.CmisBinding; + +/** + * Helper methods for binding handling. + */ +public class CmisBindingHelper { + /** + * Creates a {@link CmisProvider} object. + */ + public static CmisBinding createProvider(Map parameters) { + if (parameters == null || parameters.isEmpty()) { + throw new CmisRuntimeException("Session parameter not set!"); + } + + if (!parameters.containsKey(SessionParameter.BINDING_TYPE)) { + parameters.put(SessionParameter.BINDING_TYPE, BindingType.CUSTOM.value()); + } + + BindingType bt = BindingType.fromValue(parameters.get(SessionParameter.BINDING_TYPE)); + + switch (bt) { + case ATOMPUB: + return createAtomPubBinding(parameters); + case WEBSERVICES: + return createWebServiceBinding(parameters); + case CUSTOM: + return createCustomBinding(parameters); + default: + throw new CmisRuntimeException("Ambiguous session parameter: " + parameters); + } + } + + /** + * Creates a provider with custom parameters. + */ + private static CmisBinding createCustomBinding(Map parameters) { + CmisBindingFactory factory = CmisBindingFactory.newInstance(); + CmisBinding binding = factory.createCmisBinding(parameters); + + return binding; + } + + /** + * Creates a Web Services provider. + */ + private static CmisBinding createWebServiceBinding(Map parameters) { + CmisBindingFactory factory = CmisBindingFactory.newInstance(); + CmisBinding binding = factory.createCmisWebServicesBinding(parameters); + + return binding; + } + + /** + * Creates an AtomPub provider. + */ + private static CmisBinding createAtomPubBinding(Map parameters) { + CmisBindingFactory factory = CmisBindingFactory.newInstance(); + CmisBinding binding = factory.createCmisAtomPubBinding(parameters); + + return binding; + } +} Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentDocumentImpl.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentDocumentImpl.java?rev=980504&r1=980503&r2=980504&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentDocumentImpl.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentDocumentImpl.java Thu Jul 29 16:45:49 2010 @@ -1,391 +1,391 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.chemistry.opencmis.client.runtime; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.chemistry.opencmis.client.api.CmisObject; -import org.apache.chemistry.opencmis.client.api.Document; -import org.apache.chemistry.opencmis.client.api.ObjectFactory; -import org.apache.chemistry.opencmis.client.api.ObjectId; -import org.apache.chemistry.opencmis.client.api.ObjectType; -import org.apache.chemistry.opencmis.client.api.OperationContext; -import org.apache.chemistry.opencmis.client.api.Policy; -import org.apache.chemistry.opencmis.client.api.Property; -import org.apache.chemistry.opencmis.commons.PropertyIds; -import org.apache.chemistry.opencmis.commons.data.Ace; -import org.apache.chemistry.opencmis.commons.data.ContentStream; -import org.apache.chemistry.opencmis.commons.data.ObjectData; -import org.apache.chemistry.opencmis.commons.enums.Updatability; -import org.apache.chemistry.opencmis.commons.enums.VersioningState; -import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; -import org.apache.chemistry.opencmis.commons.spi.Holder; - -public class PersistentDocumentImpl extends AbstractPersistentFilableCmisObject implements Document { - - /** - * Constructor. - */ - public PersistentDocumentImpl(PersistentSessionImpl session, ObjectType objectType, ObjectData objectData, - OperationContext context) { - initialize(session, objectType, objectData, context); - } - - // properties - - public String getCheckinComment() { - return getPropertyValue(PropertyIds.CHECKIN_COMMENT); - } - - public String getVersionLabel() { - return getPropertyValue(PropertyIds.VERSION_LABEL); - } - - public String getVersionSeriesId() { - return getPropertyValue(PropertyIds.VERSION_SERIES_ID); - } - - public String getVersionSeriesCheckedOutId() { - return getPropertyValue(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID); - } - - public String getVersionSeriesCheckedOutBy() { - return getPropertyValue(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY); - } - - public Boolean isImmutable() { - return getPropertyValue(PropertyIds.IS_IMMUTABLE); - } - - public Boolean isLatestMajorVersion() { - return getPropertyValue(PropertyIds.IS_LATEST_MAJOR_VERSION); - } - - public Boolean isLatestVersion() { - return getPropertyValue(PropertyIds.IS_LATEST_VERSION); - } - - public Boolean isMajorVersion() { - return getPropertyValue(PropertyIds.IS_MAJOR_VERSION); - } - - public Boolean isVersionSeriesCheckedOut() { - return getPropertyValue(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT); - } - - public long getContentStreamLength() { - BigInteger bigInt = getPropertyValue(PropertyIds.CONTENT_STREAM_LENGTH); - return (bigInt == null) ? (long) -1 : bigInt.longValue(); - } - - public String getContentStreamMimeType() { - return getPropertyValue(PropertyIds.CONTENT_STREAM_MIME_TYPE); - } - - public String getContentStreamFileName() { - return getPropertyValue(PropertyIds.CONTENT_STREAM_FILE_NAME); - } - - public String getContentStreamId() { - return getPropertyValue(PropertyIds.CONTENT_STREAM_ID); - } - - // operations - - public Document copy(List> properties, VersioningState versioningState, List policies, - List addACEs, List removeACEs) { - throw new CmisRuntimeException("not implemented"); - } - - /* - * (non-Javadoc) - * - * @see org.apache.opencmis.client.api.Document#deleteAllVersions() - */ - public void deleteAllVersions() { - delete(true); - } - - // versioning - - /* - * (non-Javadoc) - * - * @see org.apache.opencmis.client.api.Document#checkOut() - */ - public ObjectId checkOut() { - String objectId = getObjectId(); - Holder objectIdHolder = new Holder(objectId); - - getBinding().getVersioningService().checkOut(getRepositoryId(), objectIdHolder, null, null); - - if (objectIdHolder.getValue() == null) { - return null; - } - - return getSession().createObjectId(objectIdHolder.getValue()); - } - - /* - * (non-Javadoc) - * - * @see org.apache.opencmis.client.api.Document#cancelCheckOut() - */ - public void cancelCheckOut() { - String objectId = getObjectId(); - - getBinding().getVersioningService().cancelCheckOut(getRepositoryId(), objectId, null); - } - - /* - * (non-Javadoc) - * - * @see org.apache.opencmis.client.api.Document#checkIn(boolean, - * java.util.Map, org.apache.opencmis.client.api.ContentStream, - * java.lang.String, java.util.List, java.util.List, java.util.List) - */ - public ObjectId checkIn(boolean major, Map properties, ContentStream contentStream, - String checkinComment, List policies, List addAces, List removeAces) { - String objectId; - ObjectType type; - readLock(); - try { - objectId = getObjectId(); - type = getType(); - } finally { - readUnlock(); - } - - Holder objectIdHolder = new Holder(objectId); - - ObjectFactory of = getObjectFactory(); - - Set updatebility = new HashSet(); - updatebility.add(Updatability.READWRITE); - updatebility.add(Updatability.WHENCHECKEDOUT); - - getBinding().getVersioningService() - .checkIn(getRepositoryId(), objectIdHolder, major, - of.convertProperties(properties, type, updatebility), of.convertContentStream(contentStream), - checkinComment, of.convertPolicies(policies), of.convertAces(addAces), - of.convertAces(removeAces), null); - - if (objectIdHolder.getValue() == null) { - return null; - } - - return getSession().createObjectId(objectIdHolder.getValue()); - - } - - /* - * (non-Javadoc) - * - * @see org.apache.opencmis.client.api.Document#getAllVersions() - */ - public List getAllVersions() { - return getAllVersions(getSession().getDefaultContext()); - } - - /* - * (non-Javadoc) - * - * @seeorg.apache.opencmis.client.api.Document#getAllVersions(org.apache. - * opencmis.client.api. OperationContext) - */ - public List getAllVersions(OperationContext context) { - String objectId; - String versionSeriesId; - - readLock(); - try { - objectId = getObjectId(); - versionSeriesId = getVersionSeriesId(); - } finally { - readUnlock(); - } - - List versions = getBinding().getVersioningService().getAllVersions(getRepositoryId(), objectId, - versionSeriesId, context.getFilterString(), context.isIncludeAllowableActions(), null); - - ObjectFactory objectFactory = getSession().getObjectFactory(); - - List result = new ArrayList(); - if (versions != null) { - for (ObjectData objectData : versions) { - CmisObject doc = objectFactory.convertObject(objectData, context); - if (!(doc instanceof Document)) { - // should not happen... - continue; - } - - result.add((Document) doc); - } - } - - return result; - - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.opencmis.client.api.Document#getObjectOfLatestVersion(boolean) - */ - public Document getObjectOfLatestVersion(boolean major) { - return getObjectOfLatestVersion(major, getSession().getDefaultContext()); - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.opencmis.client.api.Document#getObjectOfLatestVersion(boolean, - * org.apache.opencmis.client.api.OperationContext) - */ - public Document getObjectOfLatestVersion(boolean major, OperationContext context) { - String objectId; - String versionSeriesId; - - readLock(); - try { - objectId = getObjectId(); - versionSeriesId = getVersionSeriesId(); - } finally { - readUnlock(); - } - - if (versionSeriesId == null) { - throw new CmisRuntimeException("Version series id is unknown!"); - } - - ObjectData objectData = getBinding().getVersioningService().getObjectOfLatestVersion(getRepositoryId(), - objectId, versionSeriesId, major, context.getFilterString(), context.isIncludeAllowableActions(), - context.getIncludeRelationships(), context.getRenditionFilterString(), context.isIncludePolicies(), - context.isIncludeAcls(), null); - - ObjectFactory objectFactory = getSession().getObjectFactory(); - - CmisObject result = objectFactory.convertObject(objectData, context); - if (!(result instanceof Document)) { - throw new CmisRuntimeException("Latest version is not a document!"); - } - - return (Document) result; - } - - // content operations - - /* - * (non-Javadoc) - * - * @see org.apache.chemistry.opencmis.client.api.Document#getContentStream() - */ - public ContentStream getContentStream() { - return getContentStream(null); - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.chemistry.opencmis.client.api.Document#getContentStream(java - * .lang.String) - */ - public ContentStream getContentStream(String streamId) { - String objectId = getObjectId(); - - // get the stream - ContentStream contentStream = getBinding().getObjectService().getContentStream(getRepositoryId(), objectId, - streamId, null, null, null); - - // TODO: what should happen if the length is not set? - long length = (contentStream.getBigLength() == null ? -1 : contentStream.getBigLength().longValue()); - - // convert and return stream object - return getSession().getObjectFactory().createContentStream(contentStream.getFileName(), length, - contentStream.getMimeType(), contentStream.getStream()); - } - - /* - * (non-Javadoc) - * - * @see org.apache.opencmis.client.api.Document#setContentStream(boolean, - * org.apache.opencmis.client.api.ContentStream) - */ - public ObjectId setContentStream(ContentStream contentStream, boolean overwrite) { - String objectId; - String changeToken; - - readLock(); - try { - objectId = getObjectId(); - changeToken = getPropertyValue(PropertyIds.CHANGE_TOKEN); - } finally { - readUnlock(); - } - - Holder objectIdHolder = new Holder(objectId); - Holder changeTokenHolder = new Holder(changeToken); - - getBinding().getObjectService().setContentStream(getRepositoryId(), objectIdHolder, overwrite, - changeTokenHolder, getObjectFactory().convertContentStream(contentStream), null); - - if (objectIdHolder.getValue() == null) { - return null; - } - - return getSession().createObjectId(objectIdHolder.getValue()); - } - - /* - * (non-Javadoc) - * - * @see org.apache.opencmis.client.api.Document#deleteContentStream() - */ - public ObjectId deleteContentStream() { - String objectId; - String changeToken; - - readLock(); - try { - objectId = getObjectId(); - changeToken = getPropertyValue(PropertyIds.CHANGE_TOKEN); - } finally { - readUnlock(); - } - - Holder objectIdHolder = new Holder(objectId); - Holder changeTokenHolder = new Holder(changeToken); - - getBinding().getObjectService().deleteContentStream(getRepositoryId(), objectIdHolder, changeTokenHolder, null); - - if (objectIdHolder.getValue() == null) { - return null; - } - - return getSession().createObjectId(objectIdHolder.getValue()); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.client.runtime; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.chemistry.opencmis.client.api.CmisObject; +import org.apache.chemistry.opencmis.client.api.Document; +import org.apache.chemistry.opencmis.client.api.ObjectFactory; +import org.apache.chemistry.opencmis.client.api.ObjectId; +import org.apache.chemistry.opencmis.client.api.ObjectType; +import org.apache.chemistry.opencmis.client.api.OperationContext; +import org.apache.chemistry.opencmis.client.api.Policy; +import org.apache.chemistry.opencmis.client.api.Property; +import org.apache.chemistry.opencmis.commons.PropertyIds; +import org.apache.chemistry.opencmis.commons.data.Ace; +import org.apache.chemistry.opencmis.commons.data.ContentStream; +import org.apache.chemistry.opencmis.commons.data.ObjectData; +import org.apache.chemistry.opencmis.commons.enums.Updatability; +import org.apache.chemistry.opencmis.commons.enums.VersioningState; +import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; +import org.apache.chemistry.opencmis.commons.spi.Holder; + +public class PersistentDocumentImpl extends AbstractPersistentFilableCmisObject implements Document { + + /** + * Constructor. + */ + public PersistentDocumentImpl(PersistentSessionImpl session, ObjectType objectType, ObjectData objectData, + OperationContext context) { + initialize(session, objectType, objectData, context); + } + + // properties + + public String getCheckinComment() { + return getPropertyValue(PropertyIds.CHECKIN_COMMENT); + } + + public String getVersionLabel() { + return getPropertyValue(PropertyIds.VERSION_LABEL); + } + + public String getVersionSeriesId() { + return getPropertyValue(PropertyIds.VERSION_SERIES_ID); + } + + public String getVersionSeriesCheckedOutId() { + return getPropertyValue(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID); + } + + public String getVersionSeriesCheckedOutBy() { + return getPropertyValue(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY); + } + + public Boolean isImmutable() { + return getPropertyValue(PropertyIds.IS_IMMUTABLE); + } + + public Boolean isLatestMajorVersion() { + return getPropertyValue(PropertyIds.IS_LATEST_MAJOR_VERSION); + } + + public Boolean isLatestVersion() { + return getPropertyValue(PropertyIds.IS_LATEST_VERSION); + } + + public Boolean isMajorVersion() { + return getPropertyValue(PropertyIds.IS_MAJOR_VERSION); + } + + public Boolean isVersionSeriesCheckedOut() { + return getPropertyValue(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT); + } + + public long getContentStreamLength() { + BigInteger bigInt = getPropertyValue(PropertyIds.CONTENT_STREAM_LENGTH); + return (bigInt == null) ? (long) -1 : bigInt.longValue(); + } + + public String getContentStreamMimeType() { + return getPropertyValue(PropertyIds.CONTENT_STREAM_MIME_TYPE); + } + + public String getContentStreamFileName() { + return getPropertyValue(PropertyIds.CONTENT_STREAM_FILE_NAME); + } + + public String getContentStreamId() { + return getPropertyValue(PropertyIds.CONTENT_STREAM_ID); + } + + // operations + + public Document copy(List> properties, VersioningState versioningState, List policies, + List addACEs, List removeACEs) { + throw new CmisRuntimeException("not implemented"); + } + + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Document#deleteAllVersions() + */ + public void deleteAllVersions() { + delete(true); + } + + // versioning + + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Document#checkOut() + */ + public ObjectId checkOut() { + String objectId = getObjectId(); + Holder objectIdHolder = new Holder(objectId); + + getBinding().getVersioningService().checkOut(getRepositoryId(), objectIdHolder, null, null); + + if (objectIdHolder.getValue() == null) { + return null; + } + + return getSession().createObjectId(objectIdHolder.getValue()); + } + + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Document#cancelCheckOut() + */ + public void cancelCheckOut() { + String objectId = getObjectId(); + + getBinding().getVersioningService().cancelCheckOut(getRepositoryId(), objectId, null); + } + + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Document#checkIn(boolean, + * java.util.Map, org.apache.opencmis.client.api.ContentStream, + * java.lang.String, java.util.List, java.util.List, java.util.List) + */ + public ObjectId checkIn(boolean major, Map properties, ContentStream contentStream, + String checkinComment, List policies, List addAces, List removeAces) { + String objectId; + ObjectType type; + readLock(); + try { + objectId = getObjectId(); + type = getType(); + } finally { + readUnlock(); + } + + Holder objectIdHolder = new Holder(objectId); + + ObjectFactory of = getObjectFactory(); + + Set updatebility = new HashSet(); + updatebility.add(Updatability.READWRITE); + updatebility.add(Updatability.WHENCHECKEDOUT); + + getBinding().getVersioningService() + .checkIn(getRepositoryId(), objectIdHolder, major, + of.convertProperties(properties, type, updatebility), of.convertContentStream(contentStream), + checkinComment, of.convertPolicies(policies), of.convertAces(addAces), + of.convertAces(removeAces), null); + + if (objectIdHolder.getValue() == null) { + return null; + } + + return getSession().createObjectId(objectIdHolder.getValue()); + + } + + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Document#getAllVersions() + */ + public List getAllVersions() { + return getAllVersions(getSession().getDefaultContext()); + } + + /* + * (non-Javadoc) + * + * @seeorg.apache.opencmis.client.api.Document#getAllVersions(org.apache. + * opencmis.client.api. OperationContext) + */ + public List getAllVersions(OperationContext context) { + String objectId; + String versionSeriesId; + + readLock(); + try { + objectId = getObjectId(); + versionSeriesId = getVersionSeriesId(); + } finally { + readUnlock(); + } + + List versions = getBinding().getVersioningService().getAllVersions(getRepositoryId(), objectId, + versionSeriesId, context.getFilterString(), context.isIncludeAllowableActions(), null); + + ObjectFactory objectFactory = getSession().getObjectFactory(); + + List result = new ArrayList(); + if (versions != null) { + for (ObjectData objectData : versions) { + CmisObject doc = objectFactory.convertObject(objectData, context); + if (!(doc instanceof Document)) { + // should not happen... + continue; + } + + result.add((Document) doc); + } + } + + return result; + + } + + /* + * (non-Javadoc) + * + * @see + * org.apache.opencmis.client.api.Document#getObjectOfLatestVersion(boolean) + */ + public Document getObjectOfLatestVersion(boolean major) { + return getObjectOfLatestVersion(major, getSession().getDefaultContext()); + } + + /* + * (non-Javadoc) + * + * @see + * org.apache.opencmis.client.api.Document#getObjectOfLatestVersion(boolean, + * org.apache.opencmis.client.api.OperationContext) + */ + public Document getObjectOfLatestVersion(boolean major, OperationContext context) { + String objectId; + String versionSeriesId; + + readLock(); + try { + objectId = getObjectId(); + versionSeriesId = getVersionSeriesId(); + } finally { + readUnlock(); + } + + if (versionSeriesId == null) { + throw new CmisRuntimeException("Version series id is unknown!"); + } + + ObjectData objectData = getBinding().getVersioningService().getObjectOfLatestVersion(getRepositoryId(), + objectId, versionSeriesId, major, context.getFilterString(), context.isIncludeAllowableActions(), + context.getIncludeRelationships(), context.getRenditionFilterString(), context.isIncludePolicies(), + context.isIncludeAcls(), null); + + ObjectFactory objectFactory = getSession().getObjectFactory(); + + CmisObject result = objectFactory.convertObject(objectData, context); + if (!(result instanceof Document)) { + throw new CmisRuntimeException("Latest version is not a document!"); + } + + return (Document) result; + } + + // content operations + + /* + * (non-Javadoc) + * + * @see org.apache.chemistry.opencmis.client.api.Document#getContentStream() + */ + public ContentStream getContentStream() { + return getContentStream(null); + } + + /* + * (non-Javadoc) + * + * @see + * org.apache.chemistry.opencmis.client.api.Document#getContentStream(java + * .lang.String) + */ + public ContentStream getContentStream(String streamId) { + String objectId = getObjectId(); + + // get the stream + ContentStream contentStream = getBinding().getObjectService().getContentStream(getRepositoryId(), objectId, + streamId, null, null, null); + + // TODO: what should happen if the length is not set? + long length = (contentStream.getBigLength() == null ? -1 : contentStream.getBigLength().longValue()); + + // convert and return stream object + return getSession().getObjectFactory().createContentStream(contentStream.getFileName(), length, + contentStream.getMimeType(), contentStream.getStream()); + } + + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Document#setContentStream(boolean, + * org.apache.opencmis.client.api.ContentStream) + */ + public ObjectId setContentStream(ContentStream contentStream, boolean overwrite) { + String objectId; + String changeToken; + + readLock(); + try { + objectId = getObjectId(); + changeToken = getPropertyValue(PropertyIds.CHANGE_TOKEN); + } finally { + readUnlock(); + } + + Holder objectIdHolder = new Holder(objectId); + Holder changeTokenHolder = new Holder(changeToken); + + getBinding().getObjectService().setContentStream(getRepositoryId(), objectIdHolder, overwrite, + changeTokenHolder, getObjectFactory().convertContentStream(contentStream), null); + + if (objectIdHolder.getValue() == null) { + return null; + } + + return getSession().createObjectId(objectIdHolder.getValue()); + } + + /* + * (non-Javadoc) + * + * @see org.apache.opencmis.client.api.Document#deleteContentStream() + */ + public ObjectId deleteContentStream() { + String objectId; + String changeToken; + + readLock(); + try { + objectId = getObjectId(); + changeToken = getPropertyValue(PropertyIds.CHANGE_TOKEN); + } finally { + readUnlock(); + } + + Holder objectIdHolder = new Holder(objectId); + Holder changeTokenHolder = new Holder(changeToken); + + getBinding().getObjectService().deleteContentStream(getRepositoryId(), objectIdHolder, changeTokenHolder, null); + + if (objectIdHolder.getValue() == null) { + return null; + } + + return getSession().createObjectId(objectIdHolder.getValue()); + } +} Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentDocumentImpl.java ------------------------------------------------------------------------------ svn:eol-style = native