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