ARP Attribute serialization.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 20 Dec 2002 18:38:54 +0000 (18:38 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 20 Dec 2002 18:38:54 +0000 (18:38 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@392 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/arp/Rule.java

index adfed72..4266a7d 100755 (executable)
@@ -125,6 +125,11 @@ public class Rule {
                                ruleNode.appendChild(descriptionNode);
                        }
                        ruleNode.appendChild(placeHolder.importNode(target.unmarshall(), true));
+                       Iterator attrIterator = attributes.iterator();
+                       while (attrIterator.hasNext()) {
+                               ruleNode.appendChild(
+                                       placeHolder.importNode(((Attribute) attrIterator.next()).unmarshall(), true));
+                       }
                        return ruleNode;
                } catch (ParserConfigurationException e) {
                        log.error("Encountered a problem unmarshalling an ARP Rule: " + e);
@@ -558,6 +563,41 @@ public class Rule {
                }
 
                /**
+                * Unmarshalls an <code>Attribute</code> into an xml <code>Element</code>.
+                * @return the xml <code>Element</code>
+                */
+
+               Element unmarshall() throws ArpMarshallingException {
+
+                       try {
+                               Document placeHolder =
+                                       DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+                               Element attributeNode = placeHolder.createElement("Attribute");
+
+                               attributeNode.setAttribute("name", name.toString());
+                               if (anyValue) {
+                                       Element anyValueNode = placeHolder.createElement("AnyValue");
+                                       anyValueNode.setAttribute("release", anyValueRelease);
+                                       attributeNode.appendChild(anyValueNode);
+                               }
+                               Iterator valueIterator = values.iterator();
+                               while (valueIterator.hasNext()) {
+                                       AttributeValue value = (AttributeValue) valueIterator.next();
+                                       Element valueNode = placeHolder.createElement("Value");
+                                       valueNode.setAttribute("release", value.getRelease());
+                                       Text valueTextNode = placeHolder.createTextNode(value.getValue());
+                                       valueNode.appendChild(valueTextNode);
+                                       attributeNode.appendChild(valueNode);
+                               }
+                               return attributeNode;
+
+                       } catch (ParserConfigurationException e) {
+                               log.error("Encountered a problem unmarshalling an ARP Rule: " + e);
+                               throw new ArpMarshallingException("Encountered a problem unmarshalling an ARP Rule.");
+                       }
+               }
+               
+               /**
                 * Creates an ARP Rule Attribute from an xml representation.
                 * @param element the xml <code>Element</code> containing the ARP Rule.
                 */