protected void prepLists(ActionContext actionContext, boolean reloaded) throws GTClientException { try { OperationContext opCon = OperationContext.getOperationContext(actionContext.getRequest()); List gridMasterList = (List) opCon.getAttribute(GRIDMASTER_LIST); if (reloaded || (gridMasterList == null)) { IGTConnectionSetupResultEntity result = (IGTConnectionSetupResultEntity) getEntity(actionContext); gridMasterList = (List) result.getFieldEntities(IGTConnectionSetupResultEntity.AVAILABLE_GRIDMASTERS); List routerList = (List) result.getFieldEntities(IGTConnectionSetupResultEntity.AVAILABLE_ROUTERS); if (gridMasterList == null) throw new NullPointerException("gridMasterList is null"); // 20030422AH if (routerList == null) throw new NullPointerException("routerList is null"); // 20030422AH opCon.setAttribute(GRIDMASTER_LIST, gridMasterList); opCon.setAttribute(ROUTER_LIST, routerList); ConnectionSetupResultAForm form = (ConnectionSetupResultAForm) actionContext.getActionForm(); String initRoutersOrder = StaticUtils.initialOrderString(routerList.size()); String initMastersOrder = StaticUtils.initialOrderString(gridMasterList.size()); form.setAvailableGridMastersOrder(initMastersOrder); form.setAvailableRoutersOrder(initRoutersOrder); } } catch (Throwable t) { throw new GTClientException( "Error prepping GridMaster and Router lists in OperationContext", t); } }
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); } }
/** * Obtain the ImportSchema entity from the previous entity. * * @param actionContext * @return * @throws GTClientException */ private IGTImportSchemaEntity getImportSchema(ActionContext actionContext) throws GTClientException { try { OperationContext opContext = OperationContext.getOperationContext(actionContext.getRequest()); OperationContext parentOpContext = opContext.getPreviousContext(); if (parentOpContext == null) { throw new java.lang.NullPointerException("null parent OperationContext reference"); } IGTImportSchemaEntity importSchema = (IGTImportSchemaEntity) parentOpContext.getAttribute(IOperationContextKeys.ENTITY); if (importSchema == null) { throw new java.lang.NullPointerException( "No entity object found in parent OperationContext"); } if (!(importSchema instanceof IGTImportSchemaEntity)) { throw new java.lang.IllegalStateException( "Entity found in parent OperationContext is" + " not a IGTImportSchemaEntity entity. Entity=" + importSchema); } return importSchema; } catch (Exception ex) { throw new GTClientException( "[SchemaMappingFileDispatchAction.getImportSchema] Error retrieving ImportSchema entity from previous OperationContext", ex); } }
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); } }
/** instead of save the entity into backend, we save it in to the importSchema entity */ @Override protected void saveWithManager(ActionContext actionContext, IGTManager manager, IGTEntity entity) throws GTClientException { try { OperationContext op = OperationContext.getOperationContext(actionContext.getRequest()); String index = (String) op.getAttribute( INDEX_KEY); // It can be used to differentiate whether we are saving a new entity // or an existing one // I followed the existing implementation, so didn't use boolean. IGTImportSchemaEntity importSchema = getImportSchema(actionContext); ArrayList schemaMappingList = (ArrayList) importSchema.getFieldValue(IGTImportSchemaEntity.SCHEMA_MAPPING); if ("new".equals(index)) { schemaMappingList.add(entity); } } catch (Exception ex) { throw new GTClientException( "[SchemaMappingFileDispatchAction.saveWithManager] Error perfroming saving in ImportSchema entity", ex); } }