Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ParameterRepositoryService |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright 2006-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 | ||
17 | package org.kuali.rice.core.api.parameter; | |
18 | ||
19 | import java.util.Collection; | |
20 | ||
21 | import javax.jws.WebMethod; | |
22 | import javax.jws.WebParam; | |
23 | import javax.jws.WebResult; | |
24 | import javax.jws.WebService; | |
25 | import javax.jws.soap.SOAPBinding; | |
26 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; | |
27 | ||
28 | import org.kuali.rice.core.api.CoreConstants; | |
29 | import org.kuali.rice.core.api.criteria.QueryByCriteria; | |
30 | import org.kuali.rice.core.api.exception.RiceIllegalArgumentException; | |
31 | import org.kuali.rice.core.api.exception.RiceIllegalStateException; | |
32 | import org.kuali.rice.core.jaxb.ImmutableCollectionAdapter; | |
33 | ||
34 | /** | |
35 | * Service for interacting with {@link Parameter Parameters}. | |
36 | */ | |
37 | @WebService(name = "parameterServiceSoap", 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 | * @throws IllegalArgumentException if the parameter is null | |
46 | * @throws IllegalStateException if the parameter is already existing in the system | |
47 | */ | |
48 | @WebMethod(operationName="createParameter") | |
49 | void createParameter(@WebParam(name = "parameter") Parameter parameter) | |
50 | throws RiceIllegalArgumentException, RiceIllegalStateException; | |
51 | ||
52 | /** | |
53 | * This will update a {@link Parameter}. | |
54 | * | |
55 | * <p> | |
56 | * If the parameter does not exist under the application | |
57 | * code passed, then this method will check if the parameter | |
58 | * exists under the default rice application code and | |
59 | * will update that parameter. | |
60 | * </p> | |
61 | * | |
62 | * @param parameter the parameter to update | |
63 | * @throws IllegalArgumentException if the parameter is null | |
64 | * @throws IllegalStateException if the parameter does not exist in the system under the | |
65 | * specific application code or default rice application code | |
66 | */ | |
67 | @WebMethod(operationName="updateParameter") | |
68 | void updateParameter(@WebParam(name = "parameter") Parameter parameter) | |
69 | throws RiceIllegalArgumentException, RiceIllegalStateException; | |
70 | ||
71 | /** | |
72 | * Gets a {@link Parameter} from a {@link ParameterKey}. | |
73 | * | |
74 | * <p> | |
75 | * If the parameter does not exist under the application | |
76 | * code passed, then this method will check if the parameter | |
77 | * exists under the default rice application code and | |
78 | * will return that parameter. | |
79 | * </p> | |
80 | * | |
81 | * <p> | |
82 | * This method will return null if the parameter does not exist. | |
83 | * </p> | |
84 | * | |
85 | * @param key the key to retrieve the parameter by. cannot be null. | |
86 | * @return a {@link Parameter} or null | |
87 | * @throws IllegalArgumentException if the key is null | |
88 | */ | |
89 | @WebMethod(operationName="getParameter") | |
90 | @WebResult(name = "parameter") | |
91 | Parameter getParameter(@WebParam(name = "key") ParameterKey key) throws RiceIllegalArgumentException; | |
92 | ||
93 | /** | |
94 | * Gets a {@link ParameterContract#getValue()} from a {@link ParameterKey}. | |
95 | * | |
96 | * <p> | |
97 | * If the parameter does not exist under the application | |
98 | * code passed, then this method will check if the parameter | |
99 | * exists under the default rice application code and | |
100 | * will return that parameter. | |
101 | * </p> | |
102 | * | |
103 | * <p> | |
104 | * This method will return null if the parameter does not exist. | |
105 | * </p> | |
106 | * | |
107 | * @param key the key to retrieve the parameter by. cannot be null. | |
108 | * @return a string value or null | |
109 | * @throws IllegalArgumentException if the key is null | |
110 | */ | |
111 | @WebMethod(operationName="getParameterValueAsString") | |
112 | @WebResult(name = "value") | |
113 | String getParameterValueAsString(@WebParam(name = "key") ParameterKey key); | |
114 | ||
115 | /** | |
116 | * Gets a {@link ParameterContract#getValue()} as a Boolean from a {@link ParameterKey}. | |
117 | * | |
118 | * <p> | |
119 | * If the parameter does not exist under the application | |
120 | * code passed, then this method will check if the parameter | |
121 | * exists under the default rice application code and | |
122 | * will return that parameter. | |
123 | * </p> | |
124 | * | |
125 | * <p> | |
126 | * This method will return null if the parameter does not exist or is not a valid truth value. | |
127 | * </p> | |
128 | * | |
129 | * valid truth values (case insensitive): | |
130 | * <ul> | |
131 | * <li>Y</li> | |
132 | * <li>true</li> | |
133 | * <li>N</li> | |
134 | * <li>false</li> | |
135 | * </ul> | |
136 | * | |
137 | * @param key the key to retrieve the parameter by. cannot be null. | |
138 | * @return a boolean value or null | |
139 | * @throws IllegalArgumentException if the key is null | |
140 | */ | |
141 | @WebMethod(operationName="getParameterValueAsBoolean") | |
142 | @WebResult(name = "value") | |
143 | Boolean getParameterValueAsBoolean(@WebParam(name = "key") ParameterKey key); | |
144 | ||
145 | /** | |
146 | * Gets a {@link ParameterContract#getValue()} from a {@link ParameterKey} | |
147 | * where the value is split on a semi-colon delimeter and each token is trimmed | |
148 | * of white space. | |
149 | * | |
150 | * for example: param_name=foo; bar; baz | |
151 | * | |
152 | * will yield a collection containing foo, bar, baz | |
153 | * | |
154 | * <p> | |
155 | * If the parameter does not exist under the application | |
156 | * code passed, then this method will check if the parameter | |
157 | * exists under the default rice application code and | |
158 | * will return that parameter. | |
159 | * </p> | |
160 | * | |
161 | * <p> | |
162 | * This method will always return an <b>immutable</b> Collection | |
163 | * even when no values exist. | |
164 | * </p> | |
165 | * | |
166 | * @param key the key to retrieve the parameter by. cannot be null. | |
167 | * @return an immutable collection of strings | |
168 | * @throws IllegalArgumentException if the key is null | |
169 | */ | |
170 | @WebMethod(operationName="getParameterValuesAsString") | |
171 | @WebResult(name = "values") | |
172 | @XmlJavaTypeAdapter(ImmutableCollectionAdapter.class) | |
173 | Collection<String> getParameterValuesAsString(@WebParam(name = "key") ParameterKey key); | |
174 | ||
175 | /** | |
176 | * Gets a {@link ParameterContract#getValue()} from a {@link ParameterKey} | |
177 | * where the value is split on a semi-colon delimeter and each token is trimmed | |
178 | * of white space. Those values are themselves keyvalue pairs which are searched | |
179 | * for the sub parameter name. | |
180 | * | |
181 | * for example: | |
182 | * | |
183 | * param_name=foo=f1; bar=b1; baz=z1 | |
184 | * subParameterName=bar | |
185 | * | |
186 | * will yield b1 | |
187 | * | |
188 | * <p>if multiple subparameters are contained in the parameter value the first one is returned</p> | |
189 | * | |
190 | * <p> | |
191 | * If the parameter does not exist under the application | |
192 | * code passed, then this method will check if the parameter | |
193 | * exists under the default rice application code and | |
194 | * will return that parameter. | |
195 | * </p> | |
196 | * | |
197 | * <p> | |
198 | * This method will always return null when the subparameter does not | |
199 | * exist or if the parameter value does not conform to the following format(s): | |
200 | * <ol> | |
201 | * <li>subparameter_name=subparameter_value;</li> | |
202 | * </ol> | |
203 | * </p> | |
204 | * | |
205 | * @param key the key to retrieve the parameter by. cannot be null. | |
206 | * @param subParameterName the sub parameter to search for | |
207 | * @return a string value or null | |
208 | * @throws IllegalArgumentException if the key is null or if the subParameterName is blank | |
209 | */ | |
210 | @WebMethod(operationName="getSubParameterValueAsString") | |
211 | @WebResult(name = "value") | |
212 | String getSubParameterValueAsString(@WebParam(name = "key") ParameterKey key, | |
213 | @WebParam(name = "subParameterName") String subParameterName) | |
214 | throws RiceIllegalArgumentException; | |
215 | ||
216 | /** | |
217 | * Gets a {@link ParameterContract#getValue()} from a {@link ParameterKey} | |
218 | * where the value is split on a semi-colon delimeter and each token is trimmed | |
219 | * of white space. Those values are themselves keyvalue pairs which are searched | |
220 | * for the sub parameter name. After the sub parameter is found it is split on a comma | |
221 | * and trimmed or whitespace before adding it to the final collection for return. | |
222 | * | |
223 | * for example: | |
224 | * | |
225 | * param_name=foo=f1,f2,f3; bar=b1,b2; baz=z1 | |
226 | * subParameterName=bar | |
227 | * | |
228 | * will yield a collection containing b1, b2 | |
229 | * | |
230 | * <p>if multiple subparameters are contained in the parameter value the first one is returned</p> | |
231 | * | |
232 | * <p> | |
233 | * If the parameter does not exist under the application | |
234 | * code passed, then this method will check if the parameter | |
235 | * exists under the default rice application code and | |
236 | * will return that parameter. | |
237 | * </p> | |
238 | * | |
239 | * <p> | |
240 | * This method will always return an <b>immutable</b> Collection | |
241 | * even when no values exist. | |
242 | * </p> | |
243 | * | |
244 | * <p> | |
245 | * This method will always return an empty <b>immutable</b> Collection when | |
246 | * the subparameter does not exist or if the parameter value does not | |
247 | * conform to the following format(s): | |
248 | * <ol> | |
249 | * <li>subparameter_name=subparameter_value;</li> | |
250 | * <li>subparameter_name=subparameter_value1, subparameter_value2;</li> | |
251 | * <li>subparameter_name=subparameter_value1, subparameter_value2,;</li> | |
252 | * </ol> | |
253 | * </p> | |
254 | * | |
255 | * @param key the key to retrieve the parameter by. cannot be null. | |
256 | * @param subParameterName the sub parameter to search for | |
257 | * @return an immutable collection of strings | |
258 | * @throws IllegalArgumentException if the key is null or if the subParameterName is blank | |
259 | */ | |
260 | @WebMethod(operationName="getSubParameterValuesAsString") | |
261 | @WebResult(name = "values") | |
262 | @XmlJavaTypeAdapter(ImmutableCollectionAdapter.class) | |
263 | Collection<String> getSubParameterValuesAsString(@WebParam(name = "key") ParameterKey key, | |
264 | @WebParam(name = "subParameterName") String subParameterName) | |
265 | throws RiceIllegalArgumentException; | |
266 | ||
267 | @WebMethod(operationName="findParameters") | |
268 | @WebResult(name = "results") | |
269 | ParameterQueryResults findParameters(@WebParam(name = "query") QueryByCriteria<Parameter> queryByCriteria); | |
270 | } |