001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.softwarecatalog.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.permission.ActionKeys;
020    import com.liferay.portal.service.ServiceContext;
021    import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
022    import com.liferay.portlet.softwarecatalog.service.base.SCProductEntryServiceBaseImpl;
023    import com.liferay.portlet.softwarecatalog.service.permission.SCPermission;
024    import com.liferay.portlet.softwarecatalog.service.permission.SCProductEntryPermission;
025    
026    import java.util.List;
027    
028    /**
029     * @author Jorge Ferrer
030     * @author Brian Wing Shun Chan
031     */
032    public class SCProductEntryServiceImpl extends SCProductEntryServiceBaseImpl {
033    
034            @Override
035            public SCProductEntry addProductEntry(
036                            String name, String type, String tags, String shortDescription,
037                            String longDescription, String pageURL, String author,
038                            String repoGroupId, String repoArtifactId, long[] licenseIds,
039                            List<byte[]> thumbnails, List<byte[]> fullImages,
040                            ServiceContext serviceContext)
041                    throws PortalException, SystemException {
042    
043                    SCPermission.check(
044                            getPermissionChecker(), serviceContext.getScopeGroupId(),
045                            ActionKeys.ADD_PRODUCT_ENTRY);
046    
047                    return scProductEntryLocalService.addProductEntry(
048                            getUserId(), name, type, tags, shortDescription, longDescription,
049                            pageURL, author, repoGroupId, repoArtifactId, licenseIds,
050                            thumbnails, fullImages, serviceContext);
051            }
052    
053            @Override
054            public void deleteProductEntry(long productEntryId)
055                    throws PortalException, SystemException {
056    
057                    SCProductEntryPermission.check(
058                            getPermissionChecker(), productEntryId, ActionKeys.DELETE);
059    
060                    scProductEntryLocalService.deleteProductEntry(productEntryId);
061            }
062    
063            @Override
064            public SCProductEntry getProductEntry(long productEntryId)
065                    throws PortalException, SystemException {
066    
067                    SCProductEntryPermission.check(
068                            getPermissionChecker(), productEntryId, ActionKeys.VIEW);
069    
070                    return scProductEntryLocalService.getProductEntry(productEntryId);
071            }
072    
073            @Override
074            public SCProductEntry updateProductEntry(
075                            long productEntryId, String name, String type, String tags,
076                            String shortDescription, String longDescription, String pageURL,
077                            String author, String repoGroupId, String repoArtifactId,
078                            long[] licenseIds, List<byte[]> thumbnails, List<byte[]> fullImages)
079                    throws PortalException, SystemException {
080    
081                    SCProductEntryPermission.check(
082                            getPermissionChecker(), productEntryId, ActionKeys.UPDATE);
083    
084                    return scProductEntryLocalService.updateProductEntry(
085                            productEntryId, name, type, tags, shortDescription, longDescription,
086                            pageURL, author, repoGroupId, repoArtifactId, licenseIds,
087                            thumbnails, fullImages);
088            }
089    
090    }