コード例 #1
0
  public boolean isResourceConfigured(
      HttpServletRequest request, ServletContext ctx, boolean setError)
      throws ServletException, AppdefEntityNotFoundException, SessionNotFoundException,
          SessionTimeoutException, PermissionException, EncodingException, RemoteException {
    final String CONFIG_ATTR = "IsResourceUnconfigured";

    Boolean configured = (Boolean) request.getAttribute(CONFIG_ATTR);
    if (configured != null) return !configured.booleanValue();

    if (entityId.isGroup()) return true;

    int sessionId = RequestUtils.getSessionId(request).intValue();

    if (this instanceof ApplicationInventoryHelper) return true;

    ProductBoss productBoss = Bootstrap.getBean(ProductBoss.class);

    String context = request.getContextPath();
    try {
      productBoss.getMergedConfigResponse(
          sessionId, ProductPlugin.TYPE_MEASUREMENT, entityId, true);
    } catch (ConfigFetchException e) {
      if (setError) {
        ActionMessage error =
            new ActionMessage(
                CFG_ERR_RES,
                new String[] {
                  context, String.valueOf(entityId.getType()), String.valueOf(entityId.getID())
                });
        RequestUtils.setError(request, error, ActionMessages.GLOBAL_MESSAGE);
      }
      request.setAttribute(CONFIG_ATTR, Boolean.TRUE);
      return false;
    }

    // only check where the config is invalid
    String validationError =
        productBoss.getConfigResponse(sessionId, entityId).getValidationError();

    if (validationError == null) {
      request.setAttribute(CONFIG_ATTR, Boolean.FALSE);
      return true;
    }
    if (setError) {
      ActionMessage error =
          new ActionMessage(
              CFG_INVALID_RES,
              new String[] {
                StringUtil.replace(validationError, "\n", "<br>&nbsp;&nbsp;" + "&nbsp;&nbsp;"),
                context,
                String.valueOf(entityId.getType()),
                String.valueOf(entityId.getID())
              });
      RequestUtils.setError(request, error, ActionMessages.GLOBAL_MESSAGE);
    }
    request.setAttribute(CONFIG_ATTR, Boolean.TRUE);
    return false;
  }
コード例 #2
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);
  }