| VerifyImageGallery.java |
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.portal.verify;
16
17 import com.liferay.portal.kernel.log.Log;
18 import com.liferay.portal.kernel.log.LogFactoryUtil;
19 import com.liferay.portlet.imagegallery.model.IGImage;
20 import com.liferay.portlet.imagegallery.service.IGImageLocalServiceUtil;
21
22 import java.util.List;
23
24 /**
25 * <a href="VerifyImageGallery.java.html"><b><i>View Source</i></b></a>
26 *
27 * @author Raymond Augé
28 */
29 public class VerifyImageGallery extends VerifyProcess {
30
31 protected void doVerify() throws Exception {
32 List<IGImage> images = IGImageLocalServiceUtil.getNoAssetImages();
33
34 if (_log.isDebugEnabled()) {
35 _log.debug("Processing " + images.size() + " images with no asset");
36 }
37
38 for (IGImage image : images) {
39 try {
40 IGImageLocalServiceUtil.updateAsset(
41 image.getUserId(), image, null, null, null);
42 }
43 catch (Exception e) {
44 if (_log.isWarnEnabled()) {
45 _log.warn(
46 "Unable to update asset for image " +
47 image.getImageId() + ": " + e.getMessage());
48 }
49 }
50 }
51
52 if (_log.isDebugEnabled()) {
53 _log.debug("Assets verified for images");
54 }
55 }
56
57 private static Log _log = LogFactoryUtil.getLog(VerifyImageGallery.class);
58
59 }