Sets enabled/disabled for a response

@param pathId ID of path
@param enabled 1 for enabled, 0 for disabled
@param clientUUID client ID
@throws Exception exception
559599
public void setResponseEnabled(int pathId, boolean enabled, String clientUUID) throws Exception {
        PreparedStatement statement = null;
        int profileId = EditService.getProfileIdFromPathID(pathId);
        try (Connection sqlConnection = sqlService.getConnection()) {
            statement = sqlConnection.prepareStatement(
                "UPDATE " + Constants.DB_TABLE_REQUEST_RESPONSE +
                    " SET " + Constants.DB_TABLE_PATH_RESPONSE_ENABLED + "= ?" +
                    " WHERE " + Constants.GENERIC_PROFILE_ID + "= ?" +
                    " AND " + Constants.GENERIC_CLIENT_UUID + "= ?" +
                    " AND " + Constants.REQUEST_RESPONSE_PATH_ID + "= ?"
            );
            statement.setBoolean(1, enabled);
            statement.setInt(2, profileId);
            statement.setString(3, clientUUID);
            statement.setInt(4, pathId);
            statement.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }
    }
238035
public boolean disable(Jid pushJid, String node)
            throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
        DisablePushNotificationsIQ disablePushNotificationsIQ = new DisablePushNotificationsIQ(pushJid, node);
        return changePushNotificationsStatus(disablePushNotificationsIQ);
    }
167525
public void setEnabled(boolean enabled) {
		this.enabled = enabled;
		if (enabled) {
			DOM.setElementProperty(lineElement, "className", SLIDER_LINE);
		} else {
			DOM.setElementProperty(lineElement, "className", SLIDER_LINE + " "
					+ SLIDER_LINE_DISABLED);
		}
		redraw();
	}
338531
public void clearRequestSettings(int pathId, String clientUUID) throws Exception {
        this.setRequestEnabled(pathId, false, clientUUID);
        OverrideService.getInstance().disableAllOverrides(pathId, clientUUID, Constants.OVERRIDE_TYPE_REQUEST);
        EditService.getInstance().updateRepeatNumber(Constants.OVERRIDE_TYPE_REQUEST, pathId, clientUUID);
    }
476578
public void setEnabled(boolean enabled) {

        if (m_frozen) {
            throw new CmsRuntimeException(Messages.get().container(Messages.ERR_CONFIG_SUBSCRIPTIONMANAGER_FROZEN_0));
        }
        m_enabled = enabled;
    }
1234891
public void disableAll(int profileId, String client_uuid) {
        PreparedStatement statement = null;
        try (Connection sqlConnection = sqlService.getConnection()) {
            statement = sqlConnection.prepareStatement(
                "DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE +
                    " WHERE " + Constants.CLIENT_PROFILE_ID + " = ?" +
                    " AND " + Constants.CLIENT_CLIENT_UUID + " =? "
            );
            statement.setInt(1, profileId);
            statement.setString(2, client_uuid);
            statement.executeUpdate();
            statement.close();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }
    }
246292
public static ResourceManagerId fromUuidOrNull(@Nullable UUID uuid) {
		return  uuid == null ? null : new ResourceManagerId(uuid);
	}
1133496
public static base_response enable(nitro_service client) throws Exception {
		reporting enableresource = new reporting();
		return enableresource.perform_operation(client,"enable");
	}
893488
public void updateClientId(String clientId) {
        if (configForVM != null) {
            configForVM.withClientId(clientId);
        } else {
            configForAppService.withClientId(clientId);
        }
    }
121624
public void setClientId(String clientId) throws HelloSignException {
        if (clientId == null) {
            throw new HelloSignException("Client ID cannot be null");
        }
        this.clientId = clientId.trim();
    }
976094
public void disableAllOverrides(int pathID, String clientUUID, int overrideType) {
        PreparedStatement statement = null;

        try (Connection sqlConnection = sqlService.getConnection()) {
            ArrayList<Integer> enabledOverrides = new ArrayList<Integer>();
            enabledOverrides.add(Constants.PLUGIN_REQUEST_HEADER_OVERRIDE_ADD);
            enabledOverrides.add(Constants.PLUGIN_REQUEST_HEADER_OVERRIDE_REMOVE);
            enabledOverrides.add(Constants.PLUGIN_REQUEST_OVERRIDE_CUSTOM);
            enabledOverrides.add(Constants.PLUGIN_REQUEST_OVERRIDE_CUSTOM_POST_BODY);

            String overridePlaceholders = preparePlaceHolders(enabledOverrides.size());

            statement = sqlConnection.prepareStatement(
                "DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE +
                    " WHERE " + Constants.ENABLED_OVERRIDES_PATH_ID + " = ? " +
                    " AND " + Constants.GENERIC_CLIENT_UUID + " = ? " +
                    " AND " + Constants.ENABLED_OVERRIDES_OVERRIDE_ID +
                    (overrideType == Constants.OVERRIDE_TYPE_RESPONSE ? " NOT" : "") +
                    " IN ( " + overridePlaceholders + " )"
            );
            statement.setInt(1, pathID);
            statement.setString(2, clientUUID);
            for (int i = 3; i <= enabledOverrides.size() + 2; ++i) {
                statement.setInt(i, enabledOverrides.get(i - 3));
            }
            statement.execute();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }
    }
211428
public SetEnabledResponse setEnabled(Boolean saMLEnabled) throws ApiException {
        ApiResponse<SetEnabledResponse> resp = setEnabledWithHttpInfo(saMLEnabled);
        return resp.getData();
    }
33995
public void remove(int profileId, String clientUUID) throws Exception {
        PreparedStatement statement = null;
        ResultSet results = null;
        try (Connection sqlConnection = sqlService.getConnection()) {
            // first try selecting the row we want to deal with
            statement = sqlConnection.prepareStatement(
                "SELECT * FROM " + Constants.DB_TABLE_CLIENT +
                    " WHERE " + Constants.GENERIC_CLIENT_UUID + " = ?" +
                    " AND " + Constants.CLIENT_PROFILE_ID + "= ?"
            );
            statement.setString(1, clientUUID);
            statement.setInt(2, profileId);
            results = statement.executeQuery();
            if (!results.next()) {
                throw new Exception("Could not find specified clientUUID: " + clientUUID);
            }
        } catch (Exception e) {
            throw e;
        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }

        // delete from the client table
        String queryString = "DELETE FROM " + Constants.DB_TABLE_CLIENT +
            " WHERE " + Constants.CLIENT_CLIENT_UUID + " = ? " +
            " AND " + Constants.CLIENT_PROFILE_ID + " = ?";

        try (Connection sqlConnection = sqlService.getConnection()) {
            statement = sqlConnection.prepareStatement(queryString);
            statement.setString(1, clientUUID);
            statement.setInt(2, profileId);

            logger.info("Query: {}", statement.toString());
            statement.executeUpdate();
        } catch (Exception e) {
            throw e;
        } finally {
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }

        // delete from other tables as appropriate
        // need to delete from enabled_overrides and request_response
        try (Connection sqlConnection = sqlService.getConnection()) {
            statement = sqlConnection.prepareStatement(
                "DELETE FROM " + Constants.DB_TABLE_REQUEST_RESPONSE +
                    " WHERE " + Constants.CLIENT_CLIENT_UUID + " = ? " +
                    " AND " + Constants.CLIENT_PROFILE_ID + " = ?"
            );
            statement.setString(1, clientUUID);
            statement.setInt(2, profileId);
            statement.executeUpdate();
        } catch (Exception e) {
            // ok to swallow this.. just means there wasn't any
        }

        try (Connection sqlConnection = sqlService.getConnection()) {
            statement = sqlConnection.prepareStatement(
                "DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE +
                    " WHERE " + Constants.CLIENT_CLIENT_UUID + " = ? " +
                    " AND " + Constants.CLIENT_PROFILE_ID + " = ?"
            );
            statement.setString(1, clientUUID);
            statement.setInt(2, profileId);
            statement.executeUpdate();
        } catch (Exception e) {
            // ok to swallow this.. just means there wasn't any
        } finally {
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }
    }
211438
@Transactional
    protected void _setServiceEnabled(boolean enabled) {
        synchronized (_serviceManagementRecordService) {
            ServiceManagementRecord record = _serviceManagementRecordService.findServiceManagementRecord(Service.SCHEDULING);

            if (record == null) {
                record = new ServiceManagementRecord(_userService.findAdminUser(), Service.SCHEDULING, enabled);
            }
            record.setEnabled(enabled);
            _serviceManagementRecordService.updateServiceManagementRecord(record);
        }
    }
956097
@PUT
  @Path("/{path: .*}")
  public void disable(@PathParam("path") String path, @HeaderParam("Authorization") @DefaultValue("no token") String auth) throws Exception {
    sendJGroupsMessage(UpdateOpteration.DISABLE, path, auth);
  }
1246180
public Client findClient(String clientUUID, Integer profileId) throws Exception {
        Client client = null;
        /* ERROR CODE: 500 WHEN TRYING TO DELETE A SERVER GROUP.
            THIS APPEARS TO BE BECAUSE CLIENT UUID IS NULL.
         */
        /* CODE ADDED TO PREVENT NULL POINTERS. */
        if (clientUUID == null) {
            clientUUID = "";
        }

        // first see if the clientUUID is actually a uuid.. it might be a friendlyName and need conversion
        /* A UUID IS A UNIVERSALLY UNIQUE IDENTIFIER. */
        if (clientUUID.compareTo(Constants.PROFILE_CLIENT_DEFAULT_ID) != 0 &&
            !clientUUID.matches("[\\w]{8}-[\\w]{4}-[\\w]{4}-[\\w]{4}-[\\w]{12}")) {
            Client tmpClient = this.findClientFromFriendlyName(profileId, clientUUID);

            // if we can't find a client then fall back to the default ID
            if (tmpClient == null) {
                clientUUID = Constants.PROFILE_CLIENT_DEFAULT_ID;
            } else {
                return tmpClient;
            }
        }

        PreparedStatement statement = null;
        ResultSet results = null;
        try (Connection sqlConnection = sqlService.getConnection()) {
            String queryString = "SELECT * FROM " + Constants.DB_TABLE_CLIENT +
                " WHERE " + Constants.CLIENT_CLIENT_UUID + " = ?";

            if (profileId != null) {
                queryString += " AND " + Constants.GENERIC_PROFILE_ID + "=?";
            }

            statement = sqlConnection.prepareStatement(queryString);
            statement.setString(1, clientUUID);

            if (profileId != null) {
                statement.setInt(2, profileId);
            }

            results = statement.executeQuery();
            if (results.next()) {
                client = this.getClientFromResultSet(results);
            }
        } catch (Exception e) {
            throw e;
        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }

        return client;
    }
598857
@RequestMapping(value = "api/edit/disable", method = RequestMethod.POST)
    public
    @ResponseBody
    String disableResponses(Model model, int path_id, @RequestParam(defaultValue = Constants.PROFILE_CLIENT_DEFAULT_ID) String clientUUID) throws Exception {
        OverrideService.getInstance().disableAllOverrides(path_id, clientUUID);
        //TODO also need to disable custom override if there is one of those
        editService.removeCustomOverride(path_id, clientUUID);

        return null;
    }