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.portlet.documentlibrary.model;
016    
017    /**
018     * <p>
019     * This contains several utility methods for the purpose of determining folder
020     * IDs and data repository IDs as used by back-end data systems like search and
021     * Document Library stores. These repository IDs should not be confused with the
022     * repository ID used by {@link
023     * com.liferay.portal.service.impl.RepositoryServiceImpl}.
024     * </p>
025     *
026     * @author Samuel Kong
027     * @author Alexander Chow
028     */
029    public class DLFolderConstants {
030    
031            public static final long DEFAULT_PARENT_FOLDER_ID = 0;
032    
033            public static final int RESTRICTION_TYPE_FILE_ENTRY_TYPES_AND_WORKFLOW = 1;
034    
035            public static final int RESTRICTION_TYPE_INHERIT = 0;
036    
037            public static final int RESTRICTION_TYPE_WORKFLOW = 2;
038    
039            public static String getClassName() {
040                    return DLFolder.class.getName();
041            }
042    
043            /**
044             * Determine the data repository ID from the repository ID and folder ID.
045             * The folder ID may be zero, implying that it is the root folder for the
046             * given repository.
047             */
048            public static long getDataRepositoryId(long repositoryId, long folderId) {
049                    if (folderId != DEFAULT_PARENT_FOLDER_ID) {
050                            return folderId;
051                    }
052                    else {
053                            return repositoryId;
054                    }
055            }
056    
057            /**
058             * Determine the folder ID when no knowledge of it currently exists.
059             */
060            public static long getFolderId(long groupId, long dataRepositoryId) {
061                    if (groupId != dataRepositoryId) {
062                            return dataRepositoryId;
063                    }
064                    else {
065                            return DEFAULT_PARENT_FOLDER_ID;
066                    }
067            }
068    
069    }