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.portal.verify;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portlet.blogs.model.BlogsEntry;
020    import com.liferay.portlet.blogs.service.BlogsEntryLocalServiceUtil;
021    
022    import java.util.List;
023    
024    /**
025     * @author Raymond Aug??
026     */
027    public class VerifyBlogs extends VerifyProcess {
028    
029            @Override
030            protected void doVerify() throws Exception {
031                    List<BlogsEntry> entries =
032                            BlogsEntryLocalServiceUtil.getNoAssetEntries();
033    
034                    if (_log.isDebugEnabled()) {
035                            _log.debug(
036                                    "Processing " + entries.size() + " entries with no asset");
037                    }
038    
039                    for (BlogsEntry entry : entries) {
040                            try {
041                                    BlogsEntryLocalServiceUtil.updateAsset(
042                                            entry.getUserId(), entry, null, null, null);
043                            }
044                            catch (Exception e) {
045                                    if (_log.isWarnEnabled()) {
046                                            _log.warn(
047                                                    "Unable to update asset for entry " +
048                                                            entry.getEntryId() + ": " + e.getMessage());
049                                    }
050                            }
051                    }
052    
053                    if (_log.isDebugEnabled()) {
054                            _log.debug("Assets verified for entries");
055                    }
056            }
057    
058            private static Log _log = LogFactoryUtil.getLog(VerifyBlogs.class);
059    
060    }