001    /**
002     * Copyright (c) 2000-2010 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.portlet.documentlibrary.model.DLFileEntry;
020    import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
021    import com.liferay.portlet.documentlibrary.model.DLFolder;
022    import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
023    import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class DLFileShortcutImpl
029            extends DLFileShortcutModelImpl implements DLFileShortcut {
030    
031            public DLFileShortcutImpl() {
032            }
033    
034            public DLFolder getFolder() {
035                    DLFolder folder = null;
036    
037                    if (getFolderId() > 0) {
038                            try {
039                                    folder = DLFolderLocalServiceUtil.getFolder(getFolderId());
040                            }
041                            catch (Exception e) {
042                                    folder = new DLFolderImpl();
043    
044                                    _log.error(e);
045                            }
046                    }
047                    else {
048                            folder = new DLFolderImpl();
049                    }
050    
051                    return folder;
052            }
053    
054            public String getToTitle() {
055                    String toTitle = null;
056    
057                    try {
058                            DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.getFileEntry(
059                                    getGroupId(), getToFolderId(), getToName());
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    }