Skip to content

Commit

Permalink
LPS-90262 Add upgrade process to use the dashboard theme for personal…
Browse files Browse the repository at this point in the history
… applications for existing installations
  • Loading branch information
pei-jung authored and brianchandotcom committed Apr 12, 2019
1 parent 9e49ad4 commit 3a2d0bf
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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<String, Object> properties = new HashMapDictionary<>();

properties.put("personalApplicationsLookAndFeel", "my-dashboard");

configuration.update(properties);
}

private final ConfigurationAdmin _configurationAdmin;

}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
* <p>
* 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.
* <p>
* 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");
}

}

0 comments on commit 3a2d0bf

Please sign in to comment.