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.portlet.softwarecatalog.model.SCProductScreenshot;
019    import com.liferay.portlet.softwarecatalog.service.base.SCProductScreenshotLocalServiceBaseImpl;
020    
021    import java.util.List;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class SCProductScreenshotLocalServiceImpl
027            extends SCProductScreenshotLocalServiceBaseImpl {
028    
029            @Override
030            public void deleteProductScreenshot(SCProductScreenshot productScreenshot)
031                    throws PortalException {
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            @Override
044            public void deleteProductScreenshots(long productEntryId)
045                    throws PortalException {
046    
047                    List<SCProductScreenshot> productScreenshots =
048                            scProductScreenshotPersistence.findByProductEntryId(productEntryId);
049    
050                    for (SCProductScreenshot productScreenshot : productScreenshots) {
051                            deleteProductScreenshot(productScreenshot);
052                    }
053            }
054    
055            @Override
056            public SCProductScreenshot getProductScreenshot(
057                            long productEntryId, int priority)
058                    throws PortalException {
059    
060                    return scProductScreenshotPersistence.findByP_P(
061                            productEntryId, priority);
062            }
063    
064            @Override
065            public SCProductScreenshot getProductScreenshotByFullImageId(
066                            long fullImageId)
067                    throws PortalException {
068    
069                    return scProductScreenshotPersistence.findByFullImageId(fullImageId);
070            }
071    
072            @Override
073            public SCProductScreenshot getProductScreenshotByThumbnailId(
074                            long thumbnailId)
075                    throws PortalException {
076    
077                    return scProductScreenshotPersistence.findByThumbnailId(thumbnailId);
078            }
079    
080            @Override
081            public List<SCProductScreenshot> getProductScreenshots(
082                    long productEntryId) {
083    
084                    return scProductScreenshotPersistence.findByProductEntryId(
085                            productEntryId);
086            }
087    
088    }