diff --git a/modules/apps/product-navigation/product-navigation-personal-menu-web/build.gradle b/modules/apps/product-navigation/product-navigation-personal-menu-web/build.gradle index 3f4ac1a9092528..0f850c33ba54ae 100644 --- a/modules/apps/product-navigation/product-navigation-personal-menu-web/build.gradle +++ b/modules/apps/product-navigation/product-navigation-personal-menu-web/build.gradle @@ -9,6 +9,7 @@ dependencies { compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0" compileOnly project(":apps:configuration-admin:configuration-admin-api") compileOnly project(":apps:dynamic-data-mapping:dynamic-data-mapping-api") + compileOnly project(":apps:portal:portal-upgrade-api") compileOnly project(":apps:product-navigation:product-navigation-control-menu-api") compileOnly project(":apps:product-navigation:product-navigation-personal-menu-api") compileOnly project(":apps:product-navigation:product-navigation-taglib") diff --git a/modules/apps/product-navigation/product-navigation-personal-menu-web/src/main/java/com/liferay/product/navigation/personal/menu/web/internal/upgrade/ProductNavigationPersonalMenuWebUpgrade.java b/modules/apps/product-navigation/product-navigation-personal-menu-web/src/main/java/com/liferay/product/navigation/personal/menu/web/internal/upgrade/ProductNavigationPersonalMenuWebUpgrade.java new file mode 100644 index 00000000000000..0cd57f9a7d4db2 --- /dev/null +++ b/modules/apps/product-navigation/product-navigation-personal-menu-web/src/main/java/com/liferay/product/navigation/personal/menu/web/internal/upgrade/ProductNavigationPersonalMenuWebUpgrade.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2000-present Liferay, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + */ + +package com.liferay.product.navigation.personal.menu.web.internal.upgrade; + +import com.liferay.portal.kernel.upgrade.DummyUpgradeStep; +import com.liferay.portal.upgrade.registry.UpgradeStepRegistrator; +import com.liferay.product.navigation.personal.menu.web.internal.upgrade.v1_0_0.UpgradePersonalMenuConfiguration; + +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; + +/** + * @author Pei-Jung Lan + */ +@Component(immediate = true, service = UpgradeStepRegistrator.class) +public class ProductNavigationPersonalMenuWebUpgrade + implements UpgradeStepRegistrator { + + @Override + public void register(Registry registry) { + registry.register("0.0.0", "1.0.0", new DummyUpgradeStep()); + + registry.register( + "0.0.1", "1.0.0", + new UpgradePersonalMenuConfiguration(_configurationAdmin)); + } + + @Reference + private ConfigurationAdmin _configurationAdmin; + +} \ No newline at end of file diff --git a/modules/apps/product-navigation/product-navigation-personal-menu-web/src/main/java/com/liferay/product/navigation/personal/menu/web/internal/upgrade/v1_0_0/UpgradePersonalMenuConfiguration.java b/modules/apps/product-navigation/product-navigation-personal-menu-web/src/main/java/com/liferay/product/navigation/personal/menu/web/internal/upgrade/v1_0_0/UpgradePersonalMenuConfiguration.java new file mode 100644 index 00000000000000..acc0cc571155b9 --- /dev/null +++ b/modules/apps/product-navigation/product-navigation-personal-menu-web/src/main/java/com/liferay/product/navigation/personal/menu/web/internal/upgrade/v1_0_0/UpgradePersonalMenuConfiguration.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2000-present Liferay, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + */ + +package com.liferay.product.navigation.personal.menu.web.internal.upgrade.v1_0_0; + +import com.liferay.petra.string.StringBundler; +import com.liferay.petra.string.StringPool; +import com.liferay.portal.kernel.upgrade.UpgradeProcess; +import com.liferay.portal.kernel.util.HashMapDictionary; +import com.liferay.product.navigation.personal.menu.configuration.PersonalMenuConfiguration; + +import java.util.Dictionary; + +import org.osgi.framework.Constants; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; + +/** + * @author Pei-Jung Lan + */ +public class UpgradePersonalMenuConfiguration extends UpgradeProcess { + + public UpgradePersonalMenuConfiguration( + ConfigurationAdmin configurationAdmin) { + + _configurationAdmin = configurationAdmin; + } + + @Override + protected void doUpgrade() throws Exception { + String filterString = StringBundler.concat( + "(", Constants.SERVICE_PID, "=", + PersonalMenuConfiguration.class.getName(), ")"); + + Configuration[] configurations = _configurationAdmin.listConfigurations( + filterString); + + if (configurations != null) { + return; + } + + Configuration configuration = _configurationAdmin.getConfiguration( + PersonalMenuConfiguration.class.getName(), StringPool.QUESTION); + + Dictionary properties = new HashMapDictionary<>(); + + properties.put("personalApplicationsLookAndFeel", "my-dashboard"); + + configuration.update(properties); + } + + private final ConfigurationAdmin _configurationAdmin; + +} \ No newline at end of file diff --git a/portal-impl/src/com/liferay/portal/upgrade/v7_2_x/PortalUpgradeProcessRegistryImpl.java b/portal-impl/src/com/liferay/portal/upgrade/v7_2_x/PortalUpgradeProcessRegistryImpl.java index 5206fbed676a95..7ec87bb6ad5ec0 100644 --- a/portal-impl/src/com/liferay/portal/upgrade/v7_2_x/PortalUpgradeProcessRegistryImpl.java +++ b/portal-impl/src/com/liferay/portal/upgrade/v7_2_x/PortalUpgradeProcessRegistryImpl.java @@ -37,6 +37,8 @@ public void registerUpgradeProcesses( upgradeProcesses.put(new Version("4.0.0"), new UpgradeSchema()); upgradeProcesses.put(new Version("5.0.0"), new UpgradeBadColumnNames()); + + upgradeProcesses.put(new Version("5.0.1"), new UpgradePersonalMenu()); } } \ No newline at end of file diff --git a/portal-impl/src/com/liferay/portal/upgrade/v7_2_x/UpgradePersonalMenu.java b/portal-impl/src/com/liferay/portal/upgrade/v7_2_x/UpgradePersonalMenu.java new file mode 100644 index 00000000000000..d4ca4078200e9a --- /dev/null +++ b/portal-impl/src/com/liferay/portal/upgrade/v7_2_x/UpgradePersonalMenu.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2000-present Liferay, Inc. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + *

+ * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + */ + +package com.liferay.portal.upgrade.v7_2_x; + +import com.liferay.portal.kernel.model.dao.ReleaseDAO; +import com.liferay.portal.kernel.upgrade.UpgradeProcess; + +/** + * @author Pei-Jung Lan + */ +public class UpgradePersonalMenu extends UpgradeProcess { + + @Override + protected void doUpgrade() throws Exception { + ReleaseDAO releaseDAO = new ReleaseDAO(); + + releaseDAO.addRelease( + connection, "com.liferay.product.navigation.personal.menu.web"); + } + +} \ No newline at end of file