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