001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.documentlibrary.service.impl;
022:
023: import com.liferay.portal.PortalException;
024: import com.liferay.portal.SystemException;
025: import com.liferay.portal.kernel.security.permission.ActionKeys;
026: import com.liferay.portal.security.auth.PrincipalException;
027: import com.liferay.portlet.documentlibrary.FileShortcutPermissionException;
028: import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
029: import com.liferay.portlet.documentlibrary.service.base.DLFileShortcutServiceBaseImpl;
030: import com.liferay.portlet.documentlibrary.service.permission.DLFileEntryPermission;
031: import com.liferay.portlet.documentlibrary.service.permission.DLFileShortcutPermission;
032: import com.liferay.portlet.documentlibrary.service.permission.DLFolderPermission;
033:
034: /**
035: * <a href="DLFileShortcutServiceImpl.java.html"><b><i>View Source</i></b></a>
036: *
037: * @author Brian Wing Shun Chan
038: *
039: */
040: public class DLFileShortcutServiceImpl extends
041: DLFileShortcutServiceBaseImpl {
042:
043: public DLFileShortcut addFileShortcut(long folderId,
044: long toFolderId, String toName,
045: boolean addCommunityPermissions, boolean addGuestPermissions)
046: throws PortalException, SystemException {
047:
048: DLFolderPermission.check(getPermissionChecker(), folderId,
049: ActionKeys.ADD_SHORTCUT);
050:
051: try {
052: DLFileEntryPermission.check(getPermissionChecker(),
053: toFolderId, toName, ActionKeys.VIEW);
054: } catch (PrincipalException pe) {
055: throw new FileShortcutPermissionException();
056: }
057:
058: return dlFileShortcutLocalService.addFileShortcut(getUserId(),
059: folderId, toFolderId, toName, addCommunityPermissions,
060: addGuestPermissions);
061: }
062:
063: public DLFileShortcut addFileShortcut(long folderId,
064: long toFolderId, String toName,
065: String[] communityPermissions, String[] guestPermissions)
066: throws PortalException, SystemException {
067:
068: DLFolderPermission.check(getPermissionChecker(), folderId,
069: ActionKeys.ADD_SHORTCUT);
070:
071: try {
072: DLFileEntryPermission.check(getPermissionChecker(),
073: toFolderId, toName, ActionKeys.VIEW);
074: } catch (PrincipalException pe) {
075: throw new FileShortcutPermissionException();
076: }
077:
078: return dlFileShortcutLocalService.addFileShortcut(getUserId(),
079: folderId, toFolderId, toName, communityPermissions,
080: guestPermissions);
081: }
082:
083: public void deleteFileShortcut(long fileShortcutId)
084: throws PortalException, SystemException {
085:
086: DLFileShortcutPermission.check(getPermissionChecker(),
087: fileShortcutId, ActionKeys.DELETE);
088:
089: dlFileShortcutLocalService.deleteFileShortcut(fileShortcutId);
090: }
091:
092: public DLFileShortcut getFileShortcut(long fileShortcutId)
093: throws PortalException, SystemException {
094:
095: DLFileShortcutPermission.check(getPermissionChecker(),
096: fileShortcutId, ActionKeys.VIEW);
097:
098: return dlFileShortcutLocalService
099: .getFileShortcut(fileShortcutId);
100: }
101:
102: public DLFileShortcut updateFileShortcut(long fileShortcutId,
103: long folderId, long toFolderId, String toName)
104: throws PortalException, SystemException {
105:
106: DLFileShortcutPermission.check(getPermissionChecker(),
107: fileShortcutId, ActionKeys.UPDATE);
108:
109: try {
110: DLFileEntryPermission.check(getPermissionChecker(),
111: toFolderId, toName, ActionKeys.VIEW);
112: } catch (PrincipalException pe) {
113: throw new FileShortcutPermissionException();
114: }
115:
116: return dlFileShortcutLocalService.updateFileShortcut(
117: getUserId(), fileShortcutId, folderId, toFolderId,
118: toName);
119: }
120:
121: }
|