コード例 #1
0
  /** {@inheritDoc} */
  @Override
  public ActionForward handleDispatch(
      ListSessionSetHelper helper,
      ActionMapping mapping,
      ActionForm formIn,
      HttpServletRequest request,
      HttpServletResponse response) {
    RequestContext context = new RequestContext(request);
    ActivationKey key = context.lookupAndBindActivationKey();
    ConfigChannelListProcessor proc = new ConfigChannelListProcessor();
    Set<String> set = helper.getSet();

    for (String id : set) {
      Long ccid = Long.valueOf(id);
      ConfigChannel cc = ConfigurationFactory.lookupConfigChannelById(ccid);
      proc.remove(key.getConfigChannelsFor(context.getCurrentUser()), cc);
    }
    getStrutsDelegate()
        .saveMessage(
            "config_channels_to_unsubscribe.unsubscribe.success",
            new String[] {String.valueOf(set.size())},
            request);

    Map<String, Object> params = new HashMap<String, Object>();
    params.put(RequestContext.TOKEN_ID, key.getToken().getId().toString());
    StrutsDelegate strutsDelegate = getStrutsDelegate();
    return strutsDelegate.forwardParams(mapping.findForward("success"), params);
  }
コード例 #2
0
  /** {@inheritDoc} */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm formIn,
      HttpServletRequest request,
      HttpServletResponse response) {

    RequestContext context = new RequestContext(request);
    User user = context.getCurrentUser();

    long cid = context.getRequiredParam("cid");
    Channel chan = ChannelFactory.lookupByIdAndUser(cid, user);
    request.setAttribute("channel_name", chan.getName());
    request.setAttribute("cid", chan.getId());

    Map<String, Object> params = new HashMap<String, Object>();
    params.put(RequestContext.CID, chan.getId().toString());

    ListSessionSetHelper helper = new ListSessionSetHelper(this, request, params);

    if (!context.isSubmitted()) {
      List<ContentSource> result = getResult(context);
      Set<String> preSelect = new HashSet<String>();
      for (int i = 0; i < result.size(); i++) {
        ContentSource src = result.get(i);
        if (src.getChannels().contains(chan)) {
          preSelect.add(src.getId().toString());
        }
      }
      helper.preSelect(preSelect);
    }

    helper.ignoreEmptySelection();
    helper.execute();

    if (helper.isDispatched()) {
      Set<ContentSource> foo = chan.getSources();
      foo.clear();
      Set<String> set = helper.getSet();
      for (String id : set) {
        Long sgid = Long.valueOf(id);
        ContentSource tmp = ChannelFactory.lookupContentSource(sgid, user.getOrg());
        foo.add(tmp);
      }

      ChannelFactory.save(chan);

      StrutsDelegate strutsDelegate = getStrutsDelegate();
      strutsDelegate.saveMessage(
          "channel.edit.repo.updated", new String[] {chan.getName()}, request);

      return strutsDelegate.forwardParams(mapping.findForward("success"), params);
    }

    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
  }
コード例 #3
0
  /** {@inheritDoc} */
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm formIn,
      HttpServletRequest request,
      HttpServletResponse response) {

    RequestContext context = new RequestContext(request);
    User user = context.getCurrentUser();
    Server server = context.lookupAndBindServer();
    ListSessionSetHelper helper = new ListSessionSetHelper(this, request);
    helper.execute();

    if (helper.isDispatched()) {
      ServerGroupManager manager = ServerGroupManager.getInstance();
      List<Server> servers = new LinkedList<Server>();
      servers.add(server);

      for (String id : helper.getSet()) {
        ServerGroup group = manager.lookup(Long.valueOf(id), user);
        manager.addServers(group, servers, user);
      }
      helper.destroy();
      getStrutsDelegate()
          .saveMessage(
              "systems.groups.jsp.added",
              new String[] {String.valueOf(helper.getSet().size())},
              request);

      Map<String, Object> params = new HashMap<String, Object>();
      params.put(RequestContext.SID, server.getId().toString());
      StrutsDelegate strutsDelegate = getStrutsDelegate();
      return strutsDelegate.forwardParams(mapping.findForward("success"), params);
    }
    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
  }