Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 06C39D7B4 for ; Mon, 27 May 2013 17:21:32 +0000 (UTC) Received: (qmail 66274 invoked by uid 500); 27 May 2013 17:21:31 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 66156 invoked by uid 500); 27 May 2013 17:21:31 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 66112 invoked by uid 99); 27 May 2013 17:21:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 May 2013 17:21:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Mon, 27 May 2013 17:21:24 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5F15D2388C22; Mon, 27 May 2013 17:20:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1486674 [13/44] - in /chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings: ./ css/ images/ images/logos/ xref-test/ xref-test/org/ xref-test/org/apache/ xref-test/org/apache/chemistry/... Date: Mon, 27 May 2013 17:20:22 -0000 To: commits@chemistry.apache.org From: gabriele@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130527172035.5F15D2388C22@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/ClientVersion.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/ClientVersion.html?rev=1486674&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/ClientVersion.html (added) +++ chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/ClientVersion.html Mon May 27 17:20:16 2013 @@ -0,0 +1,50 @@ + + + + +ClientVersion xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.client.bindings.impl;
+20  
+21  public class ClientVersion {
+22      
+23      public static final String OPENCMIS_VERSION;
+24      public static final String OPENCMIS_CLIENT;
+25  
+26      static {
+27          Package p = Package.getPackage("org.apache.chemistry.opencmis.client.bindings.impl");
+28          if (p == null) {
+29              OPENCMIS_VERSION = "?";
+30              OPENCMIS_CLIENT = "Apache Chemistry OpenCMIS";
+31          } else {
+32              OPENCMIS_VERSION = p.getImplementationVersion();
+33              OPENCMIS_CLIENT = "Apache Chemistry OpenCMIS/" + (OPENCMIS_VERSION == null ? "?" : OPENCMIS_VERSION);
+34          }
+35      }
+36  }
+
+
+ + Added: chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.html?rev=1486674&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.html (added) +++ chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.html Mon May 27 17:20:16 2013 @@ -0,0 +1,283 @@ + + + + +CmisBindingImpl xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.client.bindings.impl;
+20  
+21  import java.io.Serializable;
+22  import java.util.Map;
+23  
+24  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+25  import org.apache.chemistry.opencmis.client.bindings.spi.CmisSpi;
+26  import org.apache.chemistry.opencmis.client.bindings.spi.SessionAwareAuthenticationProvider;
+27  import org.apache.chemistry.opencmis.commons.SessionParameter;
+28  import org.apache.chemistry.opencmis.commons.impl.ClassLoaderUtil;
+29  import org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl;
+30  import org.apache.chemistry.opencmis.commons.spi.AclService;
+31  import org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider;
+32  import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
+33  import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
+34  import org.apache.chemistry.opencmis.commons.spi.DiscoveryService;
+35  import org.apache.chemistry.opencmis.commons.spi.MultiFilingService;
+36  import org.apache.chemistry.opencmis.commons.spi.NavigationService;
+37  import org.apache.chemistry.opencmis.commons.spi.ObjectService;
+38  import org.apache.chemistry.opencmis.commons.spi.PolicyService;
+39  import org.apache.chemistry.opencmis.commons.spi.RelationshipService;
+40  import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
+41  import org.apache.chemistry.opencmis.commons.spi.VersioningService;
+42  
+43  /**
+44   * CMIS binding implementation.
+45   */
+46  public class CmisBindingImpl implements CmisBinding, Serializable {
+47  
+48      private static final long serialVersionUID = 1L;
+49  
+50      private BindingSession session;
+51      private final BindingsObjectFactory objectFactory;
+52      private final RepositoryService repositoryServiceWrapper;
+53  
+54      /**
+55       * Constructor.
+56       * 
+57       * @param sessionParameters
+58       *            the session parameters
+59       */
+60      public CmisBindingImpl(Map<String, String> sessionParameters) {
+61          this(sessionParameters, null);
+62      }
+63  
+64      /**
+65       * Constructor.
+66       * 
+67       * @param sessionParameters
+68       *            the session parameters
+69       * @param authenticationProvider
+70       *            an authentication provider instance
+71       */
+72      public CmisBindingImpl(final Map<String, String> sessionParameters, AuthenticationProvider authenticationProvider) {
+73          // some checks first
+74          if (sessionParameters == null) {
+75              throw new IllegalArgumentException("Session parameters must be set!");
+76          }
+77          if (!sessionParameters.containsKey(SessionParameter.BINDING_SPI_CLASS)) {
+78              throw new IllegalArgumentException("Session parameters do not contain a SPI class name!");
+79          }
+80  
+81          // initialize session
+82          session = new SessionImpl();
+83          for (Map.Entry<String, String> entry : sessionParameters.entrySet()) {
+84              session.put(entry.getKey(), entry.getValue());
+85          }
+86  
+87          if (authenticationProvider == null) {
+88              // create authentication provider and add it session
+89              String authProviderClassName = sessionParameters.get(SessionParameter.AUTHENTICATION_PROVIDER_CLASS);
+90              if (authProviderClassName != null) {
+91                  Object authProviderObj = null;
+92  
+93                  try {
+94                      authProviderObj = ClassLoaderUtil.loadClass(authProviderClassName).newInstance();
+95                  } catch (Exception e) {
+96                      throw new IllegalArgumentException("Could not load authentication provider: " + e, e);
+97                  }
+98  
+99                  if (!(authProviderObj instanceof AuthenticationProvider)) {
+100                     throw new IllegalArgumentException(
+101                             "Authentication provider does not implement AuthenticationProvider!");
+102                 }
+103                 authenticationProvider = (AuthenticationProvider) authProviderObj;
+104             }
+105         }
+106 
+107         // locale
+108         String language = sessionParameters.get(SessionParameter.LOCALE_ISO639_LANGUAGE);
+109         if (language != null) {
+110             language = language.trim();
+111             if (language.length() > 0) {
+112                 String country = sessionParameters.get(SessionParameter.LOCALE_ISO3166_COUNTRY);
+113                 if (country != null) {
+114                     country = country.trim();
+115                     if (country.length() > 0) {
+116                         country = "-" + country;
+117                     }
+118                 } else {
+119                     country = "";
+120                 }
+121 
+122                 String acceptLanguage = language + country;
+123                 if ((acceptLanguage.indexOf('\n') == -1) && (acceptLanguage.indexOf('\r') == -1)) {
+124                     session.put(CmisBindingsHelper.ACCEPT_LANGUAGE, acceptLanguage);
+125                 }
+126             }
+127         }
+128 
+129         // set up caches
+130         clearAllCaches();
+131 
+132         // initialize the SPI
+133         CmisBindingsHelper.getSPI(session);
+134 
+135         // set up object factory
+136         objectFactory = new BindingsObjectFactoryImpl();
+137 
+138         // set up repository service
+139         repositoryServiceWrapper = new RepositoryServiceImpl(session);
+140 
+141         // add authentication provider to session
+142         if (authenticationProvider != null) {
+143             session.put(CmisBindingsHelper.AUTHENTICATION_PROVIDER_OBJECT, authenticationProvider);
+144             if (authenticationProvider instanceof SessionAwareAuthenticationProvider) {
+145                 ((SessionAwareAuthenticationProvider) authenticationProvider).setSession(session);
+146             }
+147         }
+148     }
+149 
+150     public RepositoryService getRepositoryService() {
+151         checkSession();
+152         return repositoryServiceWrapper;
+153     }
+154 
+155     public NavigationService getNavigationService() {
+156         checkSession();
+157         CmisSpi spi = CmisBindingsHelper.getSPI(session);
+158         return spi.getNavigationService();
+159     }
+160 
+161     public ObjectService getObjectService() {
+162         checkSession();
+163         CmisSpi spi = CmisBindingsHelper.getSPI(session);
+164         return spi.getObjectService();
+165     }
+166 
+167     public DiscoveryService getDiscoveryService() {
+168         checkSession();
+169         CmisSpi spi = CmisBindingsHelper.getSPI(session);
+170         return spi.getDiscoveryService();
+171     }
+172 
+173     public RelationshipService getRelationshipService() {
+174         checkSession();
+175         CmisSpi spi = CmisBindingsHelper.getSPI(session);
+176         return spi.getRelationshipService();
+177     }
+178 
+179     public VersioningService getVersioningService() {
+180         checkSession();
+181         CmisSpi spi = CmisBindingsHelper.getSPI(session);
+182         return spi.getVersioningService();
+183     }
+184 
+185     public AclService getAclService() {
+186         checkSession();
+187         CmisSpi spi = CmisBindingsHelper.getSPI(session);
+188         return spi.getAclService();
+189     }
+190 
+191     public MultiFilingService getMultiFilingService() {
+192         checkSession();
+193         CmisSpi spi = CmisBindingsHelper.getSPI(session);
+194         return spi.getMultiFilingService();
+195     }
+196 
+197     public PolicyService getPolicyService() {
+198         checkSession();
+199         CmisSpi spi = CmisBindingsHelper.getSPI(session);
+200         return spi.getPolicyService();
+201     }
+202 
+203     public BindingsObjectFactory getObjectFactory() {
+204         return objectFactory;
+205     }
+206 
+207     public AuthenticationProvider getAuthenticationProvider() {
+208         return CmisBindingsHelper.getAuthenticationProvider(session);
+209     }
+210 
+211     public void clearAllCaches() {
+212         checkSession();
+213 
+214         session.writeLock();
+215         try {
+216             session.put(CmisBindingsHelper.REPOSITORY_INFO_CACHE, new RepositoryInfoCache(session));
+217             session.put(CmisBindingsHelper.TYPE_DEFINTION_CACHE, new TypeDefinitionCache(session));
+218 
+219             CmisSpi spi = CmisBindingsHelper.getSPI(session);
+220             spi.clearAllCaches();
+221         } finally {
+222             session.writeUnlock();
+223         }
+224     }
+225 
+226     public void clearRepositoryCache(String repositoryId) {
+227         checkSession();
+228 
+229         if (repositoryId == null) {
+230             return;
+231         }
+232 
+233         session.writeLock();
+234         try {
+235             RepositoryInfoCache repInfoCache = (RepositoryInfoCache) session
+236                     .get(CmisBindingsHelper.REPOSITORY_INFO_CACHE);
+237             repInfoCache.remove(repositoryId);
+238 
+239             TypeDefinitionCache typeDefCache = (TypeDefinitionCache) session
+240                     .get(CmisBindingsHelper.TYPE_DEFINTION_CACHE);
+241             typeDefCache.remove(repositoryId);
+242 
+243             CmisSpi spi = CmisBindingsHelper.getSPI(session);
+244             spi.clearRepositoryCache(repositoryId);
+245         } finally {
+246             session.writeUnlock();
+247         }
+248     }
+249 
+250     public void close() {
+251         checkSession();
+252 
+253         session.writeLock();
+254         try {
+255             CmisSpi spi = CmisBindingsHelper.getSPI(session);
+256             spi.close();
+257         } finally {
+258             session.writeUnlock();
+259             session = null;
+260         }
+261 
+262     }
+263 
+264     private void checkSession() {
+265         if (session == null) {
+266             throw new IllegalStateException("Already closed.");
+267         }
+268     }
+269 }
+
+
+ + Added: chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.html?rev=1486674&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.html (added) +++ chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.html Mon May 27 17:20:16 2013 @@ -0,0 +1,168 @@ + + + + +CmisBindingsHelper xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.client.bindings.impl;
+20  
+21  import java.lang.reflect.Constructor;
+22  
+23  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+24  import org.apache.chemistry.opencmis.client.bindings.spi.CmisSpi;
+25  import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpInvoker;
+26  import org.apache.chemistry.opencmis.commons.SessionParameter;
+27  import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+28  import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+29  import org.apache.chemistry.opencmis.commons.impl.ClassLoaderUtil;
+30  import org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider;
+31  
+32  /**
+33   * A collection of static methods that are used in multiple places within the
+34   * bindings implementation.
+35   */
+36  public final class CmisBindingsHelper {
+37  
+38      public static final String REPOSITORY_INFO_CACHE = "org.apache.chemistry.opencmis.binding.repositoryInfoCache";
+39      public static final String TYPE_DEFINTION_CACHE = "org.apache.chemistry.opencmis.binding.typeDefintionCache";
+40      public static final String SPI_OBJECT = "org.apache.chemistry.opencmis.binding.spi.object";
+41      public static final String HTTP_INVOKER_OBJECT = "org.apache.chemistry.opencmis.binding.httpinvoker.object";
+42      public static final String AUTHENTICATION_PROVIDER_OBJECT = "org.apache.chemistry.opencmis.binding.auth.object";
+43      public static final String ACCEPT_LANGUAGE = "org.apache.chemistry.opencmis.binding.acceptLanguage";
+44  
+45      /**
+46       * Private constructor.
+47       */
+48      private CmisBindingsHelper() {
+49      }
+50  
+51      /**
+52       * Gets the SPI object for the given session. If there is already a SPI
+53       * object in the session it will be returned. If there is no SPI object it
+54       * will be created and put into the session.
+55       * 
+56       * @param session
+57       *            the session object
+58       * 
+59       * @return the SPI object
+60       */
+61      public static CmisSpi getSPI(BindingSession session) {
+62          // fetch from session
+63          CmisSpi spi = (CmisSpi) session.get(SPI_OBJECT);
+64          if (spi != null) {
+65              return spi;
+66          }
+67  
+68          session.writeLock();
+69          try {
+70              // try again
+71              spi = (CmisSpi) session.get(SPI_OBJECT);
+72              if (spi != null) {
+73                  return spi;
+74              }
+75  
+76              // ok, we have to create it...
+77              try {
+78                  String spiName = (String) session.get(SessionParameter.BINDING_SPI_CLASS);
+79                  Constructor<?> c = ClassLoaderUtil.loadClass(spiName).getConstructor(BindingSession.class);
+80                  spi = (CmisSpi) c.newInstance(session);
+81              } catch (CmisBaseException e) {
+82                  throw e;
+83              } catch (Exception e) {
+84                  throw new CmisRuntimeException("SPI cannot be initialized: " + e.getMessage(), e);
+85              }
+86  
+87              // we have a SPI object -> put it into the session
+88              session.put(SPI_OBJECT, spi, true);
+89          } finally {
+90              session.writeUnlock();
+91          }
+92  
+93          return spi;
+94      }
+95  
+96      /**
+97       * Gets the HTTP Invoker object from the session.
+98       */
+99      public static HttpInvoker getHttpInvoker(BindingSession session) {
+100         HttpInvoker invoker = (HttpInvoker) session.get(HTTP_INVOKER_OBJECT);
+101 
+102         if (invoker != null) {
+103             return invoker;
+104         }
+105 
+106         session.writeLock();
+107         try {
+108             // try again
+109             invoker = (HttpInvoker) session.get(HTTP_INVOKER_OBJECT);
+110             if (invoker != null) {
+111                 return invoker;
+112             }
+113 
+114             // ok, we have to create it...
+115             try {
+116                 String invokerName = (String) session.get(SessionParameter.HTTP_INVOKER_CLASS);
+117                 invoker = (HttpInvoker) ClassLoaderUtil.loadClass(invokerName).newInstance();
+118             } catch (CmisBaseException e) {
+119                 throw e;
+120             } catch (Exception e) {
+121                 throw new CmisRuntimeException("HTTP invoker cannot be initialized: " + e.getMessage(), e);
+122             }
+123 
+124             // we have an Invoker object -> put it into the session
+125             session.put(HTTP_INVOKER_OBJECT, invoker, true);
+126         } finally {
+127             session.writeUnlock();
+128         }
+129 
+130         return invoker;
+131     }
+132 
+133     /**
+134      * Returns the authentication provider from the session or <code>null</code>
+135      * if no authentication provider is set.
+136      */
+137     public static AuthenticationProvider getAuthenticationProvider(BindingSession session) {
+138         return (AuthenticationProvider) session.get(AUTHENTICATION_PROVIDER_OBJECT);
+139     }
+140 
+141     /**
+142      * Returns the repository info cache from the session.
+143      */
+144     public static RepositoryInfoCache getRepositoryInfoCache(BindingSession session) {
+145         return (RepositoryInfoCache) session.get(REPOSITORY_INFO_CACHE);
+146     }
+147 
+148     /**
+149      * Returns the type definition cache from the session.
+150      */
+151     public static TypeDefinitionCache getTypeDefinitionCache(BindingSession session) {
+152         return (TypeDefinitionCache) session.get(TYPE_DEFINTION_CACHE);
+153     }
+154 }
+
+
+ + Added: chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryInfoCache.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryInfoCache.html?rev=1486674&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryInfoCache.html (added) +++ chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryInfoCache.html Mon May 27 17:20:16 2013 @@ -0,0 +1,113 @@ + + + + +RepositoryInfoCache xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  
+20  package org.apache.chemistry.opencmis.client.bindings.impl;
+21  
+22  import java.io.Serializable;
+23  
+24  import org.apache.chemistry.opencmis.client.bindings.cache.Cache;
+25  import org.apache.chemistry.opencmis.client.bindings.cache.impl.CacheImpl;
+26  import org.apache.chemistry.opencmis.client.bindings.cache.impl.MapCacheLevelImpl;
+27  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+28  import org.apache.chemistry.opencmis.commons.SessionParameter;
+29  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+30  
+31  /**
+32   * A cache for repository info objects.
+33   */
+34  public class RepositoryInfoCache implements Serializable {
+35  
+36      private static final long serialVersionUID = 1L;
+37  
+38      private static final int CACHE_SIZE_REPOSITORIES = 10;
+39  
+40      private final Cache cache;
+41  
+42      /**
+43       * Constructor.
+44       * 
+45       * @param session
+46       *            the session object
+47       */
+48      public RepositoryInfoCache(BindingSession session) {
+49          int repCount = session.get(SessionParameter.CACHE_SIZE_REPOSITORIES, CACHE_SIZE_REPOSITORIES);
+50          if (repCount < 1) {
+51              repCount = CACHE_SIZE_REPOSITORIES;
+52          }
+53  
+54          cache = new CacheImpl("Repository Info Cache");
+55          cache.initialize(new String[] { MapCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "="
+56                  + repCount });
+57      }
+58  
+59      /**
+60       * Adds a repository info object to the cache.
+61       * 
+62       * @param repositoryInfo
+63       *            the repository info object
+64       */
+65      public void put(RepositoryInfo repositoryInfo) {
+66          if ((repositoryInfo == null) || (repositoryInfo.getId() == null)) {
+67              return;
+68          }
+69  
+70          cache.put(repositoryInfo, repositoryInfo.getId());
+71      }
+72  
+73      /**
+74       * Retrieves a repository info object from the cache.
+75       * 
+76       * @param repositoryId
+77       *            the repository id
+78       * @return the repository info object or <code>null</code> if the object is
+79       *         not in the cache
+80       */
+81      public RepositoryInfo get(String repositoryId) {
+82          return (RepositoryInfo) cache.get(repositoryId);
+83      }
+84  
+85      /**
+86       * Removes a repository info object from the cache.
+87       * 
+88       * @param repositoryId
+89       *            the repository id
+90       */
+91      public void remove(String repositoryId) {
+92          cache.remove(repositoryId);
+93      }
+94  
+95      @Override
+96      public String toString() {
+97          return cache.toString();
+98      }
+99  }
+
+
+ +