001 /** 002 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. 003 * 004 * The contents of this file are subject to the terms of the Liferay Enterprise 005 * Subscription License ("License"). You may not use this file except in 006 * compliance with the License. You can obtain a copy of the License by 007 * contacting Liferay, Inc. See the License for the specific language governing 008 * permissions and limitations under the License, including but not limited to 009 * distribution rights of the Software. 010 * 011 * 012 * 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 String getClassName() { 034 return DLFolder.class.getName(); 035 } 036 037 /** 038 * Determine the data repository ID from the group ID and folder ID. The 039 * folder ID may be zero, implying that it is the root folder for the given 040 * group. 041 */ 042 public static long getDataRepositoryId(long groupId, long folderId) { 043 if (folderId != DEFAULT_PARENT_FOLDER_ID) { 044 return folderId; 045 } 046 else { 047 return groupId; 048 } 049 } 050 051 /** 052 * Determine the folder ID when no knowledge of it currently exists. 053 */ 054 public static long getFolderId(long groupId, long dataRepositoryId) { 055 if (groupId != dataRepositoryId) { 056 return dataRepositoryId; 057 } 058 else { 059 return DEFAULT_PARENT_FOLDER_ID; 060 } 061 } 062 063 }