예제 #1
0
  public void deleteSelectedBundles() throws Exception {
    RemoteClient remoteClient;
    Subject subject;
    try {
      remoteClient = this.perspectiveClient.getRemoteClient();
      subject = this.perspectiveClient.getSubject();
    } catch (Exception e) {
      this.facesMessages.add(
          StatusMessage.Severity.FATAL, "Failed to connect to RHQ Server - cause: " + e);
      return;
    }

    // ***NOTE***: The javassist.NotFoundException stack traces that are logged by this call can be
    // ignored.
    BundleManagerRemote bundleManager = remoteClient.getBundleManagerRemote();

    int[] selectedBundleIds = new int[this.selectedBundles.size()];
    for (int i = 0, selectedBundlesSize = this.selectedBundles.size();
        i < selectedBundlesSize;
        i++) {
      Bundle selectedBundle = this.selectedBundles.get(i);
      selectedBundleIds[i] = selectedBundle.getId();
    }

    bundleManager.deleteBundles(subject, selectedBundleIds);

    // Add message to tell the user the uninventory was a success.
    String pluralizer = (this.selectedBundles.size() == 1) ? "" : "s";
    this.facesMessages.add("Deleted " + this.selectedBundles.size() + " bundle" + pluralizer + ".");

    // Reset the data model, so the current page will get refreshed to reflect the Resources we just
    // uninventoried.
    // This is essential, since we are CONVERSATION-scoped and will live on beyond this request.
    setDataModel(null);
  }