use of org.apache.syncope.common.lib.report.GroupReportletConf.Feature in project syncope by apache.
the class GroupReportlet method doExtract.
private void doExtract(final ContentHandler handler, final List<Group> groups) throws SAXException {
AttributesImpl atts = new AttributesImpl();
for (Group group : groups) {
atts.clear();
for (Feature feature : conf.getFeatures()) {
String type = null;
String value = null;
switch(feature) {
case key:
type = ReportXMLConst.XSD_STRING;
value = group.getKey();
break;
case name:
type = ReportXMLConst.XSD_STRING;
value = String.valueOf(group.getName());
break;
case groupOwner:
type = ReportXMLConst.XSD_STRING;
value = group.getGroupOwner().getKey();
break;
case userOwner:
type = ReportXMLConst.XSD_STRING;
value = group.getUserOwner().getKey();
break;
default:
}
if (type != null && value != null) {
atts.addAttribute("", "", feature.name(), type, value);
}
}
handler.startElement("", "", "group", atts);
// Using GroupTO for attribute values, since the conversion logic of
// values to String is already encapsulated there
GroupTO groupTO = groupDataBinder.getGroupTO(group, true);
doExtractAttributes(handler, groupTO, conf.getPlainAttrs(), conf.getDerAttrs(), conf.getVirAttrs());
// to get resources associated to a group
if (conf.getFeatures().contains(Feature.resources)) {
doExtractResources(handler, groupTO);
}
// to get users asscoiated to a group is preferred GroupDAO to GroupTO
if (conf.getFeatures().contains(Feature.users)) {
handler.startElement("", "", "users", null);
for (UMembership memb : groupDAO.findUMemberships(group)) {
atts.clear();
atts.addAttribute("", "", "key", ReportXMLConst.XSD_STRING, memb.getLeftEnd().getKey());
atts.addAttribute("", "", "username", ReportXMLConst.XSD_STRING, String.valueOf(memb.getLeftEnd().getUsername()));
handler.startElement("", "", "user", atts);
handler.endElement("", "", "user");
}
handler.endElement("", "", "users");
}
handler.endElement("", "", "group");
}
}
use of org.apache.syncope.common.lib.report.GroupReportletConf.Feature in project syncope by apache.
the class GroupReportlet method doExtractConf.
private void doExtractConf(final ContentHandler handler) throws SAXException {
if (conf == null) {
LOG.debug("Report configuration is not present");
}
AttributesImpl atts = new AttributesImpl();
handler.startElement("", "", "configurations", null);
handler.startElement("", "", "groupAttributes", atts);
if (conf != null) {
for (Feature feature : conf.getFeatures()) {
atts.clear();
handler.startElement("", "", "feature", atts);
handler.characters(feature.name().toCharArray(), 0, feature.name().length());
handler.endElement("", "", "feature");
}
for (String attr : conf.getPlainAttrs()) {
atts.clear();
handler.startElement("", "", "attribute", atts);
handler.characters(attr.toCharArray(), 0, attr.length());
handler.endElement("", "", "attribute");
}
for (String derAttr : conf.getDerAttrs()) {
atts.clear();
handler.startElement("", "", "derAttribute", atts);
handler.characters(derAttr.toCharArray(), 0, derAttr.length());
handler.endElement("", "", "derAttribute");
}
for (String virAttr : conf.getVirAttrs()) {
atts.clear();
handler.startElement("", "", "virAttribute", atts);
handler.characters(virAttr.toCharArray(), 0, virAttr.length());
handler.endElement("", "", "virAttribute");
}
}
handler.endElement("", "", "groupAttributes");
handler.endElement("", "", "configurations");
}
Aggregations