chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcaru...@apache.org
Subject svn commit: r936922 [2/18] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-client: chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/ chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/c...
Date Thu, 22 Apr 2010 16:04:22 GMT
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java?rev=936922&r1=936921&r2=936922&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java Thu Apr 22 16:04:19 2010
@@ -36,161 +36,161 @@ import org.apache.chemistry.opencmis.com
  */
 public interface Session {
 
-	/**
-	 * Clear all cached data. This implies that all data will be reloaded from
-	 * the repository (depending on the implementation, reloading might be done
-	 * immediately or be deferred).
-	 */
-	void clear();
-
-	/**
-	 * Save all pending actions for this session. Corresponds to a
-	 * <code>commit</code> if the CMIS provider supports transactions. If
-	 * transactions are not supported by the CMIS provider, changes might be
-	 * applied only partially.
-	 */
-	void save();
-
-	/**
-	 * Cancel all pending actions for this session. Corresponds to a
-	 * <code>rollback</code> if the CMIS provider supports transactions. If
-	 * transactions are not supported by the CMIS provider, some changes might
-	 * already be applied and therefore not rolled back.
-	 */
-	void cancel();
-
-	// session context
-
-	/**
-	 * Gets the underlying binding object.
-	 */
-	CmisBinding getBinding();
-
-	/**
-	 * Get the current default operation parameters for filtering and paging.
-	 */
-	OperationContext getDefaultContext();
-
-	/**
-	 * Set the current session parameters for filtering and paging.
-	 * 
-	 * @param context
-	 *            the <code>OperationContext</code> to be used for the session;
-	 *            if <code>null</code>, a default context is used
-	 */
-	void setDefaultContext(OperationContext context);
-
-	/**
-	 * Creates an operation context object.
-	 */
-	OperationContext createOperationContext(Set<String> filter, boolean includeAcls, boolean includeAllowableActions,
-			boolean includePolicies, IncludeRelationships includeRelationships, Set<String> renditionFilter,
-			boolean includePathSegments, String orderBy, boolean cacheEnabled);
-
-	/**
-	 * Creates an object id.
-	 */
-	ObjectId createObjectId(String id);
-
-	// localization
-
-	/**
-	 * Get the current locale to be used for this session.
-	 */
-	Locale getLocale();
-
-	// services
-
-	/**
-	 * Repository service <code>getRepositoryInfo()</code>.
-	 */
-	RepositoryInfo getRepositoryInfo();
-
-	/**
-	 * Access to the object services <code>create</code><i>...</i>, plus factory
-	 * methods to create <code>Acl</code>s, <code>Ace</code>s, and
-	 * <code>ContentStream</code>.
-	 */
-	ObjectFactory getObjectFactory();
-
-	// types
-
-	/**
-	 * Returns the type definition of the given type id.
-	 */
-	ObjectType getTypeDefinition(String typeId);
-
-	/**
-	 * Returns the type children of the given type id.
-	 */
-	PagingIterable<ObjectType> getTypeChildren(String typeId, boolean includePropertyDefinitions, int itemsPerPage);
-
-	/**
-	 * Returns the type descendants of the given type id.
-	 */
-	List<Tree<ObjectType>> getTypeDescendants(String typeId, int depth, boolean includePropertyDefinitions);
-
-	// navigation
-
-	/**
-	 * Gets the root folder for the repository.
-	 */
-	Folder getRootFolder();
-
-	Folder getRootFolder(OperationContext context);
-
-	/**
-	 * Returns all checked out documents.
-	 * 
-	 * @see Folder#getCheckedOutDocs(int)
-	 */
-	PagingIterable<Document> getCheckedOutDocs(int itemsPerPage);
-
-	PagingIterable<Document> getCheckedOutDocs(OperationContext context, int itemsPerPage);
-
-	/**
-	 * Object service <code>getObject</code>.
-	 */
-	CmisObject getObject(ObjectId objectId);
-
-	CmisObject getObject(ObjectId objectId, OperationContext context);
-
-	/**
-	 * Object service <code>getObjectByPath</code>.
-	 */
-	CmisObject getObjectByPath(String path);
-
-	CmisObject getObjectByPath(String path, OperationContext context);
-
-	// discovery
-
-	/**
-	 * Discovery service <code>query</code>.
-	 */
-	PagingIterable<QueryResult> query(String statement, boolean searchAllVersions, int itemsPerPage);
-
-	PagingIterable<QueryResult> query(String statement, boolean searchAllVersions, OperationContext context,
-			int itemsPerPage);
-
-	/**
-	 * Discovery service <code>getContentChanges</code>.
-	 */
-	PagingIterable<ChangeEvent> getContentChanges(String changeLogToken, int itemsPerPage);
-
-	// create
-
-	ObjectId createDocument(Map<String, ?> properties, ObjectId folderId, ContentStream contentStream,
-			VersioningState versioningState, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces);
-
-	ObjectId createDocumentFromSource(ObjectId source, Map<String, ?> properties, ObjectId folderId,
-			VersioningState versioningState, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces);
+    /**
+     * Clear all cached data. This implies that all data will be reloaded from
+     * the repository (depending on the implementation, reloading might be done
+     * immediately or be deferred).
+     */
+    void clear();
+
+    /**
+     * Save all pending actions for this session. Corresponds to a
+     * <code>commit</code> if the CMIS provider supports transactions. If
+     * transactions are not supported by the CMIS provider, changes might be
+     * applied only partially.
+     */
+    void save();
+
+    /**
+     * Cancel all pending actions for this session. Corresponds to a
+     * <code>rollback</code> if the CMIS provider supports transactions. If
+     * transactions are not supported by the CMIS provider, some changes might
+     * already be applied and therefore not rolled back.
+     */
+    void cancel();
+
+    // session context
+
+    /**
+     * Gets the underlying binding object.
+     */
+    CmisBinding getBinding();
+
+    /**
+     * Get the current default operation parameters for filtering and paging.
+     */
+    OperationContext getDefaultContext();
+
+    /**
+     * Set the current session parameters for filtering and paging.
+     * 
+     * @param context
+     *            the <code>OperationContext</code> to be used for the session;
+     *            if <code>null</code>, a default context is used
+     */
+    void setDefaultContext(OperationContext context);
+
+    /**
+     * Creates an operation context object.
+     */
+    OperationContext createOperationContext(Set<String> filter, boolean includeAcls, boolean includeAllowableActions,
+            boolean includePolicies, IncludeRelationships includeRelationships, Set<String> renditionFilter,
+            boolean includePathSegments, String orderBy, boolean cacheEnabled);
+
+    /**
+     * Creates an object id.
+     */
+    ObjectId createObjectId(String id);
+
+    // localization
+
+    /**
+     * Get the current locale to be used for this session.
+     */
+    Locale getLocale();
+
+    // services
+
+    /**
+     * Repository service <code>getRepositoryInfo()</code>.
+     */
+    RepositoryInfo getRepositoryInfo();
+
+    /**
+     * Access to the object services <code>create</code><i>...</i>, plus factory
+     * methods to create <code>Acl</code>s, <code>Ace</code>s, and
+     * <code>ContentStream</code>.
+     */
+    ObjectFactory getObjectFactory();
+
+    // types
+
+    /**
+     * Returns the type definition of the given type id.
+     */
+    ObjectType getTypeDefinition(String typeId);
+
+    /**
+     * Returns the type children of the given type id.
+     */
+    PagingIterable<ObjectType> getTypeChildren(String typeId, boolean includePropertyDefinitions, int itemsPerPage);
+
+    /**
+     * Returns the type descendants of the given type id.
+     */
+    List<Tree<ObjectType>> getTypeDescendants(String typeId, int depth, boolean includePropertyDefinitions);
+
+    // navigation
+
+    /**
+     * Gets the root folder for the repository.
+     */
+    Folder getRootFolder();
+
+    Folder getRootFolder(OperationContext context);
+
+    /**
+     * Returns all checked out documents.
+     * 
+     * @see Folder#getCheckedOutDocs(int)
+     */
+    PagingIterable<Document> getCheckedOutDocs(int itemsPerPage);
+
+    PagingIterable<Document> getCheckedOutDocs(OperationContext context, int itemsPerPage);
+
+    /**
+     * Object service <code>getObject</code>.
+     */
+    CmisObject getObject(ObjectId objectId);
+
+    CmisObject getObject(ObjectId objectId, OperationContext context);
+
+    /**
+     * Object service <code>getObjectByPath</code>.
+     */
+    CmisObject getObjectByPath(String path);
+
+    CmisObject getObjectByPath(String path, OperationContext context);
+
+    // discovery
+
+    /**
+     * Discovery service <code>query</code>.
+     */
+    PagingIterable<QueryResult> query(String statement, boolean searchAllVersions, int itemsPerPage);
+
+    PagingIterable<QueryResult> query(String statement, boolean searchAllVersions, OperationContext context,
+            int itemsPerPage);
+
+    /**
+     * Discovery service <code>getContentChanges</code>.
+     */
+    PagingIterable<ChangeEvent> getContentChanges(String changeLogToken, int itemsPerPage);
+
+    // create
+
+    ObjectId createDocument(Map<String, ?> properties, ObjectId folderId, ContentStream contentStream,
+            VersioningState versioningState, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces);
+
+    ObjectId createDocumentFromSource(ObjectId source, Map<String, ?> properties, ObjectId folderId,
+            VersioningState versioningState, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces);
 
-	ObjectId createFolder(Map<String, ?> properties, ObjectId folderId, List<Policy> policies, List<Ace> addAces,
-			List<Ace> removeAces);
+    ObjectId createFolder(Map<String, ?> properties, ObjectId folderId, List<Policy> policies, List<Ace> addAces,
+            List<Ace> removeAces);
 
-	ObjectId createPolicy(Map<String, ?> properties, ObjectId folderId, List<Policy> policies, List<Ace> addAces,
-			List<Ace> removeAces);
+    ObjectId createPolicy(Map<String, ?> properties, ObjectId folderId, List<Policy> policies, List<Ace> addAces,
+            List<Ace> removeAces);
 
-	ObjectId createRelationship(Map<String, ?> properties, List<Policy> policies, List<Ace> addAces,
-			List<Ace> removeAces);
+    ObjectId createRelationship(Map<String, ?> properties, List<Policy> policies, List<Ace> addAces,
+            List<Ace> removeAces);
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Tree.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Tree.java?rev=936922&r1=936921&r2=936922&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Tree.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Tree.java Thu Apr 22 16:04:19 2010
@@ -25,13 +25,13 @@ import java.util.List;
  */
 public interface Tree<T> {
 
-	/**
-	 * Returns the item on this level.
-	 */
-	T getItem();
+    /**
+     * Returns the item on this level.
+     */
+    T getItem();
 
-	/**
-	 * Returns the children.
-	 */
-	List<Tree<T>> getChildren();
+    /**
+     * Returns the children.
+     */
+    List<Tree<T>> getChildren();
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java?rev=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/CmisBindingFactory.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java Thu Apr 22 16:04:19 2010
@@ -30,177 +30,177 @@ import org.apache.chemistry.opencmis.com
  */
 public final class CmisBindingFactory {
 
-	/** Default CMIS AtomPub binding SPI implementation */
-	public static final String BINDING_SPI_ATOMPUB = "org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubSpi";
-	/** Default CMIS Web Services binding SPI implementation */
-	public static final String BINDING_SPI_WEBSERVICES = "org.apache.chemistry.opencmis.client.bindings.spi.webservices.CmisWebServicesSpi";
-	/** Default CMIS local binding SPI implementation */
-	public static final String BINDING_SPI_LOCAL = "org.apache.chemistry.opencmis.client.bindings.spi.local.CmisLocalSpi";
-	/** CMIS In Memory binding SPI implementation (for testing only!) */
-	public static final String BINDING_SPI_INMEMORY = "org.apache.chemistry.opencmis.inmemory.clientprovider.CmisInMemorySpiFactory";
-
-	/** Standard authentication provider class */
-	public static final String STANDARD_AUTHENTICATION_PROVIDER = "org.apache.chemistry.opencmis.client.bindings.spi.StandardAuthenticationProvider";
-
-	private Map<String, String> defaults;
-
-	/**
-	 * Private constructor -- it's a factory.
-	 */
-	private CmisBindingFactory() {
-		defaults = createNewDefaultParameters();
-	}
-
-	/**
-	 * Creates a new factory instance.
-	 */
-	public static CmisBindingFactory newInstance() {
-		return new CmisBindingFactory();
-	}
-
-	/**
-	 * Returns the default session parameters.
-	 */
-	public Map<String, String> getDefaultSessionParameters() {
-		return defaults;
-	}
-
-	/**
-	 * Sets the default session parameters.
-	 */
-	public void setDefaultSessionParameters(Map<String, String> sessionParameters) {
-		if (sessionParameters == null) {
-			defaults = createNewDefaultParameters();
-		} else {
-			defaults = sessionParameters;
-		}
-	}
-
-	/**
-	 * Creates a CMIS binding instance. A binding class has to be provided in
-	 * the session parameters.
-	 */
-	public CmisBinding createCmisBinding(Map<String, String> sessionParameters) {
-		checkSessionParameters(sessionParameters, true);
-
-		addDefaultParameters(sessionParameters);
-
-		return new CmisBindingImpl(sessionParameters);
-	}
-
-	/**
-	 * Creates a default CMIS AtomPub binding instance.
-	 */
-	public CmisBinding createCmisAtomPubBinding(Map<String, String> sessionParameters) {
-		checkSessionParameters(sessionParameters, false);
-
-		sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_ATOMPUB);
-		if (!sessionParameters.containsKey(SessionParameter.AUTHENTICATION_PROVIDER_CLASS)) {
-			sessionParameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, STANDARD_AUTHENTICATION_PROVIDER);
-		}
-		sessionParameters.put(SessionParameter.AUTH_HTTP_BASIC, "true");
-		sessionParameters.put(SessionParameter.AUTH_SOAP_USERNAMETOKEN, "false");
-		addDefaultParameters(sessionParameters);
-
-		check(sessionParameters, SessionParameter.ATOMPUB_URL);
-
-		return new CmisBindingImpl(sessionParameters);
-	}
-
-	/**
-	 * Creates a default CMIS Web Services binding instance.
-	 */
-	public CmisBinding createCmisWebServicesBinding(Map<String, String> sessionParameters) {
-		checkSessionParameters(sessionParameters, false);
-
-		sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_WEBSERVICES);
-		if (!sessionParameters.containsKey(SessionParameter.AUTHENTICATION_PROVIDER_CLASS)) {
-			sessionParameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, STANDARD_AUTHENTICATION_PROVIDER);
-		}
-		sessionParameters.put(SessionParameter.AUTH_HTTP_BASIC, "true");
-		sessionParameters.put(SessionParameter.AUTH_SOAP_USERNAMETOKEN, "true");
-		addDefaultParameters(sessionParameters);
-
-		check(sessionParameters, SessionParameter.WEBSERVICES_ACL_SERVICE);
-		check(sessionParameters, SessionParameter.WEBSERVICES_DISCOVERY_SERVICE);
-		check(sessionParameters, SessionParameter.WEBSERVICES_MULTIFILING_SERVICE);
-		check(sessionParameters, SessionParameter.WEBSERVICES_NAVIGATION_SERVICE);
-		check(sessionParameters, SessionParameter.WEBSERVICES_OBJECT_SERVICE);
-		check(sessionParameters, SessionParameter.WEBSERVICES_POLICY_SERVICE);
-		check(sessionParameters, SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE);
-		check(sessionParameters, SessionParameter.WEBSERVICES_REPOSITORY_SERVICE);
-		check(sessionParameters, SessionParameter.WEBSERVICES_VERSIONING_SERVICE);
-
-		return new CmisBindingImpl(sessionParameters);
-	}
-
-	/**
-	 * Creates a default CMIS local binding instance.
-	 */
-	public CmisBinding createCmisLocalBinding(Map<String, String> sessionParameters) {
-		checkSessionParameters(sessionParameters, false);
-
-		sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_LOCAL);
-		addDefaultParameters(sessionParameters);
-
-		check(sessionParameters, SessionParameter.LOCAL_FACTORY);
-
-		return new CmisBindingImpl(sessionParameters);
-	}
-
-	// ---- internal ----
-
-	/**
-	 * Checks the passed session parameters.
-	 */
-	private void checkSessionParameters(Map<String, String> sessionParameters, boolean mustContainSPI) {
-		// don't accept null
-		if (sessionParameters == null) {
-			throw new IllegalArgumentException("Session parameter map not set!");
-		}
-
-		// check binding entry
-		String SPIClass = sessionParameters.get(SessionParameter.BINDING_SPI_CLASS);
-		if (mustContainSPI) {
-			if ((SPIClass == null) || (SPIClass.trim().length() == 0)) {
-				throw new IllegalArgumentException("SPI class entry (" + SessionParameter.BINDING_SPI_CLASS
-						+ ") is missing!");
-			}
-		}
-	}
-
-	/**
-	 * Checks if the given parameter is present. If not, throw an
-	 * <code>IllegalArgumentException</code>.
-	 */
-	private void check(Map<String, String> sessionParameters, String parameter) {
-		if (!sessionParameters.containsKey(parameter)) {
-			throw new IllegalArgumentException("Parameter '" + parameter + "' is missing!");
-		}
-	}
-
-	/**
-	 * Add the default session parameters to the given map without override
-	 * existing entries.
-	 */
-	private void addDefaultParameters(Map<String, String> sessionParameters) {
-		for (String key : defaults.keySet()) {
-			if (!sessionParameters.containsKey(key)) {
-				sessionParameters.put(key, defaults.get(key));
-			}
-		}
-	}
-
-	/**
-	 * Creates a default session parameters map with some reasonable defaults.
-	 */
-	private Map<String, String> createNewDefaultParameters() {
-		Map<String, String> result = new HashMap<String, String>();
-
-		result.put(SessionParameter.CACHE_SIZE_REPOSITORIES, "10");
-		result.put(SessionParameter.CACHE_SIZE_TYPES, "100");
-		result.put(SessionParameter.CACHE_SIZE_OBJECTS, "400");
+    /** Default CMIS AtomPub binding SPI implementation */
+    public static final String BINDING_SPI_ATOMPUB = "org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubSpi";
+    /** Default CMIS Web Services binding SPI implementation */
+    public static final String BINDING_SPI_WEBSERVICES = "org.apache.chemistry.opencmis.client.bindings.spi.webservices.CmisWebServicesSpi";
+    /** Default CMIS local binding SPI implementation */
+    public static final String BINDING_SPI_LOCAL = "org.apache.chemistry.opencmis.client.bindings.spi.local.CmisLocalSpi";
+    /** CMIS In Memory binding SPI implementation (for testing only!) */
+    public static final String BINDING_SPI_INMEMORY = "org.apache.chemistry.opencmis.inmemory.clientprovider.CmisInMemorySpiFactory";
+
+    /** Standard authentication provider class */
+    public static final String STANDARD_AUTHENTICATION_PROVIDER = "org.apache.chemistry.opencmis.client.bindings.spi.StandardAuthenticationProvider";
+
+    private Map<String, String> defaults;
+
+    /**
+     * Private constructor -- it's a factory.
+     */
+    private CmisBindingFactory() {
+        defaults = createNewDefaultParameters();
+    }
+
+    /**
+     * Creates a new factory instance.
+     */
+    public static CmisBindingFactory newInstance() {
+        return new CmisBindingFactory();
+    }
+
+    /**
+     * Returns the default session parameters.
+     */
+    public Map<String, String> getDefaultSessionParameters() {
+        return defaults;
+    }
+
+    /**
+     * Sets the default session parameters.
+     */
+    public void setDefaultSessionParameters(Map<String, String> sessionParameters) {
+        if (sessionParameters == null) {
+            defaults = createNewDefaultParameters();
+        } else {
+            defaults = sessionParameters;
+        }
+    }
+
+    /**
+     * Creates a CMIS binding instance. A binding class has to be provided in
+     * the session parameters.
+     */
+    public CmisBinding createCmisBinding(Map<String, String> sessionParameters) {
+        checkSessionParameters(sessionParameters, true);
+
+        addDefaultParameters(sessionParameters);
+
+        return new CmisBindingImpl(sessionParameters);
+    }
+
+    /**
+     * Creates a default CMIS AtomPub binding instance.
+     */
+    public CmisBinding createCmisAtomPubBinding(Map<String, String> sessionParameters) {
+        checkSessionParameters(sessionParameters, false);
+
+        sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_ATOMPUB);
+        if (!sessionParameters.containsKey(SessionParameter.AUTHENTICATION_PROVIDER_CLASS)) {
+            sessionParameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, STANDARD_AUTHENTICATION_PROVIDER);
+        }
+        sessionParameters.put(SessionParameter.AUTH_HTTP_BASIC, "true");
+        sessionParameters.put(SessionParameter.AUTH_SOAP_USERNAMETOKEN, "false");
+        addDefaultParameters(sessionParameters);
+
+        check(sessionParameters, SessionParameter.ATOMPUB_URL);
+
+        return new CmisBindingImpl(sessionParameters);
+    }
+
+    /**
+     * Creates a default CMIS Web Services binding instance.
+     */
+    public CmisBinding createCmisWebServicesBinding(Map<String, String> sessionParameters) {
+        checkSessionParameters(sessionParameters, false);
+
+        sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_WEBSERVICES);
+        if (!sessionParameters.containsKey(SessionParameter.AUTHENTICATION_PROVIDER_CLASS)) {
+            sessionParameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, STANDARD_AUTHENTICATION_PROVIDER);
+        }
+        sessionParameters.put(SessionParameter.AUTH_HTTP_BASIC, "true");
+        sessionParameters.put(SessionParameter.AUTH_SOAP_USERNAMETOKEN, "true");
+        addDefaultParameters(sessionParameters);
+
+        check(sessionParameters, SessionParameter.WEBSERVICES_ACL_SERVICE);
+        check(sessionParameters, SessionParameter.WEBSERVICES_DISCOVERY_SERVICE);
+        check(sessionParameters, SessionParameter.WEBSERVICES_MULTIFILING_SERVICE);
+        check(sessionParameters, SessionParameter.WEBSERVICES_NAVIGATION_SERVICE);
+        check(sessionParameters, SessionParameter.WEBSERVICES_OBJECT_SERVICE);
+        check(sessionParameters, SessionParameter.WEBSERVICES_POLICY_SERVICE);
+        check(sessionParameters, SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE);
+        check(sessionParameters, SessionParameter.WEBSERVICES_REPOSITORY_SERVICE);
+        check(sessionParameters, SessionParameter.WEBSERVICES_VERSIONING_SERVICE);
+
+        return new CmisBindingImpl(sessionParameters);
+    }
+
+    /**
+     * Creates a default CMIS local binding instance.
+     */
+    public CmisBinding createCmisLocalBinding(Map<String, String> sessionParameters) {
+        checkSessionParameters(sessionParameters, false);
+
+        sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_LOCAL);
+        addDefaultParameters(sessionParameters);
+
+        check(sessionParameters, SessionParameter.LOCAL_FACTORY);
+
+        return new CmisBindingImpl(sessionParameters);
+    }
+
+    // ---- internal ----
+
+    /**
+     * Checks the passed session parameters.
+     */
+    private void checkSessionParameters(Map<String, String> sessionParameters, boolean mustContainSPI) {
+        // don't accept null
+        if (sessionParameters == null) {
+            throw new IllegalArgumentException("Session parameter map not set!");
+        }
+
+        // check binding entry
+        String SPIClass = sessionParameters.get(SessionParameter.BINDING_SPI_CLASS);
+        if (mustContainSPI) {
+            if ((SPIClass == null) || (SPIClass.trim().length() == 0)) {
+                throw new IllegalArgumentException("SPI class entry (" + SessionParameter.BINDING_SPI_CLASS
+                        + ") is missing!");
+            }
+        }
+    }
+
+    /**
+     * Checks if the given parameter is present. If not, throw an
+     * <code>IllegalArgumentException</code>.
+     */
+    private void check(Map<String, String> sessionParameters, String parameter) {
+        if (!sessionParameters.containsKey(parameter)) {
+            throw new IllegalArgumentException("Parameter '" + parameter + "' is missing!");
+        }
+    }
+
+    /**
+     * Add the default session parameters to the given map without override
+     * existing entries.
+     */
+    private void addDefaultParameters(Map<String, String> sessionParameters) {
+        for (String key : defaults.keySet()) {
+            if (!sessionParameters.containsKey(key)) {
+                sessionParameters.put(key, defaults.get(key));
+            }
+        }
+    }
+
+    /**
+     * Creates a default session parameters map with some reasonable defaults.
+     */
+    private Map<String, String> createNewDefaultParameters() {
+        Map<String, String> result = new HashMap<String, String>();
+
+        result.put(SessionParameter.CACHE_SIZE_REPOSITORIES, "10");
+        result.put(SessionParameter.CACHE_SIZE_TYPES, "100");
+        result.put(SessionParameter.CACHE_SIZE_OBJECTS, "400");
 
-		return result;
-	}
+        return result;
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/Cache.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/cache/Cache.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/cache/Cache.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/Cache.java Thu Apr 22 16:04:19 2010
@@ -41,59 +41,59 @@ import java.io.Serializable;
  */
 public interface Cache extends Serializable {
 
-	/**
-	 * Initializes the cache.
-	 * 
-	 * @param cacheLevelConfig
-	 *            the level configuration strings from the root to the leafs
-	 */
-	void initialize(String[] cacheLevelConfig);
-
-	/**
-	 * Adds an object to the cache.
-	 * 
-	 * @param value
-	 *            the object
-	 * @param keys
-	 *            the keys for this object
-	 */
-	void put(Object value, String... keys);
-
-	/**
-	 * Retrieves an object from the cache.
-	 * 
-	 * @param keys
-	 *            the keys
-	 * @return the object or <code>null<code> if the branch or leaf doesn't exist
-	 */
-	Object get(String... keys);
-
-	/**
-	 * Removes a branch or leaf from the cache.
-	 * 
-	 * @param keys
-	 *            the keys of the branch or leaf
-	 */
-	void remove(String... keys);
-
-	/**
-	 * Checks if a given key is in the cache.
-	 * 
-	 * @param keys
-	 *            the keys of the branch or leaf
-	 * 
-	 * @return the index of the first key part that is not in the cache or
-	 *         <code>keys.length</code> if the object is in the cache
-	 */
-	int check(String... keys);
-
-	/**
-	 * Applies a write lock.
-	 */
-	void writeLock();
-
-	/**
-	 * Releases a write lock.
-	 */
-	void writeUnlock();
+    /**
+     * Initializes the cache.
+     * 
+     * @param cacheLevelConfig
+     *            the level configuration strings from the root to the leafs
+     */
+    void initialize(String[] cacheLevelConfig);
+
+    /**
+     * Adds an object to the cache.
+     * 
+     * @param value
+     *            the object
+     * @param keys
+     *            the keys for this object
+     */
+    void put(Object value, String... keys);
+
+    /**
+     * Retrieves an object from the cache.
+     * 
+     * @param keys
+     *            the keys
+     * @return the object or <code>null<code> if the branch or leaf doesn't exist
+     */
+    Object get(String... keys);
+
+    /**
+     * Removes a branch or leaf from the cache.
+     * 
+     * @param keys
+     *            the keys of the branch or leaf
+     */
+    void remove(String... keys);
+
+    /**
+     * Checks if a given key is in the cache.
+     * 
+     * @param keys
+     *            the keys of the branch or leaf
+     * 
+     * @return the index of the first key part that is not in the cache or
+     *         <code>keys.length</code> if the object is in the cache
+     */
+    int check(String... keys);
+
+    /**
+     * Applies 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/cache/CacheLevel.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/cache/CacheLevel.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/cache/CacheLevel.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/CacheLevel.java Thu Apr 22 16:04:19 2010
@@ -30,38 +30,38 @@ import java.util.Map;
  */
 public interface CacheLevel extends Serializable {
 
-	/**
-	 * Initialize the cache level.
-	 * 
-	 * @param parameters
-	 *            level parameters
-	 */
-	void initialize(Map<String, String> parameters);
+    /**
+     * Initialize the cache level.
+     * 
+     * @param parameters
+     *            level parameters
+     */
+    void initialize(Map<String, String> parameters);
 
-	/**
-	 * Adds an object to the cache level.
-	 * 
-	 * @param value
-	 *            the object
-	 * @param key
-	 *            the key at this level
-	 */
-	void put(Object value, String key);
+    /**
+     * Adds an object to the cache level.
+     * 
+     * @param value
+     *            the object
+     * @param key
+     *            the key at this level
+     */
+    void put(Object value, String key);
 
-	/**
-	 * Retrieves an object from the cache level.
-	 * 
-	 * @param key
-	 *            the key at this cache level
-	 * @return the object or <code>null</code> if the object doesn't exist
-	 */
-	Object get(String key);
+    /**
+     * Retrieves an object from the cache level.
+     * 
+     * @param key
+     *            the key at this cache level
+     * @return the object or <code>null</code> if the object doesn't exist
+     */
+    Object get(String key);
 
-	/**
-	 * Removes an object from this cache level.
-	 * 
-	 * @param key
-	 *            the key at this cache level
-	 */
-	void remove(String key);
+    /**
+     * Removes an object from this cache level.
+     * 
+     * @param key
+     *            the key at this cache level
+     */
+    void remove(String key);
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/AbstractMapCacheLevel.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/cache/impl/AbstractMapCacheLevel.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/cache/impl/AbstractMapCacheLevel.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/AbstractMapCacheLevel.java Thu Apr 22 16:04:19 2010
@@ -30,166 +30,166 @@ import org.apache.chemistry.opencmis.cli
  */
 public abstract class AbstractMapCacheLevel implements CacheLevel {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	private Map<String, Object> fMap;
-	private boolean fFallbackEnabled = false;
-	private String fFallbackKey = null;
-	private boolean fSingleValueEnabled = false;
-
-	public abstract void initialize(Map<String, String> parameters);
-
-	public Object get(String key) {
-		Object value = fMap.get(key);
-
-		if ((value == null) && fFallbackEnabled) {
-			value = fMap.get(fFallbackKey);
-		}
-
-		if ((value == null) && fSingleValueEnabled) {
-			if (fMap.size() == 1) {
-				value = fMap.values().iterator().next();
-			}
-		}
-
-		return value;
-	}
-
-	public void put(Object value, String key) {
-		fMap.put(key, value);
-	}
-
-	public void remove(String key) {
-		fMap.remove(key);
-	}
-
-	/**
-	 * Returns the internal map.
-	 */
-	protected Map<String, Object> getMap() {
-		return fMap;
-	}
-
-	/**
-	 * Sets the internal map.
-	 */
-	protected void setMap(Map<String, Object> map) {
-		fMap = map;
-	}
-
-	/**
-	 * Enables a fallback key if no value was found for a requested key.
-	 */
-	protected void enableKeyFallback(String key) {
-		fFallbackKey = key;
-		fFallbackEnabled = true;
-	}
-
-	/**
-	 * Disables the fallback key.
-	 */
-	protected void disableKeyFallback() {
-		fFallbackEnabled = false;
-	}
-
-	/**
-	 * Enables the single value fallback.
-	 */
-	protected void enableSingeValueFallback() {
-		fSingleValueEnabled = true;
-	}
-
-	/**
-	 * Disables the single value fallback.
-	 */
-	protected void disableSingeValueFallback() {
-		fSingleValueEnabled = false;
-	}
-
-	/**
-	 * Extracts an integer parameter from the parameters.
-	 * 
-	 * @param parameters
-	 *            the parameter map
-	 * @param name
-	 *            the parameter name
-	 * @param defValue
-	 *            the default value if the parameter can't be found
-	 */
-	protected int getIntParameter(Map<String, String> parameters, String name, int defValue) {
-		if (parameters == null) {
-			return defValue;
-		}
-
-		String value = parameters.get(name);
-		if ((value == null) || (value.trim().length() == 0)) {
-			return defValue;
-		}
-
-		try {
-			return Integer.valueOf(value);
-		} catch (NumberFormatException e) {
-			return defValue;
-		}
-	}
-
-	/**
-	 * Extracts a float parameter from the parameters.
-	 * 
-	 * @param parameters
-	 *            the parameter map
-	 * @param name
-	 *            the parameter name
-	 * @param defValue
-	 *            the default value if the parameter can't be found
-	 */
-	protected float getFloatParameter(Map<String, String> parameters, String name, float defValue) {
-		if (parameters == null) {
-			return defValue;
-		}
-
-		String value = parameters.get(name);
-		if ((value == null) || (value.trim().length() == 0)) {
-			return defValue;
-		}
-
-		try {
-			return Float.valueOf(value);
-		} catch (NumberFormatException e) {
-			return defValue;
-		}
-	}
-
-	/**
-	 * Extracts a boolean parameter from the parameters.
-	 * 
-	 * @param parameters
-	 *            the parameter map
-	 * @param name
-	 *            the parameter name
-	 * @param defValue
-	 *            the default value if the parameter can't be found
-	 */
-	protected boolean getBooleanParameter(Map<String, String> parameters, String name, boolean defValue) {
-		if (parameters == null) {
-			return defValue;
-		}
-
-		String value = parameters.get(name);
-		if ((value == null) || (value.trim().length() == 0)) {
-			return defValue;
-		}
-
-		return Boolean.parseBoolean(value);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.lang.Object#toString()
-	 */
-	@Override
-	public String toString() {
-		return (fMap == null ? "[no map]" : fMap.toString());
-	}
+    private Map<String, Object> fMap;
+    private boolean fFallbackEnabled = false;
+    private String fFallbackKey = null;
+    private boolean fSingleValueEnabled = false;
+
+    public abstract void initialize(Map<String, String> parameters);
+
+    public Object get(String key) {
+        Object value = fMap.get(key);
+
+        if ((value == null) && fFallbackEnabled) {
+            value = fMap.get(fFallbackKey);
+        }
+
+        if ((value == null) && fSingleValueEnabled) {
+            if (fMap.size() == 1) {
+                value = fMap.values().iterator().next();
+            }
+        }
+
+        return value;
+    }
+
+    public void put(Object value, String key) {
+        fMap.put(key, value);
+    }
+
+    public void remove(String key) {
+        fMap.remove(key);
+    }
+
+    /**
+     * Returns the internal map.
+     */
+    protected Map<String, Object> getMap() {
+        return fMap;
+    }
+
+    /**
+     * Sets the internal map.
+     */
+    protected void setMap(Map<String, Object> map) {
+        fMap = map;
+    }
+
+    /**
+     * Enables a fallback key if no value was found for a requested key.
+     */
+    protected void enableKeyFallback(String key) {
+        fFallbackKey = key;
+        fFallbackEnabled = true;
+    }
+
+    /**
+     * Disables the fallback key.
+     */
+    protected void disableKeyFallback() {
+        fFallbackEnabled = false;
+    }
+
+    /**
+     * Enables the single value fallback.
+     */
+    protected void enableSingeValueFallback() {
+        fSingleValueEnabled = true;
+    }
+
+    /**
+     * Disables the single value fallback.
+     */
+    protected void disableSingeValueFallback() {
+        fSingleValueEnabled = false;
+    }
+
+    /**
+     * Extracts an integer parameter from the parameters.
+     * 
+     * @param parameters
+     *            the parameter map
+     * @param name
+     *            the parameter name
+     * @param defValue
+     *            the default value if the parameter can't be found
+     */
+    protected int getIntParameter(Map<String, String> parameters, String name, int defValue) {
+        if (parameters == null) {
+            return defValue;
+        }
+
+        String value = parameters.get(name);
+        if ((value == null) || (value.trim().length() == 0)) {
+            return defValue;
+        }
+
+        try {
+            return Integer.valueOf(value);
+        } catch (NumberFormatException e) {
+            return defValue;
+        }
+    }
+
+    /**
+     * Extracts a float parameter from the parameters.
+     * 
+     * @param parameters
+     *            the parameter map
+     * @param name
+     *            the parameter name
+     * @param defValue
+     *            the default value if the parameter can't be found
+     */
+    protected float getFloatParameter(Map<String, String> parameters, String name, float defValue) {
+        if (parameters == null) {
+            return defValue;
+        }
+
+        String value = parameters.get(name);
+        if ((value == null) || (value.trim().length() == 0)) {
+            return defValue;
+        }
+
+        try {
+            return Float.valueOf(value);
+        } catch (NumberFormatException e) {
+            return defValue;
+        }
+    }
+
+    /**
+     * Extracts a boolean parameter from the parameters.
+     * 
+     * @param parameters
+     *            the parameter map
+     * @param name
+     *            the parameter name
+     * @param defValue
+     *            the default value if the parameter can't be found
+     */
+    protected boolean getBooleanParameter(Map<String, String> parameters, String name, boolean defValue) {
+        if (parameters == null) {
+            return defValue;
+        }
+
+        String value = parameters.get(name);
+        if ((value == null) || (value.trim().length() == 0)) {
+            return defValue;
+        }
+
+        return Boolean.parseBoolean(value);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return (fMap == null ? "[no map]" : fMap.toString());
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/CacheImpl.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/cache/impl/CacheImpl.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/cache/impl/CacheImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/CacheImpl.java Thu Apr 22 16:04:19 2010
@@ -37,285 +37,285 @@ import org.apache.commons.logging.LogFac
  */
 public class CacheImpl implements Cache {
 
-	private static Log log = LogFactory.getLog(CacheImpl.class);
+    private static Log log = LogFactory.getLog(CacheImpl.class);
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	private List<Class<?>> fLevels;
-	private List<Map<String, String>> fLevelParameters;
+    private List<Class<?>> fLevels;
+    private List<Map<String, String>> fLevelParameters;
 
-	private String fName;
+    private String fName;
 
-	private CacheLevel fRoot;
-
-	private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock();
-
-	/**
-	 * Constructor.
-	 */
-	public CacheImpl() {
-		fName = "Cache";
-	}
-
-	/**
-	 * Constructor.
-	 */
-	public CacheImpl(String name) {
-		fName = name;
-	}
-
-	public void initialize(String[] cacheLevelConfig) {
-		if (fLevels != null) {
-			throw new IllegalStateException("Cache already initialize!");
-		}
-
-		if ((cacheLevelConfig == null) || (cacheLevelConfig.length == 0)) {
-			throw new IllegalArgumentException("Cache config must not be empty!");
-		}
-
-		fLock.writeLock().lock();
-		try {
-			fLevels = new ArrayList<Class<?>>();
-			fLevelParameters = new ArrayList<Map<String, String>>();
-
-			// build level lists
-			for (String config : cacheLevelConfig) {
-				int x = config.indexOf(' ');
-				if (x == -1) {
-					addLevel(config, null);
-				} else {
-					addLevel(config.substring(0, x), config.substring(x + 1));
-				}
-			}
-
-			// create root
-			fRoot = createCacheLevel(0);
-		} finally {
-			fLock.writeLock().unlock();
-		}
-	}
-
-	private void addLevel(String className, String parameters) {
-		// get the class
-		Class<?> clazz;
-		try {
-			clazz = Class.forName(className);
-		} catch (ClassNotFoundException e) {
-			throw new IllegalArgumentException("Class '" + className + "' not found!", e);
-		}
-
-		// check the class
-		if (!CacheLevel.class.isAssignableFrom(clazz)) {
-			throw new IllegalArgumentException("Class '" + className + "' does not implement the CacheLevel interface!");
-		}
-
-		fLevels.add(clazz);
-
-		// process parameters
-		if (parameters == null) {
-			fLevelParameters.add(null);
-		} else {
-			Map<String, String> parameterMap = new HashMap<String, String>();
-			fLevelParameters.add(parameterMap);
-
-			for (String pair : parameters.split(",")) {
-				String[] keyValue = pair.split("=");
-				if (keyValue.length == 1) {
-					parameterMap.put(keyValue[0], "");
-				} else {
-					parameterMap.put(keyValue[0], keyValue[1]);
-				}
-			}
-		}
-	}
-
-	public Object get(String... keys) {
-		// check keys
-		if (keys == null) {
-			return null;
-		}
-
-		// check level depth
-		if (fLevels.size() != keys.length) {
-			throw new IllegalArgumentException("Wrong number of keys!");
-		}
-
-		Object result = null;
-
-		fLock.readLock().lock();
-		try {
-			CacheLevel cacheLevel = fRoot;
-
-			// follow the branch
-			for (int i = 0; i < keys.length - 1; i++) {
-				Object level = cacheLevel.get(keys[i]);
-
-				// does the branch exist?
-				if (level == null) {
-					return null;
-				}
-
-				// next level
-				cacheLevel = (CacheLevel) level;
-			}
-
-			// get the value
-			result = cacheLevel.get(keys[keys.length - 1]);
-		} finally {
-			fLock.readLock().unlock();
-		}
-
-		return result;
-	}
-
-	public void put(Object value, String... keys) {
-		// check keys
-		if (keys == null) {
-			return;
-		}
-
-		// check level depth
-		if (fLevels.size() != keys.length) {
-			throw new IllegalArgumentException("Wrong number of keys!");
-		}
-
-		fLock.writeLock().lock();
-		try {
-			CacheLevel cacheLevel = fRoot;
-
-			// follow the branch
-			for (int i = 0; i < keys.length - 1; i++) {
-				Object level = cacheLevel.get(keys[i]);
-
-				// does the branch exist?
-				if (level == null) {
-					level = createCacheLevel(i + 1);
-					cacheLevel.put(level, keys[i]);
-				}
-
-				// next level
-				cacheLevel = (CacheLevel) level;
-			}
-
-			cacheLevel.put(value, keys[keys.length - 1]);
-
-			if (log.isDebugEnabled()) {
-				log.debug(fName + ": put [" + getFormattedKeys(keys) + "] = " + value);
-			}
-		} finally {
-			fLock.writeLock().unlock();
-		}
-	}
-
-	public void remove(String... keys) {
-		if (keys == null) {
-			return;
-		}
-
-		fLock.writeLock().lock();
-		try {
-			CacheLevel cacheLevel = fRoot;
-
-			// follow the branch
-			for (int i = 0; i < keys.length - 1; i++) {
-				Object level = cacheLevel.get(keys[i]);
-
-				// does the branch exist?
-				if (level == null) {
-					return;
-				}
-
-				// next level
-				cacheLevel = (CacheLevel) level;
-			}
-
-			cacheLevel.remove(keys[keys.length - 1]);
-
-			if (log.isDebugEnabled()) {
-				log.debug(fName + ": removed [" + getFormattedKeys(keys) + "]");
-			}
-		} finally {
-			fLock.writeLock().unlock();
-		}
-	}
-
-	public int check(String... keys) {
-		if (keys == null) {
-			return -1;
-		}
-
-		fLock.readLock().lock();
-		try {
-			CacheLevel cacheLevel = fRoot;
-
-			// follow the branch
-			for (int i = 0; i < keys.length - 1; i++) {
-				Object level = cacheLevel.get(keys[i]);
-
-				// does the branch exist?
-				if (level == null) {
-					return i;
-				}
-
-				// next level
-				cacheLevel = (CacheLevel) level;
-			}
-		} finally {
-			fLock.readLock().unlock();
-		}
-
-		return keys.length;
-	}
-
-	public void writeLock() {
-		fLock.writeLock().lock();
-	}
-
-	public void writeUnlock() {
-		fLock.writeLock().unlock();
-	}
-
-	// ---- internal ----
-
-	/**
-	 * Creates a cache level object.
-	 */
-	private CacheLevel createCacheLevel(int level) {
-		if ((level < 0) || (level >= fLevels.size())) {
-			throw new IllegalArgumentException("Cache level doesn't fit the configuration!");
-		}
-
-		// get the class and create an instance
-		Class<?> clazz = fLevels.get(level);
-		CacheLevel cacheLevel = null;
-		try {
-			cacheLevel = (CacheLevel) clazz.newInstance();
-		} catch (Exception e) {
-			throw new IllegalArgumentException("Cache level problem?!", e);
-		}
-
-		// initialize it
-		cacheLevel.initialize(fLevelParameters.get(level));
-
-		return cacheLevel;
-	}
-
-	@Override
-	public String toString() {
-		return (fRoot == null ? "(no cache root)" : fRoot.toString());
-	}
-
-	// ---- internal ----
-
-	private String getFormattedKeys(String[] keys) {
-		StringBuilder sb = new StringBuilder();
-		for (String k : keys) {
-			if (sb.length() > 0) {
-				sb.append(", ");
-			}
-			sb.append(k);
-		}
+    private CacheLevel fRoot;
+
+    private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock();
+
+    /**
+     * Constructor.
+     */
+    public CacheImpl() {
+        fName = "Cache";
+    }
+
+    /**
+     * Constructor.
+     */
+    public CacheImpl(String name) {
+        fName = name;
+    }
+
+    public void initialize(String[] cacheLevelConfig) {
+        if (fLevels != null) {
+            throw new IllegalStateException("Cache already initialize!");
+        }
+
+        if ((cacheLevelConfig == null) || (cacheLevelConfig.length == 0)) {
+            throw new IllegalArgumentException("Cache config must not be empty!");
+        }
+
+        fLock.writeLock().lock();
+        try {
+            fLevels = new ArrayList<Class<?>>();
+            fLevelParameters = new ArrayList<Map<String, String>>();
+
+            // build level lists
+            for (String config : cacheLevelConfig) {
+                int x = config.indexOf(' ');
+                if (x == -1) {
+                    addLevel(config, null);
+                } else {
+                    addLevel(config.substring(0, x), config.substring(x + 1));
+                }
+            }
+
+            // create root
+            fRoot = createCacheLevel(0);
+        } finally {
+            fLock.writeLock().unlock();
+        }
+    }
+
+    private void addLevel(String className, String parameters) {
+        // get the class
+        Class<?> clazz;
+        try {
+            clazz = Class.forName(className);
+        } catch (ClassNotFoundException e) {
+            throw new IllegalArgumentException("Class '" + className + "' not found!", e);
+        }
+
+        // check the class
+        if (!CacheLevel.class.isAssignableFrom(clazz)) {
+            throw new IllegalArgumentException("Class '" + className + "' does not implement the CacheLevel interface!");
+        }
+
+        fLevels.add(clazz);
+
+        // process parameters
+        if (parameters == null) {
+            fLevelParameters.add(null);
+        } else {
+            Map<String, String> parameterMap = new HashMap<String, String>();
+            fLevelParameters.add(parameterMap);
+
+            for (String pair : parameters.split(",")) {
+                String[] keyValue = pair.split("=");
+                if (keyValue.length == 1) {
+                    parameterMap.put(keyValue[0], "");
+                } else {
+                    parameterMap.put(keyValue[0], keyValue[1]);
+                }
+            }
+        }
+    }
+
+    public Object get(String... keys) {
+        // check keys
+        if (keys == null) {
+            return null;
+        }
+
+        // check level depth
+        if (fLevels.size() != keys.length) {
+            throw new IllegalArgumentException("Wrong number of keys!");
+        }
+
+        Object result = null;
+
+        fLock.readLock().lock();
+        try {
+            CacheLevel cacheLevel = fRoot;
+
+            // follow the branch
+            for (int i = 0; i < keys.length - 1; i++) {
+                Object level = cacheLevel.get(keys[i]);
+
+                // does the branch exist?
+                if (level == null) {
+                    return null;
+                }
+
+                // next level
+                cacheLevel = (CacheLevel) level;
+            }
+
+            // get the value
+            result = cacheLevel.get(keys[keys.length - 1]);
+        } finally {
+            fLock.readLock().unlock();
+        }
+
+        return result;
+    }
+
+    public void put(Object value, String... keys) {
+        // check keys
+        if (keys == null) {
+            return;
+        }
+
+        // check level depth
+        if (fLevels.size() != keys.length) {
+            throw new IllegalArgumentException("Wrong number of keys!");
+        }
+
+        fLock.writeLock().lock();
+        try {
+            CacheLevel cacheLevel = fRoot;
+
+            // follow the branch
+            for (int i = 0; i < keys.length - 1; i++) {
+                Object level = cacheLevel.get(keys[i]);
+
+                // does the branch exist?
+                if (level == null) {
+                    level = createCacheLevel(i + 1);
+                    cacheLevel.put(level, keys[i]);
+                }
+
+                // next level
+                cacheLevel = (CacheLevel) level;
+            }
+
+            cacheLevel.put(value, keys[keys.length - 1]);
+
+            if (log.isDebugEnabled()) {
+                log.debug(fName + ": put [" + getFormattedKeys(keys) + "] = " + value);
+            }
+        } finally {
+            fLock.writeLock().unlock();
+        }
+    }
+
+    public void remove(String... keys) {
+        if (keys == null) {
+            return;
+        }
+
+        fLock.writeLock().lock();
+        try {
+            CacheLevel cacheLevel = fRoot;
+
+            // follow the branch
+            for (int i = 0; i < keys.length - 1; i++) {
+                Object level = cacheLevel.get(keys[i]);
+
+                // does the branch exist?
+                if (level == null) {
+                    return;
+                }
+
+                // next level
+                cacheLevel = (CacheLevel) level;
+            }
+
+            cacheLevel.remove(keys[keys.length - 1]);
+
+            if (log.isDebugEnabled()) {
+                log.debug(fName + ": removed [" + getFormattedKeys(keys) + "]");
+            }
+        } finally {
+            fLock.writeLock().unlock();
+        }
+    }
+
+    public int check(String... keys) {
+        if (keys == null) {
+            return -1;
+        }
+
+        fLock.readLock().lock();
+        try {
+            CacheLevel cacheLevel = fRoot;
+
+            // follow the branch
+            for (int i = 0; i < keys.length - 1; i++) {
+                Object level = cacheLevel.get(keys[i]);
+
+                // does the branch exist?
+                if (level == null) {
+                    return i;
+                }
+
+                // next level
+                cacheLevel = (CacheLevel) level;
+            }
+        } finally {
+            fLock.readLock().unlock();
+        }
+
+        return keys.length;
+    }
+
+    public void writeLock() {
+        fLock.writeLock().lock();
+    }
+
+    public void writeUnlock() {
+        fLock.writeLock().unlock();
+    }
+
+    // ---- internal ----
+
+    /**
+     * Creates a cache level object.
+     */
+    private CacheLevel createCacheLevel(int level) {
+        if ((level < 0) || (level >= fLevels.size())) {
+            throw new IllegalArgumentException("Cache level doesn't fit the configuration!");
+        }
+
+        // get the class and create an instance
+        Class<?> clazz = fLevels.get(level);
+        CacheLevel cacheLevel = null;
+        try {
+            cacheLevel = (CacheLevel) clazz.newInstance();
+        } catch (Exception e) {
+            throw new IllegalArgumentException("Cache level problem?!", e);
+        }
+
+        // initialize it
+        cacheLevel.initialize(fLevelParameters.get(level));
+
+        return cacheLevel;
+    }
+
+    @Override
+    public String toString() {
+        return (fRoot == null ? "(no cache root)" : fRoot.toString());
+    }
+
+    // ---- internal ----
+
+    private String getFormattedKeys(String[] keys) {
+        StringBuilder sb = new StringBuilder();
+        for (String k : keys) {
+            if (sb.length() > 0) {
+                sb.append(", ");
+            }
+            sb.append(k);
+        }
 
-		return sb.toString();
-	}
+        return sb.toString();
+    }
 }
\ No newline at end of file

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/ContentTypeCacheLevelImpl.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/cache/impl/ContentTypeCacheLevelImpl.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/cache/impl/ContentTypeCacheLevelImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/ContentTypeCacheLevelImpl.java Thu Apr 22 16:04:19 2010
@@ -30,111 +30,111 @@ import java.util.TreeMap;
  */
 public class ContentTypeCacheLevelImpl extends MapCacheLevelImpl {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	/**
-	 * Constructor.
-	 */
-	public ContentTypeCacheLevelImpl() {
-		enableKeyFallback(null);
-	}
-
-	@Override
-	public Object get(String key) {
-		return super.get(normalize(key));
-	}
-
-	@Override
-	public void put(Object value, String key) {
-		super.put(value, normalize(key));
-	}
-
-	@Override
-	public void remove(String key) {
-		super.remove(normalize(key));
-	}
-
-	/**
-	 * Normalizes the key which should be a content type. It's quite simple at
-	 * the moment but should cover most cases.
-	 */
-	private String normalize(String key) {
-		if (key == null) {
-			return null;
-		}
-
-		StringBuilder sb = new StringBuilder();
-		int parameterStart = 0;
-
-		// first, get the MIME type
-		for (int i = 0; i < key.length(); i++) {
-			char c = key.charAt(i);
-
-			if (Character.isWhitespace(c)) {
-				continue;
-			} else if (c == ';') {
-				parameterStart = i;
-				break;
-			}
-
-			sb.append(Character.toLowerCase(c));
-		}
-
-		// if parameters have been found, gather them
-		if (parameterStart > 0) {
-			SortedMap<String, String> parameter = new TreeMap<String, String>();
-			StringBuilder ksb = new StringBuilder();
-			StringBuilder vsb = new StringBuilder();
-			boolean isKey = true;
-
-			for (int i = parameterStart + 1; i < key.length(); i++) {
-				char c = key.charAt(i);
-				if (Character.isWhitespace(c)) {
-					continue;
-				}
-
-				if (isKey) {
-					if (c == '=') {
-						// value start
-						isKey = false;
-						continue;
-					}
-
-					ksb.append(Character.toLowerCase(c));
-				} else {
-					if (c == ';') {
-						// next key
-						isKey = true;
-
-						parameter.put(ksb.toString(), vsb.toString());
-
-						ksb = new StringBuilder();
-						vsb = new StringBuilder();
-
-						continue;
-					} else if (c == '"') {
-						// filter quotes
-						continue;
-					}
-
-					vsb.append(Character.toLowerCase(c));
-				}
-			}
-
-			// add last parameter
-			if (ksb.length() > 0) {
-				parameter.put(ksb.toString(), vsb.toString());
-			}
-
-			// write parameters sorted by key
-			for (Map.Entry<String, String> entry : parameter.entrySet()) {
-				sb.append(";");
-				sb.append(entry.getKey());
-				sb.append("=");
-				sb.append(entry.getValue());
-			}
-		}
+    /**
+     * Constructor.
+     */
+    public ContentTypeCacheLevelImpl() {
+        enableKeyFallback(null);
+    }
+
+    @Override
+    public Object get(String key) {
+        return super.get(normalize(key));
+    }
+
+    @Override
+    public void put(Object value, String key) {
+        super.put(value, normalize(key));
+    }
+
+    @Override
+    public void remove(String key) {
+        super.remove(normalize(key));
+    }
+
+    /**
+     * Normalizes the key which should be a content type. It's quite simple at
+     * the moment but should cover most cases.
+     */
+    private String normalize(String key) {
+        if (key == null) {
+            return null;
+        }
+
+        StringBuilder sb = new StringBuilder();
+        int parameterStart = 0;
+
+        // first, get the MIME type
+        for (int i = 0; i < key.length(); i++) {
+            char c = key.charAt(i);
+
+            if (Character.isWhitespace(c)) {
+                continue;
+            } else if (c == ';') {
+                parameterStart = i;
+                break;
+            }
+
+            sb.append(Character.toLowerCase(c));
+        }
+
+        // if parameters have been found, gather them
+        if (parameterStart > 0) {
+            SortedMap<String, String> parameter = new TreeMap<String, String>();
+            StringBuilder ksb = new StringBuilder();
+            StringBuilder vsb = new StringBuilder();
+            boolean isKey = true;
+
+            for (int i = parameterStart + 1; i < key.length(); i++) {
+                char c = key.charAt(i);
+                if (Character.isWhitespace(c)) {
+                    continue;
+                }
+
+                if (isKey) {
+                    if (c == '=') {
+                        // value start
+                        isKey = false;
+                        continue;
+                    }
+
+                    ksb.append(Character.toLowerCase(c));
+                } else {
+                    if (c == ';') {
+                        // next key
+                        isKey = true;
+
+                        parameter.put(ksb.toString(), vsb.toString());
+
+                        ksb = new StringBuilder();
+                        vsb = new StringBuilder();
+
+                        continue;
+                    } else if (c == '"') {
+                        // filter quotes
+                        continue;
+                    }
+
+                    vsb.append(Character.toLowerCase(c));
+                }
+            }
+
+            // add last parameter
+            if (ksb.length() > 0) {
+                parameter.put(ksb.toString(), vsb.toString());
+            }
+
+            // write parameters sorted by key
+            for (Map.Entry<String, String> entry : parameter.entrySet()) {
+                sb.append(";");
+                sb.append(entry.getKey());
+                sb.append("=");
+                sb.append(entry.getValue());
+            }
+        }
 
-		return sb.toString();
-	}
+        return sb.toString();
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/LruCacheLevelImpl.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/cache/impl/LruCacheLevelImpl.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/cache/impl/LruCacheLevelImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/LruCacheLevelImpl.java Thu Apr 22 16:04:19 2010
@@ -29,20 +29,20 @@ import java.util.Map;
  */
 public class LruCacheLevelImpl extends AbstractMapCacheLevel {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	public final static String MAX_ENTRIES = "maxEntries";
+    public final static String MAX_ENTRIES = "maxEntries";
 
-	public void initialize(Map<String, String> parameters) {
-		final int maxEntries = getIntParameter(parameters, MAX_ENTRIES, 100);
+    public void initialize(Map<String, String> parameters) {
+        final int maxEntries = getIntParameter(parameters, MAX_ENTRIES, 100);
 
-		setMap(new LinkedHashMap<String, Object>(maxEntries + 1, 0.70f, true) {
-			private static final long serialVersionUID = 1L;
+        setMap(new LinkedHashMap<String, Object>(maxEntries + 1, 0.70f, true) {
+            private static final long serialVersionUID = 1L;
 
-			@Override
-			public boolean removeEldestEntry(Map.Entry<String, Object> eldest) {
-				return size() > maxEntries;
-			}
-		});
-	}
+            @Override
+            public boolean removeEldestEntry(Map.Entry<String, Object> eldest) {
+                return size() > maxEntries;
+            }
+        });
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/MapCacheLevelImpl.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/cache/impl/MapCacheLevelImpl.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/cache/impl/MapCacheLevelImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/MapCacheLevelImpl.java Thu Apr 22 16:04:19 2010
@@ -29,27 +29,27 @@ import java.util.Map;
  */
 public class MapCacheLevelImpl extends AbstractMapCacheLevel {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	public final static String CAPACITY = "capacity";
-	public final static String LOAD_FACTOR = "loadFactor";
-	public final static String SINGLE_VALUE = "singleValue";
+    public final static String CAPACITY = "capacity";
+    public final static String LOAD_FACTOR = "loadFactor";
+    public final static String SINGLE_VALUE = "singleValue";
 
-	/**
-	 * Constructor.
-	 */
-	public MapCacheLevelImpl() {
-	}
+    /**
+     * Constructor.
+     */
+    public MapCacheLevelImpl() {
+    }
 
-	public void initialize(Map<String, String> parameters) {
-		int initialCapacity = getIntParameter(parameters, CAPACITY, 32);
-		float loadFactor = getFloatParameter(parameters, LOAD_FACTOR, 0.75f);
-		boolean singleValue = getBooleanParameter(parameters, SINGLE_VALUE, false);
+    public void initialize(Map<String, String> parameters) {
+        int initialCapacity = getIntParameter(parameters, CAPACITY, 32);
+        float loadFactor = getFloatParameter(parameters, LOAD_FACTOR, 0.75f);
+        boolean singleValue = getBooleanParameter(parameters, SINGLE_VALUE, false);
 
-		setMap(new HashMap<String, Object>(initialCapacity, loadFactor));
-		disableKeyFallback();
-		if (singleValue) {
-			enableSingeValueFallback();
-		}
-	}
+        setMap(new HashMap<String, Object>(initialCapacity, loadFactor));
+        disableKeyFallback();
+        if (singleValue) {
+            enableSingeValueFallback();
+        }
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.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/CmisBindingImpl.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/CmisBindingImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.java Thu Apr 22 16:04:19 2010
@@ -42,180 +42,180 @@ import org.apache.chemistry.opencmis.com
  */
 public class CmisBindingImpl implements CmisBinding {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	private Session session;
-	private BindingsObjectFactory objectFactory;
-	private RepositoryService repositoryServiceWrapper;
-
-	/**
-	 * Constructor.
-	 * 
-	 * @param sessionParameters
-	 *            the session parameters
-	 */
-	public CmisBindingImpl(Map<String, String> sessionParameters) {
-		// some checks first
-		if (sessionParameters == null) {
-			throw new IllegalArgumentException("Session parameters must be set!");
-		}
-		if (!sessionParameters.containsKey(SessionParameter.BINDING_SPI_CLASS)) {
-			throw new IllegalArgumentException("Session parameters do not contain a SPI class name!");
-		}
-
-		// initialize session
-		session = new SessionImpl();
-		for (Map.Entry<String, String> entry : sessionParameters.entrySet()) {
-			session.put(entry.getKey(), entry.getValue());
-		}
-
-		// create authentication provider and add it session
-		String authProvider = sessionParameters.get(SessionParameter.AUTHENTICATION_PROVIDER_CLASS);
-		if (authProvider != null) {
-			Object authProviderObj = null;
-
-			try {
-				authProviderObj = Class.forName(authProvider).newInstance();
-			} catch (Exception e) {
-				throw new IllegalArgumentException("Could not load authentication provider: " + e, e);
-			}
-
-			if (!(authProviderObj instanceof AbstractAuthenticationProvider)) {
-				throw new IllegalArgumentException(
-						"Authentication provider does not extend AbstractAuthenticationProvider!");
-			}
-
-			session.put(CmisBindingsHelper.AUTHENTICATION_PROVIDER_OBJECT,
-					(AbstractAuthenticationProvider) authProviderObj);
-			((AbstractAuthenticationProvider) authProviderObj).setSession(session);
-		}
-
-		// set up caches
-		clearAllCaches();
-
-		// initialize the SPI
-		CmisBindingsHelper.getSPI(session);
-
-		// set up object factory
-		objectFactory = new BindingsObjectFactoryImpl();
-
-		// set up repository service
-		repositoryServiceWrapper = new RepositoryServiceImpl(session);
-	}
-
-	public RepositoryService getRepositoryService() {
-		checkSession();
-		return repositoryServiceWrapper;
-	}
-
-	public NavigationService getNavigationService() {
-		checkSession();
-		CmisSpi spi = CmisBindingsHelper.getSPI(session);
-		return spi.getNavigationService();
-	}
-
-	public ObjectService getObjectService() {
-		checkSession();
-		CmisSpi spi = CmisBindingsHelper.getSPI(session);
-		return spi.getObjectService();
-	}
-
-	public DiscoveryService getDiscoveryService() {
-		checkSession();
-		CmisSpi spi = CmisBindingsHelper.getSPI(session);
-		return spi.getDiscoveryService();
-	}
-
-	public RelationshipService getRelationshipService() {
-		checkSession();
-		CmisSpi spi = CmisBindingsHelper.getSPI(session);
-		return spi.getRelationshipService();
-	}
-
-	public VersioningService getVersioningService() {
-		checkSession();
-		CmisSpi spi = CmisBindingsHelper.getSPI(session);
-		return spi.getVersioningService();
-	}
-
-	public AclService getAclService() {
-		checkSession();
-		CmisSpi spi = CmisBindingsHelper.getSPI(session);
-		return spi.getAclService();
-	}
-
-	public MultiFilingService getMultiFilingService() {
-		checkSession();
-		CmisSpi spi = CmisBindingsHelper.getSPI(session);
-		return spi.getMultiFilingService();
-	}
-
-	public PolicyService getPolicyService() {
-		checkSession();
-		CmisSpi spi = CmisBindingsHelper.getSPI(session);
-		return spi.getPolicyService();
-	}
-
-	public BindingsObjectFactory getObjectFactory() {
-		return objectFactory;
-	}
-
-	public void clearAllCaches() {
-		checkSession();
-
-		session.writeLock();
-		try {
-			session.put(CmisBindingsHelper.REPOSITORY_INFO_CACHE, new RepositoryInfoCache(session));
-			session.put(CmisBindingsHelper.TYPE_DEFINTION_CACHE, new TypeDefinitionCache(session));
-
-			CmisSpi spi = CmisBindingsHelper.getSPI(session);
-			spi.clearAllCaches();
-		} finally {
-			session.writeUnlock();
-		}
-	}
-
-	public void clearRepositoryCache(String repositoryId) {
-		checkSession();
-
-		if (repositoryId == null) {
-			return;
-		}
-
-		session.writeLock();
-		try {
-			RepositoryInfoCache repInfoCache = (RepositoryInfoCache) session
-					.get(CmisBindingsHelper.REPOSITORY_INFO_CACHE);
-			repInfoCache.remove(repositoryId);
-
-			TypeDefinitionCache typeDefCache = (TypeDefinitionCache) session
-					.get(CmisBindingsHelper.TYPE_DEFINTION_CACHE);
-			typeDefCache.remove(repositoryId);
-
-			CmisSpi spi = CmisBindingsHelper.getSPI(session);
-			spi.clearRepositoryCache(repositoryId);
-		} finally {
-			session.writeUnlock();
-		}
-	}
-
-	public void close() {
-		checkSession();
-
-		session.writeLock();
-		try {
-			CmisSpi spi = CmisBindingsHelper.getSPI(session);
-			spi.close();
-		} finally {
-			session.writeUnlock();
-			session = null;
-		}
-
-	}
-
-	private void checkSession() {
-		if (session == null) {
-			throw new IllegalStateException("Already closed.");
-		}
-	}
+    private Session session;
+    private BindingsObjectFactory objectFactory;
+    private RepositoryService repositoryServiceWrapper;
+
+    /**
+     * Constructor.
+     * 
+     * @param sessionParameters
+     *            the session parameters
+     */
+    public CmisBindingImpl(Map<String, String> sessionParameters) {
+        // some checks first
+        if (sessionParameters == null) {
+            throw new IllegalArgumentException("Session parameters must be set!");
+        }
+        if (!sessionParameters.containsKey(SessionParameter.BINDING_SPI_CLASS)) {
+            throw new IllegalArgumentException("Session parameters do not contain a SPI class name!");
+        }
+
+        // initialize session
+        session = new SessionImpl();
+        for (Map.Entry<String, String> entry : sessionParameters.entrySet()) {
+            session.put(entry.getKey(), entry.getValue());
+        }
+
+        // create authentication provider and add it session
+        String authProvider = sessionParameters.get(SessionParameter.AUTHENTICATION_PROVIDER_CLASS);
+        if (authProvider != null) {
+            Object authProviderObj = null;
+
+            try {
+                authProviderObj = Class.forName(authProvider).newInstance();
+            } catch (Exception e) {
+                throw new IllegalArgumentException("Could not load authentication provider: " + e, e);
+            }
+
+            if (!(authProviderObj instanceof AbstractAuthenticationProvider)) {
+                throw new IllegalArgumentException(
+                        "Authentication provider does not extend AbstractAuthenticationProvider!");
+            }
+
+            session.put(CmisBindingsHelper.AUTHENTICATION_PROVIDER_OBJECT,
+                    (AbstractAuthenticationProvider) authProviderObj);
+            ((AbstractAuthenticationProvider) authProviderObj).setSession(session);
+        }
+
+        // set up caches
+        clearAllCaches();
+
+        // initialize the SPI
+        CmisBindingsHelper.getSPI(session);
+
+        // set up object factory
+        objectFactory = new BindingsObjectFactoryImpl();
+
+        // set up repository service
+        repositoryServiceWrapper = new RepositoryServiceImpl(session);
+    }
+
+    public RepositoryService getRepositoryService() {
+        checkSession();
+        return repositoryServiceWrapper;
+    }
+
+    public NavigationService getNavigationService() {
+        checkSession();
+        CmisSpi spi = CmisBindingsHelper.getSPI(session);
+        return spi.getNavigationService();
+    }
+
+    public ObjectService getObjectService() {
+        checkSession();
+        CmisSpi spi = CmisBindingsHelper.getSPI(session);
+        return spi.getObjectService();
+    }
+
+    public DiscoveryService getDiscoveryService() {
+        checkSession();
+        CmisSpi spi = CmisBindingsHelper.getSPI(session);
+        return spi.getDiscoveryService();
+    }
+
+    public RelationshipService getRelationshipService() {
+        checkSession();
+        CmisSpi spi = CmisBindingsHelper.getSPI(session);
+        return spi.getRelationshipService();
+    }
+
+    public VersioningService getVersioningService() {
+        checkSession();
+        CmisSpi spi = CmisBindingsHelper.getSPI(session);
+        return spi.getVersioningService();
+    }
+
+    public AclService getAclService() {
+        checkSession();
+        CmisSpi spi = CmisBindingsHelper.getSPI(session);
+        return spi.getAclService();
+    }
+
+    public MultiFilingService getMultiFilingService() {
+        checkSession();
+        CmisSpi spi = CmisBindingsHelper.getSPI(session);
+        return spi.getMultiFilingService();
+    }
+
+    public PolicyService getPolicyService() {
+        checkSession();
+        CmisSpi spi = CmisBindingsHelper.getSPI(session);
+        return spi.getPolicyService();
+    }
+
+    public BindingsObjectFactory getObjectFactory() {
+        return objectFactory;
+    }
+
+    public void clearAllCaches() {
+        checkSession();
+
+        session.writeLock();
+        try {
+            session.put(CmisBindingsHelper.REPOSITORY_INFO_CACHE, new RepositoryInfoCache(session));
+            session.put(CmisBindingsHelper.TYPE_DEFINTION_CACHE, new TypeDefinitionCache(session));
+
+            CmisSpi spi = CmisBindingsHelper.getSPI(session);
+            spi.clearAllCaches();
+        } finally {
+            session.writeUnlock();
+        }
+    }
+
+    public void clearRepositoryCache(String repositoryId) {
+        checkSession();
+
+        if (repositoryId == null) {
+            return;
+        }
+
+        session.writeLock();
+        try {
+            RepositoryInfoCache repInfoCache = (RepositoryInfoCache) session
+                    .get(CmisBindingsHelper.REPOSITORY_INFO_CACHE);
+            repInfoCache.remove(repositoryId);
+
+            TypeDefinitionCache typeDefCache = (TypeDefinitionCache) session
+                    .get(CmisBindingsHelper.TYPE_DEFINTION_CACHE);
+            typeDefCache.remove(repositoryId);
+
+            CmisSpi spi = CmisBindingsHelper.getSPI(session);
+            spi.clearRepositoryCache(repositoryId);
+        } finally {
+            session.writeUnlock();
+        }
+    }
+
+    public void close() {
+        checkSession();
+
+        session.writeLock();
+        try {
+            CmisSpi spi = CmisBindingsHelper.getSPI(session);
+            spi.close();
+        } finally {
+            session.writeUnlock();
+            session = null;
+        }
+
+    }
+
+    private void checkSession() {
+        if (session == null) {
+            throw new IllegalStateException("Already closed.");
+        }
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.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/CmisBindingsHelper.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/CmisBindingsHelper.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.java Thu Apr 22 16:04:19 2010
@@ -32,90 +32,90 @@ import org.apache.chemistry.opencmis.com
  */
 public final class CmisBindingsHelper {
 
-	public static final String REPOSITORY_INFO_CACHE = "org.apache.chemistry.opencmis.bindings.repositoryInfoCache";
-	public static final String TYPE_DEFINTION_CACHE = "org.apache.chemistry.opencmis.bindings.typeDefintionCache";
-	public static final String SPI_OBJECT = "org.apache.chemistry.opencmis.bindings.spi.object";
-	public static final String AUTHENTICATION_PROVIDER_OBJECT = "org.apache.chemistry.opencmis.bindings.auth.object";
-
-	/**
-	 * Private constructor.
-	 */
-	private CmisBindingsHelper() {
-	}
-
-	/**
-	 * Gets the SPI object for the given session. If there is already a SPI
-	 * object in the session it will be returned. If there is no SPI object it
-	 * will be created and put into the session.
-	 * 
-	 * @param session
-	 *            the session object
-	 * 
-	 * @return the SPI object
-	 */
-	public static CmisSpi getSPI(Session session) {
-		// fetch from session
-		CmisSpi spi = (CmisSpi) session.get(SPI_OBJECT);
-		if (spi != null) {
-			return spi;
-		}
-
-		session.writeLock();
-		try {
-			// try again
-			spi = (CmisSpi) session.get(SPI_OBJECT);
-			if (spi != null) {
-				return spi;
-			}
-
-			// ok, we have to create it...
-			try {
-				String spiFactoryName = (String) session.get(SessionParameter.BINDING_SPI_CLASS);
-				Class<?> spiFactoryClass = Class.forName(spiFactoryName);
-				Object spiFactory = spiFactoryClass.newInstance();
-
-				if (!(spiFactory instanceof CmisSpiFactory)) {
-					throw new CmisRuntimeException("Not a CMISSPIFactory class!");
-				}
-
-				spi = ((CmisSpiFactory) spiFactory).getSpiInstance(session);
-				if (spi == null) {
-					throw new CmisRuntimeException("SPI factory returned null!");
-				}
-			} catch (CmisBaseException e) {
-				throw e;
-			} catch (Exception e) {
-				throw new CmisRuntimeException("SPI cannot be initialized: " + e.getMessage(), e);
-			}
-
-			// we have a SPI object -> put it into the session
-			session.put(SPI_OBJECT, spi, true);
-		} finally {
-			session.writeUnlock();
-		}
-
-		return spi;
-	}
-
-	/**
-	 * Returns the authentication provider from the session or <code>null</code>
-	 * if no authentication provider is set.
-	 */
-	public static AbstractAuthenticationProvider getAuthenticationProvider(Session session) {
-		return (AbstractAuthenticationProvider) session.get(AUTHENTICATION_PROVIDER_OBJECT);
-	}
-
-	/**
-	 * Returns the repository info cache from the session.
-	 */
-	public static RepositoryInfoCache getRepositoryInfoCache(Session session) {
-		return (RepositoryInfoCache) session.get(REPOSITORY_INFO_CACHE);
-	}
-
-	/**
-	 * Returns the type definition cache from the session.
-	 */
-	public static TypeDefinitionCache getTypeDefinitionCache(Session session) {
-		return (TypeDefinitionCache) session.get(TYPE_DEFINTION_CACHE);
-	}
+    public static final String REPOSITORY_INFO_CACHE = "org.apache.chemistry.opencmis.bindings.repositoryInfoCache";
+    public static final String TYPE_DEFINTION_CACHE = "org.apache.chemistry.opencmis.bindings.typeDefintionCache";
+    public static final String SPI_OBJECT = "org.apache.chemistry.opencmis.bindings.spi.object";
+    public static final String AUTHENTICATION_PROVIDER_OBJECT = "org.apache.chemistry.opencmis.bindings.auth.object";
+
+    /**
+     * Private constructor.
+     */
+    private CmisBindingsHelper() {
+    }
+
+    /**
+     * Gets the SPI object for the given session. If there is already a SPI
+     * object in the session it will be returned. If there is no SPI object it
+     * will be created and put into the session.
+     * 
+     * @param session
+     *            the session object
+     * 
+     * @return the SPI object
+     */
+    public static CmisSpi getSPI(Session session) {
+        // fetch from session
+        CmisSpi spi = (CmisSpi) session.get(SPI_OBJECT);
+        if (spi != null) {
+            return spi;
+        }
+
+        session.writeLock();
+        try {
+            // try again
+            spi = (CmisSpi) session.get(SPI_OBJECT);
+            if (spi != null) {
+                return spi;
+            }
+
+            // ok, we have to create it...
+            try {
+                String spiFactoryName = (String) session.get(SessionParameter.BINDING_SPI_CLASS);
+                Class<?> spiFactoryClass = Class.forName(spiFactoryName);
+                Object spiFactory = spiFactoryClass.newInstance();
+
+                if (!(spiFactory instanceof CmisSpiFactory)) {
+                    throw new CmisRuntimeException("Not a CMISSPIFactory class!");
+                }
+
+                spi = ((CmisSpiFactory) spiFactory).getSpiInstance(session);
+                if (spi == null) {
+                    throw new CmisRuntimeException("SPI factory returned null!");
+                }
+            } catch (CmisBaseException e) {
+                throw e;
+            } catch (Exception e) {
+                throw new CmisRuntimeException("SPI cannot be initialized: " + e.getMessage(), e);
+            }
+
+            // we have a SPI object -> put it into the session
+            session.put(SPI_OBJECT, spi, true);
+        } finally {
+            session.writeUnlock();
+        }
+
+        return spi;
+    }
+
+    /**
+     * Returns the authentication provider from the session or <code>null</code>
+     * if no authentication provider is set.
+     */
+    public static AbstractAuthenticationProvider getAuthenticationProvider(Session session) {
+        return (AbstractAuthenticationProvider) session.get(AUTHENTICATION_PROVIDER_OBJECT);
+    }
+
+    /**
+     * Returns the repository info cache from the session.
+     */
+    public static RepositoryInfoCache getRepositoryInfoCache(Session session) {
+        return (RepositoryInfoCache) session.get(REPOSITORY_INFO_CACHE);
+    }
+
+    /**
+     * Returns the type definition cache from the session.
+     */
+    public static TypeDefinitionCache getTypeDefinitionCache(Session session) {
+        return (TypeDefinitionCache) session.get(TYPE_DEFINTION_CACHE);
+    }
 }



Mime
View raw message