001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.repository.cmis;
016    
017    import java.util.HashSet;
018    import java.util.Set;
019    
020    import org.apache.chemistry.opencmis.client.api.OperationContext;
021    import org.apache.chemistry.opencmis.client.api.SessionFactory;
022    import org.apache.chemistry.opencmis.client.runtime.OperationContextImpl;
023    import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
024    import org.apache.chemistry.opencmis.commons.PropertyIds;
025    import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
026    
027    /**
028     * @author Alexander Chow
029     */
030    public class CMISRepositoryUtil {
031    
032            public static OperationContext getOperationContext() {
033                    return _operationContext;
034            }
035    
036            public static SessionFactory getSessionFactory() {
037                    return _sessionFactory;
038            }
039    
040            private static final OperationContext _operationContext;
041            private static final SessionFactory _sessionFactory =
042                    SessionFactoryImpl.newInstance();
043    
044            static {
045                    Set<String> defaultFilterSet = new HashSet<>();
046    
047                    // Base
048    
049                    defaultFilterSet.add(PropertyIds.BASE_TYPE_ID);
050                    defaultFilterSet.add(PropertyIds.CREATED_BY);
051                    defaultFilterSet.add(PropertyIds.CREATION_DATE);
052                    defaultFilterSet.add(PropertyIds.LAST_MODIFIED_BY);
053                    defaultFilterSet.add(PropertyIds.LAST_MODIFICATION_DATE);
054                    defaultFilterSet.add(PropertyIds.NAME);
055                    defaultFilterSet.add(PropertyIds.OBJECT_ID);
056                    defaultFilterSet.add(PropertyIds.OBJECT_TYPE_ID);
057    
058                    // Document
059    
060                    defaultFilterSet.add(PropertyIds.CONTENT_STREAM_LENGTH);
061                    defaultFilterSet.add(PropertyIds.CONTENT_STREAM_MIME_TYPE);
062                    defaultFilterSet.add(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
063                    defaultFilterSet.add(PropertyIds.VERSION_LABEL);
064                    defaultFilterSet.add(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY);
065                    defaultFilterSet.add(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID);
066                    defaultFilterSet.add(PropertyIds.VERSION_SERIES_ID);
067    
068                    // Folder
069    
070                    defaultFilterSet.add(PropertyIds.PARENT_ID);
071                    defaultFilterSet.add(PropertyIds.PATH);
072    
073                    // Operation context
074    
075                    _operationContext = new OperationContextImpl(
076                            defaultFilterSet, false, true, false, IncludeRelationships.NONE,
077                            null, false, "cmis:name ASC", true, 1000);
078            }
079    
080    }