001
014
015 package com.liferay.portal.verify;
016
017 import com.liferay.portal.kernel.util.StringBundler;
018 import com.liferay.portal.kernel.util.StringPool;
019 import com.liferay.portal.model.Layout;
020 import com.liferay.portal.model.LayoutFriendlyURL;
021 import com.liferay.portal.service.LayoutFriendlyURLLocalServiceUtil;
022 import com.liferay.portal.service.LayoutLocalServiceUtil;
023
024 import java.util.List;
025
026
030 public class VerifyLayout extends VerifyProcess {
031
032 @Override
033 protected void doVerify() throws Exception {
034 verifyFriendlyURL();
035 verifyUuid();
036 }
037
038 protected void verifyFriendlyURL() throws Exception {
039 List<Layout> layouts =
040 LayoutLocalServiceUtil.getNullFriendlyURLLayouts();
041
042 for (Layout layout : layouts) {
043 List<LayoutFriendlyURL> layoutFriendlyURLs =
044 LayoutFriendlyURLLocalServiceUtil.getLayoutFriendlyURLs(
045 layout.getPlid());
046
047 for (LayoutFriendlyURL layoutFriendlyURL : layoutFriendlyURLs) {
048 String friendlyURL = StringPool.SLASH + layout.getLayoutId();
049
050 LayoutLocalServiceUtil.updateFriendlyURL(
051 layout.getPlid(), friendlyURL,
052 layoutFriendlyURL.getLanguageId());
053 }
054 }
055 }
056
057 protected void verifyUuid() throws Exception {
058 verifyUuid("AssetEntry");
059 verifyUuid("JournalArticle");
060
061 StringBundler sb = new StringBundler(3);
062
063 sb.append("update Layout set uuid_ = sourcePrototypeLayoutUuid where ");
064 sb.append("sourcePrototypeLayoutUuid != '' and ");
065 sb.append("uuid_ != sourcePrototypeLayoutUuid");
066
067 runSQL(sb.toString());
068 }
069
070 protected void verifyUuid(String tableName) throws Exception {
071 StringBundler sb = new StringBundler(12);
072
073 sb.append("update ");
074 sb.append(tableName);
075 sb.append(" set layoutUuid = (select distinct ");
076 sb.append("sourcePrototypeLayoutUuid from Layout where ");
077 sb.append("Layout.uuid_ = ");
078 sb.append(tableName);
079 sb.append(".layoutUuid) where exists (select 1 from Layout where ");
080 sb.append("Layout.uuid_ = ");
081 sb.append(tableName);
082 sb.append(".layoutUuid and Layout.uuid_ != ");
083 sb.append("Layout.sourcePrototypeLayoutUuid and ");
084 sb.append("Layout.sourcePrototypeLayoutUuid != '')");
085
086 runSQL(sb.toString());
087 }
088
089 }