| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.krad.web.struts.form; |
| 17 | |
|
| 18 | |
import java.security.GeneralSecurityException; |
| 19 | |
import java.util.HashMap; |
| 20 | |
import java.util.Iterator; |
| 21 | |
import java.util.List; |
| 22 | |
import java.util.Map; |
| 23 | |
|
| 24 | |
import javax.servlet.http.HttpServletRequest; |
| 25 | |
|
| 26 | |
import org.apache.commons.lang.StringUtils; |
| 27 | |
import org.kuali.rice.core.api.CoreApiServiceLocator; |
| 28 | |
import org.kuali.rice.core.api.encryption.EncryptionService; |
| 29 | |
import org.kuali.rice.krad.bo.BusinessObject; |
| 30 | |
import org.kuali.rice.krad.service.BusinessObjectAuthorizationService; |
| 31 | |
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; |
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | 0 | public class DisplayInactivationBlockersForm extends KualiForm { |
| 40 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DisplayInactivationBlockersForm.class); |
| 41 | |
|
| 42 | |
private String businessObjectClassName; |
| 43 | |
private Map<String, String> primaryKeyFieldValues; |
| 44 | |
private Map<String, List<String>> blockingValues; |
| 45 | |
|
| 46 | |
@Override |
| 47 | |
public void populate(HttpServletRequest request) { |
| 48 | 0 | super.populate(request); |
| 49 | 0 | primaryKeyFieldValues = new HashMap<String, String>(); |
| 50 | |
|
| 51 | 0 | if (StringUtils.isBlank(businessObjectClassName)) { |
| 52 | 0 | throw new IllegalArgumentException("BO Class Name missing."); |
| 53 | |
} |
| 54 | |
|
| 55 | 0 | Class businessObjectClass = null; |
| 56 | |
try { |
| 57 | 0 | businessObjectClass = Class.forName(businessObjectClassName); |
| 58 | 0 | } catch (ClassNotFoundException e) { |
| 59 | 0 | LOG.error("Unable to find class: " + businessObjectClassName, e); |
| 60 | 0 | throw new IllegalArgumentException("Unable to find class: " + businessObjectClassName, e); |
| 61 | 0 | } |
| 62 | |
|
| 63 | 0 | if (!BusinessObject.class.isAssignableFrom(businessObjectClass)) { |
| 64 | 0 | LOG.error("BO Class is not a BusinessObject: " + businessObjectClassName); |
| 65 | 0 | throw new IllegalArgumentException("BO Class is not a BusinessObject: " + businessObjectClassName); |
| 66 | |
} |
| 67 | |
|
| 68 | 0 | EncryptionService encryptionService = CoreApiServiceLocator.getEncryptionService(); |
| 69 | 0 | BusinessObjectAuthorizationService businessObjectAuthorizationService = KRADServiceLocatorWeb |
| 70 | |
.getBusinessObjectAuthorizationService(); |
| 71 | |
|
| 72 | 0 | List primaryKeyFieldNames = KRADServiceLocatorWeb.getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(businessObjectClass); |
| 73 | 0 | for (Iterator i = primaryKeyFieldNames.iterator(); i.hasNext();) { |
| 74 | 0 | String primaryKeyFieldName = (String) i.next(); |
| 75 | |
|
| 76 | 0 | String primaryKeyFieldValue = request.getParameter(primaryKeyFieldName); |
| 77 | 0 | if (StringUtils.isBlank(primaryKeyFieldValue)) { |
| 78 | 0 | LOG.error("Missing primary key value for: " + primaryKeyFieldName); |
| 79 | 0 | throw new IllegalArgumentException("Missing primary key value for: " + primaryKeyFieldName); |
| 80 | |
} |
| 81 | |
|
| 82 | |
|
| 83 | 0 | if (businessObjectAuthorizationService.attributeValueNeedsToBeEncryptedOnFormsAndLinks(businessObjectClass, primaryKeyFieldName)) { |
| 84 | |
try { |
| 85 | 0 | primaryKeyFieldValue = encryptionService.decrypt(primaryKeyFieldValue); |
| 86 | |
} |
| 87 | 0 | catch (GeneralSecurityException e) { |
| 88 | 0 | LOG.error("Unable to decrypt secure field for BO " + businessObjectClassName + " field " + primaryKeyFieldName, e); |
| 89 | 0 | throw new RuntimeException("Unable to decrypt secure field for BO " + businessObjectClassName + " field " + primaryKeyFieldName, e); |
| 90 | 0 | } |
| 91 | |
} |
| 92 | |
|
| 93 | 0 | primaryKeyFieldValues.put(primaryKeyFieldName, primaryKeyFieldValue); |
| 94 | 0 | } |
| 95 | 0 | } |
| 96 | |
|
| 97 | |
public String getBusinessObjectClassName() { |
| 98 | 0 | return this.businessObjectClassName; |
| 99 | |
} |
| 100 | |
|
| 101 | |
public void setBusinessObjectClassName(String businessObjectClassName) { |
| 102 | 0 | this.businessObjectClassName = businessObjectClassName; |
| 103 | 0 | } |
| 104 | |
|
| 105 | |
public Map<String, String> getPrimaryKeyFieldValues() { |
| 106 | 0 | return this.primaryKeyFieldValues; |
| 107 | |
} |
| 108 | |
|
| 109 | |
public void setPrimaryKeyFieldValues(Map<String, String> primaryKeyFieldValues) { |
| 110 | 0 | this.primaryKeyFieldValues = primaryKeyFieldValues; |
| 111 | 0 | } |
| 112 | |
|
| 113 | |
public Map<String, List<String>> getBlockingValues() { |
| 114 | 0 | return this.blockingValues; |
| 115 | |
} |
| 116 | |
|
| 117 | |
public void setBlockingValues(Map<String, List<String>> blockingValues) { |
| 118 | 0 | this.blockingValues = blockingValues; |
| 119 | 0 | } |
| 120 | |
} |