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.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            @Override
031            public void deleteProductScreenshot(SCProductScreenshot productScreenshot)
032                    throws PortalException, SystemException {
033    
034                    // Product screenshot
035    
036                    scProductScreenshotPersistence.remove(productScreenshot);
037    
038                    // Images
039    
040                    imageLocalService.deleteImage(productScreenshot.getThumbnailId());
041                    imageLocalService.deleteImage(productScreenshot.getFullImageId());
042            }
043    
044            @Override
045            public void deleteProductScreenshots(long productEntryId)
046                    throws PortalException, SystemException {
047    
048                    List<SCProductScreenshot> productScreenshots =
049                            scProductScreenshotPersistence.findByProductEntryId(productEntryId);
050    
051                    for (SCProductScreenshot productScreenshot : productScreenshots) {
052                            deleteProductScreenshot(productScreenshot);
053                    }
054            }
055    
056            @Override
057            public SCProductScreenshot getProductScreenshot(
058                            long productEntryId, int priority)
059                    throws PortalException, SystemException {
060    
061                    return scProductScreenshotPersistence.findByP_P(
062                            productEntryId, priority);
063            }
064    
065            @Override
066            public SCProductScreenshot getProductScreenshotByFullImageId(
067                            long fullImageId)
068                    throws PortalException, SystemException {
069    
070                    return scProductScreenshotPersistence.findByFullImageId(fullImageId);
071            }
072    
073            @Override
074            public SCProductScreenshot getProductScreenshotByThumbnailId(
075                            long thumbnailId)
076                    throws PortalException, SystemException {
077    
078                    return scProductScreenshotPersistence.findByThumbnailId(thumbnailId);
079            }
080    
081            @Override
082            public List<SCProductScreenshot> getProductScreenshots(long productEntryId)
083                    throws SystemException {
084    
085                    return scProductScreenshotPersistence.findByProductEntryId(
086                            productEntryId);
087            }
088    
089    }