コード例 #1
0
 private void removePlatforms(AuthzSubject subject, Collection<Platform> platforms) {
   for (Platform platform : platforms) {
     try {
       // removeServers(subject, platform.getServers());
       appdefBoss.removePlatform(subject, platform.getId());
     } catch (Exception e) {
       log.error("Unable to remove platform: " + e, e);
     }
   }
 }
コード例 #2
0
 private final void removeServices(AuthzSubject subject, Collection<Service> services) {
   final StopWatch watch = new StopWatch();
   watch.markTimeBegin("removeServices");
   final List<Service> svcs = new ArrayList<Service>(services);
   // can't use iterator for loop here. Since we are modifying the
   // internal hibernate collection, which this collection is based on,
   // it will throw a ConcurrentModificationException
   // This occurs even if you disassociate the Collection by trying
   // something like new ArrayList(services). Not sure why.
   for (int i = 0; i < svcs.size(); i++) {
     try {
       final Service service = svcs.get(i);
       appdefBoss.removeService(subject, service.getId());
     } catch (Exception e) {
       log.error("Unable to remove service: " + e, e);
     }
   }
   watch.markTimeEnd("removeServices");
   if (log.isDebugEnabled()) {
     log.debug("Removed " + services.size() + " services");
   }
 }
コード例 #3
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    HttpSession session = request.getSession();

    AddApplicationServicesForm addForm = (AddApplicationServicesForm) form;
    AppdefEntityID aeid = new AppdefEntityID(addForm.getType().intValue(), addForm.getRid());

    HashMap<String, Object> forwardParams = new HashMap<String, Object>(2);
    forwardParams.put(Constants.ENTITY_ID_PARAM, aeid.getAppdefKey());
    forwardParams.put(Constants.ACCORDION_PARAM, "3");

    ActionForward forward = checkSubmit(request, mapping, form, forwardParams);
    if (forward != null) {
      BaseValidatorForm spiderForm = (BaseValidatorForm) form;

      if (spiderForm.isCancelClicked()
          || spiderForm.isResetClicked()
          || forward.getName().equalsIgnoreCase(Constants.RESET_URL)) {
        log.trace("removing pending service list");
        SessionUtils.removeList(session, Constants.PENDING_APPSVCS_SES_ATTR);
      } else if (spiderForm.isAddClicked()) {
        log.trace(
            "adding to pending service list " + Arrays.asList(addForm.getAvailableServices()));
        SessionUtils.addToList(
            session, Constants.PENDING_APPSVCS_SES_ATTR, addForm.getAvailableServices());
      } else if (spiderForm.isRemoveClicked()) {
        log.trace("removing from pending service list");
        SessionUtils.removeFromList(
            session, Constants.PENDING_APPSVCS_SES_ATTR, addForm.getPendingServices());
      }
      return forward;
    }

    Integer sessionId = RequestUtils.getSessionId(request);

    log.trace("getting pending service list");
    List<String> uiPendings =
        SessionUtils.getListAsListStr(session, Constants.PENDING_APPSVCS_SES_ATTR);
    List<AppdefEntityID> svcList = new ArrayList<AppdefEntityID>();

    for (int pRcs = 0; pRcs < uiPendings.size(); pRcs++) {
      log.debug("uiPendings = " + uiPendings.get(pRcs));
      StringTokenizer tok = new StringTokenizer(uiPendings.get(pRcs), " ");
      svcList.add(new AppdefEntityID(tok.nextToken()));
    }
    // when we call boss.setApplicationServices(...) our map must
    // be populated with all of the existing services (and whether
    // or not they're entry points) as well as our new ones

    // first, get the existing ones
    PageControl nullPc = new PageControl(-1, -1);
    List<AppdefResourceValue> existingServices =
        appdefBoss.findServiceInventoryByApplication(sessionId.intValue(), aeid.getId(), nullPc);
    DependencyTree tree = appdefBoss.getAppDependencyTree(sessionId.intValue(), aeid.getId());
    for (AppdefResourceValue service : existingServices) {

      log.debug("service =" + service.getClass().getName());

      tree.findAppService(service);
      svcList.add(service.getEntityId());
    }

    // second, get the new ones

    // set all added services to be entry points, if they're not to be
    // entry points and are instead part of a dependency chain,
    // setting up the dependencies is a separate activity

    log.trace("adding servicess " + svcList + " for application [" + aeid.getID() + "]");
    appdefBoss.setApplicationServices(sessionId.intValue(), aeid.getId(), svcList);
    log.trace("removing pending service list");
    SessionUtils.removeList(session, Constants.PENDING_APPSVCS_SES_ATTR);

    RequestUtils.setConfirmation(request, "resource.application.inventory.confirm.AddedServices");
    return returnSuccess(request, mapping, forwardParams);
  }