You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by re...@apache.org on 2013/02/21 21:24:04 UTC
svn commit: r1448794 - in /stanbol/trunk/commons/security/usermanagement: ./
src/main/java/org/apache/stanbol/commons/usermanagement/resource/
src/main/resources/templates/html/org/apache/stanbol/commons/usermanagement/
src/main/resources/templates/htm...
Author: reto
Date: Thu Feb 21 20:24:04 2013
New Revision: 1448794
URL: http://svn.apache.org/r1448794
Log:
STANBOL-897: applied patch Danny, despite some weaknes it provides clear improvements comparing with the satus quo
Modified:
stanbol/trunk/commons/security/usermanagement/README.md
stanbol/trunk/commons/security/usermanagement/pom.xml
stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/resource/UserResource.java
stanbol/trunk/commons/security/usermanagement/src/main/resources/templates/html/org/apache/stanbol/commons/usermanagement/resource/listUser.ftl
stanbol/trunk/commons/security/usermanagement/src/main/resources/templates/html/org/apache/stanbol/commons/usermanagement/webConsole.ftl
Modified: stanbol/trunk/commons/security/usermanagement/README.md
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/usermanagement/README.md?rev=1448794&r1=1448793&r2=1448794&view=diff
==============================================================================
--- stanbol/trunk/commons/security/usermanagement/README.md (original)
+++ stanbol/trunk/commons/security/usermanagement/README.md Thu Feb 21 20:24:04 2013
@@ -5,19 +5,18 @@ A usermanager for stanbol. It provides a
following HTTP resources to manage users and roles, the HTTP services are
described in terms of curl-commands and assume Stanbol to be running on localhost.
-Note that users are uniquely identified by their clerezza:userName (= login) but may also have a foaf:name (= full name).
+Note that users are uniquely identified by their cz:userName (= login) but may also have a foaf:name (= full name).
The following assumes your stanbol instance is running on localhost port 8080.
Add user:
curl -i -X POST -H "Content-Type: text/turtle" \
- --user admin:admin \
- --data \
- ' @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+ --user admin:admin \
+ --data \
+ ' @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix cz: <http://clerezza.org/2009/08/platform#> .
-
[] a foaf:Agent ;
cz:userName "hugob" . ' \
http://localhost:8080/user-management/add-user
@@ -33,9 +32,11 @@ Delete user:
[] a foaf:Agent ;
cz:userName "tristant" . ' \
-[TODO: also add password, maybe showing 2 options one setting encryed passord (as its stored) and other transmitting clear text password]
http://localhost:8080/user-management/delete-user
+[TODO: also add password, maybe showing 2 options one setting encryed password
+(as its stored) and other transmitting clear text password]
+
Change user details. Multiple change blocks may appear in a message. If old
value isn't specified, the corresponding triple won't be removed from the system.
@@ -67,7 +68,7 @@ e.g. add email (replacing a previous add
Get user Turtle :
- curl --user admin:admin -H "Accept:text/turtle" http://localhost:8080/user-management/user/anonymous
+ curl --user admin:admin -H "Accept:text/turtle" http://localhost:8080/user-management/users/anonymous
Get user roles :
Modified: stanbol/trunk/commons/security/usermanagement/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/usermanagement/pom.xml?rev=1448794&r1=1448793&r2=1448794&view=diff
==============================================================================
--- stanbol/trunk/commons/security/usermanagement/pom.xml (original)
+++ stanbol/trunk/commons/security/usermanagement/pom.xml Thu Feb 21 20:24:04 2013
@@ -16,155 +16,161 @@
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>stanbol-parent</artifactId>
+ <version>4-SNAPSHOT</version>
+ <relativePath>../../../parent</relativePath>
+ </parent>
- <parent>
<groupId>org.apache.stanbol</groupId>
- <artifactId>stanbol-parent</artifactId>
- <version>4-SNAPSHOT</version>
- <relativePath>../../../parent</relativePath>
- </parent>
-
- <groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.commons.security.usermanagement</artifactId>
- <version>0.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <name>Apache Stanbol Commons User Management</name>
- <description>A Webconsole plugin for user management</description>
-
- <inceptionYear>2012</inceptionYear>
- <licenses>
- <license>
- <name>Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- <distribution>repo</distribution>
- <comments>A business-friendly OSS license</comments>
- </license>
- </licenses>
-
- <scm>
- <connection>
- scm:svn:http://svn.apache.org/repos/asf/stanbol/trunk/commons/security/usermanagement
- </connection>
- <developerConnection>
- scm:svn:https://svn.apache.org/repos/asf/stanbol/trunk/commons/security/usermanagement
- </developerConnection>
- <url>http://stanbol.apache.org/</url>
- </scm>
-
- <build>
- <!-- make it an OSGi bundle -->
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-scr-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- javax.servlet.*; version="[2.5.0,4.0.0)",
- javax.ws.rs.*; version="[0,2)",
- org.apache.stanbol.commons.web.base; provide:=true,
- org.apache.felix.webconsole; provide:=true,
- *
- </Import-Package>
- <Export-Package>
- org.apache.stanbol.commons.usermanagement; version=${project.version}
- </Export-Package>
- <Private-Package>
- org.apache.stanbol.commons.usermanagement.resource; version=${project.version},
- org.apache.stanbol.commons.usermanagement.webfragment; version=${project.version}
- </Private-Package>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludeSubProjects>false</excludeSubProjects>
- <excludes>
- <exclude>src/license/THIRD-PARTY.properties</exclude>
-
- <!-- Apache License 2.0 -->
- <exclude>src/main/resources/org/apache/stanbol/commons/usermanagement/webfragment/test.txt</exclude>
- <exclude>src/main/resources/org/apache/stanbol/commons/usermanagement/test.txt</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.commons.web.base</artifactId>
- <version>0.12.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.commons.ldpathtemplate</artifactId>
- <version>0.12.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey.contribs</groupId>
- <artifactId>jersey-multipart</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.ontologies</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.webconsole</artifactId>
- <version>3.1.8</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.config</artifactId>
- <version>0.3-incubating</version>
- </dependency>
- <dependency>
- <groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.commons.web.viewable</artifactId>
- <version>0.12.0-SNAPSHOT</version>
- </dependency>
+ <artifactId>org.apache.stanbol.commons.security.usermanagement</artifactId>
+ <version>0.12.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>Apache Stanbol Commons User Management</name>
+ <description>A Webconsole plugin for user management</description>
+
+ <inceptionYear>2012</inceptionYear>
+ <licenses>
+ <license>
+ <name>Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ <distribution>repo</distribution>
+ <comments>A business-friendly OSS license</comments>
+ </license>
+ </licenses>
+
+ <scm>
+ <connection>
+ scm:svn:http://svn.apache.org/repos/asf/stanbol/trunk/commons/security/usermanagement
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.apache.org/repos/asf/stanbol/trunk/commons/security/usermanagement
+ </developerConnection>
+ <url>http://stanbol.apache.org/</url>
+ </scm>
+
+ <build>
+ <!-- make it an OSGi bundle -->
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ javax.servlet.*; version="[2.5.0,4.0.0)",
+ javax.ws.rs.*; version="[0,2)",
+ org.apache.stanbol.commons.web.base; provide:=true,
+ org.apache.felix.webconsole; provide:=true,
+ *
+ </Import-Package>
+ <Export-Package>
+ org.apache.stanbol.commons.usermanagement; version=${project.version}
+ </Export-Package>
+ <Private-Package>
+ org.apache.stanbol.commons.usermanagement.resource; version=${project.version},
+ org.apache.stanbol.commons.usermanagement.webfragment; version=${project.version}
+ </Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludeSubProjects>false</excludeSubProjects>
+ <excludes>
+ <exclude>src/license/THIRD-PARTY.properties</exclude>
+
+ <!-- Apache License 2.0 -->
+ <exclude>src/main/resources/org/apache/stanbol/commons/usermanagement/webfragment/test.txt</exclude>
+ <exclude>src/main/resources/org/apache/stanbol/commons/usermanagement/test.txt</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.web.base</artifactId>
+ <version>0.12.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.ldpathtemplate</artifactId>
+ <version>0.12.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey.contribs</groupId>
+ <artifactId>jersey-multipart</artifactId>
+ </dependency>
-
- <!-- OSGi tax -->
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.commons.security.core</artifactId>
- <version>0.11.0</version>
- </dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>rdf.ontologies</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>rdf.utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.webconsole</artifactId>
+ <version>3.1.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>platform.config</artifactId>
+ <version>0.3-incubating</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.web.viewable</artifactId>
+ <version>0.12.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- OSGi tax -->
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.security.core</artifactId>
+ <version>0.11.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.testing.stanbol</artifactId>
+ <version>0.10.0-SNAPSHOT</version>
+ <scope>test</scope>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
</project>
Modified: stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/resource/UserResource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/resource/UserResource.java?rev=1448794&r1=1448793&r2=1448794&view=diff
==============================================================================
--- stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/resource/UserResource.java (original)
+++ stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/resource/UserResource.java Thu Feb 21 20:24:04 2013
@@ -82,6 +82,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sun.jersey.multipart.FormDataParam;
+import java.net.URISyntaxException;
+import java.util.logging.Level;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriBuilder;
+import org.apache.clerezza.rdf.core.MGraph;
@Component
@Service(UserResource.class)
@@ -95,53 +101,92 @@ public class UserResource {
private Parser parser;
@Reference
private Serializer serializer;
+ private static GraphNode dummyNode;
- @GET
- public String index() throws UnsupportedEncodingException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- serializer.serialize(baos, systemGraph, SupportedFormat.TURTLE);
- String serialized = new String(baos.toByteArray(), "utf-8");
- return serialized;
+ static {
+ dummyNode = new GraphNode(new BNode(), new SimpleMGraph());
+ dummyNode.addProperty(RDF.type, FOAF.Agent);
}
+ // **********************************
+ // ****** SHOW USER DETAILS ******
+ // **********************************
+ /**
+ *
+ * @param userName
+ * @return
+ */
@GET
- @Path("users")
+ @Path("view-user")
@Produces(MediaType.TEXT_HTML)
- public RdfViewable listUsers() {
- return new RdfViewable("listUser.ftl", getUserType(), this.getClass());
- }
-
- public GraphNode getUserType() {
- return new GraphNode(FOAF.Agent, systemGraph);
+ public RdfViewable viewUser(@QueryParam("userName") String userName) {
+ // System.out.println("HEEEEEEEEEEEEEEEEERE");
+ return new RdfViewable("edit.ftl", getUser(userName), this.getClass());
}
@GET
@Path("user/{username}")
+ @Produces(MediaType.TEXT_HTML)
public RdfViewable editUser(@PathParam("username") String userName) {
return new RdfViewable("editUser.ftl", getUser(userName),
this.getClass());
}
- private static GraphNode dummyNode;
- static {
- dummyNode = new GraphNode(new BNode(), new SimpleMGraph());
- dummyNode.addProperty(RDF.type, FOAF.Agent);
+ @GET
+ @Path("user/{username}/permissionsCheckboxes")
+ @Produces(MediaType.TEXT_HTML)
+ public RdfViewable permissionsCheckboxes(@PathParam("username") String userName) { //getUser(userName)
+ return new RdfViewable("permissionsCheckboxes.ftl", getUser(userName), this.getClass());
}
+ /**
+ * RESTful access to individual user data [has integration test]
+ *
+ * @param userName
+ * @return context graph for user
+ * @throws UnsupportedEncodingException
+ */
@GET
- @Path("create-form")
- public RdfViewable getCreateUserForm(@Context UriInfo uriInfo) {
- return new RdfViewable("editUser.ftl", dummyNode,
- this.getClass());
+ @Path("users/{username}")
+ @Produces(SupportedFormat.TURTLE)
+ public Response getUserTurtle(@PathParam("username") String userName)
+ throws UnsupportedEncodingException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ serializer.serialize(baos, getUser(userName).getNodeContext(),
+ SupportedFormat.TURTLE);
+ String serialized = new String(baos.toByteArray(), "utf-8");
+ // System.out.println("User = "+serialized);
+ return Response.ok(serialized).build();
}
+ /**
+ * RESTful access to user roles (and permissions right now - may change)
+ * [has integration test]
+ *
+ * @param userName
+ * @return context graph for user
+ * @throws UnsupportedEncodingException
+ */
@GET
- @Path("view-user")
- @Produces(MediaType.TEXT_HTML)
- public RdfViewable viewUser(@QueryParam("userName") String userName) {
- return new RdfViewable("edit.ftl", getUser(userName), this.getClass());
+ @Path("roles/{username}")
+ @Produces(SupportedFormat.TURTLE)
+ public Response getUserRoles(@PathParam("username") String userName)
+ throws UnsupportedEncodingException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ MGraph rolesGraph = getUserRolesGraph(userName);
+
+ // case of no roles not handled - what best to return : empty graph or
+ // 404?
+ serializer.serialize(baos, rolesGraph, SupportedFormat.TURTLE);
+ String serialized = new String(baos.toByteArray(), "utf-8");
+ return Response.ok(serialized).build();
}
+ // **********************************
+ // ****** UPDATE USER DETAILS *******
+ // **********************************
@POST
@Path("store-user")
// @Consumes("multipart/form-data")
@@ -157,26 +202,393 @@ public class UserResource {
GraphNode userNode;
- if(currentLogin != null){ //
+ if (currentLogin != null) { //
currentLogin = currentLogin.trim();
}
-
+
// System.out.println("CURRENTUSERNAME = ["+currentUserName+"]");
if (currentLogin != null && !currentLogin.equals("")) {
userNode = getUser(currentLogin);
return store(userNode, uriInfo, currentLogin, newLogin, fullName, email, password, roles, permissions);
}
-
+
// try {
// userNode = getUser(newLogin);
// } catch(Exception e) {
- userNode = createUser(newLogin);
- // }
+ userNode = createUser(newLogin);
+ // }
// System.out.println("NEWLOGIN = [" + newLogin + "]");
-
+
return store(userNode, uriInfo, newLogin, newLogin, fullName, email, password, roles, permissions);
}
+ @GET
+ @Path("rolesCheckboxes")
+ @Produces(SupportedFormat.HTML)
+ public RdfViewable rolesCheckboxes() {
+ return new RdfViewable("rolesCheckboxes.ftl", getRoleType(), this.getClass());
+ }
+
+ // needs refactoring and locks adding?
+ /*
+ * API/Turtle style
+ */
+ @POST
+ @Consumes(SupportedFormat.TURTLE)
+ @Path("change-user")
+ public Response changeUser(String userData) {
+
+ log.debug("changeUser called with " + userData);
+
+ Graph inputGraph = readData(userData);
+
+ Lock readLock = systemGraph.getLock().readLock();
+ readLock.lock();
+ Iterator<Triple> changes = inputGraph.filter(null, null,
+ Ontology.Change);
+
+ while (changes.hasNext()) {
+ Triple changeTriple = changes.next();
+
+ NonLiteral changeNode = changeTriple.getSubject();
+
+ Literal userName = (Literal) inputGraph
+ .filter(changeNode, PLATFORM.userName, null).next()
+ .getObject();
+
+ NonLiteral userNode = (NonLiteral) systemGraph
+ .filter(null, PLATFORM.userName, userName).next()
+ .getSubject();
+
+ UriRef predicateUriRef = (UriRef) inputGraph
+ .filter(changeNode, Ontology.predicate, null).next()
+ .getObject();
+
+ // System.out.println("predicateUriRef = " + predicateUriRef);
+
+ // handle old value (if it exists)
+ Iterator<Triple> iterator = inputGraph.filter(changeNode,
+ Ontology.oldValue, null);
+ Resource oldValue = null;
+
+ if (iterator.hasNext()) {
+ oldValue = iterator.next().getObject();
+
+ // Triple oldTriple = systemGraph.filter(null, predicateUriRef,
+ // oldValue).next();
+ Triple oldTriple = systemGraph.filter(userNode,
+ predicateUriRef, oldValue).next();
+
+ systemGraph.remove(oldTriple);
+ }
+
+ Resource newValue = inputGraph
+ .filter(changeNode, Ontology.newValue, null).next()
+ .getObject();
+
+ Triple newTriple = new TripleImpl(userNode, predicateUriRef,
+ newValue);
+
+ systemGraph.add(newTriple);
+ }
+
+ // it's not actually creating a resource at this URI so this
+ // seems the most appropriate response
+ return Response.noContent().build();
+ }
+
+ /*
+ * Isn't very pretty but is just a one-off
+ */
+ @GET
+ @Path("user/{username}/rolesCheckboxes")
+ @Produces(MediaType.TEXT_HTML)
+ public Response rolesCheckboxes(@PathParam("username") String userName) {
+ // return new RdfViewable("rolesCheckboxes.ftl", getRoleType(), this.getClass());
+ StringBuffer html = new StringBuffer();
+
+ Iterator<Triple> allRoleTriples = systemGraph.filter(null, RDF.type, PERMISSION.Role);
+
+ ArrayList<String> allRoleNames = new ArrayList<String>();
+
+ Lock readLock = systemGraph.getLock().readLock();
+ readLock.lock();
+ try { // pulls out all role names
+ while (allRoleTriples.hasNext()) {
+ Triple triple = allRoleTriples.next();
+ // if (triple.getPredicate().equals(DC.title)) {
+ // allRoleNames.add(((Literal) triple.getObject()).getLexicalForm());
+ // System.out.println("system role = "+((Literal) triple.getObject()).getLexicalForm());
+ // }
+ // NonLiteral roleNode = triple.getSubject();
+ GraphNode roleNode = new GraphNode(triple.getSubject(), systemGraph);
+ Iterator<Literal> titlesIterator = roleNode.getLiterals(DC.title);
+ while (titlesIterator.hasNext()) {
+ allRoleNames.add(titlesIterator.next().getLexicalForm());
+ // System.out.println("system role = " + titlesIterator.next().getLexicalForm());
+ }
+ }
+ } finally {
+ readLock.unlock();
+ }
+
+ MGraph rolesGraph = getUserRolesGraph(userName);
+
+ ArrayList<String> userRoleNames = new ArrayList<String>();
+
+ Iterator<Triple> userRoleTriples = rolesGraph.filter(null, RDF.type, PERMISSION.Role);
+ while (userRoleTriples.hasNext()) {
+ Triple triple = userRoleTriples.next();
+ GraphNode roleNode = new GraphNode(triple.getSubject(), rolesGraph);
+
+ Iterator<Literal> titlesIterator = roleNode.getLiterals(DC.title);
+ while (titlesIterator.hasNext()) {
+ userRoleNames.add(titlesIterator.next().getLexicalForm());
+ // System.out.println("user role = " + titlesIterator.next().getLexicalForm());
+ }
+ }
+ for (int i = 0; i < allRoleNames.size(); i++) {
+ // BasePermissionsRole
+ String role = allRoleNames.get(i);
+ if (role.equals("BasePermissionsRole")) {
+ continue;
+ }
+ if (userRoleNames.contains(role)) {
+ html.append("<input class=\"role\" type=\"checkbox\" id=\"" + role + "\" name=\"" + role + "\" value=\"" + role + "\" checked=\"checked\" />");
+ } else {
+ html.append("<input class=\"role\" type=\"checkbox\" id=\"" + role + "\" name=\"" + role + "\" value=\"" + role + "\" />");
+ }
+ html.append("<label for=\"" + role + "\">" + role + "</label>");
+ html.append("<br />");
+ }
+ return Response.ok(html.toString()).build();
+ }
+
+ // **********************************
+ // ****** LIST USERS ******
+ // **********************************
+ @GET
+ @Path("users")
+ @Produces(MediaType.TEXT_HTML)
+ public RdfViewable listUsers() {
+ return new RdfViewable("listUser.ftl", getUserType(), this.getClass());
+ }
+
+ // **********************************
+// ****** CREATE USER ******
+ // **********************************
+ @GET
+ @Path("create-form")
+ public RdfViewable getCreateUserForm(@Context UriInfo uriInfo) {
+ return new RdfViewable("editUser.ftl", dummyNode,
+ this.getClass());
+ }
+
+ /**
+ * Endpoint-style user creation takes a little bunch of Turtle e.g. [] a
+ * foaf:Agent ; cz:userName "Hugo Ball" .
+ *
+ * [has test]
+ *
+ * @param userData
+ * @return HTTP/1.1 204 No Content
+ */
+ @POST // @TODO add RESTful PUT version
+ @Consumes(SupportedFormat.TURTLE)
+ @Path("add-user")
+ public Response addUser(@Context UriInfo uriInfo, String userData) {
+
+ log.debug(("addUser called with " + userData));
+
+ Graph inputGraph = readData(userData);
+
+ Iterator<Triple> agents = inputGraph.filter(null, null, FOAF.Agent);
+
+ NonLiteral userNode = agents.next().getSubject();
+
+ Iterator<Triple> userTriples = inputGraph.filter(userNode, null, null);
+
+ String userName = "";
+ Triple userTriple= null;
+
+ Lock writeLock = systemGraph.getLock().writeLock();
+ writeLock.lock();
+ try {
+ while (userTriples.hasNext()) {
+ userTriple = userTriples.next();
+ systemGraph.add(userTriple);
+ }
+ userName = ((Literal) userTriple.getObject()).getLexicalForm();
+ } finally {
+ writeLock.unlock();
+ }
+
+ UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
+
+ URI createdResource = null;
+ // try {
+ // createdResource = new URI("http://localhost:8080/user-management/users/" + userName);
+ createdResource = uriBuilder.replacePath("/user-management/users/" + userName).build();
+// } catch (URISyntaxException ex) {
+// java.util.logging.Logger.getLogger(UserResource.class.getName()).log(Level.SEVERE, null, ex);
+// }
+ System.out.println("URI ="+createdResource);
+// from HTTPbis
+//The request has been fulfilled and has resulted in one or more new
+// resources being created.
+// Response.ResponseBuilder builder = Response.status(Response.Status.CREATED);
+// // builder.header("Location", createdResource);
+//
+// Response response = builder.build();
+// MultivaluedMap<String,Object> meta = response.getMetadata();
+// meta.putSingle("Location", createdResource);
+ return Response.created(createdResource).build();
+ }
+ // // http://localhost:8080/user-management/add-user/user-management/users/hugob
+ // http://localhost:8080/user-management/users/hugob
+
+// **********************************
+// ****** REMOVE USER ***************
+// **********************************
+ @POST
+ @Path("delete")
+ public void removeUser(@FormParam("user") String userName) {
+ // System.out.println("DELETE " + userName);
+ Resource userResource = getNamedUser(userName).getNode();
+ Iterator<Triple> userTriples = systemGraph.filter((NonLiteral) userResource, null, null);
+
+ ArrayList<Triple> buffer = new ArrayList<Triple>();
+
+ Lock readLock = systemGraph.getLock().readLock();
+ readLock.lock();
+ try {
+ while (userTriples.hasNext()) {
+ Triple triple = userTriples.next();
+ buffer.add(triple);
+ }
+ } finally {
+ readLock.unlock();
+ }
+
+ // Graph context = getNamedUser(userName).getNodeContext();
+ Lock writeLock = systemGraph.getLock().writeLock();
+ writeLock.lock();
+ try {
+ systemGraph.removeAll(buffer);
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ /**
+ * Endpoint-style user deletion takes a little bunch of Turtle e.g. [] a
+ * foaf:Agent ; cz:userName "Hugo Ball" .
+ *
+ * @param userData
+ * @return HTTP/1.1 204 No Content
+ */
+ @POST
+ @Consumes(SupportedFormat.TURTLE)
+ @Path("delete-user")
+ public Response deleteUser(String userData) {
+
+ log.debug("deleteUser called with " + userData);
+
+ Graph inputGraph = readData(userData);
+
+ Iterator<Triple> userNameTriples = inputGraph.filter(null,
+ PLATFORM.userName, null);
+
+ Literal userNameNode = (Literal) userNameTriples.next().getObject();
+
+ // gives concurrent mod exception otherwise
+ ArrayList<Triple> tripleBuffer = new ArrayList<Triple>();
+ Lock readLock = systemGraph.getLock().readLock();
+ readLock.lock();
+ try {
+ Iterator<Triple> userTriples = systemGraph.filter(null, null,
+ userNameNode);
+
+ Triple userTriple = userTriples.next();
+ Iterator<Triple> systemUserTriples = systemGraph.filter(
+ userTriple.getSubject(), null, null);
+
+
+ while (systemUserTriples.hasNext()) {
+ tripleBuffer.add(systemUserTriples.next());
+ }
+ } finally {
+ readLock.unlock();
+ }
+
+ systemGraph.removeAll(tripleBuffer);
+
+ // it's not actually creating a resource at this URI so this
+ // seems the most appropriate response
+ return Response.noContent().build();
+ }
+
+// **********************************
+// ****** SHOW ROLE DETAILS *********
+// **********************************
+// **********************************
+// ****** LIST ROLES ****************
+// **********************************
+ @GET
+ @Path("roles")
+ @Produces(MediaType.TEXT_HTML)
+ public RdfViewable listRoles() {
+ return new RdfViewable("listRole.ftl", getRoleType(), this.getClass());
+ }
+
+// **********************************
+// ****** ADD ROLE ******************
+// **********************************
+// **********************************
+// ****** REMOVE ROLE ***************
+// **********************************
+// **********************************
+// ****** ASSIGN ROLE TO USER *******
+// **********************************
+// **********************************
+// ****** REMOVE ROLE FROM USER *****
+// **********************************
+// **********************************
+// ****** LIST PERMISSIONS **********
+// **********************************
+ @GET
+ @Path("permissions")
+ @Produces(MediaType.TEXT_HTML)
+ public RdfViewable listPermissions() {
+ addClassToPermissions();
+ return new RdfViewable("listPermission.ftl", getPermissionType(), this.getClass());
+ }
+
+// **********************************
+// ****** ADD PERMISSION TO USER ****
+// **********************************
+// **************************************
+// ****** REMOVE PERMISSION FROM USER ***
+// **************************************
+// ************************************
+// ****** ADD PERMISSION TO ROLE ******
+// ************************************
+// **************************************
+// ****** REMOVE PERMISSION FROM ROLE ***
+// **************************************
+ // misc
+ @GET
+ public String index() throws UnsupportedEncodingException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ serializer.serialize(baos, systemGraph, SupportedFormat.TURTLE);
+ String serialized = new String(baos.toByteArray(), "utf-8");
+ return serialized;
+ }
+
+ public GraphNode getUserType() {
+ return new GraphNode(FOAF.Agent, systemGraph);
+ }
+
/**
* takes edit form data and pushes into store "" values are ignored
*/
@@ -282,7 +694,7 @@ public class UserResource {
public void replaceSubGraph(@QueryParam("graph") UriRef graphUri,
@FormDataParam("assert") String assertedString,
@FormDataParam("revoke") String revokedString,
- @FormDataParam("format") @DefaultValue("text/turtle") String format) {
+ @FormDataParam("format") @DefaultValue(SupportedFormat.TURTLE) String format) {
final Graph assertedGraph;
final Graph revokedGraph;
try {
@@ -303,28 +715,6 @@ public class UserResource {
systemGraph.addAll(assertedGraph);
}
- @GET
- @Path("roles")
- @Produces(MediaType.TEXT_HTML)
- public RdfViewable listRoles() {
- return new RdfViewable("listRole.ftl", getRoleType(), this.getClass());
- }
-
- @GET
- @Path("permissions")
- @Produces(MediaType.TEXT_HTML)
- public RdfViewable listPermissions() {
- addClassToPermissions();
- return new RdfViewable("listPermission.ftl", getPermissionType(), this.getClass());
- }
-
- @GET
- @Path("user/{username}/permissionsCheckboxes")
- @Produces(MediaType.TEXT_HTML)
- public RdfViewable permissionsCheckboxes(@PathParam("username") String userName) { //getUser(userName)
- return new RdfViewable("permissionsCheckboxes.ftl", getUser(userName), this.getClass());
- }
-
public GraphNode getPermissionType() {
return new GraphNode(PERMISSION.Permission,
systemGraph);
@@ -362,240 +752,12 @@ public class UserResource {
}
}
- @GET
- @Path("rolesCheckboxes")
- @Produces(MediaType.TEXT_HTML)
- public RdfViewable rolesCheckboxes() {
- return new RdfViewable("rolesCheckboxes.ftl", getRoleType(), this.getClass());
- }
-
public GraphNode getRoleType() {
return new GraphNode(PERMISSION.Role,
systemGraph);
}
- @POST
- @Path("delete")
- public void removeUser(@FormParam("user") String userName) {
- // System.out.println("DELETE " + userName);
- Resource userResource = getNamedUser(userName).getNode();
- Iterator<Triple> userTriples = systemGraph.filter((NonLiteral) userResource, null, null);
-
- ArrayList<Triple> buffer = new ArrayList<Triple>();
-
- Lock readLock = systemGraph.getLock().readLock();
- readLock.lock();
- try {
- while (userTriples.hasNext()) {
- Triple triple = userTriples.next();
- buffer.add(triple);
- }
- } finally {
- readLock.unlock();
- }
-
- // Graph context = getNamedUser(userName).getNodeContext();
- Lock writeLock = systemGraph.getLock().writeLock();
- writeLock.lock();
- try {
- systemGraph.removeAll(buffer);
- } finally {
- writeLock.unlock();
- }
- }
-
- /**
- * ********************
- * Endpoint API ********************
- */
- /**
- * Endpoint-style user creation takes a little bunch of Turtle e.g. [] a
- * foaf:Agent ; cz:userName "Hugo Ball" .
- *
- * @param userData
- * @return HTTP/1.1 204 No Content
- */
- @POST
- @Consumes(SupportedFormat.TURTLE)
- @Path("add-user")
- public Response addUser(String userData) {
-
- log.debug(("addUser called with " + userData));
-
- Graph inputGraph = readData(userData);
-
- Iterator<Triple> agents = inputGraph.filter(null, null, FOAF.Agent);
-
- NonLiteral userNode = agents.next().getSubject();
-
- Iterator<Triple> userTriples = inputGraph.filter(userNode, null, null);
-
-
- Lock writeLock = systemGraph.getLock().writeLock();
- writeLock.lock();
- try {
- while (userTriples.hasNext()) {
- Triple userTriple = userTriples.next();
- systemGraph.add(userTriple);
- }
- } finally {
- writeLock.unlock();
- }
-
- // it's not actually creating a resource at this URI so this
- // seems the most appropriate response
- return Response.noContent().build();
- }
-
- /**
- * Endpoint-style user deletion takes a little bunch of Turtle e.g. [] a
- * foaf:Agent ; cz:userName "Hugo Ball" .
- *
- * @param userData
- * @return HTTP/1.1 204 No Content
- */
- @POST
- @Consumes(SupportedFormat.TURTLE)
- @Path("delete-user")
- public Response deleteUser(String userData) {
-
- log.debug("deleteUser called with " + userData);
-
- Graph inputGraph = readData(userData);
-
- Iterator<Triple> userNameTriples = inputGraph.filter(null,
- PLATFORM.userName, null);
-
- Literal userNameNode = (Literal) userNameTriples.next().getObject();
-
- // gives concurrent mod exception otherwise
- ArrayList<Triple> tripleBuffer = new ArrayList<Triple>();
- Lock readLock = systemGraph.getLock().readLock();
- readLock.lock();
- try {
- Iterator<Triple> userTriples = systemGraph.filter(null, null,
- userNameNode);
-
- Triple userTriple = userTriples.next();
- Iterator<Triple> systemUserTriples = systemGraph.filter(
- userTriple.getSubject(), null, null);
-
-
- while (systemUserTriples.hasNext()) {
- tripleBuffer.add(systemUserTriples.next());
- }
- } finally {
- readLock.unlock();
- }
-
- systemGraph.removeAll(tripleBuffer);
-
- // it's not actually creating a resource at this URI so this
- // seems the most appropriate response
- return Response.noContent().build();
- }
-
- // needs refactoring and locks adding
- @POST
- @Consumes(SupportedFormat.TURTLE)
- @Path("change-user")
- public Response changeUser(String userData) {
-
- log.debug("changeUser called with " + userData);
-
- Graph inputGraph = readData(userData);
-
- Lock readLock = systemGraph.getLock().readLock();
- readLock.lock();
- Iterator<Triple> changes = inputGraph.filter(null, null,
- Ontology.Change);
-
- while (changes.hasNext()) {
- Triple changeTriple = changes.next();
-
- NonLiteral changeNode = changeTriple.getSubject();
-
- Literal userName = (Literal) inputGraph
- .filter(changeNode, PLATFORM.userName, null).next()
- .getObject();
-
- NonLiteral userNode = (NonLiteral) systemGraph
- .filter(null, PLATFORM.userName, userName).next()
- .getSubject();
-
- UriRef predicateUriRef = (UriRef) inputGraph
- .filter(changeNode, Ontology.predicate, null).next()
- .getObject();
-
- // System.out.println("predicateUriRef = " + predicateUriRef);
-
- // handle old value (if it exists)
- Iterator<Triple> iterator = inputGraph.filter(changeNode,
- Ontology.oldValue, null);
- Resource oldValue = null;
-
- if (iterator.hasNext()) {
- oldValue = iterator.next().getObject();
-
- // Triple oldTriple = systemGraph.filter(null, predicateUriRef,
- // oldValue).next();
- Triple oldTriple = systemGraph.filter(userNode,
- predicateUriRef, oldValue).next();
-
- systemGraph.remove(oldTriple);
- }
-
- Resource newValue = inputGraph
- .filter(changeNode, Ontology.newValue, null).next()
- .getObject();
-
- Triple newTriple = new TripleImpl(userNode, predicateUriRef,
- newValue);
-
- systemGraph.add(newTriple);
- }
-
- // it's not actually creating a resource at this URI so this
- // seems the most appropriate response
- return Response.noContent().build();
- }
-
- /**
- * RESTful access to individual user data
- *
- * @param userName
- * @return context graph for user
- * @throws UnsupportedEncodingException
- */
- @GET
- @Path("users/{username}")
- @Produces(SupportedFormat.TURTLE)
- public Response getUserTurtle(@PathParam("username") String userName)
- throws UnsupportedEncodingException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- serializer.serialize(baos, getUser(userName).getNodeContext(),
- SupportedFormat.TURTLE);
- String serialized = new String(baos.toByteArray(), "utf-8");
- // System.out.println("User = "+serialized);
- return Response.ok(serialized).build();
- }
-
- /// LOCKS MAYBE OK TO HERE
- /**
- * RESTful access to user roles (and permissions right now - may change)
- *
- * @param userName
- * @return context graph for user
- * @throws UnsupportedEncodingException
- */
- @GET
- @Path("roles/{username}")
- @Produces(SupportedFormat.TURTLE)
- public Response getUserRoles(@PathParam("username") String userName)
- throws UnsupportedEncodingException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
+ private MGraph getUserRolesGraph(String userName) {
GraphNode userNode = getUser(userName);
Iterator<Resource> functionIterator = userNode
@@ -622,16 +784,12 @@ public class UserResource {
rolesGraph.addAll(detailsGraph);
}
}
- // case of no roles not handled - what best to return : empty graph or
- // 404?
- serializer.serialize(baos, rolesGraph, SupportedFormat.TURTLE);
- String serialized = new String(baos.toByteArray(), "utf-8");
- return Response.ok(serialized).build();
+ return rolesGraph;
}
/**
**********************
- * helper methods
+ * helper methods *********************
*/
private GraphNode createUser(String newUserName) {
BNode subject = new BNode();
@@ -835,7 +993,7 @@ public class UserResource {
try {
inputGraph = parser.parse(
new ByteArrayInputStream(data.getBytes("utf-8")),
- "text/turtle");
+ SupportedFormat.TURTLE);
} catch (IOException ex) {
log.error("parsing error with userData", ex);
throw new WebApplicationException(ex, 500);
@@ -857,8 +1015,8 @@ public class UserResource {
if (!iter.hasNext()) {
return null;
}
-
- return new GraphNode(iter.next().getSubject(), systemGraph);
+
+ return new GraphNode(iter.next().getSubject(), systemGraph);
}
public Set<GraphNode> getUsers() {
@@ -871,12 +1029,12 @@ public class UserResource {
try {
final Iterator<Triple> triples = systemGraph.filter(null, RDF.type,
type);
- Set<GraphNode> userRoles = new HashSet<GraphNode>();
+ Set<GraphNode> resources = new HashSet<GraphNode>();
while (triples.hasNext()) {
- userRoles.add(new GraphNode(triples.next().getSubject(),
+ resources.add(new GraphNode(triples.next().getSubject(),
systemGraph));
}
- return userRoles;
+ return resources;
} finally {
readLock.unlock();
}
Modified: stanbol/trunk/commons/security/usermanagement/src/main/resources/templates/html/org/apache/stanbol/commons/usermanagement/resource/listUser.ftl
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/usermanagement/src/main/resources/templates/html/org/apache/stanbol/commons/usermanagement/resource/listUser.ftl?rev=1448794&r1=1448793&r2=1448794&view=diff
==============================================================================
--- stanbol/trunk/commons/security/usermanagement/src/main/resources/templates/html/org/apache/stanbol/commons/usermanagement/resource/listUser.ftl (original)
+++ stanbol/trunk/commons/security/usermanagement/src/main/resources/templates/html/org/apache/stanbol/commons/usermanagement/resource/listUser.ftl Thu Feb 21 20:24:04 2013
@@ -1,18 +1,18 @@
<#--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
-->
<@namespace platform="http://clerezza.org/2009/08/platform#" />
<@namespace permission="http://clerezza.org/2008/10/permission#" />
@@ -22,31 +22,37 @@
<tbody>
<@ldpath path="fn:sort(^rdf:type)">
<#assign fullName>
- <@ldpath path="foaf:name :: xsd:string"/>
+ <@ldpath path="foaf:name :: xsd:string"/>
</#assign>
<#assign userName>
- <@ldpath path="platform:userName :: xsd:string"/>
+ <@ldpath path="platform:userName :: xsd:string"/>
+ </#assign>
+
+ <#assign mbox>
+ <@ldpath path="foaf:mbox" />
</#assign>
+
+ <#assign email>
+ <#if mbox != "">${mbox?substring(7)}</#if>
+ </#assign>
+
+ <#assign roles>
+ <@ldpath path="fn:sort(sioc:has_function)">
+
+ <#assign role>
+ <@ldpath path="dc:title :: xsd:string"/>
+ </#assign>
+ <#if role != "BasePermissionsRole">${role}</#if>
+ </...@ldpath>
+ </#assign>
+
<tr>
<td>${fullName}</td>
<td>${userName}</td>
-
- <#assign mbox>
- <@ldpath path="foaf:mbox" />
- </#assign>
-
- <#assign email>
- <#if mbox != "">${mbox?substring(7)}</#if>
- </#assign>
-
<td>${email}</td>
+ <td>${roles}</td>
<td>
- <@ldpath path="fn:sort(sioc:has_function)">
- <@ldpath path="dc:title :: xsd:string"/>
- </...@ldpath>
- </td>
- <td>
<ul class="icons ui-widget">
<li class="dynhover ui-state-default ui-corner-all" title="Edit" onClick="javascript:editUser('${userName}')"><span class="ui-icon ui-icon-edit"> </span></li>
<li class="dynhover ui-state-default ui-corner-all delete" title="Delete" onClick="javascript:removeUser('${userName}')"><span class="ui-icon ui-icon-trash"> </span><div id="remove${userName}" class="hidden delete-dialog" title="Remove User"><p><br/>Delete user : ${userName}?</p></div></li>
Modified: stanbol/trunk/commons/security/usermanagement/src/main/resources/templates/html/org/apache/stanbol/commons/usermanagement/webConsole.ftl
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/usermanagement/src/main/resources/templates/html/org/apache/stanbol/commons/usermanagement/webConsole.ftl?rev=1448794&r1=1448793&r2=1448794&view=diff
==============================================================================
--- stanbol/trunk/commons/security/usermanagement/src/main/resources/templates/html/org/apache/stanbol/commons/usermanagement/webConsole.ftl (original)
+++ stanbol/trunk/commons/security/usermanagement/src/main/resources/templates/html/org/apache/stanbol/commons/usermanagement/webConsole.ftl Thu Feb 21 20:24:04 2013
@@ -31,12 +31,6 @@ limitations under the License.
<br />
-<!--
-<#assign userName>
-<@ldpath path="platform:userName :: xsd:string"/>
-</#assign>
--->
-
<div title="Edit User" id="editUserForm">
</div>
<!-- #include "/html/editUserForm.ftl" -->
@@ -54,10 +48,8 @@ limitations under the License.
<script>
- $(function() {
-
-
-
+ $(function() {
+ $.ajaxSetup({dataType:"text/html"}); // set default
$("#tabs").tabs();
showUserList();
showRoleList();
@@ -258,17 +250,21 @@ limitations under the License.
});
}
+// accepts: "text/html",
+
function editUser(userName){
+ $.ajaxSetup({dataType:"text/html"});
$.ajax({
url: '/user-management/user/'+userName,
success: function(data) {
$("#editUserForm").html(data);
$("#password-label").html("<label for='password' id='password-label'>Password (leave blank to retain existing password)</label>");
- $.get("/user-management/rolesCheckboxes",
+ $.get("/user-management/user/"+userName+"/rolesCheckboxes",
function(data){
$("#roles-checkboxes").html(data);
}, "text/html");
+
$.get("/user-management/user/"+userName+"/permissionsCheckboxes",
function(data){