public void marshall(XMLStreamWriter wrt, IdentityDetails value) throws Exception { // write out the identitydetails element.. wrt.writeStartElement("identitydetails"); if (value != null) { // marshall the name. String name = value.getName(); wrt.writeStartElement("name"); wrt.writeAttribute("value", name); wrt.writeEndElement(); // marshall the identity type String identityType = value.getType(); wrt.writeStartElement("type"); wrt.writeAttribute("value", identityType); wrt.writeEndElement(); // marshall the realm String realm = value.getRealm(); wrt.writeStartElement("realm"); wrt.writeAttribute("value", realm); wrt.writeEndElement(); // write the roles. String[] roles = value.getRoles(); for (int i = 0; (roles != null && i < roles.length); i++) { wrt.writeStartElement("role"); wrt.writeAttribute("id", roles[i]); wrt.writeEndElement(); } // write the groups. String[] groups = value.getGroups(); for (int i = 0; (groups != null && i < groups.length); i++) { wrt.writeStartElement("group"); wrt.writeAttribute("id", groups[i]); wrt.writeEndElement(); } // write the memberships. String[] members = value.getMembers(); for (int i = 0; (members != null && i < members.length); i++) { wrt.writeStartElement("member"); wrt.writeAttribute("id", members[i]); wrt.writeEndElement(); } // write each of the attributes XMLAttributeMarshaller attrMarshaller = new XMLAttributeMarshaller(); Attribute[] vals = value.getAttributes(); for (int i = 0; ((vals != null) && (i < vals.length)); i++) { Attribute attr = vals[i]; attrMarshaller.marshall(wrt, attr); } } // end the identitydetails.. wrt.writeEndElement(); }
public void marshall(PrintWriter wrt, String prefix, IdentityDetails details) throws Exception { String prfx = prefix + "identitydetails."; if (details != null) { // write the name wrt.print(prfx); wrt.print("name="); wrt.println(details.getName()); // write the identity type wrt.print(prfx); wrt.print("type="); wrt.println(details.getType()); // write the realm wrt.print(prfx); wrt.print("realm="); wrt.println(details.getRealm()); // write the roles. String[] roles = details.getRoles(); for (int i = 0; (roles != null && i < roles.length); i++) { // add prefix to denote a parent object.. wrt.print(prfx); wrt.print("role="); wrt.println(roles[i]); } // write the groups. String[] groups = details.getGroups(); for (int i = 0; (groups != null && i < groups.length); i++) { // add prefix to denote a parent object.. wrt.print(prfx); wrt.print("group="); wrt.println(groups[i]); } // write the members. String[] members = details.getMembers(); for (int i = 0; (members != null && i < members.length); i++) { // add prefix to denote a parent object.. wrt.print(prfx); wrt.print("member="); wrt.println(members[i]); } // write the attributes.. PropertiesAttributeMarshaller attrMarshaller = new PropertiesAttributeMarshaller(); Attribute[] atts = details.getAttributes(); for (int i = 0; ((atts != null) && (i < atts.length)); i++) { Attribute attr = atts[i]; wrt.print(prfx); wrt.println("attribute="); attrMarshaller.marshall(wrt, prfx, attr); } } }