Coverage Report - org.kuali.rice.core.api.parameter.ParameterRepositoryService
 
Classes in this File Line Coverage Branch Coverage Complexity
ParameterRepositoryService
N/A
N/A
1
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.core.api.parameter;
 17  
 
 18  
 import org.kuali.rice.core.api.CoreConstants;
 19  
 import org.kuali.rice.core.api.criteria.QueryByCriteria;
 20  
 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
 21  
 import org.kuali.rice.core.api.exception.RiceIllegalStateException;
 22  
 import org.springframework.cache.annotation.CacheEvict;
 23  
 import org.springframework.cache.annotation.Cacheable;
 24  
 
 25  
 import javax.jws.WebMethod;
 26  
 import javax.jws.WebParam;
 27  
 import javax.jws.WebResult;
 28  
 import javax.jws.WebService;
 29  
 import javax.jws.soap.SOAPBinding;
 30  
 import javax.xml.bind.annotation.XmlElement;
 31  
 import javax.xml.bind.annotation.XmlElementWrapper;
 32  
 import java.util.Collection;
 33  
 
 34  
 /**
 35  
  * Service for interacting with {@link Parameter Parameters}.
 36  
  */
 37  
 @WebService(name = "parameterService", targetNamespace = CoreConstants.Namespaces.CORE_NAMESPACE_2_0)
 38  
 @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
 39  
 public interface ParameterRepositoryService {
 40  
 
 41  
     /**
 42  
      * This will create a {@link Parameter} exactly like the parameter passed in.
 43  
      *
 44  
      * @param parameter the parameter to create
 45  
      * @return the parameter that was created
 46  
      * @throws IllegalArgumentException if the parameter is null
 47  
      * @throws IllegalStateException if the parameter is already existing in the system
 48  
      */
 49  
     @WebMethod(operationName="createParameter")
 50  
     @WebResult(name = "parameter")
 51  
     @CacheEvict(value={Parameter.Cache.NAME}, allEntries = true)
 52  
     Parameter createParameter(@WebParam(name = "parameter") Parameter parameter)
 53  
             throws RiceIllegalArgumentException, RiceIllegalStateException;
 54  
 
 55  
     /**
 56  
      * This will update a {@link Parameter}.
 57  
      *
 58  
      *  <p>
 59  
      *     If the parameter does not exist under the application
 60  
      *     code passed, then this method will check if the parameter
 61  
      *     exists under the default rice application id and
 62  
      *     will update that parameter.
 63  
      * </p>
 64  
      *
 65  
      * @param parameter the parameter to update
 66  
      * @return the parameter that was updated
 67  
      * @throws IllegalArgumentException if the parameter is null
 68  
      * @throws IllegalStateException if the parameter does not exist in the system under the
 69  
      * specific application id or default rice application id
 70  
      */
 71  
     @WebMethod(operationName="updateParameter")
 72  
     @WebResult(name = "parameter")
 73  
     @CacheEvict(value={Parameter.Cache.NAME}, allEntries = true)
 74  
     Parameter updateParameter(@WebParam(name = "parameter") Parameter parameter)
 75  
             throws RiceIllegalArgumentException, RiceIllegalStateException;
 76  
 
 77  
     /**
 78  
      * Gets a {@link Parameter} from a {@link ParameterKey}.
 79  
      *
 80  
      * <p>
 81  
      *     If the parameter does not exist under the application
 82  
      *     code passed, then this method will check if the parameter
 83  
      *     exists under the default rice application id and
 84  
      *     will return that parameter.
 85  
      * </p>
 86  
      *
 87  
      * <p>
 88  
      *   This method will return null if the parameter does not exist.
 89  
      * </p>
 90  
      *
 91  
      * @param key the key to retrieve the parameter by. cannot be null.
 92  
      * @return a {@link Parameter} or null
 93  
      * @throws IllegalArgumentException if the key is null
 94  
      */
 95  
     @WebMethod(operationName="getParameter")
 96  
     @WebResult(name = "parameter")
 97  
     @Cacheable(value= Parameter.Cache.NAME, key="'key=' + #p0.hashCode()")
 98  
     Parameter getParameter(@WebParam(name = "key") ParameterKey key) throws RiceIllegalArgumentException;
 99  
 
 100  
     /**
 101  
      * Gets a {@link ParameterContract#getValue()} from a {@link ParameterKey}.
 102  
      *
 103  
      *  <p>
 104  
      *     If the parameter does not exist under the application
 105  
      *     code passed, then this method will check if the parameter
 106  
      *     exists under the default rice application id and
 107  
      *     will return that parameter.
 108  
      * </p>
 109  
      *
 110  
      * <p>
 111  
      *   This method will return null if the parameter does not exist.
 112  
      * </p>
 113  
      *
 114  
      * @param key the key to retrieve the parameter by. cannot be null.
 115  
      * @return a string value or null
 116  
      * @throws IllegalArgumentException if the key is null
 117  
      */
 118  
     @WebMethod(operationName="getPropertyValueAsString")
 119  
     @WebResult(name = "value")
 120  
     @Cacheable(value= Parameter.Cache.NAME, key="'{getParameterValueAsString}' + 'key=' + #p0.hashCode()")
 121  
     String getParameterValueAsString(@WebParam(name = "key") ParameterKey key) throws RiceIllegalArgumentException;
 122  
 
 123  
     /**
 124  
      * Gets a {@link ParameterContract#getValue()} as a Boolean from a {@link ParameterKey}.
 125  
      *
 126  
      * <p>
 127  
      *     If the parameter does not exist under the application
 128  
      *     code passed, then this method will check if the parameter
 129  
      *     exists under the default rice application id and
 130  
      *     will return that parameter.
 131  
      * </p>
 132  
      *
 133  
      * <p>
 134  
      *   This method will return null if the parameter does not exist or is not a valid truth value.
 135  
      * </p>
 136  
      *
 137  
      * valid true values (case insensitive):
 138  
      * <ul>
 139  
      *     <li>Y</li>
 140  
      *     <li>true</li>
 141  
      *     <li>on</li>
 142  
      *     <li>1</li>
 143  
      *     <li>t</li>
 144  
      *     <li>enabled</li>
 145  
      * </ul>
 146  
      *
 147  
      * valid false values (case insensitive):
 148  
      * <ul>
 149  
      *     <li>N</li>
 150  
      *     <li>false</li>
 151  
      *     <li>off</li>
 152  
      *     <li>0</li>
 153  
      *     <li>f</li>
 154  
      *     <li>disabled</li>
 155  
      * </ul>
 156  
      *
 157  
      * @param key the key to retrieve the parameter by. cannot be null.
 158  
      * @return a boolean value or null
 159  
      * @throws IllegalArgumentException if the key is null
 160  
      */
 161  
     @WebMethod(operationName="getParameterValueAsBoolean")
 162  
     @WebResult(name = "value")
 163  
     @Cacheable(value= Parameter.Cache.NAME, key="'{getParameterValueAsBoolean}' + 'key=' + #p0.hashCode()")
 164  
     Boolean getParameterValueAsBoolean(@WebParam(name = "key") ParameterKey key) throws RiceIllegalArgumentException;
 165  
 
 166  
     /**
 167  
      * Gets a {@link ParameterContract#getValue()} from a {@link ParameterKey}
 168  
      * where the value is split on a semi-colon delimeter and each token is trimmed
 169  
      * of white space.
 170  
      *
 171  
      * for example:  param_name=foo; bar; baz
 172  
      *
 173  
      * will yield a collection containing foo, bar, baz
 174  
      *
 175  
      * <p>
 176  
      *     If the parameter does not exist under the application
 177  
      *     code passed, then this method will check if the parameter
 178  
      *     exists under the default rice application id and
 179  
      *     will return that parameter.
 180  
      * </p>
 181  
      *
 182  
      * <p>
 183  
      *   This method will always return an <b>immutable</b> Collection
 184  
      *   even when no values exist.
 185  
      * </p>
 186  
      *
 187  
      * @param key the key to retrieve the parameter by. cannot be null.
 188  
      * @return an immutable collection of strings
 189  
      * @throws IllegalArgumentException if the key is null
 190  
      */
 191  
     @WebMethod(operationName="getParameterValuesAsString")
 192  
     @XmlElementWrapper(name = "values", required = true)
 193  
     @XmlElement(name = "value", required = false)
 194  
     @WebResult(name = "values")
 195  
     @Cacheable(value= Parameter.Cache.NAME, key="'{getParameterValuesAsString}' + 'key=' + #p0.hashCode()")
 196  
     Collection<String> getParameterValuesAsString(@WebParam(name = "key") ParameterKey key) throws RiceIllegalArgumentException;
 197  
 
 198  
     /**
 199  
      * Gets a {@link ParameterContract#getValue()} from a {@link ParameterKey}
 200  
      * where the value is split on a semi-colon delimeter and each token is trimmed
 201  
      * of white space.  Those values are themselves keyvalue pairs which are searched
 202  
      * for the sub parameter name.
 203  
      *
 204  
      * for example:
 205  
      *
 206  
      * param_name=foo=f1; bar=b1; baz=z1
 207  
      * subParameterName=bar
 208  
      *
 209  
      * will yield b1
 210  
      *
 211  
      * <p>if multiple subparameters are contained in the parameter value the first one is returned</p>
 212  
      *
 213  
      * <p>
 214  
      *     If the parameter does not exist under the application
 215  
      *     code passed, then this method will check if the parameter
 216  
      *     exists under the default rice application id and
 217  
      *     will return that parameter.
 218  
      * </p>
 219  
      *
 220  
      * <p>
 221  
      *   This method will always return null when the subparameter does not
 222  
      *   exist or if the parameter value does not conform to the following format(s):
 223  
      *   <ol>
 224  
      *      <li>subparameter_name=subparameter_value;</li>
 225  
      *   </ol>
 226  
      * </p>
 227  
      *
 228  
      * @param key the key to retrieve the parameter by. cannot be null.
 229  
      * @param subParameterName the sub parameter to search for
 230  
      * @return a string value or null
 231  
      * @throws IllegalArgumentException if the key is null or if the subParameterName is blank
 232  
      */
 233  
     @WebMethod(operationName="getSubParameterValueAsString")
 234  
     @WebResult(name = "value")
 235  
     @Cacheable(value= Parameter.Cache.NAME, key="'{getSubParameterValueAsString}' + 'key=' + #p0.hashCode() + '|' + 'subParameterName=' + #p1")
 236  
     String getSubParameterValueAsString(@WebParam(name = "key") ParameterKey key,
 237  
                                         @WebParam(name = "subParameterName") String subParameterName)
 238  
             throws RiceIllegalArgumentException;
 239  
 
 240  
     /**
 241  
      * Gets a {@link ParameterContract#getValue()} from a {@link ParameterKey}
 242  
      * where the value is split on a semi-colon delimeter and each token is trimmed
 243  
      * of white space.  Those values are themselves keyvalue pairs which are searched
 244  
      * for the sub parameter name.  After the sub parameter is found it is split on a comma
 245  
      * and trimmed or whitespace before adding it to the final collection for return.
 246  
      *
 247  
      * for example:
 248  
      *
 249  
      * param_name=foo=f1,f2,f3; bar=b1,b2; baz=z1
 250  
      * subParameterName=bar
 251  
      *
 252  
      * will yield a collection containing b1, b2
 253  
      *
 254  
      * <p>if multiple subparameters are contained in the parameter value the first one is returned</p>
 255  
      *
 256  
      * <p>
 257  
      *     If the parameter does not exist under the application
 258  
      *     code passed, then this method will check if the parameter
 259  
      *     exists under the default rice application id and
 260  
      *     will return that parameter.
 261  
      * </p>
 262  
      *
 263  
      * <p>
 264  
      *   This method will always return an <b>immutable</b> Collection
 265  
      *   even when no values exist.
 266  
      * </p>
 267  
      *
 268  
      *  <p>
 269  
      *   This method will always return an empty <b>immutable</b> Collection when
 270  
      *   the subparameter does not exist or if the parameter value does not
 271  
      *   conform to the following format(s):
 272  
      *   <ol>
 273  
      *      <li>subparameter_name=subparameter_value;</li>
 274  
      *      <li>subparameter_name=subparameter_value1, subparameter_value2;</li>
 275  
      *      <li>subparameter_name=subparameter_value1, subparameter_value2,;</li>
 276  
      *   </ol>
 277  
      * </p>
 278  
      *
 279  
      * @param key the key to retrieve the parameter by. cannot be null.
 280  
      * @param subParameterName the sub parameter to search for
 281  
      * @return an immutable collection of strings
 282  
      * @throws IllegalArgumentException if the key is null or if the subParameterName is blank
 283  
      */
 284  
     @WebMethod(operationName="getSubParameterValuesAsString")
 285  
     @XmlElementWrapper(name = "values", required = true)
 286  
     @XmlElement(name = "value", required = false)
 287  
     @WebResult(name = "values")
 288  
     @Cacheable(value= Parameter.Cache.NAME, key="'{getSubParameterValuesAsString}' + 'key=' + #p0.hashCode() + '|' + 'subParameterName=' + #p1")
 289  
     Collection<String> getSubParameterValuesAsString(@WebParam(name = "key") ParameterKey key,
 290  
                                                      @WebParam(name = "subParameterName") String subParameterName)
 291  
             throws RiceIllegalArgumentException;
 292  
     
 293  
     @WebMethod(operationName="findParameters")
 294  
     @WebResult(name = "results")
 295  
     ParameterQueryResults findParameters(@WebParam(name = "query") QueryByCriteria queryByCriteria) throws RiceIllegalArgumentException;
 296  
 }