001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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.wiki.model.WikiPage;
020    import com.liferay.portlet.wiki.service.WikiPageLocalServiceUtil;
021    
022    import java.util.List;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class VerifyWiki extends VerifyProcess {
028    
029            protected void doVerify() throws Exception {
030                    List<WikiPage> pages = WikiPageLocalServiceUtil.getNoAssetPages();
031    
032                    if (_log.isDebugEnabled()) {
033                            _log.debug("Processing " + pages.size() + " pages with no asset");
034                    }
035    
036                    for (WikiPage page : pages) {
037                            try {
038                                    WikiPageLocalServiceUtil.updateAsset(
039                                            page.getUserId(), page, null, null);
040                            }
041                            catch (Exception e) {
042                                    if (_log.isWarnEnabled()) {
043                                            _log.warn(
044                                                    "Unable to update asset for page " + page.getPageId() +
045                                                            ": " + e.getMessage());
046                                    }
047                            }
048                    }
049    
050                    if (_log.isDebugEnabled()) {
051                            _log.debug("Assets verified for pages");
052                    }
053            }
054    
055            private static Log _log = LogFactoryUtil.getLog(VerifyWiki.class);
056    
057    }