public String deleteSub() {
    // delete a planet subscription
    log.debug("Deleting Planet Subscription ...");

    PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
    try {
      if (!StringUtils.isEmpty(getSubid())) {
        Subscription sub = pmgr.getSubscriptionById(getSubid());
        if (sub == null) {
          setError("PlanetGroupForm.error.nullSubscription");
          return INPUT;
        } else {
          PlanetGroup group = getGroup();
          group.getSubscriptions().remove(sub);
          sub.getGroups().remove(group);
          pmgr.saveGroup(group);
          PlanetFactory.getPlanet().flush();
        }

        setSuccess("PlanetGroupForm.message.subscriptionDeleteSucceeded", sub.getTitle());
      } else {
        setError("PlanetGroupForm.error.subscriptionNull");
      }

      return INPUT;

    } catch (PlanetException ex) {
      log.error("Unable to lookup planet group", ex);
      setError("PlanetGroupForm.error.subscriptionDeleteFailed", getSubid());
      return INPUT;
    }
  }
  // Validation - sub url cannot be null, must be valid url
  public String addSub() {
    // add a planet subscription
    log.debug("Adding Planet Subscription ...");

    PlanetManager pMgr = PlanetFactory.getPlanet().getPlanetManager();
    try {
      PlanetGroup group = getGroup();
      if (group == null) {
        setError("PlanetSubscriptionForm.error.groupNull");
        return INPUT;
      }

      // check if this subscription already exists before adding it
      Subscription sub = pMgr.getSubscription(getAddSubUrl());
      if (sub == null) {
        // sub doesn't exist yet, so we need to fetch it
        FeedFetcher fetcher = PlanetFactory.getPlanet().getFeedFetcher();
        sub = fetcher.fetchSubscription(getAddSubUrl());

        // save new sub
        pMgr.saveSubscription(sub);
      }

      // add the sub to the group
      group.getSubscriptions().add(sub);
      sub.getGroups().add(group);
      pMgr.saveGroup(group);

      // flush changes
      PlanetFactory.getPlanet().flush();

      // clear field after success
      setAddSubUrl(null);

    } catch (PlanetException ex) {
      log.error("Error adding subscription", ex);
      setError("PlanetSubscriptionForm.error.saveFailed");
      return INPUT;
    }

    setSuccess("PlanetSubscriptionForm.message.saveSucceeded");
    return INPUT;
  }
  /** Load relevant Planet if possible. */
  public void prepare() throws Exception {
    PlanetManager pMgr = PlanetFactory.getPlanet().getPlanetManager();
    if (getGroupid() != null && !"".equals(getGroupid())) {
      // load a planet group
      log.debug("Loading Planet Group ...");

      group = pMgr.getGroupById(getGroupid());
    } else {
      // new group, must have a planet to add it to
      Planet planet = pMgr.getPlanetById(getPlanetid());
      if (planet != null) {
        group = new PlanetGroup();
        group.setPlanet(planet);
      } else {
        throw new PlanetException("could not determine planet " + getPlanetid());
      }
    }
  }