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(3);
053
054 sb.append("update Layout set uuid_ = sourcePrototypeLayoutUuid where ");
055 sb.append("sourcePrototypeLayoutUuid != '' and ");
056 sb.append("uuid_ != sourcePrototypeLayoutUuid");
057
058 runSQL(sb.toString());
059 }
060
061 protected void verifyUuid(String tableName) throws Exception {
062 StringBundler sb = new StringBundler(8);
063
064 sb.append("update ");
065 sb.append(tableName);
066 sb.append(" set layoutUuid = (select sourcePrototypeLayoutUuid from ");
067 sb.append("Layout where ");
068 sb.append(tableName);
069 sb.append(".layoutUuid = Layout.uuid_ and ");
070 sb.append("Layout.sourcePrototypeLayoutUuid != '' and ");
071 sb.append("Layout.uuid_ != Layout.sourcePrototypeLayoutUuid)");
072
073 runSQL(sb.toString());
074 }
075
076 }