Example #1
0
 protected ValidationErrors validateMandatory() {
   ValidationErrors errors = new ValidationErrors();
   for (RequestParam p : getMandatoryParams()) {
     if (p.isEmpty()) {
       errors.append(p.getName(), "Please specify a value, " + p.getName() + " is required");
     }
   }
   return errors;
 }
 /**
  * Is this action input parameter required.
  *
  * @return true if required
  */
 public boolean isRequired() {
   boolean ret;
   if (isRequestBody()) {
     ret = requestBody.required();
   } else if (isRequestParam()) {
     ret = !(isDefined(requestParam.defaultValue()) || !requestParam.required());
   } else if (isRequestHeader()) {
     ret = !(isDefined(requestHeader.defaultValue()) || !requestHeader.required());
   } else {
     ret = true;
   }
   return ret;
 }
 /**
  * Determines default value of request param or request header, if available.
  *
  * @return value or null
  */
 public String getDefaultValue() {
   String ret;
   if (isRequestParam()) {
     ret = isDefined(requestParam.defaultValue()) ? requestParam.defaultValue() : null;
   } else if (isRequestHeader()) {
     ret =
         !(ValueConstants.DEFAULT_NONE.equals(requestHeader.defaultValue()))
             ? requestHeader.defaultValue()
             : null;
   } else {
     ret = null;
   }
   return ret;
 }
Example #4
0
 protected void addParam(RequestParam param, boolean isMandatory) {
   paramMap.put(param.getName(), param);
   if (isMandatory) {
     mandatoryParamSet.add(param);
   }
 }