001    /**
002     * Copyright (c) 2000-2013 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.bookmarks.model.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portlet.bookmarks.NoSuchFolderException;
020    import com.liferay.portlet.bookmarks.model.BookmarksFolder;
021    import com.liferay.portlet.bookmarks.service.BookmarksFolderLocalServiceUtil;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class BookmarksEntryImpl extends BookmarksEntryBaseImpl {
027    
028            public BookmarksEntryImpl() {
029            }
030    
031            @Override
032            public BookmarksFolder getFolder() throws PortalException, SystemException {
033                    if (getFolderId() <= 0) {
034                            return new BookmarksFolderImpl();
035                    }
036    
037                    return BookmarksFolderLocalServiceUtil.getFolder(getFolderId());
038            }
039    
040            @Override
041            public BookmarksFolder getTrashContainer()
042                    throws PortalException, SystemException {
043    
044                    BookmarksFolder folder = null;
045    
046                    try {
047                            folder = getFolder();
048                    }
049                    catch (NoSuchFolderException nsfe) {
050                            return null;
051                    }
052    
053                    if (folder.isInTrash()) {
054                            return folder;
055                    }
056    
057                    return folder.getTrashContainer();
058            }
059    
060            @Override
061            public boolean isInTrashContainer()
062                    throws PortalException, SystemException {
063    
064                    if (getTrashContainer() != null) {
065                            return true;
066                    }
067                    else {
068                            return false;
069                    }
070            }
071    
072    }