1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.imagegallery.service.impl;
24  
25  import com.liferay.portal.PortalException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.kernel.security.permission.ActionKeys;
28  import com.liferay.portal.service.impl.PrincipalBean;
29  import com.liferay.portlet.imagegallery.model.IGImage;
30  import com.liferay.portlet.imagegallery.service.IGImageLocalServiceUtil;
31  import com.liferay.portlet.imagegallery.service.IGImageService;
32  import com.liferay.portlet.imagegallery.service.permission.IGFolderPermission;
33  import com.liferay.portlet.imagegallery.service.permission.IGImagePermission;
34  
35  import java.io.File;
36  
37  /**
38   * <a href="IGImageServiceImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * @author Brian Wing Shun Chan
41   *
42   */
43  public class IGImageServiceImpl
44      extends PrincipalBean implements IGImageService {
45  
46      public IGImage addImage(
47              long folderId, String description, File file, String contentType,
48              String[] tagsEntries, boolean addCommunityPermissions,
49              boolean addGuestPermissions)
50          throws PortalException, SystemException {
51  
52          IGFolderPermission.check(
53              getPermissionChecker(), folderId, ActionKeys.ADD_IMAGE);
54  
55          return IGImageLocalServiceUtil.addImage(
56              getUserId(), folderId, description, file, contentType, tagsEntries,
57              addCommunityPermissions, addGuestPermissions);
58      }
59  
60      public IGImage addImage(
61              long folderId, String description, File file, String contentType,
62              String[] tagsEntries, String[] communityPermissions,
63              String[] guestPermissions)
64          throws PortalException, SystemException {
65  
66          IGFolderPermission.check(
67              getPermissionChecker(), folderId, ActionKeys.ADD_IMAGE);
68  
69          return IGImageLocalServiceUtil.addImage(
70              getUserId(), folderId, description, file, contentType, tagsEntries,
71              communityPermissions, guestPermissions);
72      }
73  
74      public void deleteImage(long imageId)
75          throws PortalException, SystemException {
76  
77          IGImagePermission.check(
78              getPermissionChecker(), imageId, ActionKeys.DELETE);
79  
80          IGImageLocalServiceUtil.deleteImage(imageId);
81      }
82  
83      public IGImage getImage(long imageId)
84          throws PortalException, SystemException {
85  
86          IGImagePermission.check(
87              getPermissionChecker(), imageId, ActionKeys.VIEW);
88  
89          return IGImageLocalServiceUtil.getImage(imageId);
90      }
91  
92      public IGImage updateImage(
93              long imageId, long folderId, String description, File file,
94              String contentType, String[] tagsEntries)
95          throws PortalException, SystemException {
96  
97          IGImagePermission.check(
98              getPermissionChecker(), imageId, ActionKeys.UPDATE);
99  
100         return IGImageLocalServiceUtil.updateImage(
101             getUserId(), imageId, folderId, description, file, contentType,
102             tagsEntries);
103     }
104 
105 }