001    /**
002     * Copyright (c) 2000-2010 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            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, SystemException {
041    
042                    SCPermission.check(
043                            getPermissionChecker(), serviceContext.getScopeGroupId(),
044                            ActionKeys.ADD_PRODUCT_ENTRY);
045    
046                    return scProductEntryLocalService.addProductEntry(
047                            getUserId(), name, type, tags, shortDescription,
048                            longDescription, pageURL, author, repoGroupId, repoArtifactId,
049                            licenseIds, thumbnails, fullImages, serviceContext);
050            }
051    
052            public void deleteProductEntry(long productEntryId)
053                    throws PortalException, SystemException {
054    
055                    SCProductEntryPermission.check(
056                            getPermissionChecker(), productEntryId, ActionKeys.DELETE);
057    
058                    scProductEntryLocalService.deleteProductEntry(productEntryId);
059            }
060    
061            public SCProductEntry getProductEntry(long productEntryId)
062                    throws PortalException, SystemException {
063    
064                    SCProductEntryPermission.check(
065                            getPermissionChecker(), productEntryId, ActionKeys.VIEW);
066    
067                    return scProductEntryLocalService.getProductEntry(productEntryId);
068            }
069    
070            public SCProductEntry updateProductEntry(
071                            long productEntryId, String name, String type, String tags,
072                            String shortDescription, String longDescription, String pageURL,
073                            String author, String repoGroupId, String repoArtifactId,
074                            long[] licenseIds, List<byte[]> thumbnails, List<byte[]> fullImages)
075                    throws PortalException, SystemException {
076    
077                    SCProductEntryPermission.check(
078                            getPermissionChecker(), productEntryId, ActionKeys.UPDATE);
079    
080                    return scProductEntryLocalService.updateProductEntry(
081                            productEntryId, name, type, tags, shortDescription, longDescription,
082                            pageURL, author, repoGroupId, repoArtifactId, licenseIds,
083                            thumbnails, fullImages);
084            }
085    
086    }