protected void updateEntityFields(ActionContext actionContext, IGTEntity entity)
      throws GTClientException {
    ConnectionSetupResultAForm form = (ConnectionSetupResultAForm) actionContext.getActionForm();
    IGTConnectionSetupResultEntity result = (IGTConnectionSetupResultEntity) entity;
    IGTConnectionSetupParamEntity param =
        (IGTConnectionSetupParamEntity)
            result.getFieldValue(IGTConnectionSetupResultEntity.SETUP_PARAMETERS);

    Short status = form.getStatusShort();
    if (IGTConnectionSetupResultEntity.STATUS_FAILURE.equals(status)
        || IGTConnectionSetupResultEntity.STATUS_NOT_DONE.equals(status)) {
      param.setFieldValue(
          IGTConnectionSetupParamEntity.ORIGINAL_LOCATION, form.getOriginalLocation());
      param.setFieldValue(
          IGTConnectionSetupParamEntity.SERVICING_ROUTER, form.getServicingRouter());
      param.setFieldValue(
          IGTConnectionSetupParamEntity.SECURITY_PASSWORD, form.getSecurityPassword());
    } else if (IGTConnectionSetupResultEntity.STATUS_SUCCESS.equals(status)) {
      OperationContext opCon = OperationContext.getOperationContext(actionContext.getRequest());
      List gridMasterList = (List) opCon.getAttribute(GRIDMASTER_LIST);
      List routerList = (List) opCon.getAttribute(ROUTER_LIST);
      Collection gridMasterUids = StaticCtrlUtils.getUids(gridMasterList);
      Collection routerUids = StaticCtrlUtils.getUids(routerList);
      result.setFieldValue(IGTConnectionSetupResultEntity.AVAILABLE_GRIDMASTERS, gridMasterUids);
      result.setFieldValue(IGTConnectionSetupResultEntity.AVAILABLE_ROUTERS, routerUids);
    } else {
      throw new java.lang.IllegalStateException(
          "Illegal STATUS for connectionSetupResult:" + status);
    }
  }
  protected void arrangeLists(ActionContext actionContext) throws GTClientException {
    try {
      ConnectionSetupResultAForm form = (ConnectionSetupResultAForm) actionContext.getActionForm();
      // IGTConnectionSetupResultEntity result =
      // (IGTConnectionSetupResultEntity)getEntity(actionContext);
      Short status = form.getStatusShort();
      if (IGTConnectionSetupResultEntity.STATUS_SUCCESS.equals(status)) {
        OperationContext opCon = OperationContext.getOperationContext(actionContext.getRequest());
        List gridMasterList = (List) opCon.getAttribute(GRIDMASTER_LIST);
        if (gridMasterList == null)
          throw new NullPointerException("gridMasterList (inOpCon"); // 20030422AH
        List routerList = (List) opCon.getAttribute(ROUTER_LIST);
        if (routerList == null)
          throw new NullPointerException("routerList (in opCon)"); // 20030422AH

        StaticUtils.arrangeList(gridMasterList, form.getAvailableGridMastersOrder());
        StaticUtils.arrangeList(routerList, form.getAvailableRoutersOrder());

        form.setAvailableGridMastersOrder(StaticUtils.initialOrderString(gridMasterList.size()));
        form.setAvailableRoutersOrder(StaticUtils.initialOrderString(routerList.size()));
      }
    } catch (Throwable t) {
      throw new GTClientException(
          "Error processing order of availableRouters and availableGridMasters", t);
    }
  }
  protected void validateActionForm(
      ActionContext actionContext, IGTEntity entity, ActionForm form, ActionErrors actionErrors)
      throws GTClientException {
    ConnectionSetupResultAForm rForm = (ConnectionSetupResultAForm) form;
    IGTConnectionSetupResultEntity result = (IGTConnectionSetupResultEntity) entity;
    IGTConnectionSetupParamEntity param =
        (IGTConnectionSetupParamEntity)
            result.getFieldValue(IGTConnectionSetupResultEntity.SETUP_PARAMETERS);
    Short status = rForm.getStatusShort();
    if (IGTConnectionSetupResultEntity.STATUS_FAILURE.equals(status)
        || IGTConnectionSetupResultEntity.STATUS_NOT_DONE.equals(status)) {
      if (result.getSession().isNoSecurity()) { // 20031105AH
        rForm.setSecurityPassword(IGTSession.PCP_DEFAULT);
      }

      basicValidateString(
          actionErrors, IGTConnectionSetupParamEntity.CURRENT_LOCATION, rForm, param);
      basicValidateString(
          actionErrors, IGTConnectionSetupParamEntity.SERVICING_ROUTER, rForm, param);
      basicValidateString(
          actionErrors, IGTConnectionSetupParamEntity.SECURITY_PASSWORD, rForm, param);
    } else if (IGTConnectionSetupResultEntity.STATUS_SUCCESS.equals(status)) {
      // Only the order can be changed.
      // We leave uid validation to b-tier
    } else {
      actionErrors.add("status", new ActionError("connectionSetupResult.error.status.invalid"));
    }
  }
 protected void saveWithManager(ActionContext actionContext, IGTManager manager, IGTEntity entity)
     throws GTClientException {
   Short status = (Short) entity.getFieldValue(IGTConnectionSetupResultEntity.STATUS);
   boolean returnToUpdate = !(IGTConnectionSetupResultEntity.STATUS_SUCCESS.equals(status));
   actionContext.setAttribute(RETURN_TO_UPDATE_KEY, new Boolean(returnToUpdate));
   manager.update(entity);
   if (returnToUpdate) {
     initialiseActionForm(actionContext, entity);
     prepLists(actionContext, true); // yuck (we are calling it twice this way - but it works)
   }
 }