View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.client.api;
20  
21  import java.util.List;
22  import java.util.Map;
23  
24  /**
25   * Entry point into the OpenCMIS Client API.
26   * <p>
27   * There might be different ways to get a {@code SessionFactory} instance. For
28   * example it could be retrieved via a J2EE JNDI lookup or an OSGi service
29   * lookup. Clients outside a container might use the
30   * {@link org.apache.chemistry.opencmis.client.SessionFactoryFinder} class.
31   * <p>
32   * The entries of the parameter map are defined by
33   * {@link org.apache.chemistry.opencmis.commons.SessionParameter} class which is
34   * part of the commons package. Parameters specify connection settings (user
35   * name, authentication, connection URL, binding type, etc.).
36   * </p>
37   * <p>
38   * The {@link Session} class which is constructed is either the {@code session}
39   * base class which is the default implementation or it can be derived from that
40   * implementing special behavior for the session.
41   * </p>
42   * <p>
43   * Sample code:
44   * </p>
45   * 
46   * <pre>
47   * SessionFactory factory = ...
48   * 
49   * Map&lt;String, String&gt; parameter = new HashMap&lt;String, String&gt;();
50   * 
51   * parameter.put(SessionParameter.USER, "Otto");
52   * parameter.put(SessionParameter.PASSWORD, "****");
53   * 
54   * parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost/cmis/atom");
55   * parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
56   * parameter.put(SessionParameter.REPOSITORY_ID, "myRepository");
57   * ...
58   * Session session = factory.createSession(parameter);
59   * </pre>
60   * 
61   * @see org.apache.chemistry.opencmis.client.SessionFactoryFinder
62   * @see org.apache.chemistry.opencmis.commons.SessionParameter
63   * @see org.apache.chemistry.opencmis.client.SessionParameterMap
64   * @see Session
65   */
66  public interface SessionFactory {
67  
68      /**
69       * Creates a new session.
70       * 
71       * @param parameters
72       *            a map of name/value pairs with parameters for the session, see
73       *            {@link org.apache.chemistry.opencmis.commons.SessionParameter}
74       *            for parameters supported by OpenCMIS
75       * 
76       * 
77       * @return a {@link Session} connected to the CMIS repository, never
78       *         {@code null}
79       * 
80       * @see org.apache.chemistry.opencmis.commons.SessionParameter
81       */
82      Session createSession(Map<String, String> parameters);
83  
84      /**
85       * Returns all repositories that are available at the endpoint.
86       * 
87       * 
88       * @param parameters
89       *            a map of name/value pairs with parameters for the session, see
90       *            {@link org.apache.chemistry.opencmis.commons.SessionParameter}
91       *            for parameters supported by OpenCMIS, the parameter
92       *            {@link org.apache.chemistry.opencmis.commons.SessionParameter#REPOSITORY_ID}
93       *            should not be set
94       * 
95       * @return a list of all available repositories, never {@code null}
96       * 
97       * @see org.apache.chemistry.opencmis.commons.SessionParameter
98       */
99      List<Repository> getRepositories(Map<String, String> parameters);
100 }