1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.edl.components; |
18 | |
|
19 | |
import org.kuali.rice.kew.edl.EDLXmlUtils; |
20 | |
import org.kuali.rice.kew.edl.RequestParser; |
21 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
22 | |
import org.kuali.rice.kim.bo.entity.KimPrincipal; |
23 | |
import org.kuali.rice.kew.user.AuthenticationUserId; |
24 | |
import org.kuali.rice.kim.bo.entity.KimPrincipal; |
25 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
26 | |
import org.w3c.dom.Element; |
27 | |
import org.w3c.dom.NodeList; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public class NetworkIdWorkflowEDLConfigComponent extends SimpleWorkflowEDLConfigComponent { |
36 | |
|
37 | 0 | private boolean required = false; |
38 | |
|
39 | |
@Override |
40 | |
public Element getReplacementConfigElement(Element element) { |
41 | 0 | Element replacementEl = (Element)element.cloneNode(true); |
42 | 0 | Element type = (Element)((NodeList)replacementEl.getElementsByTagName(EDLXmlUtils.TYPE_E)).item(0); |
43 | 0 | type.setTextContent("text"); |
44 | |
|
45 | |
|
46 | |
|
47 | 0 | Element validation = (Element)((NodeList)replacementEl.getElementsByTagName(EDLXmlUtils.VALIDATION_E)).item(0); |
48 | 0 | if (validation != null && validation.getAttribute("required").equals("true")) { |
49 | 0 | required = true; |
50 | |
} |
51 | 0 | return replacementEl; |
52 | |
} |
53 | |
|
54 | |
@Override |
55 | |
public String getErrorMessage(Element originalConfigElement, RequestParser requestParser, MatchingParam param) { |
56 | |
|
57 | 0 | if (param.getParamValue().length() == 0 && required == true) { |
58 | |
|
59 | 0 | return ("Network ID is a required field"); |
60 | 0 | } else if (param.getParamValue().length() == 0 && required == false) { |
61 | |
|
62 | 0 | return null; |
63 | |
} else { |
64 | |
|
65 | 0 | KimPrincipal principal = KIMServiceLocator.getIdentityManagementService().getPrincipalByPrincipalName(param.getParamValue()); |
66 | 0 | if (principal == null) { |
67 | 0 | return ("The value " + param.getParamValue() + " is an invalid principal name"); |
68 | |
} |
69 | |
} |
70 | 0 | return null; |
71 | |
} |
72 | |
|
73 | |
public boolean isRequired() { |
74 | 0 | return required; |
75 | |
} |
76 | |
|
77 | |
public void setRequired(boolean required) { |
78 | 0 | this.required = required; |
79 | 0 | } |
80 | |
|
81 | |
} |