| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ResponsibilityService |
|
| 1.0;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.kim.api.responsibility; | |
| 17 | ||
| 18 | import org.kuali.rice.core.api.criteria.QueryByCriteria; | |
| 19 | import org.kuali.rice.core.api.exception.RiceIllegalArgumentException; | |
| 20 | import org.kuali.rice.core.api.exception.RiceIllegalStateException; | |
| 21 | import org.kuali.rice.core.api.util.jaxb.MapStringStringAdapter; | |
| 22 | import org.kuali.rice.kim.api.KimConstants; | |
| 23 | import org.kuali.rice.kim.api.common.template.Template; | |
| 24 | import org.kuali.rice.kim.api.common.template.TemplateQueryResults; | |
| 25 | import org.springframework.cache.annotation.CacheEvict; | |
| 26 | import org.springframework.cache.annotation.Cacheable; | |
| 27 | ||
| 28 | import javax.jws.WebMethod; | |
| 29 | import javax.jws.WebParam; | |
| 30 | import javax.jws.WebResult; | |
| 31 | import javax.jws.WebService; | |
| 32 | import javax.jws.soap.SOAPBinding; | |
| 33 | import javax.xml.bind.annotation.XmlElement; | |
| 34 | import javax.xml.bind.annotation.XmlElementWrapper; | |
| 35 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; | |
| 36 | import java.util.List; | |
| 37 | import java.util.Map; | |
| 38 | ||
| 39 | /** | |
| 40 | * This service provides operations for determining what responsibility actions | |
| 41 | * a principal has and for querying about responsibility data. It also provides several | |
| 42 | * write operations. | |
| 43 | * | |
| 44 | * <p> | |
| 45 | * A responsibility represents an action that a principal is requested to | |
| 46 | * take. This is used for defining workflow actions (such as approve, | |
| 47 | * acknowledge, fyi) that the principal has the responsibility to take. The | |
| 48 | * workflow engine integrates with this service to provide responsibility-driven routing. | |
| 49 | * <p/> | |
| 50 | * | |
| 51 | * <p> | |
| 52 | * A responsibility is very similar to a permission in a couple of ways. | |
| 53 | * First of all, responsibilities are always granted to a role, never assigned | |
| 54 | * directly to a principal or group. Furthermore, in a similar fashion to | |
| 55 | * permissions, a role has the concept of a responsibility template. The | |
| 56 | * responsibility template specifies what additional responsibility details | |
| 57 | * need to be defined when the responsibility is created. | |
| 58 | * <p/> | |
| 59 | * | |
| 60 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 61 | */ | |
| 62 | @WebService(name = "responsibilityService", targetNamespace = KimConstants.Namespaces.KIM_NAMESPACE_2_0) | |
| 63 | @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED) | |
| 64 | public interface ResponsibilityService { | |
| 65 | ||
| 66 | /** | |
| 67 | * This will create a {@link Responsibility} exactly like the responsibility passed in. | |
| 68 | * | |
| 69 | * @param responsibility the responsibility to create | |
| 70 | * @return the id of the newly created object. will never be null. | |
| 71 | * @throws IllegalArgumentException if the responsibility is null | |
| 72 | * @throws IllegalStateException if the responsibility is already existing in the system | |
| 73 | */ | |
| 74 | @WebMethod(operationName="createResponsibility") | |
| 75 | @WebResult(name = "responsibility") | |
| 76 | @CacheEvict(value={Responsibility.Cache.NAME, Template.Cache.NAME + "{Responsibility}"}, allEntries = true) | |
| 77 | Responsibility createResponsibility(@WebParam(name = "responsibility") Responsibility responsibility) | |
| 78 | throws RiceIllegalArgumentException, RiceIllegalStateException; | |
| 79 | ||
| 80 | /** | |
| 81 | * This will up ev a {@link Responsibility}. | |
| 82 | * | |
| 83 | * @param responsibility the responsibility to update | |
| 84 | * @throws IllegalArgumentException if the responsibility is null | |
| 85 | * @throws IllegalStateException if the responsibility does not exist in the system | |
| 86 | */ | |
| 87 | @WebMethod(operationName="updateResponsibility") | |
| 88 | @WebResult(name = "responsibility") | |
| 89 | @CacheEvict(value={Responsibility.Cache.NAME, Template.Cache.NAME + "{Responsibility}"}, allEntries = true) | |
| 90 | Responsibility updateResponsibility(@WebParam(name = "responsibility") Responsibility responsibility) | |
| 91 | throws RiceIllegalArgumentException, RiceIllegalStateException; | |
| 92 | ||
| 93 | /** | |
| 94 | * Gets a {@link Responsibility} from an id. | |
| 95 | * | |
| 96 | * <p> | |
| 97 | * This method will return null if the responsibility does not exist. | |
| 98 | * </p> | |
| 99 | * | |
| 100 | * @param id the unique id to retrieve the responsibility by. cannot be null or blank. | |
| 101 | * @return a {@link Responsibility} or null | |
| 102 | * @throws IllegalArgumentException if the id is null or blank | |
| 103 | */ | |
| 104 | @WebMethod(operationName = "getResponsibility") | |
| 105 | @WebResult(name = "responsibility") | |
| 106 | @Cacheable(value=Responsibility.Cache.NAME, key="'id=' + #p0") | |
| 107 | Responsibility getResponsibility(@WebParam(name = "id") String id) throws RiceIllegalArgumentException; | |
| 108 | ||
| 109 | /** | |
| 110 | * Finds a {@link Responsibility} for namespaceCode and name. | |
| 111 | * | |
| 112 | * @param namespaceCode the namespace code. cannot be null or blank. | |
| 113 | * @param name the responsibility name. cannot be null or blank. | |
| 114 | * @return a {@link Responsibility} or null | |
| 115 | * @throws IllegalArgumentException if the id or namespaceCode is null or blank | |
| 116 | */ | |
| 117 | @WebMethod(operationName = "findRespByNamespaceCodeAndName") | |
| 118 | @WebResult(name = "responsibility") | |
| 119 | @Cacheable(value=Responsibility.Cache.NAME, key="'namespaceCode=' + #p0 + '|' + 'name=' + #p1") | |
| 120 | Responsibility findRespByNamespaceCodeAndName(@WebParam(name = "namespaceCode") String namespaceCode, | |
| 121 | @WebParam(name = "name") String name) throws RiceIllegalArgumentException; | |
| 122 | /** | |
| 123 | * Gets a {@link Template} from an id. | |
| 124 | * | |
| 125 | * <p> | |
| 126 | * This method will return null if the template does not exist. | |
| 127 | * </p> | |
| 128 | * | |
| 129 | * @param id the unique id to retrieve the template by. cannot be null or blank. | |
| 130 | * @return a {@link Template} or null | |
| 131 | * @throws IllegalArgumentException if the id is null or blank | |
| 132 | */ | |
| 133 | @WebMethod(operationName = "getResponsibilityTemplate") | |
| 134 | @WebResult(name = "template") | |
| 135 | @Cacheable(value=Template.Cache.NAME + "{Responsibility}", key="'id=' + #p0") | |
| 136 | Template getResponsibilityTemplate(@WebParam(name = "id") String id) throws RiceIllegalArgumentException; | |
| 137 | ||
| 138 | /** | |
| 139 | * Finds a {@link Template} for namespaceCode and name. | |
| 140 | * | |
| 141 | * @param namespaceCode the namespace code. cannot be null or blank. | |
| 142 | * @param name the template name. cannot be null or blank. | |
| 143 | * @return a {@link Template} or null | |
| 144 | * @throws IllegalArgumentException if the id or namespaceCode is null or blank | |
| 145 | */ | |
| 146 | @WebMethod(operationName = "findRespTemplateByNamespaceCodeAndName") | |
| 147 | @WebResult(name = "template") | |
| 148 | @Cacheable(value=Template.Cache.NAME + "{Responsibility}", key="'namespaceCode=' + #p0 + '|' + 'name=' + #p1") | |
| 149 | Template findRespTemplateByNamespaceCodeAndName(@WebParam(name = "namespaceCode") String namespaceCode, | |
| 150 | @WebParam(name = "name") String name) throws RiceIllegalArgumentException; | |
| 151 | /** | |
| 152 | * Checks in a given principal id has a responsibility using the passed in responsibility information. | |
| 153 | * | |
| 154 | * @param principalId the principal id to check. cannot be null or blank. | |
| 155 | * @param namespaceCode the namespace code. cannot be null or blank. | |
| 156 | * @param respName the responsibility name. cannot be null or blank. | |
| 157 | * @param qualification the qualification for the responsibility. cannot be null. | |
| 158 | * @param respDetails the responsibility details. cannot be null. | |
| 159 | * @return true is principal has responsibility | |
| 160 | * @throws IllegalArgumentException if the principalId, namespaceCode, respName is null or blank | |
| 161 | * @throws IllegalArgumentException if the qualification or responsibilityDetails is null | |
| 162 | */ | |
| 163 | @WebMethod(operationName = "hasResponsibility") | |
| 164 | @WebResult(name = "result") | |
| 165 | boolean hasResponsibility(@WebParam(name = "principalId") String principalId, | |
| 166 | @WebParam(name = "namespaceCode") String namespaceCode, | |
| 167 | @WebParam(name = "respName") String respName, | |
| 168 | @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) | |
| 169 | @WebParam(name = "qualification") Map<String, String> qualification, | |
| 170 | @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) | |
| 171 | @WebParam(name = "responsibilityDetails") Map<String, String> respDetails) throws RiceIllegalArgumentException; | |
| 172 | ||
| 173 | /** | |
| 174 | * Checks in a given principal id has a responsibility using the passed in responsibility <b>template</b> information. | |
| 175 | * | |
| 176 | * @param principalId the principal id to check. cannot be null or blank. | |
| 177 | * @param namespaceCode the namespace code. cannot be null or blank. | |
| 178 | * @param respTemplateName the responsibility template name. cannot be null or blank. | |
| 179 | * @param qualification the qualification for the responsibility. cannot be null. | |
| 180 | * @param respDetails the responsibility details. cannot be null. | |
| 181 | * @return true is principal has responsibility | |
| 182 | * @throws IllegalArgumentException if the principalId, namespaceCode, respName is null or blank | |
| 183 | * @throws IllegalArgumentException if the qualification or responsibilityDetails is null | |
| 184 | */ | |
| 185 | @WebMethod(operationName = "hasResponsibilityByTemplateName") | |
| 186 | @WebResult(name = "result") | |
| 187 | boolean hasResponsibilityByTemplateName(@WebParam(name = "principalId") String principalId, | |
| 188 | @WebParam(name = "namespaceCode") String namespaceCode, | |
| 189 | @WebParam(name = "respTemplateName") String respTemplateName, | |
| 190 | @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) | |
| 191 | @WebParam(name = "qualification") Map<String, String> qualification, | |
| 192 | @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) | |
| 193 | @WebParam(name = "respDetails") Map<String, String> respDetails) throws RiceIllegalArgumentException; | |
| 194 | ||
| 195 | /** | |
| 196 | * Gets a List of {@link ResponsibilityAction} based on passed in responsibility information. | |
| 197 | * | |
| 198 | * @param namespaceCode the namespace code. cannot be null or blank. | |
| 199 | * @param respName the responsibility name. cannot be null or blank. | |
| 200 | * @param qualification the qualification for the responsibility. cannot be null. | |
| 201 | * @param respDetails the responsibility details. cannot be null. | |
| 202 | * @return an immutable list of ResponsibilityAction. Will not return null. | |
| 203 | * @throws IllegalArgumentException if the namespaceCode, respName is null or blank | |
| 204 | * @throws IllegalArgumentException if the qualification or respDetails is null | |
| 205 | */ | |
| 206 | @WebMethod(operationName = "getResponsibilityActions") | |
| 207 | @XmlElementWrapper(name = "responsibilityActions", required = true) | |
| 208 | @XmlElement(name = "responsibilityAction", required = false) | |
| 209 | @WebResult(name = "responsibilityActions") | |
| 210 | List<ResponsibilityAction> getResponsibilityActions(@WebParam(name = "namespaceCode") String namespaceCode, | |
| 211 | @WebParam(name = "respName") String respName, | |
| 212 | @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) | |
| 213 | @WebParam(name = "qualification") Map<String, String> qualification, | |
| 214 | @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) | |
| 215 | @WebParam(name = "respDetails") Map<String, String> respDetails) throws RiceIllegalArgumentException; | |
| 216 | ||
| 217 | /** | |
| 218 | * Gets a List of {@link ResponsibilityAction} based on passed in responsibility template information. | |
| 219 | * | |
| 220 | * @param namespaceCode the namespace code. cannot be null or blank. | |
| 221 | * @param respTemplateName the responsibility name. cannot be null or blank. | |
| 222 | * @param qualification the qualification for the responsibility. cannot be null. | |
| 223 | * @param respDetails the responsibility details. cannot be null. | |
| 224 | * @return an immutable list of ResponsibilityAction. Will not return null. | |
| 225 | * @throws IllegalArgumentException if the namespaceCode, respName is null or blank | |
| 226 | * @throws IllegalArgumentException if the qualification or respDetails is null | |
| 227 | */ | |
| 228 | @WebMethod(operationName = "getResponsibilityActionsByTemplateName") | |
| 229 | @XmlElementWrapper(name = "responsibilityActions", required = true) | |
| 230 | @XmlElement(name = "responsibilityAction", required = false) | |
| 231 | @WebResult(name = "responsibilityActions") | |
| 232 | List<ResponsibilityAction> getResponsibilityActionsByTemplateName(@WebParam(name = "namespaceCode") String namespaceCode, | |
| 233 | @WebParam(name = "responsibilityTemplateName") String respTemplateName, | |
| 234 | @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) | |
| 235 | @WebParam(name = "qualification") Map<String, String> qualification, | |
| 236 | @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) | |
| 237 | @WebParam(name = "respDetails") Map<String, String> respDetails) throws RiceIllegalArgumentException; | |
| 238 | ||
| 239 | /** | |
| 240 | * Gets a List of roleIds that the responsibility is associated with. | |
| 241 | * | |
| 242 | * @param id the unique id to retrieve the roleIds for. cannot be null or blank. | |
| 243 | * @param qualification the qualification for the responsibility. cannot be null. | |
| 244 | * @return an immutable list of roleIds. Will not return null. | |
| 245 | * @throws IllegalArgumentException if the id is null or blank or if the qualification is null | |
| 246 | */ | |
| 247 | @WebMethod(operationName = "getRoleIdsForResponsibility") | |
| 248 | @XmlElementWrapper(name = "roleIds", required = true) | |
| 249 | @XmlElement(name = "roleId", required = false) | |
| 250 | @WebResult(name = "roleIds") | |
| 251 | List<String> getRoleIdsForResponsibility(@WebParam(name = "id") String id, | |
| 252 | @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) | |
| 253 | @WebParam(name = "qualification") Map<String, String> qualification) throws RiceIllegalArgumentException; | |
| 254 | ||
| 255 | /** | |
| 256 | * This method find Responsibilities based on a query criteria. The criteria cannot be null. | |
| 257 | * | |
| 258 | * @param queryByCriteria the criteria. Cannot be null. | |
| 259 | * @return query results. will never return null. | |
| 260 | * @throws IllegalArgumentException if the queryByCriteria is null | |
| 261 | */ | |
| 262 | @WebMethod(operationName = "findResponsibilities") | |
| 263 | @WebResult(name = "results") | |
| 264 | ResponsibilityQueryResults findResponsibilities(@WebParam(name = "query") QueryByCriteria queryByCriteria) throws RiceIllegalArgumentException; | |
| 265 | ||
| 266 | ||
| 267 | /** | |
| 268 | * This method find Responsibility Templates based on a query criteria. The criteria cannot be null. | |
| 269 | * | |
| 270 | * @param queryByCriteria the criteria. Cannot be null. | |
| 271 | * @return query results. will never return null. | |
| 272 | * @throws IllegalArgumentException if the queryByCriteria is null | |
| 273 | */ | |
| 274 | @WebMethod(operationName = "findResponsibilityTemplates") | |
| 275 | @WebResult(name = "results") | |
| 276 | TemplateQueryResults findResponsibilityTemplates(@WebParam(name = "query") QueryByCriteria queryByCriteria) throws RiceIllegalArgumentException; | |
| 277 | } |