1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.documentlibrary.model.impl;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portlet.documentlibrary.model.DLFileEntry;
20  import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
21  import com.liferay.portlet.documentlibrary.model.DLFolder;
22  import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
23  import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
24  
25  /**
26   * <a href="DLFileShortcutImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class DLFileShortcutImpl
31      extends DLFileShortcutModelImpl implements DLFileShortcut {
32  
33      public DLFileShortcutImpl() {
34      }
35  
36      public DLFolder getFolder() {
37          DLFolder folder = null;
38  
39          if (getFolderId() > 0) {
40              try {
41                  folder = DLFolderLocalServiceUtil.getFolder(getFolderId());
42              }
43              catch (Exception e) {
44                  folder = new DLFolderImpl();
45  
46                  _log.error(e);
47              }
48          }
49          else {
50              folder = new DLFolderImpl();
51          }
52  
53          return folder;
54      }
55  
56      public String getToTitle() {
57          String toTitle = null;
58  
59          try {
60              DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.getFileEntry(
61                  getGroupId(), getToFolderId(), getToName());
62  
63              toTitle = fileEntry.getTitle();
64          }
65          catch (Exception e) {
66              _log.error(e);
67          }
68  
69          return toTitle;
70      }
71  
72      private static Log _log = LogFactoryUtil.getLog(DLFileShortcutImpl.class);
73  
74  }