001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (C) Alkacon Software (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.cmis;
029
030import org.opencms.main.OpenCms;
031
032import java.math.BigInteger;
033import java.util.ArrayList;
034import java.util.List;
035
036import org.apache.chemistry.opencmis.commons.data.Acl;
037import org.apache.chemistry.opencmis.commons.data.AllowableActions;
038import org.apache.chemistry.opencmis.commons.data.ContentStream;
039import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
040import org.apache.chemistry.opencmis.commons.data.FailedToDeleteData;
041import org.apache.chemistry.opencmis.commons.data.ObjectData;
042import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
043import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
044import org.apache.chemistry.opencmis.commons.data.ObjectList;
045import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
046import org.apache.chemistry.opencmis.commons.data.Properties;
047import org.apache.chemistry.opencmis.commons.data.RenditionData;
048import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
049import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
050import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
051import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
052import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
053import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
054import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
055import org.apache.chemistry.opencmis.commons.enums.VersioningState;
056import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
057import org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService;
058import org.apache.chemistry.opencmis.commons.server.CallContext;
059import org.apache.chemistry.opencmis.commons.server.ObjectInfo;
060import org.apache.chemistry.opencmis.commons.spi.Holder;
061
062/**
063 * The CMIS service class for OpenCms repositories.<p>
064 *
065 * Typically, a new instance of this class will be created for every CMIS service request. This class delegates the
066 * actual work to an implementation of the {@link I_CmsCmisRepository} class.<p>
067 */
068public class CmsCmisService extends AbstractCmisService {
069
070    /** The call context. */
071    protected CallContext m_callContext;
072
073    /**
074     * Creates a new CMIS service instance.<p>
075     *
076     * @param context the CMIS call context
077     */
078    public CmsCmisService(CallContext context) {
079
080        m_callContext = context;
081    }
082
083    /**
084     * @param repositoryId
085     * @param objectId
086     * @param folderId
087     * @param allVersions
088     * @param extension
089     * @see org.apache.chemistry.opencmis.commons.spi.MultiFilingService#addObjectToFolder(java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
090     */
091    @Override
092    public void addObjectToFolder(
093        String repositoryId,
094        String objectId,
095        String folderId,
096        Boolean allVersions,
097        ExtensionsData extension) {
098
099        getRepository(repositoryId).addObjectToFolder(makeContext(), objectId, folderId, allVersions.booleanValue());
100    }
101
102    /**
103     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#applyPolicy(java.lang.String, java.lang.String, java.lang.String, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
104     */
105    @Override
106    public void applyPolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
107
108        getRepository(repositoryId).applyPolicy(makeContext(), policyId, objectId);
109    }
110
111    /**
112     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#createDocument(java.lang.String, org.apache.chemistry.opencmis.commons.data.Properties, java.lang.String, org.apache.chemistry.opencmis.commons.data.ContentStream, org.apache.chemistry.opencmis.commons.enums.VersioningState, java.util.List, org.apache.chemistry.opencmis.commons.data.Acl, org.apache.chemistry.opencmis.commons.data.Acl, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
113     */
114    @Override
115    public String createDocument(
116        String repositoryId,
117        Properties properties,
118        String folderId,
119        ContentStream contentStream,
120        VersioningState versioningState,
121        List<String> policies,
122        Acl addAces,
123        Acl removeAces,
124        ExtensionsData extension) {
125
126        return getRepository(repositoryId).createDocument(
127            makeContext(),
128            properties,
129            folderId,
130            contentStream,
131            versioningState,
132            policies,
133            addAces,
134            removeAces);
135    }
136
137    /**
138     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#createDocumentFromSource(java.lang.String, java.lang.String, org.apache.chemistry.opencmis.commons.data.Properties, java.lang.String, org.apache.chemistry.opencmis.commons.enums.VersioningState, java.util.List, org.apache.chemistry.opencmis.commons.data.Acl, org.apache.chemistry.opencmis.commons.data.Acl, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
139     */
140    @Override
141    public String createDocumentFromSource(
142        String repositoryId,
143        String sourceId,
144        Properties properties,
145        String folderId,
146        VersioningState versioningState,
147        List<String> policies,
148        Acl addAces,
149        Acl removeAces,
150        ExtensionsData extension) {
151
152        return getRepository(repositoryId).createDocumentFromSource(
153            makeContext(),
154            sourceId,
155            properties,
156            folderId,
157            versioningState,
158            policies,
159            addAces,
160            removeAces);
161    }
162
163    /**
164     * @see org.apache.chemistry.opencmis.commons.spi.ObjectService#createFolder(java.lang.String, org.apache.chemistry.opencmis.commons.data.Properties, java.lang.String, java.util.List, org.apache.chemistry.opencmis.commons.data.Acl, org.apache.chemistry.opencmis.commons.data.Acl, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
165     */
166    @Override
167    public String createFolder(
168        String repositoryId,
169        Properties properties,
170        String folderId,
171        List<String> policies,
172        Acl addAces,
173        Acl removeAces,
174        ExtensionsData extension) {
175
176        return getRepository(repositoryId).createFolder(
177            makeContext(),
178            properties,
179            folderId,
180            policies,
181            addAces,
182            removeAces);
183    }
184
185    /**
186     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#createPolicy(java.lang.String, org.apache.chemistry.opencmis.commons.data.Properties, java.lang.String, java.util.List, org.apache.chemistry.opencmis.commons.data.Acl, org.apache.chemistry.opencmis.commons.data.Acl, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
187     */
188    @Override
189    public String createPolicy(
190        String repositoryId,
191        Properties properties,
192        String folderId,
193        List<String> policies,
194        Acl addAces,
195        Acl removeAces,
196        ExtensionsData extension) {
197
198        return getRepository(repositoryId).createPolicy(
199            makeContext(),
200            properties,
201            folderId,
202            policies,
203            addAces,
204            removeAces);
205    }
206
207    /**
208     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#createRelationship(java.lang.String, org.apache.chemistry.opencmis.commons.data.Properties, java.util.List, org.apache.chemistry.opencmis.commons.data.Acl, org.apache.chemistry.opencmis.commons.data.Acl, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
209     */
210    @Override
211    public String createRelationship(
212        String repositoryId,
213        Properties properties,
214        List<String> policies,
215        Acl addAces,
216        Acl removeAces,
217        ExtensionsData extension) {
218
219        return getRepository(repositoryId).createRelationship(makeContext(), properties, policies, addAces, removeAces);
220    }
221
222    /**
223     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#deleteContentStream(java.lang.String, org.apache.chemistry.opencmis.commons.spi.Holder, org.apache.chemistry.opencmis.commons.spi.Holder, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
224     */
225    @Override
226    public void deleteContentStream(
227        String repositoryId,
228        Holder<String> objectId,
229        Holder<String> changeToken,
230        ExtensionsData extension) {
231
232        getRepository(repositoryId).deleteContentStream(makeContext(), objectId, changeToken);
233    }
234
235    /**
236     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#deleteObject(java.lang.String, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
237     */
238    @Override
239    public void deleteObject(String repositoryId, String objectId, Boolean allVersions, ExtensionsData extension) {
240
241        getRepository(repositoryId).deleteObject(makeContext(), objectId, allVersions.booleanValue());
242    }
243
244    /**
245     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#deleteObjectOrCancelCheckOut(java.lang.String, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
246     */
247    @Override
248    public void deleteObjectOrCancelCheckOut(
249        String repositoryId,
250        String objectId,
251        Boolean allVersions,
252        ExtensionsData extension) {
253
254        getRepository(repositoryId).deleteObject(makeContext(), objectId, allVersions.booleanValue());
255    }
256
257    /**
258     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#deleteTree(java.lang.String, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.enums.UnfileObject, java.lang.Boolean, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
259     */
260    @Override
261    public FailedToDeleteData deleteTree(
262        String repositoryId,
263        String folderId,
264        Boolean allVersions,
265        UnfileObject unfileObjects,
266        Boolean continueOnFailure,
267        ExtensionsData extension) {
268
269        return getRepository(repositoryId).deleteTree(
270            makeContext(),
271            folderId,
272            allVersions.booleanValue(),
273            unfileObjects,
274            continueOnFailure.booleanValue());
275    }
276
277    /**
278     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getAcl(java.lang.String, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
279     */
280    @Override
281    public Acl getAcl(String repositoryId, String objectId, Boolean onlyBasicPermissions, ExtensionsData extension) {
282
283        return getRepository(repositoryId).getAcl(makeContext(), objectId, onlyBasicPermissions.booleanValue());
284    }
285
286    /**
287     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getAllowableActions(java.lang.String, java.lang.String, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
288     */
289    @Override
290    public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension) {
291
292        return getRepository(repositoryId).getAllowableActions(makeContext(), objectId);
293    }
294
295    /**
296     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getAppliedPolicies(java.lang.String, java.lang.String, java.lang.String, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
297     */
298    @Override
299    public List<ObjectData> getAppliedPolicies(
300        String repositoryId,
301        String objectId,
302        String filter,
303        ExtensionsData extension) {
304
305        return getRepository(repositoryId).getAppliedPolicies(makeContext(), objectId, filter);
306    }
307
308    /**
309     *
310     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getCheckedOutDocs(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.enums.IncludeRelationships, java.lang.String, java.math.BigInteger, java.math.BigInteger, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
311     */
312    @Override
313    public ObjectList getCheckedOutDocs(
314        String repositoryId,
315        String folderId,
316        String filter,
317        String orderBy,
318        Boolean includeAllowableActions,
319        IncludeRelationships includeRelationships,
320        String renditionFilter,
321        BigInteger maxItems,
322        BigInteger skipCount,
323        ExtensionsData extension) {
324
325        return getRepository(repositoryId).getCheckedOutDocs(
326            makeContext(),
327            folderId,
328            filter,
329            orderBy,
330            includeAllowableActions.booleanValue(),
331            includeRelationships,
332            renditionFilter,
333            maxItems,
334            skipCount);
335    }
336
337    /**
338     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getChildren(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.enums.IncludeRelationships, java.lang.String, java.lang.Boolean, java.math.BigInteger, java.math.BigInteger, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
339     */
340    @Override
341    public ObjectInFolderList getChildren(
342        String repositoryId,
343        String folderId,
344        String filter,
345        String orderBy,
346        Boolean includeAllowableActions,
347        IncludeRelationships includeRelationships,
348        String renditionFilter,
349        Boolean includePathSegment,
350        BigInteger maxItems,
351        BigInteger skipCount,
352        ExtensionsData extension) {
353
354        return getRepository(repositoryId).getChildren(
355            makeContext(),
356            folderId,
357            filter,
358            orderBy,
359            includeAllowableActions.booleanValue(),
360            includeRelationships,
361            renditionFilter,
362            includePathSegment.booleanValue(),
363            maxItems,
364            skipCount);
365    }
366
367    /**
368     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getContentChanges(java.lang.String, org.apache.chemistry.opencmis.commons.spi.Holder, java.lang.Boolean, java.lang.String, java.lang.Boolean, java.lang.Boolean, java.math.BigInteger, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
369     */
370    @Override
371    public ObjectList getContentChanges(
372        String repositoryId,
373        Holder<String> changeLogToken,
374        Boolean includeProperties,
375        String filter,
376        Boolean includePolicyIds,
377        Boolean includeAcl,
378        BigInteger maxItems,
379        ExtensionsData extension) {
380
381        return getRepository(repositoryId).getContentChanges(
382            makeContext(),
383            changeLogToken,
384            includeProperties.booleanValue(),
385            filter,
386            includePolicyIds.booleanValue(),
387            includeAcl.booleanValue(),
388            maxItems);
389    }
390
391    /**
392     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getContentStream(java.lang.String, java.lang.String, java.lang.String, java.math.BigInteger, java.math.BigInteger, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
393     */
394    @Override
395    public ContentStream getContentStream(
396        String repositoryId,
397        String objectId,
398        String streamId,
399        BigInteger offset,
400        BigInteger length,
401        ExtensionsData extension) {
402
403        return getRepository(repositoryId).getContentStream(makeContext(), objectId, streamId, offset, length);
404    }
405
406    /**
407     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getDescendants(java.lang.String, java.lang.String, java.math.BigInteger, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.enums.IncludeRelationships, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
408     */
409    @Override
410    public List<ObjectInFolderContainer> getDescendants(
411        String repositoryId,
412        String folderId,
413        BigInteger depth,
414        String filter,
415        Boolean includeAllowableActions,
416        IncludeRelationships includeRelationships,
417        String renditionFilter,
418        Boolean includePathSegment,
419        ExtensionsData extension) {
420
421        return getRepository(repositoryId).getDescendants(
422            makeContext(),
423            folderId,
424            depth,
425            filter,
426            includeAllowableActions.booleanValue(),
427            includePathSegment.booleanValue(),
428            false);
429    }
430
431    /**
432     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getFolderParent(java.lang.String, java.lang.String, java.lang.String, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
433     */
434    @Override
435    public ObjectData getFolderParent(String repositoryId, String folderId, String filter, ExtensionsData extension) {
436
437        return getRepository(repositoryId).getFolderParent(makeContext(), folderId, filter);
438    }
439
440    /**
441     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getFolderTree(java.lang.String, java.lang.String, java.math.BigInteger, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.enums.IncludeRelationships, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
442     */
443    @Override
444    public List<ObjectInFolderContainer> getFolderTree(
445        String repositoryId,
446        String folderId,
447        BigInteger depth,
448        String filter,
449        Boolean includeAllowableActions,
450        IncludeRelationships includeRelationships,
451        String renditionFilter,
452        Boolean includePathSegment,
453        ExtensionsData extension) {
454
455        return getRepository(repositoryId).getDescendants(
456            makeContext(),
457            folderId,
458            depth,
459            filter,
460            includeAllowableActions.booleanValue(),
461            includePathSegment.booleanValue(),
462            true);
463    }
464
465    /**
466     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getObject(java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.enums.IncludeRelationships, java.lang.String, java.lang.Boolean, java.lang.Boolean, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
467     */
468    @Override
469    public ObjectData getObject(
470        String repositoryId,
471        String objectId,
472        String filter,
473        Boolean includeAllowableActions,
474        IncludeRelationships includeRelationships,
475        String renditionFilter,
476        Boolean includePolicyIds,
477        Boolean includeAcl,
478        ExtensionsData extension) {
479
480        return getRepository(repositoryId).getObject(
481            makeContext(),
482            objectId,
483            filter,
484            includeAllowableActions.booleanValue(),
485            includeRelationships,
486            renditionFilter,
487            includePolicyIds.booleanValue(),
488            includeAcl.booleanValue());
489    }
490
491    /**
492     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getObjectByPath(java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.enums.IncludeRelationships, java.lang.String, java.lang.Boolean, java.lang.Boolean, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
493     */
494    @Override
495    public ObjectData getObjectByPath(
496        String repositoryId,
497        String path,
498        String filter,
499        Boolean includeAllowableActions,
500        IncludeRelationships includeRelationships,
501        String renditionFilter,
502        Boolean includePolicyIds,
503        Boolean includeAcl,
504        ExtensionsData extension) {
505
506        return getRepository(repositoryId).getObjectByPath(
507            makeContext(),
508            path,
509            filter,
510            includeAllowableActions.booleanValue(),
511            includeRelationships,
512            renditionFilter,
513            includePolicyIds.booleanValue(),
514            includeAcl.booleanValue());
515    }
516
517    /**
518     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getObjectInfo(java.lang.String, java.lang.String)
519     */
520    @Override
521    public ObjectInfo getObjectInfo(String repositoryId, String objectId) {
522
523        ObjectInfo result = super.getObjectInfo(repositoryId, objectId);
524        return result;
525    }
526
527    /**
528     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getObjectParents(java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.enums.IncludeRelationships, java.lang.String, java.lang.Boolean, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
529     */
530    @Override
531    public List<ObjectParentData> getObjectParents(
532        String repositoryId,
533        String objectId,
534        String filter,
535        Boolean includeAllowableActions,
536        IncludeRelationships includeRelationships,
537        String renditionFilter,
538        Boolean includeRelativePathSegment,
539        ExtensionsData extension) {
540
541        return getRepository(repositoryId).getObjectParents(
542            makeContext(),
543            objectId,
544            filter,
545            includeAllowableActions.booleanValue(),
546            includeRelativePathSegment.booleanValue());
547    }
548
549    /**
550     * Gets all or a subset of relationships associated with an independent
551     * object.
552     */
553    @Override
554    public ObjectList getObjectRelationships(
555        String repositoryId,
556        String objectId,
557        Boolean includeSubRelationshipTypes,
558        RelationshipDirection relationshipDirection,
559        String typeId,
560        String filter,
561        Boolean includeAllowableActions,
562        BigInteger maxItems,
563        BigInteger skipCount,
564        ExtensionsData extension) {
565
566        return getRepository(repositoryId).getObjectRelationships(
567            makeContext(),
568            objectId,
569            includeSubRelationshipTypes.booleanValue(),
570            relationshipDirection,
571            typeId,
572            filter,
573            includeAllowableActions.booleanValue(),
574            maxItems,
575            skipCount);
576    }
577
578    /**
579     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getProperties(java.lang.String, java.lang.String, java.lang.String, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
580     */
581    @Override
582    public Properties getProperties(String repositoryId, String objectId, String filter, ExtensionsData extension) {
583
584        return getRepository(repositoryId).getProperties(makeContext(), objectId, filter);
585    }
586
587    /**
588     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getRenditions(java.lang.String, java.lang.String, java.lang.String, java.math.BigInteger, java.math.BigInteger, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
589     */
590    @Override
591    public List<RenditionData> getRenditions(
592        String repositoryId,
593        String objectId,
594        String renditionFilter,
595        BigInteger maxItems,
596        BigInteger skipCount,
597        ExtensionsData extension) {
598
599        return getRepository(repositoryId).getRenditions(makeContext(), objectId, renditionFilter, maxItems, skipCount);
600    }
601
602    /**
603     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getRepositoryInfo(java.lang.String, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
604     */
605    @Override
606    public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
607
608        return getRepository(repositoryId).getRepositoryInfo();
609    }
610
611    /**
612     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getRepositoryInfos(org.apache.chemistry.opencmis.commons.data.ExtensionsData)
613     */
614    @Override
615    public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {
616
617        List<RepositoryInfo> result = new ArrayList<RepositoryInfo>();
618        for (I_CmsCmisRepository repository : OpenCms.getRepositoryManager().getRepositories(
619            I_CmsCmisRepository.class)) {
620            result.add(repository.getRepositoryInfo());
621        }
622        return result;
623    }
624
625    /**
626     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getTypeChildren(java.lang.String, java.lang.String, java.lang.Boolean, java.math.BigInteger, java.math.BigInteger, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
627     */
628    @Override
629    public TypeDefinitionList getTypeChildren(
630        String repositoryId,
631        String typeId,
632        Boolean includePropertyDefinitions,
633        BigInteger maxItems,
634        BigInteger skipCount,
635        ExtensionsData extension) {
636
637        return getRepository(repositoryId).getTypeChildren(
638            makeContext(),
639            typeId,
640            includePropertyDefinitions.booleanValue(),
641            maxItems,
642            skipCount);
643    }
644
645    /**
646     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getTypeDefinition(java.lang.String, java.lang.String, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
647     */
648    @Override
649    public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) {
650
651        return getRepository(repositoryId).getTypeDefinition(makeContext(), typeId);
652    }
653
654    /**
655     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#getTypeDescendants(java.lang.String, java.lang.String, java.math.BigInteger, java.lang.Boolean, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
656     */
657    @Override
658    public List<TypeDefinitionContainer> getTypeDescendants(
659        String repositoryId,
660        String typeId,
661        BigInteger depth,
662        Boolean includePropertyDefinitions,
663        ExtensionsData extension) {
664
665        return getRepository(repositoryId).getTypeDescendants(
666            makeContext(),
667            typeId,
668            depth,
669            includePropertyDefinitions.booleanValue());
670    }
671
672    /**
673     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#moveObject(java.lang.String, org.apache.chemistry.opencmis.commons.spi.Holder, java.lang.String, java.lang.String, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
674     */
675    @Override
676    public void moveObject(
677        String repositoryId,
678        Holder<String> objectId,
679        String targetFolderId,
680        String sourceFolderId,
681        ExtensionsData extension) {
682
683        getRepository(repositoryId).moveObject(makeContext(), objectId, targetFolderId, sourceFolderId);
684    }
685
686    /**
687     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#query(java.lang.String, java.lang.String, java.lang.Boolean, java.lang.Boolean, org.apache.chemistry.opencmis.commons.enums.IncludeRelationships, java.lang.String, java.math.BigInteger, java.math.BigInteger, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
688     */
689    @Override
690    public ObjectList query(
691        String repositoryId,
692        String statement,
693        Boolean searchAllVersions,
694        Boolean includeAllowableActions,
695        IncludeRelationships includeRelationships,
696        String renditionFilter,
697        BigInteger maxItems,
698        BigInteger skipCount,
699        ExtensionsData extension) {
700
701        return getRepository(repositoryId).query(
702            makeContext(),
703            statement,
704            searchAllVersions.booleanValue(),
705            includeAllowableActions.booleanValue(),
706            includeRelationships,
707            renditionFilter,
708            maxItems,
709            skipCount);
710    }
711
712    /**
713     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#removeObjectFromFolder(java.lang.String, java.lang.String, java.lang.String, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
714     */
715    @Override
716    public void removeObjectFromFolder(
717        String repositoryId,
718        String objectId,
719        String folderId,
720        ExtensionsData extension) {
721
722        getRepository(repositoryId).removeObjectFromFolder(makeContext(), objectId, folderId);
723    }
724
725    /**
726     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#removePolicy(java.lang.String, java.lang.String, java.lang.String, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
727     */
728    @Override
729    public void removePolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
730
731        getRepository(repositoryId).removePolicy(makeContext(), policyId, objectId);
732    }
733
734    /**
735     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#setContentStream(java.lang.String, org.apache.chemistry.opencmis.commons.spi.Holder, java.lang.Boolean, org.apache.chemistry.opencmis.commons.spi.Holder, org.apache.chemistry.opencmis.commons.data.ContentStream, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
736     */
737    @Override
738    public void setContentStream(
739        String repositoryId,
740        Holder<String> objectId,
741        Boolean overwriteFlag,
742        Holder<String> changeToken,
743        ContentStream contentStream,
744        ExtensionsData extension) {
745
746        getRepository(repositoryId).setContentStream(
747            makeContext(),
748            objectId,
749            overwriteFlag.booleanValue(),
750            changeToken,
751            contentStream);
752    }
753
754    /**
755     * @see org.apache.chemistry.opencmis.commons.impl.server.AbstractCmisService#updateProperties(java.lang.String, org.apache.chemistry.opencmis.commons.spi.Holder, org.apache.chemistry.opencmis.commons.spi.Holder, org.apache.chemistry.opencmis.commons.data.Properties, org.apache.chemistry.opencmis.commons.data.ExtensionsData)
756     */
757    @Override
758    public void updateProperties(
759        String repositoryId,
760        Holder<String> objectId,
761        Holder<String> changeToken,
762        Properties properties,
763        ExtensionsData extension) {
764
765        getRepository(repositoryId).updateProperties(makeContext(), objectId, changeToken, properties);
766    }
767
768    /**
769     * Gets the repository for a given repository id.<p>
770     *
771     * @param repositoryId the repository id
772     *
773     * @return the repository with the given id
774     */
775    protected I_CmsCmisRepository getRepository(String repositoryId) {
776
777        I_CmsCmisRepository result = OpenCms.getRepositoryManager().getRepository(
778            repositoryId,
779            I_CmsCmisRepository.class);
780        if (result == null) {
781            throw new CmisConnectionException("missing repository: " + repositoryId);
782        }
783        return result;
784    }
785
786    /**
787     * Creates a call context wrapper.<p>
788     *
789     * @return the created wrapper
790     */
791    private CmsCmisCallContext makeContext() {
792
793        return new CmsCmisCallContext(m_callContext, this);
794    }
795}