1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.softwarecatalog.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portlet.softwarecatalog.model.SCProductScreenshot;
20  import com.liferay.portlet.softwarecatalog.service.base.SCProductScreenshotLocalServiceBaseImpl;
21  
22  import java.util.List;
23  
24  /**
25   * <a href="SCProductScreenshotLocalServiceImpl.java.html"><b><i>View Source</i>
26   * </b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class SCProductScreenshotLocalServiceImpl
31      extends SCProductScreenshotLocalServiceBaseImpl {
32  
33      public void deleteProductScreenshot(SCProductScreenshot productScreenshot)
34          throws PortalException, SystemException {
35  
36          // Product screenshot
37  
38          scProductScreenshotPersistence.remove(productScreenshot);
39  
40          // Images
41  
42          imageLocalService.deleteImage(productScreenshot.getThumbnailId());
43          imageLocalService.deleteImage(productScreenshot.getFullImageId());
44      }
45  
46      public void deleteProductScreenshots(long productEntryId)
47          throws PortalException, SystemException {
48  
49          List<SCProductScreenshot> productScreenshots =
50              scProductScreenshotPersistence.findByProductEntryId(productEntryId);
51  
52          for (SCProductScreenshot productScreenshot : productScreenshots) {
53              deleteProductScreenshot(productScreenshot);
54          }
55      }
56  
57      public SCProductScreenshot getProductScreenshot(
58              long productEntryId, int priority)
59          throws PortalException, SystemException {
60  
61          return scProductScreenshotPersistence.findByP_P(
62              productEntryId, priority);
63      }
64  
65      public SCProductScreenshot getProductScreenshotByFullImageId(
66              long fullImageId)
67          throws PortalException, SystemException {
68  
69          return scProductScreenshotPersistence.findByFullImageId(fullImageId);
70      }
71  
72      public SCProductScreenshot getProductScreenshotByThumbnailId(
73              long thumbnailId)
74          throws PortalException, SystemException {
75  
76          return scProductScreenshotPersistence.findByThumbnailId(thumbnailId);
77      }
78  
79      public List<SCProductScreenshot> getProductScreenshots(long productEntryId)
80          throws SystemException {
81  
82          return scProductScreenshotPersistence.findByProductEntryId(
83              productEntryId);
84      }
85  
86  }