class RequestScheduleResourceProvider extends AbstractControllerResourceProvider {

  private synchronized void deleteRequestSchedule(RequestScheduleRequest request)
    throws AmbariException {

    if (request.getId() == null) {
      throw new AmbariException("Id is a required field.");
    }

    Clusters clusters = getManagementController().getClusters();

    Cluster cluster;
    try {
      cluster = clusters.getCluster(request.getClusterName());
    } catch (ClusterNotFoundException e) {
      throw new ParentObjectNotFoundException(
        "Attempted to delete a request schedule from a cluster which doesn't "
          + "exist", e);
    }

    RequestExecution requestExecution =
      cluster.getAllRequestExecutions().get(request.getId());

    if (requestExecution == null) {
      throw new AmbariException("Request Schedule not found "
        + ", clusterName = " + request.getClusterName()
        + ", description = " + request.getDescription()
        + ", id = " + request.getId());
    }

    String username = getManagementController().getAuthName();

    LOG.info("Disabling Request Schedule "
      + ", clusterName = " + request.getClusterName()
      + ", id = " + request.getId()
      + ", user = " + username);

    // Delete all jobs and triggers
    getManagementController().getExecutionScheduleManager()
      .deleteAllJobs(requestExecution);

    requestExecution.updateStatus(RequestExecution.Status.DISABLED);
  }

  protected  RequestScheduleResourceProvider(AmbariManagementController managementController);

}