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.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            @Override
033            public Folder getFolder() {
034                    Folder folder = null;
035    
036                    if (getFolderId() > 0) {
037                            try {
038                                    folder = DLAppLocalServiceUtil.getFolder(getFolderId());
039                            }
040                            catch (Exception e) {
041                                    folder = new LiferayFolder(new DLFolderImpl());
042    
043                                    _log.error(e);
044                            }
045                    }
046                    else {
047                            folder = new LiferayFolder(new DLFolderImpl());
048                    }
049    
050                    return folder;
051            }
052    
053            @Override
054            public String getToTitle() {
055                    String toTitle = null;
056    
057                    try {
058                            FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(
059                                    getToFileEntryId());
060    
061                            toTitle = fileEntry.getTitle();
062                    }
063                    catch (Exception e) {
064                            _log.error(e);
065                    }
066    
067                    return toTitle;
068            }
069    
070            private static Log _log = LogFactoryUtil.getLog(DLFileShortcutImpl.class);
071    
072    }