@Override public T parse(FhirContext theContext, String theName, List<QualifiedParamList> theParams) throws InternalErrorException, InvalidRequestException { if (theParams.size() == 0 || theParams.get(0).size() == 0) { return null; } if (theParams.size() > 1 || theParams.get(0).size() > 1) { throw new InvalidRequestException("Multiple values detected for non-repeatable parameter '" + theName + "'. This server is not configured to allow multiple (AND) values for this param."); } T value = doParse(theParams.get(0).get(0)); return value; }
@Override public IQueryParameterType parse(FhirContext theContext, String theParamName, List<QualifiedParamList> theParams) throws InternalErrorException, InvalidRequestException { String value = theParams.get(0).get(0); if (StringUtils.isBlank(value)) { return null; } IQueryParameterType dt = super.newInstance(); if (theParams.size() == 0 || theParams.get(0).size() == 0) { return dt; } if (theParams.size() > 1 || theParams.get(0).size() > 1) { throw new InvalidRequestException("Multiple values detected for non-repeatable parameter '" + theParamName + "'. This server is not configured to allow multiple (AND/OR) values for this param."); } dt.setValueAsQueryToken(theContext, theParamName, theParams.get(0).getQualifier(), value); return dt; }
@Override public void setValuesAsQueryTokens(FhirContext theContext, String theParamName, QualifiedParamList theParameters) { if (theParameters.isEmpty()) { return; } if (theParameters.size() > 1) { throw new IllegalArgumentException( "Type " + theParam.getClass().getCanonicalName() + " does not support multiple values"); } theParam.setValueAsQueryToken(theContext, theParamName, theParameters.getQualifier(), theParameters.get(0)); } };
@Override public IQueryParameterOr<?> parse(FhirContext theContext, String theParamName, List<QualifiedParamList> theString) throws InternalErrorException, InvalidRequestException { IQueryParameterOr<?> dt; try { dt = newInstance(); if (theString.size() == 0 || theString.get(0).size() == 0) { return dt; } if (theString.size() > 1) { throw new InvalidRequestException("Multiple values detected for non-repeatable parameter '" + theParamName + "'. This server is not configured to allow multiple (AND/OR) values for this param."); } dt.setValuesAsQueryTokens(theContext, theParamName, theString.get(0)); } catch (SecurityException e) { throw new InternalErrorException(e); } return dt; } }
@Override public void setValuesAsQueryTokens(FhirContext theContext, String theParamName, QualifiedParamList theParameters) { setMissing(null); setPrefix(null); setValueAsString(null); if (theParameters.size() == 1) { setValueAsString(theParameters.get(0)); } else if (theParameters.size() > 1) { throw new InvalidRequestException("This server does not support multi-valued dates for this parameter: " + theParameters); } }
@Override public void setValuesAsQueryTokens(FhirContext theContext, String theParamName, List<QualifiedParamList> theParameters) throws InvalidRequestException { boolean haveHadUnqualifiedParameter = false; for (QualifiedParamList paramList : theParameters) { if (paramList.size() == 0) { continue; } if (paramList.size() > 1) { throw new InvalidRequestException("DateRange parameter does not suppport OR queries"); } String param = paramList.get(0); /* * Since ' ' is escaped as '+' we'll be nice to anyone might have accidentally not * escaped theirs */ param = param.replace(' ', '+'); DateParam parsed = new DateParam(); parsed.setValueAsQueryToken(theContext, theParamName, paramList.getQualifier(), param); addParam(parsed); if (parsed.getPrefix() == null) { if (haveHadUnqualifiedParameter) { throw new InvalidRequestException("Multiple date parameters with the same name and no qualifier (>, <, etc.) is not supported"); } haveHadUnqualifiedParameter = true; } } }
continue; if (nextParamList.size() > 1) { throw new InvalidRequestException(theContext.getLocalizer().getMessage(IncludeParameter.class, "orIncludeInRequest"));
continue; if (nextParamList.size() > 1) { throw new InvalidRequestException(theContext.getLocalizer().getMessage(IncludeParameter.class, "orIncludeInRequest"));
if (paramList.size() > 0 && paramList.get(0).size() > 0) { String intString = paramList.get(0).get(0); try {
@Override public T parse(FhirContext theContext, String theName, List<QualifiedParamList> theParams) throws InternalErrorException, InvalidRequestException { if (theParams.size() == 0 || theParams.get(0).size() == 0) { return null; } if (theParams.size() > 1 || theParams.get(0).size() > 1) { throw new InvalidRequestException("Multiple values detected for non-repeatable parameter '" + theName + "'. This server is not configured to allow multiple (AND) values for this param."); } T value = doParse(theParams.get(0).get(0)); return value; }
@Override public IQueryParameterType parse(FhirContext theContext, String theParamName, List<QualifiedParamList> theParams) throws InternalErrorException, InvalidRequestException { String value = theParams.get(0).get(0); if (StringUtils.isBlank(value)) { return null; } IQueryParameterType dt = super.newInstance(); if (theParams.size() == 0 || theParams.get(0).size() == 0) { return dt; } if (theParams.size() > 1 || theParams.get(0).size() > 1) { throw new InvalidRequestException("Multiple values detected for non-repeatable parameter '" + theParamName + "'. This server is not configured to allow multiple (AND/OR) values for this param."); } dt.setValueAsQueryToken(theContext, theParamName, theParams.get(0).getQualifier(), value); return dt; }
@Override public void setValuesAsQueryTokens(FhirContext theContext, String theParamName, QualifiedParamList theParameters) { if (theParameters.isEmpty()) { return; } if (theParameters.size() > 1) { throw new IllegalArgumentException( "Type " + theParam.getClass().getCanonicalName() + " does not support multiple values"); } theParam.setValueAsQueryToken(theContext, theParamName, theParameters.getQualifier(), theParameters.get(0)); } };
@Override public IQueryParameterOr<?> parse(FhirContext theContext, String theParamName, List<QualifiedParamList> theString) throws InternalErrorException, InvalidRequestException { IQueryParameterOr<?> dt; try { dt = newInstance(); if (theString.size() == 0 || theString.get(0).size() == 0) { return dt; } if (theString.size() > 1) { throw new InvalidRequestException("Multiple values detected for non-repeatable parameter '" + theParamName + "'. This server is not configured to allow multiple (AND/OR) values for this param."); } dt.setValuesAsQueryTokens(theContext, theParamName, theString.get(0)); } catch (SecurityException e) { throw new InternalErrorException(e); } return dt; } }
@Override public void setValuesAsQueryTokens(FhirContext theContext, String theParamName, QualifiedParamList theParameters) { setMissing(null); setPrefix(null); setValueAsString(null); if (theParameters.size() == 1) { setValueAsString(theParameters.get(0)); } else if (theParameters.size() > 1) { throw new InvalidRequestException("This server does not support multi-valued dates for this parameter: " + theParameters); } }
@Override public void setValuesAsQueryTokens(FhirContext theContext, String theParamName, List<QualifiedParamList> theParameters) throws InvalidRequestException { boolean haveHadUnqualifiedParameter = false; for (QualifiedParamList paramList : theParameters) { if (paramList.size() == 0) { continue; } if (paramList.size() > 1) { throw new InvalidRequestException("DateRange parameter does not suppport OR queries"); } String param = paramList.get(0); /* * Since ' ' is escaped as '+' we'll be nice to anyone might have accidentally not * escaped theirs */ param = param.replace(' ', '+'); DateParam parsed = new DateParam(); parsed.setValueAsQueryToken(theContext, theParamName, paramList.getQualifier(), param); addParam(parsed); if (parsed.getPrefix() == null) { if (haveHadUnqualifiedParameter) { throw new InvalidRequestException("Multiple date parameters with the same name and no qualifier (>, <, etc.) is not supported"); } haveHadUnqualifiedParameter = true; } } }
continue; if (nextParamList.size() > 1) { throw new InvalidRequestException(theContext.getLocalizer().getMessage(IncludeParameter.class, "orIncludeInRequest"));
continue; if (nextParamList.size() > 1) { throw new InvalidRequestException(theContext.getLocalizer().getMessage(IncludeParameter.class, "orIncludeInRequest"));