1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.core.service;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.coreservice.api.parameter.EvaluationOperator;
20 import org.kuali.rice.coreservice.api.parameter.Parameter;
21 import org.kuali.rice.coreservice.api.parameter.ParameterType;
22 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
23 import org.springframework.beans.factory.InitializingBean;
24
25
26
27
28
29
30
31
32 public class DocHandlerUrlPrefixPublishingServiceImpl implements DocHandlerUrlPrefixPublishingService, InitializingBean {
33
34 private String parameterApplicationId;
35 private String parameterNamespaceCode;
36 private String parameterTypeCode;
37 private String parameterComponentCode;
38 private String parameterName;
39 private String parameterValue;
40
41 private ParameterService parameterService;
42
43 public String getParameterApplicationId() {
44 return parameterApplicationId;
45 }
46
47 public void setParameterApplicationId(String parameterApplicationId) {
48 this.parameterApplicationId = parameterApplicationId;
49 }
50
51 public String getParameterNamespaceCode() {
52 return parameterNamespaceCode;
53 }
54
55 public void setParameterNamespaceCode(String parameterNamespaceCode) {
56 this.parameterNamespaceCode = parameterNamespaceCode;
57 }
58
59 public String getParameterTypeCode() {
60 return parameterTypeCode;
61 }
62
63 public void setParameterTypeCode(String parameterTypeCode) {
64 this.parameterTypeCode = parameterTypeCode;
65 }
66
67 public String getParameterComponentCode() {
68 return parameterComponentCode;
69 }
70
71 public void setParameterComponentCode(String parameterComponentCode) {
72 this.parameterComponentCode = parameterComponentCode;
73 }
74
75 public String getParameterName() {
76 return parameterName;
77 }
78
79 public void setParameterName(String parameterName) {
80 this.parameterName = parameterName;
81 }
82
83 public String getParameterValue() {
84 return parameterValue;
85 }
86
87 public void setParameterValue(String parameterValue) {
88 this.parameterValue = parameterValue;
89 }
90
91 public void setParameterService(ParameterService parameterService) {
92 this.parameterService = parameterService;
93 }
94
95 @Override
96 public void afterPropertiesSet() throws Exception {
97 publishDocHandlerUrlPrefix();
98 }
99
100 @Override
101 public void publishDocHandlerUrlPrefix() {
102 ParameterType.Builder parameterType = ParameterType.Builder.create(parameterTypeCode);
103 Parameter.Builder parameter = Parameter.Builder.create(parameterApplicationId, parameterNamespaceCode, parameterComponentCode, parameterName, parameterType);
104 parameter.setDescription("KPME docHandler Prefix");
105 parameter.setValue(parameterValue);
106 parameter.setEvaluationOperator(EvaluationOperator.ALLOW);
107 Parameter existingParameter = parameterService.getParameter(parameterNamespaceCode, parameterComponentCode, parameterName);
108 if (existingParameter == null) {
109 parameterService.createParameter(parameter.build());
110 } else if(!StringUtils.equals(existingParameter.getValue(), parameterValue)) {
111 parameter.setObjectId(existingParameter.getObjectId());
112 parameter.setVersionNumber(existingParameter.getVersionNumber());
113 parameterService.updateParameter(parameter.build());
114 }
115 }
116
117 }