001
014
015 package com.liferay.portal.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.lar.MissingReferences;
019 import com.liferay.portal.kernel.repository.model.Folder;
020 import com.liferay.portal.portletfilerepository.PortletFileRepositoryUtil;
021 import com.liferay.portal.security.permission.ActionKeys;
022 import com.liferay.portal.service.base.StagingServiceBaseImpl;
023 import com.liferay.portal.service.permission.GroupPermissionUtil;
024
025 import java.util.Map;
026
027
030 public class StagingServiceImpl extends StagingServiceBaseImpl {
031
032 @Override
033 public void cleanUpStagingRequest(long stagingRequestId)
034 throws PortalException {
035
036 checkPermission(stagingRequestId);
037
038 stagingLocalService.cleanUpStagingRequest(stagingRequestId);
039 }
040
041 @Override
042 public long createStagingRequest(long groupId, String checksum)
043 throws PortalException {
044
045 GroupPermissionUtil.check(
046 getPermissionChecker(), groupId, ActionKeys.EXPORT_IMPORT_LAYOUTS);
047
048 return stagingLocalService.createStagingRequest(
049 getUserId(), groupId, checksum);
050 }
051
052 @Override
053 public void publishStagingRequest(
054 long stagingRequestId, boolean privateLayout,
055 Map<String, String[]> parameterMap)
056 throws PortalException {
057
058 checkPermission(stagingRequestId);
059
060 stagingLocalService.publishStagingRequest(
061 getUserId(), stagingRequestId, privateLayout, parameterMap);
062 }
063
064 @Override
065 public void updateStagingRequest(
066 long stagingRequestId, String fileName, byte[] bytes)
067 throws PortalException {
068
069 checkPermission(stagingRequestId);
070
071 stagingLocalService.updateStagingRequest(
072 getUserId(), stagingRequestId, fileName, bytes);
073 }
074
075 @Override
076 public MissingReferences validateStagingRequest(
077 long stagingRequestId, boolean privateLayout,
078 Map<String, String[]> parameterMap)
079 throws PortalException {
080
081 checkPermission(stagingRequestId);
082
083 return stagingLocalService.validateStagingRequest(
084 getUserId(), stagingRequestId, privateLayout, parameterMap);
085 }
086
087 protected void checkPermission(long stagingRequestId)
088 throws PortalException {
089
090 Folder folder = PortletFileRepositoryUtil.getPortletFolder(
091 stagingRequestId);
092
093 GroupPermissionUtil.check(
094 getPermissionChecker(), folder.getGroupId(),
095 ActionKeys.EXPORT_IMPORT_LAYOUTS);
096 }
097
098 }