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.imagegallery.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.portlet.imagegallery.model.IGImage;
027: import com.liferay.portlet.imagegallery.service.base.IGImageServiceBaseImpl;
028: import com.liferay.portlet.imagegallery.service.permission.IGFolderPermission;
029: import com.liferay.portlet.imagegallery.service.permission.IGImagePermission;
030:
031: import java.io.File;
032:
033: /**
034: * <a href="IGImageServiceImpl.java.html"><b><i>View Source</i></b></a>
035: *
036: * @author Brian Wing Shun Chan
037: *
038: */
039: public class IGImageServiceImpl extends IGImageServiceBaseImpl {
040:
041: public IGImage addImage(long folderId, String description,
042: File file, String contentType, String[] tagsEntries,
043: boolean addCommunityPermissions, boolean addGuestPermissions)
044: throws PortalException, SystemException {
045:
046: IGFolderPermission.check(getPermissionChecker(), folderId,
047: ActionKeys.ADD_IMAGE);
048:
049: return igImageLocalService.addImage(getUserId(), folderId,
050: description, file, contentType, tagsEntries,
051: addCommunityPermissions, addGuestPermissions);
052: }
053:
054: public IGImage addImage(long folderId, String description,
055: File file, String contentType, String[] tagsEntries,
056: String[] communityPermissions, String[] guestPermissions)
057: throws PortalException, SystemException {
058:
059: IGFolderPermission.check(getPermissionChecker(), folderId,
060: ActionKeys.ADD_IMAGE);
061:
062: return igImageLocalService.addImage(getUserId(), folderId,
063: description, file, contentType, tagsEntries,
064: communityPermissions, guestPermissions);
065: }
066:
067: public void deleteImage(long imageId) throws PortalException,
068: SystemException {
069:
070: IGImagePermission.check(getPermissionChecker(), imageId,
071: ActionKeys.DELETE);
072:
073: igImageLocalService.deleteImage(imageId);
074: }
075:
076: public IGImage getImage(long imageId) throws PortalException,
077: SystemException {
078:
079: IGImagePermission.check(getPermissionChecker(), imageId,
080: ActionKeys.VIEW);
081:
082: return igImageLocalService.getImage(imageId);
083: }
084:
085: public IGImage getImageByLargeImageId(long largeImageId)
086: throws PortalException, SystemException {
087:
088: IGImage image = igImageLocalService
089: .getImageByLargeImageId(largeImageId);
090:
091: IGImagePermission.check(getPermissionChecker(), image
092: .getImageId(), ActionKeys.VIEW);
093:
094: return image;
095: }
096:
097: public IGImage getImageBySmallImageId(long smallImageId)
098: throws PortalException, SystemException {
099:
100: IGImage image = igImageLocalService
101: .getImageBySmallImageId(smallImageId);
102:
103: IGImagePermission.check(getPermissionChecker(), image
104: .getImageId(), ActionKeys.VIEW);
105:
106: return image;
107: }
108:
109: public IGImage updateImage(long imageId, long folderId,
110: String description, File file, String contentType,
111: String[] tagsEntries) throws PortalException,
112: SystemException {
113:
114: IGImagePermission.check(getPermissionChecker(), imageId,
115: ActionKeys.UPDATE);
116:
117: return igImageLocalService.updateImage(getUserId(), imageId,
118: folderId, description, file, contentType, tagsEntries);
119: }
120:
121: }
|