Source:
private void updateBasicApplicationData(ServiceProvider serviceProvider, Connection connection) throws SQLException, UserStoreException, IdentityApplicationManagementException { int applicationId = serviceProvider.getApplicationID(); String applicationName = serviceProvider.getApplicationName(); String description = serviceProvider.getDescription(); boolean isSaasApp = serviceProvider.isSaasApp(); int tenantID = CarbonContext.getThreadLocalCarbonContext().getTenantId(); String storedAppName = null; if (applicationName == null) { throw new IdentityApplicationManagementException("Application Name is required."); } if (log.isDebugEnabled()) { log.debug("Updating Application with ID: " + applicationId); } storedAppName = getApplicationName(applicationId, connection); if (log.isDebugEnabled()) { log.debug("Stored Application Name " + storedAppName); } if (!StringUtils.equals(applicationName, storedAppName)) { String applicationNameforRole = ApplicationConstants.APPLICATION_DOMAIN + UserCoreConstants.DOMAIN_SEPARATOR + applicationName; String storedAppNameforRole = ApplicationConstants.APPLICATION_DOMAIN + UserCoreConstants.DOMAIN_SEPARATOR + storedAppName; ApplicationMgtUtil.renameRole(storedAppNameforRole, applicationNameforRole); if (log.isDebugEnabled()) { log.debug("Renaming application role from " + storedAppName + " to " + applicationName); } Map<String, String> applicationPermissions = readApplicationPermissions(connection, storedAppName); for (Map.Entry<String, String> entry : applicationPermissions.entrySet()) { updatePermissionPath(connection, entry.getKey(), entry.getValue().replace(storedAppName.toLowerCase(), applicationName.toLowerCase())); } } PreparedStatement storeAppPrepStmt = null; try { storeAppPrepStmt = connection .prepareStatement(ApplicationMgtDBQueries.UPDATE_BASIC_APPINFO); storeAppPrepStmt.setString(1, applicationName); storeAppPrepStmt.setString(2, description); storeAppPrepStmt.setString(3, isSaasApp ? "1" : "0"); storeAppPrepStmt.setInt(4, tenantID); storeAppPrepStmt.setInt(5, applicationId); storeAppPrepStmt.executeUpdate(); } finally { IdentityApplicationManagementUtil.closeStatement(storeAppPrepStmt); } if (log.isDebugEnabled()) { log.debug("Updated Application successfully"); } }

Target:
private void updateBasicApplicationData(ServiceProvider serviceProvider, Connection connection) throws SQLException, UserStoreException, IdentityApplicationManagementException { int applicationId = serviceProvider.getApplicationID(); String applicationName = serviceProvider.getApplicationName(); String description = serviceProvider.getDescription(); boolean isSaasApp = serviceProvider.isSaasApp(); int tenantID = CarbonContext.getThreadLocalCarbonContext().getTenantId(); String storedAppName = null; if (applicationName == null) { throw new IdentityApplicationManagementException("Application Name is required."); } if (log.isDebugEnabled()) { log.debug("Updating Application with ID: " + applicationId); } storedAppName = getApplicationName(applicationId, connection); if (log.isDebugEnabled()) { log.debug("Stored Application Name " + storedAppName); } if (!StringUtils.equals(applicationName, storedAppName)) { String applicationNameforRole = IdentityUtil.addDomainToName(applicationName, ApplicationConstants. APPLICATION_DOMAIN); String storedAppNameforRole = IdentityUtil.addDomainToName(storedAppName, ApplicationConstants. APPLICATION_DOMAIN); ApplicationMgtUtil.renameRole(storedAppNameforRole, applicationNameforRole); if (log.isDebugEnabled()) { log.debug("Renaming application role from " + storedAppName + " to " + applicationName); } Map<String, String> applicationPermissions = readApplicationPermissions(connection, storedAppName); for (Map.Entry<String, String> entry : applicationPermissions.entrySet()) { updatePermissionPath(connection, entry.getKey(), entry.getValue().replace(storedAppName.toLowerCase(), applicationName.toLowerCase())); } } PreparedStatement storeAppPrepStmt = null; try { storeAppPrepStmt = connection .prepareStatement(ApplicationMgtDBQueries.UPDATE_BASIC_APPINFO); storeAppPrepStmt.setString(1, applicationName); storeAppPrepStmt.setString(2, description); storeAppPrepStmt.setString(3, isSaasApp ? "1" : "0"); storeAppPrepStmt.setInt(4, tenantID); storeAppPrepStmt.setInt(5, applicationId); storeAppPrepStmt.executeUpdate(); } finally { IdentityApplicationManagementUtil.closeStatement(storeAppPrepStmt); } if (log.isDebugEnabled()) { log.debug("Updated Application successfully"); } }