Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryInfoCache.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/impl/RepositoryInfoCache.java?rev=936922&r1=936921&r2=936922&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryInfoCache.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryInfoCache.java Thu Apr 22 16:04:19 2010 @@ -33,67 +33,67 @@ import org.apache.chemistry.opencmis.com */ public class RepositoryInfoCache implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private static final int CACHE_SIZE_REPOSITORIES = 10; + private static final int CACHE_SIZE_REPOSITORIES = 10; - private Cache cache; + private Cache cache; - /** - * Constructor. - * - * @param session - * the session object - */ - public RepositoryInfoCache(Session session) { - int repCount = session.get(SessionParameter.CACHE_SIZE_REPOSITORIES, CACHE_SIZE_REPOSITORIES); - if (repCount < 1) { - repCount = CACHE_SIZE_REPOSITORIES; - } - - cache = new CacheImpl("Repository Info Cache"); - cache.initialize(new String[] { MapCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=" - + repCount }); - } - - /** - * Adds a repository info object to the cache. - * - * @param repositoryInfo - * the repository info object - */ - public void put(RepositoryInfo repositoryInfo) { - if ((repositoryInfo == null) || (repositoryInfo.getId() == null)) { - return; - } - - cache.put(repositoryInfo, repositoryInfo.getId()); - } - - /** - * Retrieves a repository info object from the cache. - * - * @param repositoryId - * the repository id - * @return the repository info object or <code>null</code> if the object is - * not in the cache - */ - public RepositoryInfo get(String repositoryId) { - return (RepositoryInfo) cache.get(repositoryId); - } - - /** - * Removes a repository info object from the cache. - * - * @param repositoryId - * the repository id - */ - public void remove(String repositoryId) { - cache.remove(repositoryId); - } - - @Override - public String toString() { - return cache.toString(); - } + /** + * Constructor. + * + * @param session + * the session object + */ + public RepositoryInfoCache(Session session) { + int repCount = session.get(SessionParameter.CACHE_SIZE_REPOSITORIES, CACHE_SIZE_REPOSITORIES); + if (repCount < 1) { + repCount = CACHE_SIZE_REPOSITORIES; + } + + cache = new CacheImpl("Repository Info Cache"); + cache.initialize(new String[] { MapCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=" + + repCount }); + } + + /** + * Adds a repository info object to the cache. + * + * @param repositoryInfo + * the repository info object + */ + public void put(RepositoryInfo repositoryInfo) { + if ((repositoryInfo == null) || (repositoryInfo.getId() == null)) { + return; + } + + cache.put(repositoryInfo, repositoryInfo.getId()); + } + + /** + * Retrieves a repository info object from the cache. + * + * @param repositoryId + * the repository id + * @return the repository info object or <code>null</code> if the object is + * not in the cache + */ + public RepositoryInfo get(String repositoryId) { + return (RepositoryInfo) cache.get(repositoryId); + } + + /** + * Removes a repository info object from the cache. + * + * @param repositoryId + * the repository id + */ + public void remove(String repositoryId) { + cache.remove(repositoryId); + } + + @Override + public String toString() { + return cache.toString(); + } }
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryServiceImpl.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/impl/RepositoryServiceImpl.java?rev=936922&r1=936921&r2=936922&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryServiceImpl.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryServiceImpl.java Thu Apr 22 16:04:19 2010 @@ -39,139 +39,139 @@ import org.apache.chemistry.opencmis.com */ public class RepositoryServiceImpl implements RepositoryService, Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private final Session session; + private final Session session; - /** - * Constructor. - */ - public RepositoryServiceImpl(Session session) { - this.session = session; - } - - public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) { - RepositoryInfo result = null; - boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty()); - - RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(session); - - // if extension is not set, check the cache first - if (!hasExtension) { - result = cache.get(repositoryId); - if (result != null) { - return result; - } - } - - // it was not in the cache -> get the SPI and fetch the repository info - CmisSpi spi = CmisBindingsHelper.getSPI(session); - result = spi.getRepositoryService().getRepositoryInfo(repositoryId, extension); - - // put it into the cache - if (!hasExtension) { - cache.put(result); - } - - return result; - } - - public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) { - List<RepositoryInfo> result = null; - boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty()); - - // get the SPI and fetch the repository infos - CmisSpi spi = CmisBindingsHelper.getSPI(session); - result = spi.getRepositoryService().getRepositoryInfos(extension); - - // put it into the cache - if (!hasExtension && (result != null)) { - RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(session); - for (RepositoryInfo rid : result) { - cache.put(rid); - } - } - - return result; - } - - public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions, - BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) { - TypeDefinitionList result = null; - boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty()); - boolean propDefs = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue()); - - // get the SPI and fetch the type definitions - CmisSpi spi = CmisBindingsHelper.getSPI(session); - result = spi.getRepositoryService().getTypeChildren(repositoryId, typeId, includePropertyDefinitions, maxItems, - skipCount, extension); - - // put it into the cache - if (!hasExtension && propDefs && (result != null)) { - TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session); - - for (TypeDefinition tdd : result.getList()) { - cache.put(repositoryId, tdd); - } - } - - return result; - } - - public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) { - TypeDefinition result = null; - boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty()); - - TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session); - - // if extension is not set, check the cache first - if (!hasExtension) { - result = cache.get(repositoryId, typeId); - if (result != null) { - return result; - } - } - - // it was not in the cache -> get the SPI and fetch the type definition - CmisSpi spi = CmisBindingsHelper.getSPI(session); - result = spi.getRepositoryService().getTypeDefinition(repositoryId, typeId, extension); - - // put it into the cache - if (!hasExtension && (result != null)) { - cache.put(repositoryId, result); - } - - return result; - } - - public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth, - Boolean includePropertyDefinitions, ExtensionsData extension) { - List<TypeDefinitionContainer> result = null; - boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty()); - boolean propDefs = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue()); - - // get the SPI and fetch the type definitions - CmisSpi spi = CmisBindingsHelper.getSPI(session); - result = spi.getRepositoryService().getTypeDescendants(repositoryId, typeId, depth, includePropertyDefinitions, - extension); - - // put it into the cache - if (!hasExtension && propDefs && (result != null)) { - TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session); - addToTypeCache(cache, repositoryId, result); - } - - return result; - } - - private void addToTypeCache(TypeDefinitionCache cache, String repositoryId, List<TypeDefinitionContainer> containers) { - if (containers == null) { - return; - } - - for (TypeDefinitionContainer container : containers) { - cache.put(repositoryId, container.getTypeDefinition()); - addToTypeCache(cache, repositoryId, container.getChildren()); - } - } + /** + * Constructor. + */ + public RepositoryServiceImpl(Session session) { + this.session = session; + } + + public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) { + RepositoryInfo result = null; + boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty()); + + RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(session); + + // if extension is not set, check the cache first + if (!hasExtension) { + result = cache.get(repositoryId); + if (result != null) { + return result; + } + } + + // it was not in the cache -> get the SPI and fetch the repository info + CmisSpi spi = CmisBindingsHelper.getSPI(session); + result = spi.getRepositoryService().getRepositoryInfo(repositoryId, extension); + + // put it into the cache + if (!hasExtension) { + cache.put(result); + } + + return result; + } + + public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) { + List<RepositoryInfo> result = null; + boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty()); + + // get the SPI and fetch the repository infos + CmisSpi spi = CmisBindingsHelper.getSPI(session); + result = spi.getRepositoryService().getRepositoryInfos(extension); + + // put it into the cache + if (!hasExtension && (result != null)) { + RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(session); + for (RepositoryInfo rid : result) { + cache.put(rid); + } + } + + return result; + } + + public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions, + BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) { + TypeDefinitionList result = null; + boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty()); + boolean propDefs = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue()); + + // get the SPI and fetch the type definitions + CmisSpi spi = CmisBindingsHelper.getSPI(session); + result = spi.getRepositoryService().getTypeChildren(repositoryId, typeId, includePropertyDefinitions, maxItems, + skipCount, extension); + + // put it into the cache + if (!hasExtension && propDefs && (result != null)) { + TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session); + + for (TypeDefinition tdd : result.getList()) { + cache.put(repositoryId, tdd); + } + } + + return result; + } + + public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) { + TypeDefinition result = null; + boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty()); + + TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session); + + // if extension is not set, check the cache first + if (!hasExtension) { + result = cache.get(repositoryId, typeId); + if (result != null) { + return result; + } + } + + // it was not in the cache -> get the SPI and fetch the type definition + CmisSpi spi = CmisBindingsHelper.getSPI(session); + result = spi.getRepositoryService().getTypeDefinition(repositoryId, typeId, extension); + + // put it into the cache + if (!hasExtension && (result != null)) { + cache.put(repositoryId, result); + } + + return result; + } + + public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth, + Boolean includePropertyDefinitions, ExtensionsData extension) { + List<TypeDefinitionContainer> result = null; + boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty()); + boolean propDefs = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue()); + + // get the SPI and fetch the type definitions + CmisSpi spi = CmisBindingsHelper.getSPI(session); + result = spi.getRepositoryService().getTypeDescendants(repositoryId, typeId, depth, includePropertyDefinitions, + extension); + + // put it into the cache + if (!hasExtension && propDefs && (result != null)) { + TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(session); + addToTypeCache(cache, repositoryId, result); + } + + return result; + } + + private void addToTypeCache(TypeDefinitionCache cache, String repositoryId, List<TypeDefinitionContainer> containers) { + if (containers == null) { + return; + } + + for (TypeDefinitionContainer container : containers) { + cache.put(repositoryId, container.getTypeDefinition()); + addToTypeCache(cache, repositoryId, container.getChildren()); + } + } } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/SessionImpl.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/impl/SessionImpl.java?rev=936922&r1=936921&r2=936922&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/SessionImpl.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/SessionImpl.java Thu Apr 22 16:04:19 2010 @@ -31,111 +31,111 @@ import org.apache.chemistry.opencmis.cli */ public class SessionImpl implements Session { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private Map<String, Object> data; + private Map<String, Object> data; - private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); + private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - /** - * Constructor. - */ - public SessionImpl() { - data = new HashMap<String, Object>(); - } - - public Collection<String> getKeys() { - return data.keySet(); - } - - public Object get(String key) { - Object value = null; - - lock.readLock().lock(); - try { - value = data.get(key); - } finally { - lock.readLock().unlock(); - } - - if (value instanceof TransientWrapper) { - return ((TransientWrapper) value).getObject(); - } - - return value; - } - - public Object get(String key, Object defValue) { - Object value = get(key); - return (value == null ? defValue : value); - } - - public int get(String key, int defValue) { - Object value = get(key); - int intValue = defValue; - - if (value instanceof Integer) { - intValue = ((Integer) value).intValue(); - } else if (value instanceof String) { - try { - intValue = Integer.valueOf((String) value); - } catch (NumberFormatException e) { - } - } - - return intValue; - } - - public void put(String key, Serializable obj) { - lock.writeLock().lock(); - try { - data.put(key, obj); - } finally { - lock.writeLock().unlock(); - } - } - - public void put(String key, Object obj, boolean isTransient) { - Object value = (isTransient ? new TransientWrapper(obj) : obj); - if (!(value instanceof Serializable)) { - throw new IllegalArgumentException("Object must be serializable!"); - } - - lock.writeLock().lock(); - try { - data.put(key, value); - } finally { - lock.writeLock().unlock(); - } - } - - public void remove(String key) { - lock.writeLock().lock(); - try { - data.remove(key); - } finally { - lock.writeLock().unlock(); - } - } - - public void readLock() { - lock.readLock().lock(); - } - - public void readUnlock() { - lock.readLock().unlock(); - } - - public void writeLock() { - lock.writeLock().lock(); - } - - public void writeUnlock() { - lock.writeLock().unlock(); - } - - @Override - public String toString() { - return data.toString(); - } + /** + * Constructor. + */ + public SessionImpl() { + data = new HashMap<String, Object>(); + } + + public Collection<String> getKeys() { + return data.keySet(); + } + + public Object get(String key) { + Object value = null; + + lock.readLock().lock(); + try { + value = data.get(key); + } finally { + lock.readLock().unlock(); + } + + if (value instanceof TransientWrapper) { + return ((TransientWrapper) value).getObject(); + } + + return value; + } + + public Object get(String key, Object defValue) { + Object value = get(key); + return (value == null ? defValue : value); + } + + public int get(String key, int defValue) { + Object value = get(key); + int intValue = defValue; + + if (value instanceof Integer) { + intValue = ((Integer) value).intValue(); + } else if (value instanceof String) { + try { + intValue = Integer.valueOf((String) value); + } catch (NumberFormatException e) { + } + } + + return intValue; + } + + public void put(String key, Serializable obj) { + lock.writeLock().lock(); + try { + data.put(key, obj); + } finally { + lock.writeLock().unlock(); + } + } + + public void put(String key, Object obj, boolean isTransient) { + Object value = (isTransient ? new TransientWrapper(obj) : obj); + if (!(value instanceof Serializable)) { + throw new IllegalArgumentException("Object must be serializable!"); + } + + lock.writeLock().lock(); + try { + data.put(key, value); + } finally { + lock.writeLock().unlock(); + } + } + + public void remove(String key) { + lock.writeLock().lock(); + try { + data.remove(key); + } finally { + lock.writeLock().unlock(); + } + } + + public void readLock() { + lock.readLock().lock(); + } + + public void readUnlock() { + lock.readLock().unlock(); + } + + public void writeLock() { + lock.writeLock().lock(); + } + + public void writeUnlock() { + lock.writeLock().unlock(); + } + + @Override + public String toString() { + return data.toString(); + } } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TransientWrapper.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/impl/TransientWrapper.java?rev=936922&r1=936921&r2=936922&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TransientWrapper.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TransientWrapper.java Thu Apr 22 16:04:19 2010 @@ -25,19 +25,19 @@ import java.io.Serializable; */ public class TransientWrapper implements Serializable { - private static final long serialVersionUID = 1L; - private transient Object object = null; + private static final long serialVersionUID = 1L; + private transient Object object = null; - public TransientWrapper(Object object) { - this.object = object; - } + public TransientWrapper(Object object) { + this.object = object; + } - public Object getObject() { - return object; - } + public Object getObject() { + return object; + } - @Override - public String toString() { - return (object == null ? "(no object)" : "(transient) " + object.toString()); - } + @Override + public String toString() { + return (object == null ? "(no object)" : "(transient) " + object.toString()); + } } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TypeDefinitionCache.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/impl/TypeDefinitionCache.java?rev=936922&r1=936921&r2=936922&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TypeDefinitionCache.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TypeDefinitionCache.java Thu Apr 22 16:04:19 2010 @@ -33,91 +33,91 @@ import org.apache.chemistry.opencmis.com */ public class TypeDefinitionCache implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private static final int CACHE_SIZE_REPOSITORIES = 10; - private static final int CACHE_SIZE_TYPES = 100; + private static final int CACHE_SIZE_REPOSITORIES = 10; + private static final int CACHE_SIZE_TYPES = 100; - private Cache cache; + private Cache cache; - /** - * Constructor. - * - * @param session - * the session object - */ - public TypeDefinitionCache(Session session) { - int repCount = session.get(SessionParameter.CACHE_SIZE_REPOSITORIES, CACHE_SIZE_REPOSITORIES); - if (repCount < 1) { - repCount = CACHE_SIZE_REPOSITORIES; - } - - int typeCount = session.get(SessionParameter.CACHE_SIZE_TYPES, CACHE_SIZE_TYPES); - if (typeCount < 1) { - typeCount = CACHE_SIZE_TYPES; - } - - cache = new CacheImpl("Type Definition Cache"); - cache.initialize(new String[] { - MapCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=" + repCount, // repository - LruCacheLevelImpl.class.getName() + " " + LruCacheLevelImpl.MAX_ENTRIES + "=" + typeCount // type - }); - } - - /** - * Adds a type definition object to the cache. - * - * @param repositoryId - * the repository id - * @param typeDefinition - * the type definition object - */ - public void put(String repositoryId, TypeDefinition typeDefinition) { - if ((typeDefinition == null) || (typeDefinition.getId() == null)) { - return; - } - - cache.put(typeDefinition, repositoryId, typeDefinition.getId()); - } - - /** - * Retrieves a type definition object from the cache. - * - * @param repositoryId - * the repository id - * @param typeId - * the type id - * @return the type definition object or <code>null</code> if the object is - * not in the cache - */ - public TypeDefinition get(String repositoryId, String typeId) { - return (TypeDefinition) cache.get(repositoryId, typeId); - } - - /** - * Removes a type definition object from the cache. - * - * @param repositoryId - * the repository id - * @param typeId - * the type id - */ - public void remove(String repositoryId, String typeId) { - cache.remove(repositoryId, typeId); - } - - /** - * Removes all type definition objects of a repository from the cache. - * - * @param repositoryId - * the repository id - */ - public void remove(String repositoryId) { - cache.remove(repositoryId); - } - - @Override - public String toString() { - return cache.toString(); - } + /** + * Constructor. + * + * @param session + * the session object + */ + public TypeDefinitionCache(Session session) { + int repCount = session.get(SessionParameter.CACHE_SIZE_REPOSITORIES, CACHE_SIZE_REPOSITORIES); + if (repCount < 1) { + repCount = CACHE_SIZE_REPOSITORIES; + } + + int typeCount = session.get(SessionParameter.CACHE_SIZE_TYPES, CACHE_SIZE_TYPES); + if (typeCount < 1) { + typeCount = CACHE_SIZE_TYPES; + } + + cache = new CacheImpl("Type Definition Cache"); + cache.initialize(new String[] { + MapCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=" + repCount, // repository + LruCacheLevelImpl.class.getName() + " " + LruCacheLevelImpl.MAX_ENTRIES + "=" + typeCount // type + }); + } + + /** + * Adds a type definition object to the cache. + * + * @param repositoryId + * the repository id + * @param typeDefinition + * the type definition object + */ + public void put(String repositoryId, TypeDefinition typeDefinition) { + if ((typeDefinition == null) || (typeDefinition.getId() == null)) { + return; + } + + cache.put(typeDefinition, repositoryId, typeDefinition.getId()); + } + + /** + * Retrieves a type definition object from the cache. + * + * @param repositoryId + * the repository id + * @param typeId + * the type id + * @return the type definition object or <code>null</code> if the object is + * not in the cache + */ + public TypeDefinition get(String repositoryId, String typeId) { + return (TypeDefinition) cache.get(repositoryId, typeId); + } + + /** + * Removes a type definition object from the cache. + * + * @param repositoryId + * the repository id + * @param typeId + * the type id + */ + public void remove(String repositoryId, String typeId) { + cache.remove(repositoryId, typeId); + } + + /** + * Removes all type definition objects of a repository from the cache. + * + * @param repositoryId + * the repository id + */ + public void remove(String repositoryId) { + cache.remove(repositoryId); + } + + @Override + public String toString() { + return cache.toString(); + } } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/AbstractAuthenticationProvider.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/spi/AbstractAuthenticationProvider.java?rev=936922&r1=936921&r2=936922&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/AbstractAuthenticationProvider.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/AbstractAuthenticationProvider.java Thu Apr 22 16:04:19 2010 @@ -30,78 +30,78 @@ import org.w3c.dom.Element; */ public abstract class AbstractAuthenticationProvider implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private Session fSession; + private Session fSession; - /** - * Sets the {...@link Session} the authentication provider lives in. - */ - public void setSession(Session session) { - fSession = session; - } - - /** - * Returns {...@link Session}. - */ - public Session getSession() { - return fSession; - } - - /** - * Returns a set of HTTP headers (key-value pairs) that should be added to a - * HTTP call. This will be called by the AtomPub and the Web Services - * binding. You might want to check the binding in use before you set the - * headers. - * - * @param url - * the URL of the HTTP call - * - * @return the HTTP headers or <code>null</code> if no additional headers - * should be set - */ - public Map<String, List<String>> getHTTPHeaders(String url) { - return null; - } - - /** - * Returns a SOAP header that should be added to a Web Services call. - * - * @param portObject - * the port object - * - * @return the SOAP headers or <code>null</code> if no additional headers - * should be set - */ - public Element getSOAPHeaders(Object portObject) { - return null; - } - - /** - * Gets the user name from the session. - * - * @return the user name or <code>null</code> if the user name is not set - */ - protected String getUser() { - Object userObject = getSession().get(SessionParameter.USER); - if (userObject instanceof String) { - return (String) userObject; - } - - return null; - } - - /** - * Gets the password from the session. - * - * @return the password or <code>null</code> if the password is not set - */ - protected String getPassword() { - Object passwordObject = getSession().get(SessionParameter.PASSWORD); - if (passwordObject instanceof String) { - return (String) passwordObject; - } + /** + * Sets the {...@link Session} the authentication provider lives in. + */ + public void setSession(Session session) { + fSession = session; + } + + /** + * Returns {...@link Session}. + */ + public Session getSession() { + return fSession; + } + + /** + * Returns a set of HTTP headers (key-value pairs) that should be added to a + * HTTP call. This will be called by the AtomPub and the Web Services + * binding. You might want to check the binding in use before you set the + * headers. + * + * @param url + * the URL of the HTTP call + * + * @return the HTTP headers or <code>null</code> if no additional headers + * should be set + */ + public Map<String, List<String>> getHTTPHeaders(String url) { + return null; + } + + /** + * Returns a SOAP header that should be added to a Web Services call. + * + * @param portObject + * the port object + * + * @return the SOAP headers or <code>null</code> if no additional headers + * should be set + */ + public Element getSOAPHeaders(Object portObject) { + return null; + } + + /** + * Gets the user name from the session. + * + * @return the user name or <code>null</code> if the user name is not set + */ + protected String getUser() { + Object userObject = getSession().get(SessionParameter.USER); + if (userObject instanceof String) { + return (String) userObject; + } + + return null; + } + + /** + * Gets the password from the session. + * + * @return the password or <code>null</code> if the password is not set + */ + protected String getPassword() { + Object passwordObject = getSession().get(SessionParameter.PASSWORD); + if (passwordObject instanceof String) { + return (String) passwordObject; + } - return null; - } + return null; + } } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/CmisSpi.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/spi/CmisSpi.java?rev=936922&r1=936921&r2=936922&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/CmisSpi.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/CmisSpi.java Thu Apr 22 16:04:19 2010 @@ -34,67 +34,67 @@ import org.apache.chemistry.opencmis.com * CMIS SPI interface. */ public interface CmisSpi extends Serializable { - /** - * Gets a Repository Service interface object. - */ - RepositoryService getRepositoryService(); - - /** - * Gets a Navigation Service interface object. - */ - NavigationService getNavigationService(); - - /** - * Gets an Object Service interface object. - */ - ObjectService getObjectService(); - - /** - * Gets a Versioning Service interface object. - */ - VersioningService getVersioningService(); - - /** - * Gets a Relationship Service interface object. - */ - RelationshipService getRelationshipService(); - - /** - * Gets a Discovery Service interface object. - */ - DiscoveryService getDiscoveryService(); - - /** - * Gets a Multifiling Service interface object. - */ - MultiFilingService getMultiFilingService(); - - /** - * Gets an ACL Service interface object. - */ - AclService getAclService(); - - /** - * Gets a Policy Service interface object. - */ - PolicyService getPolicyService(); - - /** - * Clears all caches of the current session. - */ - void clearAllCaches(); - - /** - * Clears all caches of the current session that are related to the given - * repository. - * - * @param repositoryId - * the repository id - */ - void clearRepositoryCache(String repositoryId); - - /** - * Releases all resources assigned to this SPI instance. - */ - void close(); + /** + * Gets a Repository Service interface object. + */ + RepositoryService getRepositoryService(); + + /** + * Gets a Navigation Service interface object. + */ + NavigationService getNavigationService(); + + /** + * Gets an Object Service interface object. + */ + ObjectService getObjectService(); + + /** + * Gets a Versioning Service interface object. + */ + VersioningService getVersioningService(); + + /** + * Gets a Relationship Service interface object. + */ + RelationshipService getRelationshipService(); + + /** + * Gets a Discovery Service interface object. + */ + DiscoveryService getDiscoveryService(); + + /** + * Gets a Multifiling Service interface object. + */ + MultiFilingService getMultiFilingService(); + + /** + * Gets an ACL Service interface object. + */ + AclService getAclService(); + + /** + * Gets a Policy Service interface object. + */ + PolicyService getPolicyService(); + + /** + * Clears all caches of the current session. + */ + void clearAllCaches(); + + /** + * Clears all caches of the current session that are related to the given + * repository. + * + * @param repositoryId + * the repository id + */ + void clearRepositoryCache(String repositoryId); + + /** + * Releases all resources assigned to this SPI instance. + */ + void close(); } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/CmisSpiFactory.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/spi/CmisSpiFactory.java?rev=936922&r1=936921&r2=936922&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/CmisSpiFactory.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/CmisSpiFactory.java Thu Apr 22 16:04:19 2010 @@ -27,6 +27,6 @@ package org.apache.chemistry.opencmis.cl */ public interface CmisSpiFactory { - CmisSpi getSpiInstance(Session session); + CmisSpi getSpiInstance(Session session); } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/Session.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/spi/Session.java?rev=936922&r1=936921&r2=936922&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/Session.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/Session.java Thu Apr 22 16:04:19 2010 @@ -26,58 +26,58 @@ import java.util.Collection; */ public interface Session extends Serializable { - /** - * Returns all keys. - */ - Collection<String> getKeys(); - - /** - * Gets a session value. - */ - Object get(String key); - - /** - * Returns a session value or the default value if the key doesn't exist. - */ - Object get(String key, Object defValue); - - /** - * Returns a session value or the default value if the key doesn't exist. - */ - int get(String key, int defValue); - - /** - * Adds a non-transient session value. - */ - void put(String key, Serializable object); - - /** - * Adds a session value. - */ - void put(String key, Object object, boolean isTransient); - - /** - * Removes a session value. - */ - void remove(String key); - - /** - * Acquires a read lock. - */ - void readLock(); - - /** - * Releases a read lock. - */ - void readUnlock(); - - /** - * Acquires a write lock. - */ - void writeLock(); - - /** - * Releases a write lock. - */ - void writeUnlock(); + /** + * Returns all keys. + */ + Collection<String> getKeys(); + + /** + * Gets a session value. + */ + Object get(String key); + + /** + * Returns a session value or the default value if the key doesn't exist. + */ + Object get(String key, Object defValue); + + /** + * Returns a session value or the default value if the key doesn't exist. + */ + int get(String key, int defValue); + + /** + * Adds a non-transient session value. + */ + void put(String key, Serializable object); + + /** + * Adds a session value. + */ + void put(String key, Object object, boolean isTransient); + + /** + * Removes a session value. + */ + void remove(String key); + + /** + * Acquires a read lock. + */ + void readLock(); + + /** + * Releases a read lock. + */ + void readUnlock(); + + /** + * Acquires a write lock. + */ + void writeLock(); + + /** + * Releases a write lock. + */ + void writeUnlock(); } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.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/spi/StandardAuthenticationProvider.java?rev=936922&r1=936921&r2=936922&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java Thu Apr 22 16:04:19 2010 @@ -42,132 +42,132 @@ import org.w3c.dom.Element; */ public class StandardAuthenticationProvider extends AbstractAuthenticationProvider { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private static final String WSSE_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; - private static final String WSU_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"; + private static final String WSSE_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; + private static final String WSU_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"; - @Override - public Map<String, List<String>> getHTTPHeaders(String url) { - Map<String, List<String>> result = null; - - // only send HTTP header if configured - if (!isTrue(SessionParameter.AUTH_HTTP_BASIC)) { - return null; - } - - // get user and password - String user = getUser(); - String password = getPassword(); - - // if no user is set, don't create HTTP headers - if (user == null) { - return null; - } - - if (password == null) { - password = ""; - } - - String authHeader = ""; - try { - authHeader = "Basic " - + new String(Base64.encodeBase64((user + ":" + password).getBytes("ISO-8859-1")), "ISO-8859-1"); - } catch (UnsupportedEncodingException e) { - // shouldn't happen... - return null; - } - - result = new HashMap<String, List<String>>(); - result.put("Authorization", Collections.singletonList(authHeader)); - - return result; - } - - @Override - public Element getSOAPHeaders(Object portObject) { - // get user and password - String user = getUser(); - String password = getPassword(); - - // only send SOAP header if configured - if (!isTrue(SessionParameter.AUTH_SOAP_USERNAMETOKEN)) { - return null; - } - - // if no user is set, don't create SOAP header - if (user == null) { - return null; - } - - if (password == null) { - password = ""; - } - - // set time - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - sdf.setTimeZone(TimeZone.getTimeZone("UTC")); - long created = System.currentTimeMillis(); - long expires = created + 24 * 60 * 60 * 1000; // 24 hours - - // create the SOAP header - try { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); - - Element wsseSecurityElement = document.createElementNS(WSSE_NAMESPACE, "Security"); - - Element wsuTimestampElement = document.createElementNS(WSU_NAMESPACE, "Timestamp"); - wsseSecurityElement.appendChild(wsuTimestampElement); - - Element tsCreatedElement = document.createElementNS(WSU_NAMESPACE, "Created"); - tsCreatedElement.setTextContent(sdf.format(created)); - wsuTimestampElement.appendChild(tsCreatedElement); - - Element tsExpiresElement = document.createElementNS(WSU_NAMESPACE, "Expires"); - tsExpiresElement.setTextContent(sdf.format(expires)); - wsuTimestampElement.appendChild(tsExpiresElement); - - Element usernameTokenElement = document.createElementNS(WSSE_NAMESPACE, "UsernameToken"); - wsseSecurityElement.appendChild(usernameTokenElement); - - Element usernameElement = document.createElementNS(WSSE_NAMESPACE, "Username"); - usernameElement.setTextContent(user); - usernameTokenElement.appendChild(usernameElement); - - Element passwordElement = document.createElementNS(WSSE_NAMESPACE, "Password"); - passwordElement.setTextContent(password); - passwordElement.setAttribute("Type", - "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"); - usernameTokenElement.appendChild(passwordElement); - - Element createdElement = document.createElementNS(WSU_NAMESPACE, "Created"); - createdElement.setTextContent(sdf.format(created)); - usernameTokenElement.appendChild(createdElement); - - return wsseSecurityElement; - } catch (ParserConfigurationException e) { - // shouldn't happen... - e.printStackTrace(); - } - - return null; - } - - /** - * Returns <code>true</code> if the given parameter exists in the session - * and is set to true, <code>false</code> otherwise. - */ - private boolean isTrue(String parameterName) { - Object value = getSession().get(parameterName); - - if (value instanceof Boolean) { - return ((Boolean) value).booleanValue(); - } - - if (value instanceof String) { - return Boolean.parseBoolean((String) value); - } + @Override + public Map<String, List<String>> getHTTPHeaders(String url) { + Map<String, List<String>> result = null; + + // only send HTTP header if configured + if (!isTrue(SessionParameter.AUTH_HTTP_BASIC)) { + return null; + } + + // get user and password + String user = getUser(); + String password = getPassword(); + + // if no user is set, don't create HTTP headers + if (user == null) { + return null; + } + + if (password == null) { + password = ""; + } + + String authHeader = ""; + try { + authHeader = "Basic " + + new String(Base64.encodeBase64((user + ":" + password).getBytes("ISO-8859-1")), "ISO-8859-1"); + } catch (UnsupportedEncodingException e) { + // shouldn't happen... + return null; + } + + result = new HashMap<String, List<String>>(); + result.put("Authorization", Collections.singletonList(authHeader)); + + return result; + } + + @Override + public Element getSOAPHeaders(Object portObject) { + // get user and password + String user = getUser(); + String password = getPassword(); + + // only send SOAP header if configured + if (!isTrue(SessionParameter.AUTH_SOAP_USERNAMETOKEN)) { + return null; + } + + // if no user is set, don't create SOAP header + if (user == null) { + return null; + } + + if (password == null) { + password = ""; + } + + // set time + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + sdf.setTimeZone(TimeZone.getTimeZone("UTC")); + long created = System.currentTimeMillis(); + long expires = created + 24 * 60 * 60 * 1000; // 24 hours + + // create the SOAP header + try { + Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + + Element wsseSecurityElement = document.createElementNS(WSSE_NAMESPACE, "Security"); + + Element wsuTimestampElement = document.createElementNS(WSU_NAMESPACE, "Timestamp"); + wsseSecurityElement.appendChild(wsuTimestampElement); + + Element tsCreatedElement = document.createElementNS(WSU_NAMESPACE, "Created"); + tsCreatedElement.setTextContent(sdf.format(created)); + wsuTimestampElement.appendChild(tsCreatedElement); + + Element tsExpiresElement = document.createElementNS(WSU_NAMESPACE, "Expires"); + tsExpiresElement.setTextContent(sdf.format(expires)); + wsuTimestampElement.appendChild(tsExpiresElement); + + Element usernameTokenElement = document.createElementNS(WSSE_NAMESPACE, "UsernameToken"); + wsseSecurityElement.appendChild(usernameTokenElement); + + Element usernameElement = document.createElementNS(WSSE_NAMESPACE, "Username"); + usernameElement.setTextContent(user); + usernameTokenElement.appendChild(usernameElement); + + Element passwordElement = document.createElementNS(WSSE_NAMESPACE, "Password"); + passwordElement.setTextContent(password); + passwordElement.setAttribute("Type", + "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"); + usernameTokenElement.appendChild(passwordElement); + + Element createdElement = document.createElementNS(WSU_NAMESPACE, "Created"); + createdElement.setTextContent(sdf.format(created)); + usernameTokenElement.appendChild(createdElement); + + return wsseSecurityElement; + } catch (ParserConfigurationException e) { + // shouldn't happen... + e.printStackTrace(); + } + + return null; + } + + /** + * Returns <code>true</code> if the given parameter exists in the session + * and is set to true, <code>false</code> otherwise. + */ + private boolean isTrue(String parameterName) { + Object value = getSession().get(parameterName); + + if (value instanceof Boolean) { + return ((Boolean) value).booleanValue(); + } + + if (value instanceof String) { + return Boolean.parseBoolean((String) value); + } - return false; - } + return false; + } }
