Get the server redirects belonging to a server group

@param profileId ID of profile
@param serverGroupId ID of server group
@return Collection of ServerRedirect for a server group
966438
public List<ServerRedirect> tableServers(int profileId, int serverGroupId) {
        ArrayList<ServerRedirect> servers = new ArrayList<>();
        PreparedStatement queryStatement = null;
        ResultSet results = null;

        try (Connection sqlConnection = sqlService.getConnection()) {
            queryStatement = sqlConnection.prepareStatement(
                "SELECT * FROM " + Constants.DB_TABLE_SERVERS +
                    " WHERE " + Constants.GENERIC_PROFILE_ID + " = ?" +
                    " AND " + Constants.SERVER_REDIRECT_GROUP_ID + " = ?"
            );
            queryStatement.setInt(1, profileId);
            queryStatement.setInt(2, serverGroupId);
            results = queryStatement.executeQuery();
            while (results.next()) {
                ServerRedirect curServer = new ServerRedirect(results.getInt(Constants.GENERIC_ID),
                                                              results.getString(Constants.SERVER_REDIRECT_REGION),
                                                              results.getString(Constants.SERVER_REDIRECT_SRC_URL),
                                                              results.getString(Constants.SERVER_REDIRECT_DEST_URL),
                                                              results.getString(Constants.SERVER_REDIRECT_HOST_HEADER));
                curServer.setProfileId(profileId);
                servers.add(curServer);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (queryStatement != null) {
                    queryStatement.close();
                }
            } catch (Exception e) {
            }
        }
        return servers;
    }
380276
public Map<Group, List<ServerMonitoringStatistics>> getMonitoringStatsAsMap(List<Group> groups, ServerMonitoringFilter config) {
        Map<Group, List<ServerMonitoringStatistics>> result = new HashMap<>(groups.size());
        groups.stream()
            .forEach(group -> result.put(group, getMonitoringStats(group, config)));

        return result;
    }
267408
public List<Layer<?>> getLayersByServerId(String serverLayerId) {
		List<Layer<?>> l = new ArrayList<Layer<?>>();
		if (layers != null) {
			for (Layer<?> layer : layers) {
				if (layer.getServerLayerId().equals(serverLayerId)) {
					l.add(layer);
				}
			}
		}
		return l;
	}
1338723
public List<ServerGroup> tableServerGroups(int profileId) {
        ArrayList<ServerGroup> serverGroups = new ArrayList<>();
        PreparedStatement queryStatement = null;
        ResultSet results = null;

        try (Connection sqlConnection = sqlService.getConnection()) {
            queryStatement = sqlConnection.prepareStatement(
                "SELECT * FROM " + Constants.DB_TABLE_SERVER_GROUPS +
                    " WHERE " + Constants.GENERIC_PROFILE_ID + " = ? " +
                    "ORDER BY " + Constants.GENERIC_NAME
            );
            queryStatement.setInt(1, profileId);
            results = queryStatement.executeQuery();
            while (results.next()) {
                ServerGroup curServerGroup = new ServerGroup(results.getInt(Constants.GENERIC_ID),
                                                             results.getString(Constants.GENERIC_NAME),
                                                             results.getInt(Constants.GENERIC_PROFILE_ID));
                curServerGroup.setServers(tableServers(profileId, curServerGroup.getId()));
                serverGroups.add(curServerGroup);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (queryStatement != null) {
                    queryStatement.close();
                }
            } catch (Exception e) {
            }
        }
        return serverGroups;
    }
570355
public AccountHeaderBuilder withProfiles(@NonNull List<IProfile> profiles) {
        if (mDrawer != null) {
            mDrawer.mDrawerBuilder.idDistributor.checkIds(profiles);
        }
        this.mProfiles = profiles;
        return this;
    }
581054
@RequestMapping(value = "api/servergroup/{id}", method = RequestMethod.POST)
    public
    @ResponseBody
    ServerGroup updateServerGroup(Model model,
                                  @PathVariable int id,
                                  @RequestParam(required = false) Integer profileId,
                                  @RequestParam(required = false) String name,
                                  @RequestParam(required = false) Boolean activate,
                                  @RequestParam(required = false) String clientUUID,
                                  @RequestParam(value = "profileIdentifier", required = false) String profileIdentifier) throws Exception {
        if (profileId == null && profileIdentifier == null) {
            throw new Exception("profileId required");
        }
        if (profileId == null) {
            profileId = ProfileService.getInstance().getIdFromName(profileIdentifier);
        }
        if (name != null) {
            ServerRedirectService.getInstance().setGroupName(name, id);
        }

        if (activate != null) {
            if (clientUUID == null) {
                throw new Exception("clientUUID required");
            }

            int clientId = ClientService.getInstance().findClient(clientUUID, profileId).getId();

            if (activate) {
                ServerRedirectService.getInstance().activateServerGroup(id, clientId);
            } else {
                ServerRedirectService.getInstance().activateServerGroup(0, clientId);
            }
        }

        return ServerRedirectService.getInstance().getServerGroup(id, profileId);
    }
1214697
public void removeGroupFromPathProfile(int group_id, int pathId, int profileId) {
        int[] groupIds = Utils.arrayFromStringOfIntegers(getGroupIdsInPathProfile(profileId,
                                                                                  pathId));
        String newGroupIds = "";
        for (int i = 0; i < groupIds.length; i++) {
            if (groupIds[i] != group_id) {
                newGroupIds += (groupIds[i] + ",");
            }
        }
        EditService.updatePathTable(Constants.PATH_PROFILE_GROUP_IDS, newGroupIds, pathId);
    }
389181
@RequestMapping(value = "/{userId}/userGroups", method = RequestMethod.GET)
    public ResponseEntity<Set<UserGroup>> findGroupsOfUser(@PathVariable Integer userId) {

        try {
            Set<UserGroup> userGroupsSet = this.service.getGroupsOfUser(userId);
            return new ResponseEntity<Set<UserGroup>>(userGroupsSet, HttpStatus.OK);
        } catch (Exception e) {
            LOG.error("Error finding user with id " + userId + ": "
                + e.getMessage());
            return new ResponseEntity<Set<UserGroup>>(HttpStatus.NOT_FOUND);
        }
    }
707659
protected Authenticated getAuthObjFromServerId(final Settings settings, final String serverId) {
        if (StringUtils.isEmpty(serverId)) {
            getLog().debug(SERVER_ID_NOT_CONFIG);
            return null;
        }

        final Server server = Utils.getServer(settings, serverId);
        try {
            assureServerExist(server, serverId);
        } catch (MojoExecutionException ex) {
            getLog().error(ex.getMessage());
            return null;
        }

        final ApplicationTokenCredentials credential = getAppTokenCredentialsFromServer(server);
        if (credential == null) {
            getLog().error(AZURE_AUTH_INVALID + serverId);
            return null;
        }

        final Authenticated auth = azureConfigure().authenticate(credential);
        if (auth != null) {
            getLog().info(AUTH_WITH_SERVER_ID + serverId);
        }
        return auth;
    }
1156175
public Server getServerByUri(final String uri) {
        for (Server server : SERVERS) {
            if (server.getManagementUri().equals(uri)) {
                return server;
            }
        }

        return null;
    }
466703
public Query queryUsersForGroup(String groupId) {
        Query q = queryEntitiesRequest(HttpMethod.GET, null, null, organizationId,
                applicationId, "groups", groupId, "users");
        return q;
    }
246422
@SuppressWarnings("unchecked")
    private String[] getGroupIds(WSCredential cred) {
        Collection<String> ids = null;
        if (cred != null) {
            try {
                ids = cred.getGroupIds();
            } catch (CredentialExpiredException e) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Caught exception getting the group access ids: " + e);
                }
            } catch (CredentialDestroyedException e) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Caught exception getting the group access ids: " + e);
                }
            }
            if (ids != null) {
                return ids.toArray(new String[ids.size()]);
            }
        }
        return null;
        // TODO if ignoreCase is Collection, then lower case the groupids
    }
691559
public ServerRedirect enableServerMapping(int serverMappingId, Boolean enabled) {
        ServerRedirect redirect = new ServerRedirect();
        BasicNameValuePair[] params = {
            new BasicNameValuePair("enabled", enabled.toString()),
            new BasicNameValuePair("profileIdentifier", this._profileName)
        };
        try {
            JSONObject response = new JSONObject(doPost(BASE_SERVER + "/" + serverMappingId, params));
            redirect = getServerRedirectFromJSON(response);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        return redirect;
    }
1250480
public void deleteServerGroup(int id) {
        try {
            sqlService.executeUpdate("DELETE FROM " + Constants.DB_TABLE_SERVER_GROUPS +
                                         " WHERE " + Constants.GENERIC_ID + " = " + id + ";");

            sqlService.executeUpdate("DELETE FROM " + Constants.DB_TABLE_SERVERS +
                                         " WHERE " + Constants.SERVER_REDIRECT_GROUP_ID + " = " + id);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
771769
public Server getServerById(final String id) {
        for (Server server : SERVERS) {
            if (server.getId().equals(id)) {
                return server;
            }
        }

        return null;
    }
925816
protected function _getRedirectUrl(ServerRequest $request)
    {
        $redirectUrl = $request->getSession()->read('SocialAuth.redirectUrl');
        if ($redirectUrl) {
            $request->getSession()->delete('SocialAuth.redirectUrl');

            return $redirectUrl;
        }

        return $this->getConfig('loginRedirect');
    }
1292688
public static SimpleDeploymentDescription of(final String name, @SuppressWarnings("TypeMayBeWeakened") final Set<String> serverGroups) {
        final SimpleDeploymentDescription result = of(name);
        if (serverGroups != null) {
            result.addServerGroups(serverGroups);
        }
        return result;
    }