View Javadoc
1   /*
2    * Copyright (c) 2002-2014, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.document.modules.cmis.service;
35  
36  import fr.paris.lutece.portal.service.util.AppLogService;
37  
38  import org.apache.chemistry.opencmis.commons.data.*;
39  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
40  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
41  import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
42  import org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService;
43  import org.apache.chemistry.opencmis.commons.server.CallContext;
44  
45  import java.math.BigInteger;
46  
47  import java.util.ArrayList;
48  import java.util.List;
49  
50  
51  /**
52   * DocumentCmisService
53   */
54  public class DocumentCmisService extends AbstractCmisService
55  {
56      private static DocumentRepository _repository = new DocumentRepository(  );
57      private CallContext _context;
58  
59      /**
60       * Set the call context
61       * @param context The context
62       */
63      public void setCallContext( CallContext context )
64      {
65          _context = context;
66      }
67  
68      /**
69       * {@inheritDoc }
70       */
71      @Override
72      public List<RepositoryInfo> getRepositoryInfos( ExtensionsData extension )
73      {
74          AppLogService.info( "getRepositoryInfos" );
75  
76          List<RepositoryInfo> list = new ArrayList<RepositoryInfo>(  );
77          list.add( _repository.getInfos(  ) );
78  
79          return list;
80      }
81  
82      /**
83       * {@inheritDoc }
84       */
85      @Override
86      public RepositoryInfo getRepositoryInfo( String repositoryId, ExtensionsData extension )
87      {
88          AppLogService.info( "getRepositoryInfo" );
89  
90          return _repository.getInfos(  );
91      }
92  
93      /**
94       * {@inheritDoc }
95       */
96      @Override
97      public TypeDefinitionList getTypeChildren( String repositoryId, String typeId, Boolean includePropertyDefinitions,
98          BigInteger maxItems, BigInteger skipCount, ExtensionsData extension )
99      {
100         AppLogService.info( "getTypeChildren" );
101 
102         return _repository.getTypesChildren( _context, typeId, true, maxItems, skipCount );
103     }
104 
105     /**
106      * {@inheritDoc }
107      */
108     @Override
109     public TypeDefinition getTypeDefinition( String repositoryId, String typeId, ExtensionsData extension )
110     {
111         AppLogService.info( "getTypeDefinition" );
112 
113         return _repository.getTypeDefinition( _context, typeId );
114     }
115 
116     /**
117      * {@inheritDoc }
118      */
119     @Override
120     public ObjectInFolderList getChildren( String repositoryId, String folderId, String filter, String orderBy,
121         Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
122         Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension )
123     {
124         AppLogService.info( "getChildren" );
125 
126         return _repository.getChildren( _context, folderId, filter, orderBy, includeAllowableActions,
127             includeRelationships, renditionFilter, includePathSegment, maxItems, skipCount, extension, this );
128     }
129 
130     /**
131      * {@inheritDoc }
132      */
133     @Override
134     public List<ObjectParentData> getObjectParents( String repositoryId, String objectId, String filter,
135         Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
136         Boolean includeRelativePathSegment, ExtensionsData extension )
137     {
138         throw new UnsupportedOperationException( "Not supported yet." );
139     }
140 
141     /**
142      * {@inheritDoc }
143      */
144     @Override
145     public ObjectData getObject( String repositoryId, String objectId, String filter, Boolean includeAllowableActions,
146         IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
147         Boolean includeAcl, ExtensionsData extension )
148     {
149         AppLogService.info( "getObject : repositoryId=" + repositoryId + " objectId=" + objectId );
150 
151         return _repository.getObject( _context, objectId, filter, includeAllowableActions, includeRelationships,
152             renditionFilter, includePolicyIds, includeAcl, extension, this );
153     }
154 
155     /**
156      * {@inheritDoc }
157      */
158     @Override
159     public ObjectData getObjectByPath( String repositoryId, String path, String filter,
160         Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
161         Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension )
162     {
163         return _repository.getObjectByPath( _context, path, filter, includeAllowableActions, includeAcl, this );
164     }
165 
166     /**
167      * {@inheritDoc }
168      */
169     @Override
170     public ContentStream getContentStream( String repositoryId, String objectId, String streamId, BigInteger offset,
171         BigInteger length, ExtensionsData extension )
172     {
173         return _repository.getContentStream( _context, objectId, offset, length );
174     }
175 
176     /**
177      * {@inheritDoc }
178      */
179     @Override
180     public List<ObjectInFolderContainer> getDescendants( String repositoryId, String folderId, BigInteger depth,
181         String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
182         String renditionFilter, Boolean includePathSegment, ExtensionsData extension )
183     {
184         return _repository.getDescendants( _context, folderId, depth, filter, includeAllowableActions,
185             includePathSegment, this, false );
186     }
187 }