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.io.InputStream;
22  import java.util.Collection;
23  import java.util.List;
24  import java.util.Map;
25  import java.util.Set;
26  
27  import org.apache.chemistry.opencmis.commons.data.Ace;
28  import org.apache.chemistry.opencmis.commons.data.Acl;
29  import org.apache.chemistry.opencmis.commons.data.ContentStream;
30  import org.apache.chemistry.opencmis.commons.data.ObjectData;
31  import org.apache.chemistry.opencmis.commons.data.ObjectList;
32  import org.apache.chemistry.opencmis.commons.data.Properties;
33  import org.apache.chemistry.opencmis.commons.data.PropertyData;
34  import org.apache.chemistry.opencmis.commons.data.RenditionData;
35  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
36  import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
37  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
38  import org.apache.chemistry.opencmis.commons.enums.Updatability;
39  
40  /**
41   * A factory to create and convert CMIS objects.
42   * 
43   * Custom {@link ObjectFactory} implementations may use the convert methods to
44   * inject specific implementations of the interfaces when the data is transfered
45   * from the low level API to the high level API.
46   * 
47   * @see org.apache.chemistry.opencmis.client.api.Session#getObjectFactory()
48   */
49  public interface ObjectFactory {
50  
51      void initialize(Session session, Map<String, String> parameters);
52  
53      // repository info
54  
55      RepositoryInfo convertRepositoryInfo(RepositoryInfo repositoryInfo);
56  
57      // ACL and ACE
58  
59      Acl convertAces(List<Ace> aces);
60  
61      Acl createAcl(List<Ace> aces);
62  
63      Ace createAce(String principal, List<String> permissions);
64  
65      // policies
66  
67      List<String> convertPolicies(List<Policy> policies);
68  
69      // renditions
70  
71      Rendition convertRendition(String objectId, RenditionData rendition);
72  
73      // content stream
74  
75      /**
76       * Creates an object that implements the {@link ContentStream} interface.
77       * 
78       * @param filename
79       *            the filename, should be set
80       * @param length
81       *            the length of the stream or -1 if the length is unknown
82       * @param mimetype
83       *            the MIME type, if unknown "application/octet-stream" should be
84       *            used
85       * @param stream
86       *            the stream, should not be <code>null</code>
87       * 
88       * @return the {@link ContentStream} object
89       */
90      ContentStream createContentStream(String filename, long length, String mimetype, InputStream stream);
91  
92      /**
93       * Creates an object that implements the {@link ContentStream} interface.
94       * 
95       * @param filename
96       *            the filename, should be set
97       * @param length
98       *            the length of the stream or -1 if the length is unknown
99       * @param mimetype
100      *            the MIME type, if unknown "application/octet-stream" should be
101      *            used
102      * @param stream
103      *            the stream, should not be <code>null</code>
104      * @param partial
105      *            if <code>false</code> the stream represents the full content,
106      *            if <code>true</code> the stream is only a part of the content
107      * 
108      * @return the {@link ContentStream} object
109      */
110     ContentStream createContentStream(String filename, long length, String mimetype, InputStream stream, boolean partial);
111 
112     /**
113      * Converts a high level {@link ContentStream} object into a low level
114      * {@link ContentStream} object.
115      * 
116      * @param contentStream
117      *            the original {@link ContentStream} object
118      * @return the {@link ContentStream} object
119      */
120     ContentStream convertContentStream(ContentStream contentStream);
121 
122     // types
123 
124     ObjectType convertTypeDefinition(TypeDefinition typeDefinition);
125 
126     ObjectType getTypeFromObjectData(ObjectData objectData);
127 
128     // properties
129 
130     <T> Property<T> createProperty(PropertyDefinition<T> type, List<T> values);
131 
132     Map<String, Property<?>> convertProperties(ObjectType objectType, Collection<SecondaryType> secondaryTypes,
133             Properties properties);
134 
135     Properties convertProperties(Map<String, ?> properties, ObjectType type, Collection<SecondaryType> secondaryTypes,
136             Set<Updatability> updatabilityFilter);
137 
138     List<PropertyData<?>> convertQueryProperties(Properties properties);
139 
140     // objects
141 
142     CmisObject convertObject(ObjectData objectData, OperationContext context);
143 
144     QueryResult convertQueryResult(ObjectData objectData);
145 
146     ChangeEvent convertChangeEvent(ObjectData objectData);
147 
148     ChangeEvents convertChangeEvents(String changeLogToken, ObjectList objectList);
149 }