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.service.LayoutLocalServiceUtil;
021
022 import java.util.List;
023
024
028 public class VerifyLayout extends VerifyProcess {
029
030 @Override
031 protected void doVerify() throws Exception {
032 verifyFriendlyURL();
033 verifyUuid();
034 }
035
036 protected void verifyFriendlyURL() throws Exception {
037 List<Layout> layouts =
038 LayoutLocalServiceUtil.getNullFriendlyURLLayouts();
039
040 for (Layout layout : layouts) {
041 String friendlyURL = StringPool.SLASH + layout.getLayoutId();
042
043 LayoutLocalServiceUtil.updateFriendlyURL(
044 layout.getPlid(), friendlyURL);
045 }
046 }
047
048 protected void verifyUuid() throws Exception {
049 verifyUuid("AssetEntry");
050 verifyUuid("JournalArticle");
051
052 StringBundler sb = new StringBundler(4);
053
054 sb.append("update Layout set uuid_ = sourcePrototypeLayoutUuid where ");
055 sb.append("sourcePrototypeLayoutUuid is not null and ");
056 sb.append("sourcePrototypeLayoutUuid != '' and ");
057 sb.append("uuid_ != sourcePrototypeLayoutUuid");
058
059 runSQL(sb.toString());
060 }
061
062 protected void verifyUuid(String tableName) throws Exception {
063 StringBundler sb = new StringBundler(9);
064
065 sb.append("update ");
066 sb.append(tableName);
067 sb.append(" set layoutUuid = (select sourcePrototypeLayoutUuid from ");
068 sb.append("Layout where ");
069 sb.append(tableName);
070 sb.append(".layoutUuid = Layout.uuid_ and ");
071 sb.append("Layout.sourcePrototypeLayoutUuid is not null and ");
072 sb.append("Layout.sourcePrototypeLayoutUuid != '' and ");
073 sb.append("Layout.uuid_ != Layout.sourcePrototypeLayoutUuid)");
074
075 runSQL(sb.toString());
076 }
077
078 }