001    /**
002     * Copyright (c) 2000-2012 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.impl;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.repository.model.FileEntry;
020    import com.liferay.portal.kernel.repository.model.Folder;
021    import com.liferay.portal.repository.liferayrepository.model.LiferayFolder;
022    import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class DLFileShortcutImpl extends DLFileShortcutBaseImpl {
028    
029            public DLFileShortcutImpl() {
030            }
031    
032            public Folder getFolder() {
033                    Folder folder = null;
034    
035                    if (getFolderId() > 0) {
036                            try {
037                                    folder = DLAppLocalServiceUtil.getFolder(getFolderId());
038                            }
039                            catch (Exception e) {
040                                    folder = new LiferayFolder(new DLFolderImpl());
041    
042                                    _log.error(e);
043                            }
044                    }
045                    else {
046                            folder = new LiferayFolder(new DLFolderImpl());
047                    }
048    
049                    return folder;
050            }
051    
052            public String getToTitle() {
053                    String toTitle = null;
054    
055                    try {
056                            FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(
057                                    getToFileEntryId());
058    
059                            toTitle = fileEntry.getTitle();
060                    }
061                    catch (Exception e) {
062                            _log.error(e);
063                    }
064    
065                    return toTitle;
066            }
067    
068            private static Log _log = LogFactoryUtil.getLog(DLFileShortcutImpl.class);
069    
070    }