1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.documentlibrary.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.security.auth.PrincipalException;
20  import com.liferay.portal.security.permission.ActionKeys;
21  import com.liferay.portlet.documentlibrary.FileShortcutPermissionException;
22  import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
23  import com.liferay.portlet.documentlibrary.service.base.DLFileShortcutServiceBaseImpl;
24  import com.liferay.portlet.documentlibrary.service.permission.DLFileEntryPermission;
25  import com.liferay.portlet.documentlibrary.service.permission.DLFileShortcutPermission;
26  import com.liferay.portlet.documentlibrary.service.permission.DLFolderPermission;
27  
28  /**
29   * <a href="DLFileShortcutServiceImpl.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Brian Wing Shun Chan
32   */
33  public class DLFileShortcutServiceImpl extends DLFileShortcutServiceBaseImpl {
34  
35      public DLFileShortcut addFileShortcut(
36              long folderId, long toFolderId, String toName,
37              boolean addCommunityPermissions, boolean addGuestPermissions)
38          throws PortalException, SystemException {
39  
40          DLFolderPermission.check(
41              getPermissionChecker(), folderId, ActionKeys.ADD_SHORTCUT);
42  
43          try {
44              DLFileEntryPermission.check(
45                  getPermissionChecker(), toFolderId, toName, ActionKeys.VIEW);
46          }
47          catch (PrincipalException pe) {
48              throw new FileShortcutPermissionException();
49          }
50  
51          return dlFileShortcutLocalService.addFileShortcut(
52              getUserId(), folderId, toFolderId, toName, addCommunityPermissions,
53              addGuestPermissions);
54      }
55  
56      public DLFileShortcut addFileShortcut(
57              long folderId, long toFolderId, String toName,
58              String[] communityPermissions, String[] guestPermissions)
59          throws PortalException, SystemException {
60  
61          DLFolderPermission.check(
62              getPermissionChecker(), folderId, ActionKeys.ADD_SHORTCUT);
63  
64          try {
65              DLFileEntryPermission.check(
66                  getPermissionChecker(), toFolderId, toName, ActionKeys.VIEW);
67          }
68          catch (PrincipalException pe) {
69              throw new FileShortcutPermissionException();
70          }
71  
72          return dlFileShortcutLocalService.addFileShortcut(
73              getUserId(), folderId, toFolderId, toName, communityPermissions,
74              guestPermissions);
75      }
76  
77      public void deleteFileShortcut(long fileShortcutId)
78          throws PortalException, SystemException {
79  
80          DLFileShortcutPermission.check(
81              getPermissionChecker(), fileShortcutId, ActionKeys.DELETE);
82  
83          dlFileShortcutLocalService.deleteFileShortcut(fileShortcutId);
84      }
85  
86      public DLFileShortcut getFileShortcut(long fileShortcutId)
87          throws PortalException, SystemException {
88  
89          DLFileShortcutPermission.check(
90              getPermissionChecker(), fileShortcutId, ActionKeys.VIEW);
91  
92          return dlFileShortcutLocalService.getFileShortcut(fileShortcutId);
93      }
94  
95      public DLFileShortcut updateFileShortcut(
96              long fileShortcutId, long folderId, long toFolderId, String toName)
97          throws PortalException, SystemException {
98  
99          DLFileShortcutPermission.check(
100             getPermissionChecker(), fileShortcutId, ActionKeys.UPDATE);
101 
102         try {
103             DLFileEntryPermission.check(
104                 getPermissionChecker(), toFolderId, toName, ActionKeys.VIEW);
105         }
106         catch (PrincipalException pe) {
107             throw new FileShortcutPermissionException();
108         }
109 
110         return dlFileShortcutLocalService.updateFileShortcut(
111             getUserId(), fileShortcutId, folderId, toFolderId, toName);
112     }
113 
114 }