19 package org.turro.socialgroup;
22 import java.io.IOException;
23 import java.util.HashSet;
24 import java.util.List;
26 import java.util.logging.Level;
27 import java.util.logging.Logger;
28 import org.jdom.Document;
29 import org.jdom.Element;
30 import org.jdom.JDOMException;
31 import org.jdom.input.SAXBuilder;
32 import org.turro.elephant.context.ElephantContext;
41 private String name, id;
42 private final Set<String> syndicate =
new HashSet<>();
43 private final Set<AllowedSocialGroup> allowed =
new HashSet<>();
44 private final Set<String> roles =
new HashSet<>();
45 private final Set<String> tags =
new HashSet<>();
72 SAXBuilder builder =
new SAXBuilder();
75 if(confFile.exists()) {
76 doc = builder.build(confFile);
77 readXML(doc.getRootElement());
79 }
catch (IOException | JDOMException ex) {
84 private void readXML(Element rootElement) {
85 name = rootElement.getAttributeValue(
"name");
86 for(Element el : (List<Element>) rootElement.getChildren(
"allowed")) {
88 asg.
setName(el.getAttributeValue(
"name"));
89 asg.
setReadonly(
"true".equals(el.getAttributeValue(
"readOnly")));
90 asg.
setInherits(
"true".equals(el.getAttributeValue(
"inherits")));
91 for(Element el2 : (List<Element>) el.getChildren(
"deny")) {
92 asg.
addDeny(el2.getAttributeValue(
"name"), el2.getAttributeValue(
"value"));
96 for(Element el : (List<Element>) rootElement.getChildren(
"role")) {
97 roles.add(el.getAttributeValue(
"name"));
99 for(Element el : (List<Element>) rootElement.getChildren(
"tag")) {
100 tags.add(el.getAttributeValue(
"name"));
102 for(Element el : (List<Element>) rootElement.getChildren(
"criteria")) {
103 String javaClass = el.getAttributeValue(
"java-class");
104 String order = el.getAttributeValue(
"order");
105 if(javaClass !=
null && javaClass.contains(
"SyndicationCriteria")) {
106 if(
"0".equals(order)) {
107 id = el.getAttributeValue(
"value");
109 syndicate.add(el.getAttributeValue(
"value"));
116 allowed.forEach(a -> a.setId(map.get(a.getName()).id));
static String logMsg(String msg)
void setName(String name)
void setReadonly(boolean readonly)
void setInherits(boolean inherits)
void addDeny(String name, String values)
Set< AllowedSocialGroup > getAllowed()
void assignAllowedIds(SocialGroupMap map)
void loadSet(File confFile)
Set< String > getSyndicate()