| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kew.impl.actionlist; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.Collections; |
| 20 | |
import java.util.List; |
| 21 | |
|
| 22 | |
import org.apache.commons.lang.StringUtils; |
| 23 | |
import org.kuali.rice.core.api.exception.RiceIllegalArgumentException; |
| 24 | |
import org.kuali.rice.kew.actionlist.CustomActionListAttribute; |
| 25 | |
import org.kuali.rice.kew.api.action.ActionItem; |
| 26 | |
import org.kuali.rice.kew.api.action.ActionItemCustomization; |
| 27 | |
import org.kuali.rice.kew.api.extension.ExtensionDefinition; |
| 28 | |
import org.kuali.rice.kew.api.extension.ExtensionRepositoryService; |
| 29 | |
import org.kuali.rice.kew.api.extension.ExtensionUtils; |
| 30 | |
import org.kuali.rice.kew.framework.actionlist.ActionListCustomizationHandlerService; |
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | 0 | public class ActionListCustomizationHandlerServiceImpl implements ActionListCustomizationHandlerService { |
| 38 | |
|
| 39 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ActionListCustomizationHandlerServiceImpl.class); |
| 40 | |
|
| 41 | |
private ExtensionRepositoryService extensionRepositoryService; |
| 42 | |
|
| 43 | |
@Override |
| 44 | |
public List<ActionItemCustomization> customizeActionList(String principalId, List<ActionItem> actionItems) |
| 45 | |
throws RiceIllegalArgumentException { |
| 46 | 0 | if (StringUtils.isBlank(principalId)) { |
| 47 | 0 | throw new RiceIllegalArgumentException("principalId was null or blank"); |
| 48 | |
} |
| 49 | 0 | if (actionItems == null) { |
| 50 | 0 | actionItems = Collections.emptyList(); |
| 51 | |
} |
| 52 | 0 | List<ActionItemCustomization> actionItemCustomizations = new ArrayList<ActionItemCustomization>(); |
| 53 | |
|
| 54 | 0 | for (ActionItem actionItem : actionItems) { |
| 55 | |
|
| 56 | |
|
| 57 | 0 | CustomActionListAttribute customActionListAttribute = loadAttribute("attributeName?"); |
| 58 | |
|
| 59 | |
ActionItemCustomization actionItemCustomization; |
| 60 | |
try { |
| 61 | 0 | actionItemCustomization = ActionItemCustomization.Builder.create(customActionListAttribute.getLegalActions(principalId, actionItem), customActionListAttribute.getDocHandlerDisplayParameters(principalId, actionItem)).build(); |
| 62 | 0 | actionItemCustomizations.add(actionItemCustomization); |
| 63 | 0 | } catch (Exception e) { |
| 64 | |
|
| 65 | 0 | LOG.error("Problem loading custom action list attribute", e); |
| 66 | 0 | } |
| 67 | 0 | } |
| 68 | 0 | return actionItemCustomizations; |
| 69 | |
} |
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
protected CustomActionListAttribute loadAttribute(String attributeName) { |
| 78 | 0 | ExtensionDefinition extensionDefinition = extensionRepositoryService.getExtensionByName(attributeName); |
| 79 | 0 | if (extensionDefinition == null) { |
| 80 | 0 | throw new RiceIllegalArgumentException("Failed to locate a CustomActionListAttribute with the given name: " + attributeName); |
| 81 | |
} |
| 82 | |
|
| 83 | 0 | CustomActionListAttribute customActionListAttribute = ExtensionUtils.loadExtension(extensionDefinition); |
| 84 | 0 | if (customActionListAttribute == null) { |
| 85 | 0 | throw new RiceIllegalArgumentException("Failed to load CustomActionListAttribute for: " + extensionDefinition); |
| 86 | |
} |
| 87 | 0 | return (CustomActionListAttribute)customActionListAttribute; |
| 88 | |
} |
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
public ExtensionRepositoryService getExtensionRepositoryService() { |
| 98 | 0 | return extensionRepositoryService; |
| 99 | |
} |
| 100 | |
|
| 101 | |
public void setExtensionRepositoryService(ExtensionRepositoryService extensionRepositoryService) { |
| 102 | 0 | this.extensionRepositoryService = extensionRepositoryService; |
| 103 | 0 | } |
| 104 | |
} |