Skip to content

Commit

Permalink
LPS-62861 auto SF
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchandotcom committed Apr 14, 2016
1 parent 74460dd commit d37df1e
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions portal-impl/src/com/liferay/portal/upgrade/v6_0_0/UpgradeGroup.java
Expand Up @@ -30,44 +30,6 @@
*/
public class UpgradeGroup extends UpgradeProcess {

protected void updateGlobalFriendlyURL(long companyId) throws Exception {
long groupId = getGroupId(
companyId, GroupConstants.GLOBAL_FRIENDLY_URL);

if (groupId == 0) {
return;
}

String friendlyURL = getNewFriendlyURL(companyId, groupId);

if (_log.isInfoEnabled()) {
_log.info(
"Updating friendly URL " + GroupConstants.GLOBAL_FRIENDLY_URL +
" of global group " + groupId + " to " + friendlyURL);
}

try (PreparedStatement ps = connection.prepareStatement(
"update Group_ set friendlyURL = ? where groupId = ?")) {

ps.setString(1, friendlyURL);
ps.setLong(2, groupId);

ps.execute();
}
}

protected void updateGlobalFriendlyURLs() throws Exception {
try (Statement s = connection.createStatement()) {
String query = "select companyId from Company";

try (ResultSet rs = s.executeQuery(query)) {
while (rs.next()) {
updateGlobalFriendlyURL(rs.getLong(1));
}
}
}
}

@Override
protected void doUpgrade() throws Exception {
updateGlobalFriendlyURLs();
Expand Down Expand Up @@ -128,6 +90,44 @@ protected String getNewFriendlyURL(long companyId, long groupId)
return friendlyURL;
}

protected void updateGlobalFriendlyURL(long companyId) throws Exception {
long groupId = getGroupId(
companyId, GroupConstants.GLOBAL_FRIENDLY_URL);

if (groupId == 0) {
return;
}

String friendlyURL = getNewFriendlyURL(companyId, groupId);

if (_log.isInfoEnabled()) {
_log.info(
"Updating friendly URL " + GroupConstants.GLOBAL_FRIENDLY_URL +
" of global group " + groupId + " to " + friendlyURL);
}

try (PreparedStatement ps = connection.prepareStatement(
"update Group_ set friendlyURL = ? where groupId = ?")) {

ps.setString(1, friendlyURL);
ps.setLong(2, groupId);

ps.execute();
}
}

protected void updateGlobalFriendlyURLs() throws Exception {
try (Statement s = connection.createStatement()) {
String query = "select companyId from Company";

try (ResultSet rs = s.executeQuery(query)) {
while (rs.next()) {
updateGlobalFriendlyURL(rs.getLong(1));
}
}
}
}

protected void updateParentGroupId() throws Exception {
try (LoggingTimer loggingTimer = new LoggingTimer()) {
long classNameId = PortalUtil.getClassNameId(
Expand Down

0 comments on commit d37df1e

Please sign in to comment.