001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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.portlet.softwarecatalog.model.SCProductScreenshot;
020    import com.liferay.portlet.softwarecatalog.service.base.SCProductScreenshotLocalServiceBaseImpl;
021    
022    import java.util.List;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class SCProductScreenshotLocalServiceImpl
028            extends SCProductScreenshotLocalServiceBaseImpl {
029    
030            public void deleteProductScreenshot(SCProductScreenshot productScreenshot)
031                    throws PortalException, SystemException {
032    
033                    // Product screenshot
034    
035                    scProductScreenshotPersistence.remove(productScreenshot);
036    
037                    // Images
038    
039                    imageLocalService.deleteImage(productScreenshot.getThumbnailId());
040                    imageLocalService.deleteImage(productScreenshot.getFullImageId());
041            }
042    
043            public void deleteProductScreenshots(long productEntryId)
044                    throws PortalException, SystemException {
045    
046                    List<SCProductScreenshot> productScreenshots =
047                            scProductScreenshotPersistence.findByProductEntryId(productEntryId);
048    
049                    for (SCProductScreenshot productScreenshot : productScreenshots) {
050                            deleteProductScreenshot(productScreenshot);
051                    }
052            }
053    
054            public SCProductScreenshot getProductScreenshot(
055                            long productEntryId, int priority)
056                    throws PortalException, SystemException {
057    
058                    return scProductScreenshotPersistence.findByP_P(
059                            productEntryId, priority);
060            }
061    
062            public SCProductScreenshot getProductScreenshotByFullImageId(
063                            long fullImageId)
064                    throws PortalException, SystemException {
065    
066                    return scProductScreenshotPersistence.findByFullImageId(fullImageId);
067            }
068    
069            public SCProductScreenshot getProductScreenshotByThumbnailId(
070                            long thumbnailId)
071                    throws PortalException, SystemException {
072    
073                    return scProductScreenshotPersistence.findByThumbnailId(thumbnailId);
074            }
075    
076            public List<SCProductScreenshot> getProductScreenshots(long productEntryId)
077                    throws SystemException {
078    
079                    return scProductScreenshotPersistence.findByProductEntryId(
080                            productEntryId);
081            }
082    
083    }