You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by dc...@apache.org on 2010/04/16 16:02:40 UTC
svn commit: r934881 [2/12] - in
/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src:
main/java/org/apache/chemistry/opencmis/client/bindings/cache/
main/java/org/apache/chemistry/opencmis/client/bindings...
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=934881&r1=934880&r2=934881&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 Fri Apr 16 14:02:38 2010
@@ -42,144 +42,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 fSession;
+ private final Session fSession;
- /**
- * Constructor.
- */
- public RepositoryServiceImpl(Session session) {
- fSession = session;
- }
-
- public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
- RepositoryInfo result = null;
- boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty());
-
- RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(fSession);
-
- // 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(fSession);
- 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(fSession);
- result = spi.getRepositoryService().getRepositoryInfos(extension);
-
- // put it into the cache
- if (!hasExtension && (result != null)) {
- RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(fSession);
- 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(fSession);
- result = spi.getRepositoryService().getTypeChildren(repositoryId, typeId,
- includePropertyDefinitions, maxItems, skipCount, extension);
-
- // put it into the cache
- if (!hasExtension && propDefs && (result != null)) {
- TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(fSession);
-
- 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(fSession);
-
- // 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(fSession);
- 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(fSession);
- result = spi.getRepositoryService().getTypeDescendants(repositoryId, typeId, depth,
- includePropertyDefinitions, extension);
-
- // put it into the cache
- if (!hasExtension && propDefs && (result != null)) {
- TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(fSession);
- 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) {
+ fSession = session;
+ }
+
+ public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
+ RepositoryInfo result = null;
+ boolean hasExtension = (extension != null) && (!extension.getExtensions().isEmpty());
+
+ RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(fSession);
+
+ // 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(fSession);
+ 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(fSession);
+ result = spi.getRepositoryService().getRepositoryInfos(extension);
+
+ // put it into the cache
+ if (!hasExtension && (result != null)) {
+ RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(fSession);
+ 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(fSession);
+ result = spi.getRepositoryService().getTypeChildren(repositoryId, typeId, includePropertyDefinitions, maxItems,
+ skipCount, extension);
+
+ // put it into the cache
+ if (!hasExtension && propDefs && (result != null)) {
+ TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(fSession);
+
+ 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(fSession);
+
+ // 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(fSession);
+ 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(fSession);
+ result = spi.getRepositoryService().getTypeDescendants(repositoryId, typeId, depth, includePropertyDefinitions,
+ extension);
+
+ // put it into the cache
+ if (!hasExtension && propDefs && (result != null)) {
+ TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(fSession);
+ 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=934881&r1=934880&r2=934881&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 Fri Apr 16 14:02:38 2010
@@ -33,113 +33,107 @@ 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> fData;
+ private Map<String, Object> fData;
- private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock();
+ private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock();
- /**
- * Constructor.
- */
- public SessionImpl() {
- fData = new HashMap<String, Object>();
- }
-
- public Object get(String key) {
- Object value = null;
-
- fLock.readLock().lock();
- try {
- value = fData.get(key);
- }
- finally {
- fLock.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) {
- fLock.writeLock().lock();
- try {
- fData.put(key, obj);
- }
- finally {
- fLock.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!");
- }
-
- fLock.writeLock().lock();
- try {
- fData.put(key, value);
- }
- finally {
- fLock.writeLock().unlock();
- }
- }
-
- public void remove(String key) {
- fLock.writeLock().lock();
- try {
- fData.remove(key);
- }
- finally {
- fLock.writeLock().unlock();
- }
- }
-
- public void readLock() {
- fLock.readLock().lock();
- }
-
- public void readUnlock() {
- fLock.readLock().unlock();
- }
-
- public void writeLock() {
- fLock.writeLock().lock();
- }
-
- public void writeUnlock() {
- fLock.writeLock().unlock();
- }
-
- @Override
- public String toString() {
- return fData.toString();
- }
+ /**
+ * Constructor.
+ */
+ public SessionImpl() {
+ fData = new HashMap<String, Object>();
+ }
+
+ public Object get(String key) {
+ Object value = null;
+
+ fLock.readLock().lock();
+ try {
+ value = fData.get(key);
+ } finally {
+ fLock.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) {
+ fLock.writeLock().lock();
+ try {
+ fData.put(key, obj);
+ } finally {
+ fLock.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!");
+ }
+
+ fLock.writeLock().lock();
+ try {
+ fData.put(key, value);
+ } finally {
+ fLock.writeLock().unlock();
+ }
+ }
+
+ public void remove(String key) {
+ fLock.writeLock().lock();
+ try {
+ fData.remove(key);
+ } finally {
+ fLock.writeLock().unlock();
+ }
+ }
+
+ public void readLock() {
+ fLock.readLock().lock();
+ }
+
+ public void readUnlock() {
+ fLock.readLock().unlock();
+ }
+
+ public void writeLock() {
+ fLock.writeLock().lock();
+ }
+
+ public void writeUnlock() {
+ fLock.writeLock().unlock();
+ }
+
+ @Override
+ public String toString() {
+ return fData.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=934881&r1=934880&r2=934881&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 Fri Apr 16 14:02:38 2010
@@ -28,19 +28,19 @@ import java.io.Serializable;
*/
public class TransientWrapper implements Serializable {
- private static final long serialVersionUID = 1L;
- private transient Object fObject = null;
+ private static final long serialVersionUID = 1L;
+ private transient Object fObject = null;
- public TransientWrapper(Object object) {
- fObject = object;
- }
+ public TransientWrapper(Object object) {
+ fObject = object;
+ }
- public Object getObject() {
- return fObject;
- }
+ public Object getObject() {
+ return fObject;
+ }
- @Override
- public String toString() {
- return (fObject == null ? "(no object)" : "(transient) " + fObject.toString());
- }
+ @Override
+ public String toString() {
+ return (fObject == null ? "(no object)" : "(transient) " + fObject.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=934881&r1=934880&r2=934881&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 Fri Apr 16 14:02:38 2010
@@ -36,90 +36,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 fCache;
+ private Cache fCache;
- /**
- * 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;
- }
-
- fCache = new CacheImpl("Type Definition Cache");
- fCache.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;
- }
-
- fCache.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) fCache.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) {
- fCache.remove(repositoryId, typeId);
- }
-
- /**
- * Removes all type definition objects of a repository from the cache.
- *
- * @param repositoryId
- * the repository id
- */
- public void remove(String repositoryId) {
- fCache.remove(repositoryId);
- }
-
- @Override
- public String toString() {
- return fCache.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;
+ }
+
+ fCache = new CacheImpl("Type Definition Cache");
+ fCache.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;
+ }
+
+ fCache.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) fCache.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) {
+ fCache.remove(repositoryId, typeId);
+ }
+
+ /**
+ * Removes all type definition objects of a repository from the cache.
+ *
+ * @param repositoryId
+ * the repository id
+ */
+ public void remove(String repositoryId) {
+ fCache.remove(repositoryId);
+ }
+
+ @Override
+ public String toString() {
+ return fCache.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=934881&r1=934880&r2=934881&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 Fri Apr 16 14:02:38 2010
@@ -33,75 +33,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=934881&r1=934880&r2=934881&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 Fri Apr 16 14:02:38 2010
@@ -35,62 +35,63 @@ import org.apache.chemistry.opencmis.com
*
*/
public interface CmisSpi {
- /**
- * 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);
+ /**
+ * 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);
}
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=934881&r1=934880&r2=934881&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 Fri Apr 16 14:02:38 2010
@@ -30,6 +30,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=934881&r1=934880&r2=934881&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 Fri Apr 16 14:02:38 2010
@@ -28,53 +28,53 @@ import java.io.Serializable;
*/
public interface Session extends Serializable {
- /**
- * 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();
+ /**
+ * 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=934881&r1=934880&r2=934881&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 Fri Apr 16 14:02:38 2010
@@ -37,143 +37,140 @@ import org.w3c.dom.Element;
/**
* Standard authentication provider class.
*
- * Adds a basic authentication HTTP header and a WS-Security UsernameToken SOAP header.
+ * Adds a basic authentication HTTP header and a WS-Security UsernameToken SOAP
+ * header.
*
* @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
*
*/
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;
+ }
}