makes the current client under the profile active

@param model
@param profileId
@param clientUUID
@return
@throws Exception
5872
@RequestMapping(value = "api/edit/activate", method = RequestMethod.POST)
    public
    @ResponseBody
    String activateProfile(Model model,
                           @RequestParam int profileId,
                           @RequestParam(defaultValue = Constants.PROFILE_CLIENT_DEFAULT_ID) String clientUUID) throws Exception {
        clientService.updateActive(profileId, clientUUID, true);
        return null;
    }
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);
    }
973081
@RequestMapping(value = "/api/profile", method = RequestMethod.GET)
    public
    @ResponseBody
    HashMap<String, Object> getList(Model model) throws Exception {
        logger.info("Using a GET request to list profiles");
        return Utils.getJQGridJSON(profileService.findAllProfiles(), "profiles");
    }
622796
@SuppressWarnings({"unused", "WeakerAccess"})
    public void pushProfile(final Map<String, Object> profile) {
        if (profile == null || profile.isEmpty())
            return;

        postAsyncSafely("profilePush", new Runnable() {
            @Override
            public void run() {
                _push(profile);
            }
        });
    }
1332416
public static void addProviderProfileInfo(Profile profile, UserProfile providerProfile) {
        String email = providerProfile.getEmail();
        if (StringUtils.isEmpty(email)) {
            throw new IllegalStateException("No email included in provider profile");
        }

        String username = providerProfile.getUsername();
        if (StringUtils.isEmpty(username)) {
            username = email;
        }

        String firstName = providerProfile.getFirstName();
        String lastName = providerProfile.getLastName();

        profile.setUsername(username);
        profile.setEmail(email);
        profile.setAttribute(FIRST_NAME_ATTRIBUTE_NAME, firstName);
        profile.setAttribute(LAST_NAME_ATTRIBUTE_NAME, lastName);
    }
956000
public Client setFriendlyName(int profileId, String clientUUID, String friendlyName) throws Exception {
        // first see if this friendlyName is already in use
        Client client = this.findClientFromFriendlyName(profileId, friendlyName);
        if (client != null && !client.getUUID().equals(clientUUID)) {
            throw new Exception("Friendly name already in use");
        }

        PreparedStatement statement = null;
        int rowsAffected = 0;

        try (Connection sqlConnection = sqlService.getConnection()) {
            statement = sqlConnection.prepareStatement(
                "UPDATE " + Constants.DB_TABLE_CLIENT +
                    " SET " + Constants.CLIENT_FRIENDLY_NAME + " = ?" +
                    " WHERE " + Constants.CLIENT_CLIENT_UUID + " = ?" +
                    " AND " + Constants.GENERIC_PROFILE_ID + " = ?"
            );
            statement.setString(1, friendlyName);
            statement.setString(2, clientUUID);
            statement.setInt(3, profileId);

            rowsAffected = statement.executeUpdate();
        } catch (Exception e) {

        } finally {
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }

        if (rowsAffected == 0) {
            return null;
        }
        return this.findClient(clientUUID, profileId);
    }
1319039
public void cullHistory(final int profileId, final String clientUUID, final int limit) throws Exception {

        //Allow only 1 delete thread to run
        if (threadActive) {
            return;
        }

        threadActive = true;
        //Create a thread so proxy will continue to work during long delete
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                PreparedStatement statement = null;

                try (Connection sqlConnection = sqlService.getConnection()) {
                    String sqlQuery = "SELECT COUNT(" + Constants.GENERIC_ID + ") FROM " + Constants.DB_TABLE_HISTORY + " ";

                    // see if profileId is set or not (-1)
                    if (profileId != -1) {
                        sqlQuery += "WHERE " + Constants.GENERIC_PROFILE_ID + "=" + profileId + " ";
                    }

                    if (clientUUID != null && clientUUID.compareTo("") != 0) {
                        sqlQuery += "AND " + Constants.GENERIC_CLIENT_UUID + "='" + clientUUID + "' ";
                    }
                    sqlQuery += ";";

                    Statement query = sqlConnection.createStatement();
                    ResultSet results = query.executeQuery(sqlQuery);
                    if (results.next()) {
                        if (results.getInt("COUNT(" + Constants.GENERIC_ID + ")") < (limit + 10000)) {
                            return;
                        }
                    }
                    //Find the last item in the table
                    statement = sqlConnection.prepareStatement("SELECT " + Constants.GENERIC_ID + " FROM " + Constants.DB_TABLE_HISTORY +
                                                                   " WHERE " + Constants.CLIENT_CLIENT_UUID + " = \'" + clientUUID + "\'" +
                                                                   " AND " + Constants.CLIENT_PROFILE_ID + " = " + profileId +
                                                                   " ORDER BY " + Constants.GENERIC_ID + " ASC LIMIT 1");

                    ResultSet resultSet = statement.executeQuery();
                    if (resultSet.next()) {
                        int currentSpot = resultSet.getInt(Constants.GENERIC_ID) + 100;
                        int finalDelete = currentSpot + 10000;
                        //Delete 100 items at a time until 10000 are deleted
                        //Do this so table is unlocked frequently to allow other proxy items to access it
                        while (currentSpot < finalDelete) {
                            PreparedStatement deleteStatement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_HISTORY +
                                                                                                   " WHERE " + Constants.CLIENT_CLIENT_UUID + " = \'" + clientUUID + "\'" +
                                                                                                   " AND " + Constants.CLIENT_PROFILE_ID + " = " + profileId +
                                                                                                   " AND " + Constants.GENERIC_ID + " < " + currentSpot);
                            deleteStatement.executeUpdate();
                            currentSpot += 100;
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    try {
                        threadActive = false;
                        if (statement != null) {
                            statement.close();
                        }
                    } catch (Exception e) {
                    }
                }
            }
        });

        t1.start();
    }
1287504
public static Actor client(String zoneId, String clientId) {
		Assert.notNull(zoneId, "zoneId must not be null");
		Assert.notNull(clientId, "clientId must not be null");
		return new Actor(OAUTH_CLIENT, zoneId + "/" + clientId);
	}
914270
public static Actor client(String clientId) {
		Assert.notNull(clientId, "clientId must not be null");
		return new Actor(OAUTH_CLIENT, clientId);
	}
1207586
protected String getRenderedUserProfile(final Map<String, Object> model) {
        if (oauthProperties.getUserProfileViewType() == OAuthProperties.UserProfileViewTypes.FLAT) {
            val flattened = new LinkedHashMap<String, Object>();
            if (model.containsKey(MODEL_ATTRIBUTE_ATTRIBUTES)) {
                val attributes = Map.class.cast(model.get(MODEL_ATTRIBUTE_ATTRIBUTES));
                flattened.putAll(attributes);
            }
            model.keySet()
                .stream()
                .filter(k -> !k.equalsIgnoreCase(MODEL_ATTRIBUTE_ATTRIBUTES))
                .forEach(k -> flattened.put(k, model.get(k)));
            LOGGER.trace("Flattened user profile attributes with the final model as [{}]", model);
            return OAuth20Utils.toJson(flattened);
        }
        return OAuth20Utils.toJson(model);

    }
817455
def setCurrentProfile(self, prof):
        
        if prof is None:
            self.clearActive()
            return
        
        # loop through the profiles looking for a match
        profile = None
        blocked = self.signalsBlocked()
        self.blockSignals(True)
        for act in self._profileGroup.actions():
            if prof in (act.profile(), act.profile().name()):
                act.setChecked(True)
                profile = act.profile()
            else:
                act.setChecked(False)
        self.blockSignals(blocked)
        
        # update the current profile
        if profile == self._currentProfile and not self._viewWidget.isEmpty():
            return
        
        self._currentProfile = profile
        if self._viewWidget and profile and not blocked:
            self._viewWidget.restoreProfile(profile)
        
        if not blocked:
            self.loadProfileFinished.emit(profile)
            self.currentProfileChanged.emit(profile)
36609
public List<Client> findAllClients(int profileId) throws Exception {
        ArrayList<Client> clients = new ArrayList<Client>();

        PreparedStatement query = null;
        ResultSet results = null;

        try (Connection sqlConnection = sqlService.getConnection()) {
            query = sqlConnection.prepareStatement(
                "SELECT * FROM " + Constants.DB_TABLE_CLIENT +
                    " WHERE " + Constants.GENERIC_PROFILE_ID + " = ?"
            );
            query.setInt(1, profileId);
            results = query.executeQuery();
            while (results.next()) {
                clients.add(this.getClientFromResultSet(results));
            }
        } catch (Exception e) {
            throw e;
        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (query != null) {
                    query.close();
                }
            } catch (Exception e) {
            }
        }
        return clients;
    }
271071
@RequestMapping(value = "api/edit/repeatNumber", method = RequestMethod.POST)
    public
    @ResponseBody
    String updateRepeatNumber(Model model, int newNum, int path_id,
                              @RequestParam(defaultValue = Constants.PROFILE_CLIENT_DEFAULT_ID) String clientUUID) throws Exception {
        logger.info("want to update repeat number of path_id={}, to newNum={}", path_id, newNum);
        editService.updateRepeatNumber(newNum, path_id, clientUUID);
        return null;
    }
934204
public int getHistoryCount(int profileId, String clientUUID, HashMap<String, String[]> searchFilter) {
        int count = 0;
        Statement query = null;
        ResultSet results = null;

        try (Connection sqlConnection = sqlService.getConnection()) {

            String sqlQuery = "SELECT COUNT(" + Constants.GENERIC_ID + ") FROM " + Constants.DB_TABLE_HISTORY + " ";

            // see if profileId is set or not (-1)
            if (profileId != -1) {
                sqlQuery += "WHERE " + Constants.GENERIC_PROFILE_ID + "=" + profileId + " ";
            }

            if (clientUUID != null && clientUUID.compareTo("") != 0) {
                sqlQuery += "AND " + Constants.GENERIC_CLIENT_UUID + "='" + clientUUID + "' ";
            }

            sqlQuery += ";";

            logger.info("Query: {}", sqlQuery);

            query = sqlConnection.createStatement();
            results = query.executeQuery(sqlQuery);
            if (results.next()) {
                count = results.getInt(1);
            }
            query.close();
        } catch (Exception e) {

        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (query != null) {
                    query.close();
                }
            } catch (Exception e) {
            }
        }

        return count;
    }
1342821
@RequestMapping(value = "/api/path/{pathId}", method = RequestMethod.DELETE)
    @ResponseBody
    public HashMap<String, Object> deletePath(Model model, @PathVariable int pathId,
                                              @RequestParam(value = "clientUUID", defaultValue = Constants.PROFILE_CLIENT_DEFAULT_ID) String clientUUID) throws Exception {
        EndpointOverride currentPath = PathOverrideService.getInstance().getPath(pathId);
        int profileId = currentPath.getProfileId();

        // remove the path
        logger.info("Removing path {}", pathId);
        PathOverrideService.getInstance().removePath(pathId);

        // return the remaining data
        List<EndpointOverride> paths = PathOverrideService.getInstance().getPaths(profileId, clientUUID, null);

        return Utils.getJQGridJSON(paths, "paths");
    }
663179
@RequestMapping(value = "api/edit/server", method = RequestMethod.GET)
    public
    @ResponseBody
    HashMap<String, Object> getjqRedirects(Model model,
                                           @RequestParam(value = "profileId", required = false) Integer profileId,
                                           @RequestParam(value = "clientUUID", required = true) 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);
        }
        int clientId = ClientService.getInstance().findClient(clientUUID, profileId).getId();

        HashMap<String, Object> returnJson = Utils.getJQGridJSON(ServerRedirectService.getInstance().tableServers(clientId), "servers");
        returnJson.put("hostEditor", Client.isAvailable());
        return returnJson;
    }
511542
public ApplyProfile createDefaultProfile(String profileType) throws RuntimeFault, RemoteException {
        return createDefaultProfile(profileType, null, null);
    }