| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kns.uif.authorization; |
| 17 | |
|
| 18 | |
import java.util.HashSet; |
| 19 | |
import java.util.Set; |
| 20 | |
|
| 21 | |
import org.apache.commons.lang.StringUtils; |
| 22 | |
import org.kuali.rice.core.framework.parameter.ParameterService; |
| 23 | |
import org.kuali.rice.core.framework.services.CoreFrameworkServiceLocator; |
| 24 | |
import org.kuali.rice.kns.document.Document; |
| 25 | |
import org.kuali.rice.kns.util.GlobalVariables; |
| 26 | |
import org.kuali.rice.kns.util.KNSConstants; |
| 27 | |
import org.kuali.rice.kns.web.spring.form.DocumentFormBase; |
| 28 | |
import org.kuali.rice.kns.web.spring.form.UifFormBase; |
| 29 | |
import org.kuali.rice.kns.workflow.service.KualiWorkflowDocument; |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | 0 | public class DocumentPresentationControllerBase extends PresentationControllerBase { |
| 35 | |
|
| 36 | |
private static transient ParameterService parameterService; |
| 37 | |
|
| 38 | |
@Override |
| 39 | |
public Set<String> getActionFlags(UifFormBase model) { |
| 40 | 0 | Set<String> documentActions = new HashSet<String>(); |
| 41 | |
|
| 42 | 0 | Document document = ((DocumentFormBase) model).getDocument(); |
| 43 | |
|
| 44 | 0 | if (canEdit(document)) { |
| 45 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_EDIT); |
| 46 | |
} |
| 47 | |
|
| 48 | 0 | if (canAnnotate(document)) { |
| 49 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_ANNOTATE); |
| 50 | |
} |
| 51 | |
|
| 52 | 0 | if (canClose(document)) { |
| 53 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_CLOSE); |
| 54 | |
} |
| 55 | |
|
| 56 | 0 | if (canSave(document)) { |
| 57 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_SAVE); |
| 58 | |
} |
| 59 | |
|
| 60 | 0 | if (canRoute(document)) { |
| 61 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_ROUTE); |
| 62 | |
} |
| 63 | |
|
| 64 | 0 | if (canCancel(document)) { |
| 65 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_CANCEL); |
| 66 | |
} |
| 67 | |
|
| 68 | 0 | if (canReload(document)) { |
| 69 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_RELOAD); |
| 70 | |
} |
| 71 | |
|
| 72 | 0 | if (canCopy(document)) { |
| 73 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_COPY); |
| 74 | |
} |
| 75 | |
|
| 76 | 0 | if (canPerformRouteReport(document)) { |
| 77 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_PERFORM_ROUTE_REPORT); |
| 78 | |
} |
| 79 | |
|
| 80 | 0 | if (canAddAdhocRequests(document)) { |
| 81 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_ADD_ADHOC_REQUESTS); |
| 82 | |
} |
| 83 | |
|
| 84 | 0 | if (canBlanketApprove(document)) { |
| 85 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_BLANKET_APPROVE); |
| 86 | |
} |
| 87 | |
|
| 88 | 0 | if (canApprove(document)) { |
| 89 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_APPROVE); |
| 90 | |
} |
| 91 | |
|
| 92 | 0 | if (canDisapprove(document)) { |
| 93 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_DISAPPROVE); |
| 94 | |
} |
| 95 | |
|
| 96 | 0 | if (canSendAdhocRequests(document)) { |
| 97 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_SEND_ADHOC_REQUESTS); |
| 98 | |
} |
| 99 | |
|
| 100 | 0 | if (canSendNoteFyi(document)) { |
| 101 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_SEND_NOTE_FYI); |
| 102 | |
} |
| 103 | |
|
| 104 | 0 | if (this.canEditDocumentOverview(document)) { |
| 105 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_EDIT__DOCUMENT_OVERVIEW); |
| 106 | |
} |
| 107 | |
|
| 108 | 0 | if (canFyi(document)) { |
| 109 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_FYI); |
| 110 | |
} |
| 111 | |
|
| 112 | 0 | if (canAcknowledge(document)) { |
| 113 | 0 | documentActions.add(KNSConstants.KUALI_ACTION_CAN_ACKNOWLEDGE); |
| 114 | |
} |
| 115 | |
|
| 116 | 0 | return documentActions; |
| 117 | |
} |
| 118 | |
|
| 119 | |
public boolean canInitiate(String documentTypeName) { |
| 120 | 0 | return true; |
| 121 | |
} |
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
protected boolean canEdit(Document document) { |
| 128 | 0 | boolean canEdit = false; |
| 129 | 0 | KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); |
| 130 | 0 | if (workflowDocument.stateIsInitiated() || workflowDocument.stateIsSaved() || workflowDocument.stateIsEnroute() |
| 131 | |
|| workflowDocument.stateIsException()) { |
| 132 | 0 | canEdit = true; |
| 133 | |
} |
| 134 | |
|
| 135 | 0 | return canEdit; |
| 136 | |
} |
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
protected boolean canAnnotate(Document document) { |
| 143 | 0 | return canEdit(document); |
| 144 | |
} |
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
|
| 150 | |
protected boolean canReload(Document document) { |
| 151 | 0 | KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); |
| 152 | 0 | return (canEdit(document) && !workflowDocument.stateIsInitiated()); |
| 153 | |
|
| 154 | |
} |
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
|
| 160 | |
protected boolean canClose(Document document) { |
| 161 | 0 | return true; |
| 162 | |
} |
| 163 | |
|
| 164 | |
|
| 165 | |
|
| 166 | |
|
| 167 | |
|
| 168 | |
protected boolean canSave(Document document) { |
| 169 | 0 | return canEdit(document); |
| 170 | |
} |
| 171 | |
|
| 172 | |
|
| 173 | |
|
| 174 | |
|
| 175 | |
|
| 176 | |
protected boolean canRoute(Document document) { |
| 177 | 0 | boolean canRoute = false; |
| 178 | 0 | KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); |
| 179 | 0 | if (workflowDocument.stateIsInitiated() || workflowDocument.stateIsSaved()) { |
| 180 | 0 | canRoute = true; |
| 181 | |
} |
| 182 | 0 | return canRoute; |
| 183 | |
} |
| 184 | |
|
| 185 | |
|
| 186 | |
|
| 187 | |
|
| 188 | |
|
| 189 | |
protected boolean canCancel(Document document) { |
| 190 | 0 | return canEdit(document); |
| 191 | |
} |
| 192 | |
|
| 193 | |
|
| 194 | |
|
| 195 | |
|
| 196 | |
|
| 197 | |
protected boolean canCopy(Document document) { |
| 198 | 0 | boolean canCopy = false; |
| 199 | 0 | if (document.getAllowsCopy()) { |
| 200 | 0 | canCopy = true; |
| 201 | |
} |
| 202 | 0 | return canCopy; |
| 203 | |
} |
| 204 | |
|
| 205 | |
|
| 206 | |
|
| 207 | |
|
| 208 | |
|
| 209 | |
protected boolean canPerformRouteReport(Document document) { |
| 210 | 0 | return getParameterService().getParameterValueAsBoolean(KNSConstants.KNS_NAMESPACE, |
| 211 | |
KNSConstants.DetailTypes.DOCUMENT_DETAIL_TYPE, |
| 212 | |
KNSConstants.SystemGroupParameterNames.DEFAULT_CAN_PERFORM_ROUTE_REPORT_IND); |
| 213 | |
} |
| 214 | |
|
| 215 | |
|
| 216 | |
|
| 217 | |
|
| 218 | |
|
| 219 | |
protected boolean canAddAdhocRequests(Document document) { |
| 220 | 0 | return true; |
| 221 | |
} |
| 222 | |
|
| 223 | |
|
| 224 | |
|
| 225 | |
|
| 226 | |
|
| 227 | |
|
| 228 | |
|
| 229 | |
protected boolean canBlanketApprove(Document document) { |
| 230 | |
|
| 231 | |
|
| 232 | |
|
| 233 | |
try { |
| 234 | 0 | if (getParameterService().getParameterValueAsBoolean(KNSConstants.KNS_NAMESPACE, |
| 235 | |
KNSConstants.DetailTypes.DOCUMENT_DETAIL_TYPE, |
| 236 | |
KNSConstants.SystemGroupParameterNames.ALLOW_ENROUTE_BLANKET_APPROVE_WITHOUT_APPROVAL_REQUEST_IND)) { |
| 237 | 0 | return canEdit(document); |
| 238 | |
} |
| 239 | |
} |
| 240 | 0 | catch (IllegalArgumentException ex) { |
| 241 | |
|
| 242 | 0 | } |
| 243 | |
|
| 244 | |
|
| 245 | |
|
| 246 | 0 | KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); |
| 247 | 0 | if (canRoute(document) |
| 248 | |
&& StringUtils.equals(workflowDocument.getInitiatorPrincipalId(), GlobalVariables.getUserSession() |
| 249 | |
.getPrincipalId())) { |
| 250 | 0 | return true; |
| 251 | |
} |
| 252 | |
|
| 253 | 0 | if (workflowDocument.isApprovalRequested()) { |
| 254 | 0 | return true; |
| 255 | |
} |
| 256 | |
|
| 257 | 0 | return false; |
| 258 | |
} |
| 259 | |
|
| 260 | |
protected boolean canApprove(Document document) { |
| 261 | 0 | return true; |
| 262 | |
} |
| 263 | |
|
| 264 | |
protected boolean canDisapprove(Document document) { |
| 265 | |
|
| 266 | 0 | return canApprove(document); |
| 267 | |
} |
| 268 | |
|
| 269 | |
protected boolean canSendAdhocRequests(Document document) { |
| 270 | 0 | KualiWorkflowDocument kualiWorkflowDocument = document.getDocumentHeader().getWorkflowDocument(); |
| 271 | 0 | return !(kualiWorkflowDocument.stateIsInitiated() || kualiWorkflowDocument.stateIsSaved()); |
| 272 | |
} |
| 273 | |
|
| 274 | |
protected boolean canSendNoteFyi(Document document) { |
| 275 | 0 | return true; |
| 276 | |
} |
| 277 | |
|
| 278 | |
protected boolean canEditDocumentOverview(Document document) { |
| 279 | 0 | KualiWorkflowDocument kualiWorkflowDocument = document.getDocumentHeader().getWorkflowDocument(); |
| 280 | 0 | return (kualiWorkflowDocument.stateIsInitiated() || kualiWorkflowDocument.stateIsSaved()); |
| 281 | |
} |
| 282 | |
|
| 283 | |
protected boolean canFyi(Document document) { |
| 284 | 0 | return true; |
| 285 | |
} |
| 286 | |
|
| 287 | |
protected boolean canAcknowledge(Document document) { |
| 288 | 0 | return true; |
| 289 | |
} |
| 290 | |
|
| 291 | |
protected ParameterService getParameterService() { |
| 292 | 0 | if (parameterService == null) { |
| 293 | 0 | parameterService = CoreFrameworkServiceLocator.getParameterService(); |
| 294 | |
} |
| 295 | 0 | return parameterService; |
| 296 | |
} |
| 297 | |
|
| 298 | |
} |