# HG changeset patch # User Ingo Weinzierl # Date 1299154647 0 # Node ID dc687827439f6d278cda0cc38c755be24b80aeed # Parent db0d20440b92404d11b26b142ffbc7cc28f3c777 Enabled the artifact database to store and load roles of users. artifacts/trunk@1385 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r db0d20440b92 -r dc687827439f ChangeLog --- a/ChangeLog Thu Mar 03 12:13:24 2011 +0000 +++ b/ChangeLog Thu Mar 03 12:17:27 2011 +0000 @@ -1,3 +1,8 @@ +2011-03-03 Ingo Weinzierl + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java: + The roles of users are stored into and loaded from database now. + 2011-03-03 Sascha L. Teichmann * artifact-database/src/main/resources/sql/org-h2-driver.properties, diff -r db0d20440b92 -r dc687827439f artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Mar 03 12:13:24 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Mar 03 12:17:27 2011 +0000 @@ -37,6 +37,8 @@ import java.util.HashSet; import java.util.List; +import javax.xml.xpath.XPathConstants; + import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Hex; @@ -44,6 +46,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; /** * The core implementation of artifact database. This layer exposes @@ -1005,8 +1008,14 @@ ec.addAttr(ue, "uuid", user.identifier()); ec.addAttr(ue, "name", user.getName()); - // TODO append the role of the user. + Document role = user.getRole(); + + if (role != null) { + ue.appendChild(result.importNode(role.getFirstChild(), true)); + } + root.appendChild(ue); + } return result; @@ -1029,9 +1038,19 @@ throw new ArtifactDatabaseException(NO_USERNAME); } - // TODO Extract the role is contained as node in the xml document. + Node tmp = (Node) XMLUtils.xpath( + data, + XPATH_USERROLE, + XPathConstants.NODE, + ArtifactNamespaceContext.INSTANCE); + Document role = XMLUtils.newDocument(); + if (tmp != null) { + Node clone = role.importNode(tmp, true); + role.appendChild(clone); + } + User newUser = null; try {