001    /**
002     * Copyright (c) 2000-present 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.security.permission.ActionKeys;
019    import com.liferay.portal.service.ServiceContext;
020    import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
021    import com.liferay.portlet.softwarecatalog.service.base.SCProductEntryServiceBaseImpl;
022    import com.liferay.portlet.softwarecatalog.service.permission.SCPermission;
023    import com.liferay.portlet.softwarecatalog.service.permission.SCProductEntryPermission;
024    
025    import java.util.List;
026    
027    /**
028     * @author Jorge Ferrer
029     * @author Brian Wing Shun Chan
030     */
031    public class SCProductEntryServiceImpl extends SCProductEntryServiceBaseImpl {
032    
033            @Override
034            public SCProductEntry addProductEntry(
035                            String name, String type, String tags, String shortDescription,
036                            String longDescription, String pageURL, String author,
037                            String repoGroupId, String repoArtifactId, long[] licenseIds,
038                            List<byte[]> thumbnails, List<byte[]> fullImages,
039                            ServiceContext serviceContext)
040                    throws PortalException {
041    
042                    SCPermission.check(
043                            getPermissionChecker(), serviceContext.getScopeGroupId(),
044                            ActionKeys.ADD_PRODUCT_ENTRY);
045    
046                    return scProductEntryLocalService.addProductEntry(
047                            getUserId(), name, type, tags, shortDescription, longDescription,
048                            pageURL, author, repoGroupId, repoArtifactId, licenseIds,
049                            thumbnails, fullImages, serviceContext);
050            }
051    
052            @Override
053            public void deleteProductEntry(long productEntryId) throws PortalException {
054                    SCProductEntryPermission.check(
055                            getPermissionChecker(), productEntryId, ActionKeys.DELETE);
056    
057                    scProductEntryLocalService.deleteProductEntry(productEntryId);
058            }
059    
060            @Override
061            public SCProductEntry getProductEntry(long productEntryId)
062                    throws PortalException {
063    
064                    SCProductEntryPermission.check(
065                            getPermissionChecker(), productEntryId, ActionKeys.VIEW);
066    
067                    return scProductEntryLocalService.getProductEntry(productEntryId);
068            }
069    
070            @Override
071            public SCProductEntry updateProductEntry(
072                            long productEntryId, String name, String type, String tags,
073                            String shortDescription, String longDescription, String pageURL,
074                            String author, String repoGroupId, String repoArtifactId,
075                            long[] licenseIds, List<byte[]> thumbnails, List<byte[]> fullImages)
076                    throws PortalException {
077    
078                    SCProductEntryPermission.check(
079                            getPermissionChecker(), productEntryId, ActionKeys.UPDATE);
080    
081                    return scProductEntryLocalService.updateProductEntry(
082                            productEntryId, name, type, tags, shortDescription, longDescription,
083                            pageURL, author, repoGroupId, repoArtifactId, licenseIds,
084                            thumbnails, fullImages);
085            }
086    
087    }