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/03/17 18:09:09 UTC

svn commit: r1457490 - in /stanbol/trunk/commons/security/usermanagement/src/main: java/org/apache/stanbol/commons/usermanagement/resource/UserResource.java resources/templates/html/org/apache/stanbol/commons/usermanagement/webConsole.ftl

Author: reto
Date: Sun Mar 17 17:09:08 2013
New Revision: 1457490

URL: http://svn.apache.org/r1457490
Log:
STANBOL-897: simplifying code (and generalizing) by providing a graph response rather than serializing to a String. Settinng dataTypein ajax request to make sure Accept is html (alternative would have been an @Produces on getCreateUserForm)

Modified:
    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/webConsole.ftl

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=1457490&r1=1457489&r2=1457490&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 Sun Mar 17 17:09:08 2013
@@ -94,8 +94,7 @@ public class UserResource {
     private LockableMGraph systemGraph;
     @Reference
     private Parser parser;
-    @Reference
-    private Serializer serializer;
+
     private static GraphNode dummyNode;
 
     static {
@@ -169,17 +168,13 @@ public class UserResource {
     @GET
     @Path("roles/{username}")
     @Produces(SupportedFormat.TURTLE)
-    public Response getUserRoles(@PathParam("username") String userName)
+    public TripleCollection 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();
+        return rolesGraph;
     }
 
     /**
@@ -589,13 +584,13 @@ public class UserResource {
 // ****** REMOVE PERMISSION FROM ROLE *** 
 // **************************************
     // misc
-    @GET
+   /* @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);
@@ -615,11 +610,6 @@ public class UserResource {
 
         //   GraphNode userNode = getUser(currentUserName);
 
-        // System.out.println("currentUserName = " + currentUserName);
-//        System.out
-//                .println("BEFORE ========================================================");
-//        // serializeTriplesWithSubject(System.out, userNode);
-//        serializer.serialize(System.out, systemGraph, SupportedFormat.TURTLE);
 
         if (newUserName != null && !newUserName.equals("")) {
             changeLiteral(userNode, PLATFORM.userName, newUserName);
@@ -977,17 +967,6 @@ public class UserResource {
         systemGraph.removeAll(oldBuffer);
     }
 
-    private void serializeTriplesWithSubject(OutputStream stream, GraphNode node) {
-        serializer.serialize(stream, getTriplesWithSubject(node),
-                SupportedFormat.TURTLE);
-    }
-
-    private TripleCollection getTriplesWithSubject(GraphNode node) {
-        TripleCollection containerGraph = node.getGraph();
-        return new SimpleGraph(containerGraph.filter(
-                (NonLiteral) node.getNode(), null, null));
-    }
-
     /**
      * Read string into graph
      *

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=1457490&r1=1457489&r2=1457490&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 Sun Mar 17 17:09:08 2013
@@ -203,6 +203,7 @@ limitations under the License.
     function addUser(){
         $.ajax({
             url: '/user-management/create-form',
+            dataType: 'html',
             success: function(data) {
                 $("#editUserForm").html(data);
                 $("#editUserForm").title = "Create User";