1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.kuali.rice.kim.impl.jaxb;
20
21 import java.io.InputStream;
22 import java.io.OutputStream;
23 import java.util.List;
24
25 import javax.xml.bind.JAXBContext;
26 import javax.xml.bind.JAXBException;
27 import javax.xml.bind.Marshaller;
28 import javax.xml.bind.Unmarshaller;
29
30 import org.kuali.rice.core.impl.jaxb.DataXmlDTO;
31
32
33
34
35
36
37
38
39 public final class KimXmlUtil {
40
41 private KimXmlUtil() {}
42
43
44
45
46
47
48 public static void parseKimXml(InputStream inputStream) {
49 try {
50 JAXBContext jaxbContext = JAXBContext.newInstance(DataXmlDTO.class);
51 Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
52 unmarshaller.unmarshal(inputStream);
53 } catch (JAXBException e) {
54 throw new RuntimeException(e);
55 }
56 }
57
58
59
60
61
62
63
64
65 public static void exportKimXml(OutputStream outputStream, List<? extends Object> permissions, List<? extends Object> roles) {
66 PermissionDataXmlDTO permissionData = (permissions != null && !permissions.isEmpty()) ?
67 new PermissionDataXmlDTO(new PermissionsXmlDTO(permissions)) : null;
68 RoleDataXmlDTO roleData = (roles != null && !roles.isEmpty()) ?
69 new RoleDataXmlDTO(new RolesXmlDTO(roles)) : null;
70 try {
71 JAXBContext jaxbContext = JAXBContext.newInstance(DataXmlDTO.class);
72 Marshaller marshaller = jaxbContext.createMarshaller();
73 marshaller.marshal(new DataXmlDTO(permissionData, roleData), outputStream);
74 } catch (JAXBException e) {
75 throw new RuntimeException(e);
76 }
77 }
78 }