1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
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(
36                  "Processing " + images.size() + " images with no tags assets");
37          }
38  
39          for (IGImage image : images) {
40              try {
41                  IGImageLocalServiceUtil.updateTagsAsset(
42                      image.getUserId(), image, new String[0], null);
43              }
44              catch (Exception e) {
45                  if (_log.isWarnEnabled()) {
46                      _log.warn(
47                          "Unable to update tags asset for image " +
48                              image.getImageId() + ": " + e.getMessage());
49                  }
50              }
51          }
52  
53          if (_log.isDebugEnabled()) {
54              _log.debug("Tags assets verified for images");
55          }
56      }
57  
58      private static Log _log = LogFactoryUtil.getLog(VerifyImageGallery.class);
59  
60  }