| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kim.impl.jaxb; |
| 17 | |
|
| 18 | |
import java.io.Serializable; |
| 19 | |
import java.util.List; |
| 20 | |
|
| 21 | |
import javax.xml.bind.Marshaller; |
| 22 | |
import javax.xml.bind.UnmarshalException; |
| 23 | |
import javax.xml.bind.Unmarshaller; |
| 24 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 25 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 26 | |
import javax.xml.bind.annotation.XmlElement; |
| 27 | |
import javax.xml.bind.annotation.XmlType; |
| 28 | |
|
| 29 | |
import org.kuali.rice.core.util.jaxb.RiceXmlExportList; |
| 30 | |
import org.kuali.rice.core.util.jaxb.RiceXmlImportList; |
| 31 | |
import org.kuali.rice.core.util.jaxb.RiceXmlListAdditionListener; |
| 32 | |
import org.kuali.rice.core.util.jaxb.RiceXmlListGetterListener; |
| 33 | |
import org.kuali.rice.kim.api.permission.PermissionContract; |
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | 0 | @XmlAccessorType(XmlAccessType.FIELD) |
| 41 | |
@XmlType(name="PermissionsType", propOrder={"permissions"}) |
| 42 | |
public class PermissionsXmlDTO implements RiceXmlListAdditionListener<PermissionXmlDTO>, |
| 43 | |
RiceXmlListGetterListener<PermissionXmlDTO,Object>, Serializable { |
| 44 | |
|
| 45 | |
private static final long serialVersionUID = 1L; |
| 46 | |
|
| 47 | |
@XmlElement(name="permission") |
| 48 | |
private List<PermissionXmlDTO> permissions; |
| 49 | |
|
| 50 | 0 | public PermissionsXmlDTO() {} |
| 51 | |
|
| 52 | 0 | public PermissionsXmlDTO(List<? extends Object> permissionsToExport) { |
| 53 | 0 | this.permissions = new RiceXmlExportList<PermissionXmlDTO,Object>(permissionsToExport, this); |
| 54 | 0 | } |
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
public List<PermissionXmlDTO> getPermissions() { |
| 60 | 0 | return this.permissions; |
| 61 | |
} |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
public void setPermissions(List<PermissionXmlDTO> permissions) { |
| 67 | 0 | this.permissions = permissions; |
| 68 | 0 | } |
| 69 | |
|
| 70 | |
void beforeUnmarshal(Unmarshaller unmarshaller, Object parent) { |
| 71 | 0 | permissions = new RiceXmlImportList<PermissionXmlDTO>(this); |
| 72 | 0 | } |
| 73 | |
|
| 74 | |
void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { |
| 75 | 0 | permissions = null; |
| 76 | 0 | } |
| 77 | |
|
| 78 | |
public void newItemAdded(PermissionXmlDTO item) { |
| 79 | |
try { |
| 80 | 0 | PermissionXmlUtil.validateAndPersistNewPermission(item); |
| 81 | 0 | } catch (UnmarshalException e) { |
| 82 | 0 | throw new RuntimeException(e); |
| 83 | 0 | } |
| 84 | 0 | } |
| 85 | |
|
| 86 | |
void afterMarshal(Marshaller marshaller) { |
| 87 | 0 | permissions = null; |
| 88 | 0 | } |
| 89 | |
|
| 90 | |
public PermissionXmlDTO gettingNextItem(Object nextItem, int index) { |
| 91 | 0 | if (!(nextItem instanceof PermissionContract)) { |
| 92 | 0 | throw new IllegalStateException("Object for exportation should have been a permission"); |
| 93 | |
} |
| 94 | 0 | return new PermissionXmlDTO((PermissionContract) nextItem); |
| 95 | |
} |
| 96 | |
} |