| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kim.api.jaxb; |
| 17 | |
|
| 18 | |
import org.apache.commons.lang.StringUtils; |
| 19 | |
import org.kuali.rice.core.api.util.jaxb.StringMapEntry; |
| 20 | |
|
| 21 | |
import javax.xml.bind.UnmarshalException; |
| 22 | |
import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; |
| 23 | |
import javax.xml.bind.annotation.adapters.XmlAdapter; |
| 24 | |
import java.util.HashMap; |
| 25 | |
import java.util.Map; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | 0 | public class PermissionDetailListAdapter extends XmlAdapter<PermissionDetailList,Map<String, String>> { |
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
@Override |
| 41 | |
public Map<String, String> unmarshal(PermissionDetailList v) throws Exception { |
| 42 | 0 | if (v != null) { |
| 43 | 0 | NormalizedStringAdapter normalizedStringAdapter = new NormalizedStringAdapter(); |
| 44 | 0 | Map<String, String> map = new HashMap<String, String>(); |
| 45 | 0 | for (StringMapEntry stringMapEntry : v.getPermissionDetails()) { |
| 46 | 0 | String tempKey = normalizedStringAdapter.unmarshal(stringMapEntry.getKey()); |
| 47 | 0 | if (StringUtils.isBlank(tempKey)) { |
| 48 | 0 | throw new UnmarshalException("Cannot create a permission detail entry with a blank key"); |
| 49 | 0 | } else if (map.containsKey(tempKey)) { |
| 50 | 0 | throw new UnmarshalException("Cannot create more than one permission detail entry with a key of \"" + tempKey + "\""); |
| 51 | |
} |
| 52 | 0 | map.put(tempKey, normalizedStringAdapter.unmarshal(stringMapEntry.getValue())); |
| 53 | 0 | } |
| 54 | |
} |
| 55 | 0 | return null; |
| 56 | |
} |
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
@Override |
| 62 | |
public PermissionDetailList marshal(Map<String, String> v) throws Exception { |
| 63 | 0 | return (v != null) ? new PermissionDetailList(v) : null; |
| 64 | |
} |
| 65 | |
|
| 66 | |
} |