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.lar;
016    
017    import com.liferay.portal.kernel.repository.model.Folder;
018    import com.liferay.portal.repository.liferayrepository.model.LiferayFolder;
019    import com.liferay.portlet.documentlibrary.NoSuchFolderException;
020    import com.liferay.portlet.documentlibrary.model.DLFolder;
021    import com.liferay.portlet.documentlibrary.service.persistence.DLFolderUtil;
022    import com.liferay.portlet.documentlibrary.util.RepositoryModelUtil;
023    
024    import java.util.List;
025    
026    /**
027     * @author Alexander Chow
028     */
029    public class FolderUtil {
030    
031            public static Folder fetchByR_P_N(
032                    long groupId, long parentFolderId, String name) {
033    
034                    DLFolder dlFolder = DLFolderUtil.fetchByG_P_N(
035                            groupId, parentFolderId, name);
036    
037                    if (dlFolder == null) {
038                            return null;
039                    }
040    
041                    return new LiferayFolder(dlFolder);
042            }
043    
044            public static Folder fetchByUUID_R(String uuid, long repositoryId) {
045                    DLFolder dlFolder = DLFolderUtil.fetchByUUID_G(uuid, repositoryId);
046    
047                    if (dlFolder == null) {
048                            return null;
049                    }
050    
051                    return new LiferayFolder(dlFolder);
052            }
053    
054            public static Folder findByPrimaryKey(long folderId)
055                    throws NoSuchFolderException {
056    
057                    DLFolder dlFolder = DLFolderUtil.findByPrimaryKey(folderId);
058    
059                    return new LiferayFolder(dlFolder);
060            }
061    
062            /**
063             * @deprecated As of 7.0.0, with no direct replacement
064             */
065            @Deprecated
066            public static List<Folder> findByR_P(
067                    long repositoryId, long parentFolderId) {
068    
069                    List<DLFolder> dlFolders = DLFolderUtil.findByG_P(
070                            repositoryId, parentFolderId);
071    
072                    return RepositoryModelUtil.toFolders(dlFolders);
073            }
074    
075            /**
076             * @deprecated As of 7.0.0, with no direct replacement
077             */
078            @Deprecated
079            public static List<Folder> findByRepositoryId(long repositoryId) {
080                    List<DLFolder> dlFolders = DLFolderUtil.findByGroupId(repositoryId);
081    
082                    return RepositoryModelUtil.toFolders(dlFolders);
083            }
084    
085    }