[ 
https://issues.apache.org/jira/browse/SOLR-183?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ryan McKinley updated SOLR-183:
-------------------------------

    Attachment: SOLR-183-required-param.patch

This adds a RequiredSolrParams class that wraps most of the getXXX() functions 
and makes sure the value exists and is valid.

the case Hoss mentioned:
 Integer bar = required.getInt( "yak", null ); 

isn't possible since getInt() takes an 'int' not an Integer as the default

I put the class in "org.apache.solr.util" rather then "org.apache.solr.request" 
- I'm really hoping with SOLR-135 most of the general non-lucene based helper 
classes can be in "util"

You'll notice some of the code style is a little non-standard - that helps my 
dyslexic head keep stuff straight (at least sometimes).

Yonik - there are no extra hash lookups with this.



> add getRequiredParameter() to SolrParams
> ----------------------------------------
>
>                 Key: SOLR-183
>                 URL: https://issues.apache.org/jira/browse/SOLR-183
>             Project: Solr
>          Issue Type: Wish
>            Reporter: Ryan McKinley
>            Priority: Trivial
>         Attachments: SOLR-183-required-param.patch, 
> SOLR-183-required-param.patch
>
>
> I find myself including this with every patch, so i'll just separate it out.  
> This simply adds a utilty function to SolrParams that throws a 400 if the 
> parameter is missing:
> /** returns the value of the param, or throws a 400 exception if missing */
>   public String getRequiredParameter(String param) throws SolrException {
>     String val = get(param);
>     if( val == null ) {
>       throw new SolrException( 400, "Missing parameter: "+param );
>     }
>     return val;
>   }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to