001
014
015 package com.liferay.portlet.documentlibrary.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.security.auth.PrincipalException;
020 import com.liferay.portal.security.permission.ActionKeys;
021 import com.liferay.portal.service.ServiceContext;
022 import com.liferay.portlet.documentlibrary.FileShortcutPermissionException;
023 import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
024 import com.liferay.portlet.documentlibrary.service.base.DLFileShortcutServiceBaseImpl;
025 import com.liferay.portlet.documentlibrary.service.permission.DLFileEntryPermission;
026 import com.liferay.portlet.documentlibrary.service.permission.DLFileShortcutPermission;
027 import com.liferay.portlet.documentlibrary.service.permission.DLFolderPermission;
028
029
032 public class DLFileShortcutServiceImpl extends DLFileShortcutServiceBaseImpl {
033
034 public DLFileShortcut addFileShortcut(
035 long groupId, long folderId, long toFileEntryId,
036 ServiceContext serviceContext)
037 throws PortalException, SystemException {
038
039 DLFolderPermission.check(
040 getPermissionChecker(), groupId, folderId, ActionKeys.ADD_SHORTCUT);
041
042 try {
043 DLFileEntryPermission.check(
044 getPermissionChecker(), toFileEntryId, ActionKeys.VIEW);
045 }
046 catch (PrincipalException pe) {
047 throw new FileShortcutPermissionException();
048 }
049
050 return dlFileShortcutLocalService.addFileShortcut(
051 getUserId(), groupId, folderId, toFileEntryId, serviceContext);
052 }
053
054 public void deleteFileShortcut(long fileShortcutId)
055 throws PortalException, SystemException {
056
057 DLFileShortcutPermission.check(
058 getPermissionChecker(), fileShortcutId, ActionKeys.DELETE);
059
060 dlFileShortcutLocalService.deleteFileShortcut(fileShortcutId);
061 }
062
063 public DLFileShortcut getFileShortcut(long fileShortcutId)
064 throws PortalException, SystemException {
065
066 DLFileShortcutPermission.check(
067 getPermissionChecker(), fileShortcutId, ActionKeys.VIEW);
068
069 return dlFileShortcutLocalService.getFileShortcut(fileShortcutId);
070 }
071
072 public DLFileShortcut updateFileShortcut(
073 long fileShortcutId, long folderId, long toFileEntryId,
074 ServiceContext serviceContext)
075 throws PortalException, SystemException {
076
077 DLFileShortcutPermission.check(
078 getPermissionChecker(), fileShortcutId, ActionKeys.UPDATE);
079
080 try {
081 DLFileEntryPermission.check(
082 getPermissionChecker(), toFileEntryId, ActionKeys.VIEW);
083 }
084 catch (PrincipalException pe) {
085 throw new FileShortcutPermissionException();
086 }
087
088 return dlFileShortcutLocalService.updateFileShortcut(
089 getUserId(), fileShortcutId, folderId, toFileEntryId,
090 serviceContext);
091 }
092
093 }