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); } }
public static boolean basicValidateFiles( ActionErrors actionErrors, Number fieldId, ActionForm form, IGTEntity entity, String[] extensions) throws GTClientException { try { boolean newEntity = entity.isNewEntity(); if (!(form instanceof GTActionFormBase)) { throw new java.lang.UnsupportedOperationException( "Form must be a subclass of GTActionFormBase"); } IGTFieldMetaInfo fmi = entity.getFieldMetaInfo(fieldId); if (fmi == null) { throw new java.lang.NullPointerException( "No fieldMetaInfo for field:" + fieldId + " of entity " + entity); } if ((!fmi.isDisplayable(newEntity)) || (!fmi.isEditable(newEntity))) { return true; } String fieldName = fmi.getFieldName(); // 20030410AH FormFileElement[] elements = ((GTActionFormBase) form).getFormFileElements(fieldName); // 20030410AH if (fmi.isMandatory(newEntity)) { if ((elements == null) || (elements.length == 0)) { addFieldError(actionErrors, fieldName, entity.getType(), REQUIRED, null); // 20021220AH return false; } } if (extensions != null) { // 20030410AH - Check file extensions are of those allowed boolean allOk = true; if (elements != null) { for (int i = 0; i < elements.length; i++) { String filename = elements[i].getFileName(); if (filename == null) throw new NullPointerException("Internal assertion failure: filename is null"); String extension = StaticUtils.getFileExtension(filename); if (StaticUtils.findValueInArray(extensions, extension, false) == -1) { String[] params = new String[] {filename}; addFieldError(actionErrors, fieldName, entity.getType(), INVALID_EXTENSION, params); return false; } } } } return true; } catch (Throwable t) { throw new GTClientException("Error validating file field:" + fieldId, t); } }
protected void updateEntityFields(ActionContext actionContext, IGTEntity entity) throws GTClientException { IGTServiceAssignmentEntity serviceAssignment = (IGTServiceAssignmentEntity) entity; ServiceAssignmentAForm form = (ServiceAssignmentAForm) actionContext.getActionForm(); serviceAssignment.setFieldValue(IGTServiceAssignmentEntity.USER_NAME, form.getUserName()); serviceAssignment.setFieldValue( IGTServiceAssignmentEntity.USER_TYPE, IGTServiceAssignmentEntity.PARTNER_TYPE); String password = form.getUserPassword(); if (entity.isNewEntity() || (password != null && password.trim().length() > 0)) { serviceAssignment.setFieldValue(IGTServiceAssignmentEntity.PASSWORD, form.getUserPassword()); } Collection webServiceUids = StaticUtils.collectionValue(form.getWebServiceUids()); serviceAssignment.setFieldValue(IGTServiceAssignmentEntity.WEBSERVICE_UIDS, webServiceUids); }
protected void initialiseActionForm(ActionContext actionContext, IGTEntity entity) throws GTClientException { IGTServiceAssignmentEntity serviceAssignment = (IGTServiceAssignmentEntity) entity; ServiceAssignmentAForm form = (ServiceAssignmentAForm) actionContext.getActionForm(); form.setUserName(serviceAssignment.getFieldString(IGTServiceAssignmentEntity.USER_NAME)); form.setUserType(IGTServiceAssignmentEntity.PARTNER_TYPE); // form.setUserPassword(serviceAssignment.getFieldString(IGTServiceAssignmentEntity.PASSWORD)); Collection webServiceUids = (Collection) serviceAssignment.getFieldValue(IGTServiceAssignmentEntity.WEBSERVICE_UIDS); if (webServiceUids == null || webServiceUids.isEmpty()) form.setWebServiceUids(StaticUtils.EMPTY_STRING_ARRAY); else { String uIds[] = StaticUtils.getStringArray(webServiceUids); form.setWebServiceUids(uIds); } }
public static boolean validateKeys( ActionErrors actionErrors, String field, String[] keys, Number entityField, IGTEntity entity) throws GTClientException { try { IGTFieldMetaInfo fmi = entity.getFieldMetaInfo(entityField); boolean newEntity = entity.isNewEntity(); if (fmi == null) { throw new java.lang.NullPointerException( "No fieldMetaInfo for field:" + entityField + "(" + field + ") of entity " + entity); } if ((!fmi.isDisplayable(newEntity)) || (!fmi.isEditable(newEntity))) { return true; } if (fmi.isMandatory(newEntity)) { if ((keys == null) || (keys.length == 0)) { // actionErrors.add(field,new ActionError(entity.getType() + ".error." + field + // ".required")); addFieldError(actionErrors, field, entity.getType(), REQUIRED, null); // 20021220AH return false; } else { // 20030515AH - Check each key to make sure it has a value as we could well // just have an array with a single empty string (or such like) boolean someOk = false; boolean someEmpty = false; for (int i = 0; i < keys.length; i++) { if (StaticUtils.stringEmpty(keys[i])) { someEmpty = true; } else { someOk = true; } } if (someEmpty) { addFieldError(actionErrors, field, entity.getType(), someOk ? INVALID : REQUIRED, null); return false; } } } return true; } catch (Throwable t) { throw new GTClientException("Error validating field " + entityField, t); } }
// 20030918 DDJ: Added method public static boolean basicValidateStringArray( ActionErrors actionErrors, String field, String[] value, Number entityField, IGTEntity entity) throws GTClientException { try { IGTFieldMetaInfo fmi = entity.getFieldMetaInfo(entityField); if (fmi == null) { throw new java.lang.NullPointerException( "No fieldMetaInfo for field:" + entityField + "(" + field + ") of entity " + entity); } boolean newEntity = entity.isNewEntity(); if (!fmi.isDisplayable(newEntity) || !fmi.isEditable(newEntity)) { return true; } if (fmi.isMandatory(newEntity)) { if (value == null || value.length == 0) { // actionErrors.add(field,new ActionError(entity.getType() + ".error." + field + // ".required")); addFieldError(actionErrors, field, entity.getType(), REQUIRED, null); return false; } } // validate based on value class String valueClass = fmi.getValueClass(); for (int i = 0; i < value.length; i++) { try { StaticUtils.convert(value[i], valueClass, true, false); } catch (UnsupportedOperationException valueClassUnsupported) { // swallow, ignore testing unsupported value class } catch (Throwable t) { addFieldError(actionErrors, field, entity.getType(), INVALID, null); return false; } } return true; } catch (Throwable t) { throw new GTClientException("Error validating field " + entityField, t); } }
protected void render() throws RenderingException { try { RenderingContext rContext = getRenderingContext(); // 20021216AH checkReloadHeader(rContext); // 20030704AH IGTRegistrationInfoEntity rego = (IGTRegistrationInfoEntity) getEntity(); // 20030115AH RegistrationInfoAForm form = (RegistrationInfoAForm) getActionForm(); renderCommonFormElements(IGTEntity.ENTITY_REGISTRATION_INFO, _edit); renderLabel("prodKey_label", "registrationInfo.prodKey", false); Short state = StaticUtils.shortValue(form.getRegistrationState()); BindingFieldPropertyRenderer bfpr = new BindingFieldPropertyRenderer(rContext); // 20030115AH if (IGTRegistrationInfoEntity.REG_STATE_NOT_REG.equals(state)) { removeNode("licDate_details", false); // 20030422 removeNode("category_details", false); // 20030422AH removeNode("security_details", false); // 20030422AH removeNode("bizConnections_details", false); // 20030422AH removeNode("cancel", false); // 20030422AH removeNode("button_divider_1", false); // 20030422AH removeNode("prodKey_details", false); // 20030416AH } else if (IGTRegistrationInfoEntity.REG_STATE_IN_PROGRESS.equals(state)) { if (_edit) { makeRegoReadOnly(); // 20030417AH } else { // 20030417AH - In progress in view mode Element stateLabel = getElementById("registrationState_value", false); if (stateLabel != null) { // Highlight the fact they havent finsihed yet! stateLabel.setAttribute("class", "errortext"); } renderLabelCarefully("edit", "registrationInfo.view.continue", false); } renderLabel("security_heading", "registrationInfo.security.heading", false); renderLabel("security_message", "registrationInfo.security.message", false); renderLabelCarefully("ok", "registrationInfo.edit.ok.confirm", false); // 20030326AH Element okIcon = getElementById("ok_icon", false); // 20030326AH if (okIcon != null) { // 20030326AH okIcon.setAttribute("src", REGISTER_IMAGE_SRC); } renderLabelCarefully( "cancel", "registrationInfo.edit.cancelRegistration", false); // 20030326AH renderLicencePeriod(form, bfpr, rego); // 20030115AH removeNode("licFile_details", false); // 20030417AH if (rego.getSession().isNoSecurity()) { // 20031105AH - HACK for GNDB00016109 removeNode("security_details"); } } else if (IGTRegistrationInfoEntity.REG_STATE_REG.equals(state) || IGTRegistrationInfoEntity.REG_STATE_EXPIRED.equals(state)) // 20030502AH { if (_edit) makeRegoReadOnly(); // 20030417AH if (_edit) removeNode("security_details", false); // 20030417AH // 20030417AH - removeNode("ok",false); // 20030417AH - removeNode("button_divider_1",false); if (!_edit) { // 20030417AH removeNode("cancel_button", false); // 20030417AH } renderLicencePeriod(form, bfpr, rego); // 20030115AH } ActionErrors actionErrors = getRenderingContext().getActionErrors(); bfpr = renderFields(bfpr, rego, _fields); // 20030416AH // 20031105 DDJ: GNDB00016116 - remove the cancel button id, so that it will // not be removed by CompanyProfileRenderer later // 20050324AH - Dont remove, but rather rename as I need to find it again later! Element cancelButton = getElementById("cancel_button", false); if (cancelButton != null) { // 20050324AH - co: cancelButton.removeAttribute("id"); cancelButton.setAttribute("id", "cancel_button_id"); // 20050324AH } renderEmbeddedProfile(); if (actionErrors != null) { ActionError prodKey = MessageUtils.getFirstError(actionErrors, "prodKey"); if (prodKey != null) { renderLabel("prodKey_error", prodKey.getKey()); } ActionError responseError = MessageUtils.getFirstError(actionErrors, "error"); if (responseError != null) { renderLabel("response_error", responseError.getKey()); } } renderTabs(rContext, "registrationTab", _tabs); // 20021217AH if (IGTRegistrationInfoEntity.REG_STATE_EXPIRED.equals(state)) { // 20030502AH renderLabelCarefully( "expired_message", "registrationInfo.registrationState.expired.message", false); // 20050324AH - Hide non editable fields from non-admin users IGTSession gtasSession = rego.getSession(); if (!gtasSession.isAdmin()) { removeNode("licFile_details", false); removeNode("ok_button", false); removeNode("help_button", false); removeNode("cancel_button_id", false); } // ... } else { removeNode("expired_message", false); } } catch (Throwable t) { throw new RenderingException("Error rendering registrationInfo screen", t); } }