001
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.portal.kernel.workflow.WorkflowConstants;
020 import com.liferay.portlet.blogs.model.BlogsEntry;
021 import com.liferay.portlet.blogs.service.BlogsEntryLocalServiceUtil;
022
023 import java.util.List;
024
025
028 public class VerifyBlogs extends VerifyProcess {
029
030 @Override
031 protected void doVerify() throws Exception {
032 updateEntryAssets();
033 verifyStatus();
034 }
035
036 protected void updateEntryAssets() throws Exception {
037 List<BlogsEntry> entries =
038 BlogsEntryLocalServiceUtil.getNoAssetEntries();
039
040 if (_log.isDebugEnabled()) {
041 _log.debug(
042 "Processing " + entries.size() + " entries with no asset");
043 }
044
045 for (BlogsEntry entry : entries) {
046 try {
047 BlogsEntryLocalServiceUtil.updateAsset(
048 entry.getUserId(), entry, null, null, null);
049 }
050 catch (Exception e) {
051 if (_log.isWarnEnabled()) {
052 _log.warn(
053 "Unable to update asset for entry " +
054 entry.getEntryId() + ": " + e.getMessage());
055 }
056 }
057 }
058
059 if (_log.isDebugEnabled()) {
060 _log.debug("Assets verified for entries");
061 }
062 }
063
064 protected void verifyStatus() throws Exception {
065 runSQL(
066 "update BlogsEntry set status = " +
067 WorkflowConstants.STATUS_APPROVED + " where status is null");
068 }
069
070 private static Log _log = LogFactoryUtil.getLog(VerifyBlogs.class);
071
072 }