You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2010/02/18 15:09:44 UTC
svn commit: r911408 - in
/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager:
./ src/main/java/org/apache/clerezza/platform/usermanager/
Author: reto
Date: Thu Feb 18 14:09:43 2010
New Revision: 911408
URL: http://svn.apache.org/viewvc?rev=911408&view=rev
Log:
CLEREZZA-107: merged up issue
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/ (props changed)
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/pom.xml
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/src/main/java/org/apache/clerezza/platform/usermanager/UserManager.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/src/main/java/org/apache/clerezza/platform/usermanager/UserManagerImpl.java
Propchange: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 18 14:09:43 2010
@@ -1 +1,2 @@
+/incubator/clerezza/issues/CLEREZZA-107/org.apache.clerezza.platform.usermanager:908104-911404
/incubator/clerezza/issues/CLEREZZA-87/org.apache.clerezza.platform.usermanager:905960-908526
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/pom.xml?rev=911408&r1=911407&r2=911408&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/pom.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/pom.xml Thu Feb 18 14:09:43 2010
@@ -24,7 +24,7 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
@@ -43,6 +43,10 @@
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.platform.graphprovider.content</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
<artifactId>org.apache.clerezza.platform.typerendering.core</artifactId>
</dependency>
<dependency>
@@ -72,4 +76,4 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/src/main/java/org/apache/clerezza/platform/usermanager/UserManager.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/src/main/java/org/apache/clerezza/platform/usermanager/UserManager.java?rev=911408&r1=911407&r2=911408&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/src/main/java/org/apache/clerezza/platform/usermanager/UserManager.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/src/main/java/org/apache/clerezza/platform/usermanager/UserManager.java Thu Feb 18 14:09:43 2010
@@ -25,14 +25,14 @@
import org.apache.clerezza.rdf.utils.GraphNode;
/**
- * An implementation of this interface provides methods to manage data about
+ * An implementation of this interface provides methods to manage data about
* users and their roles.
* Data managed are needed for authentication and for setting permissions.
- * Those data include user names, email addresses, passwords, roles, permissions,
+ * Those data include user names, email addresses, passwords, roles, permissions,
* etc.
* A user is uniquely identified by a user name.
* Each user has an email address and an email address can only belong to a user.
- *
+ *
* @author hasan, tio
*/
public interface UserManager {
@@ -54,29 +54,29 @@
public boolean roleExists(String title);
/**
- *
+ *
* @param title
* @return NonLiteral which is either a BNode or a UriRef
*/
public NonLiteral getRoleByTitle(String title);
/**
- *
+ *
* @return Iterator defining all roles
*/
public Iterator<NonLiteral> getRoles();
-
+
/**
- *
- * @param user
+ *
+ * @param user
* the user is either a BNode or a UriRef
- *
+ *
* @return Iterator defining all the Roles the specified user owns
*/
public Iterator<NonLiteral> getRolesOfUser(NonLiteral user);
/**
- *
+ *
* @param title
* the title of the role to be deleted, may not be null
*/
@@ -149,7 +149,7 @@
public boolean nameExists(String name);
/**
- * Checks if the email exists
+ * Checks if thereis already an agent with that email address.
*
* @param email
* @return true if exists otherwise false
@@ -169,14 +169,50 @@
/**
*
* @param name specifies the username of the user
- * @return NonLiteral which is either a BNode or a UriRef
+ * @return NonLiteral representing the user in the system Graph
*/
+ @Deprecated
public NonLiteral getUserByName(String name);
/**
+ * Returns the user with the specified name in an (editable) MGraph
+ * (i.e. a SimpleGraph but this is implementation specific) with the context
+ * of the user node, editing the graphnode('s Mgraph) doesn't cause any
+ * changes elsewhere. Returns null if the user does not exist.
+ * The caller of this method needs the permission to read the system graph,
+ * otherwise a AccessControlException will be thrown.
+ *
+ * @param name The username of the user
+ * @return GraphNode representing the suer with some context in a dedicated MGraph
+ */
+ public GraphNode getUserGraphNode(String name);
+
+ /**
+ * Returns the <code>GraphNode</code> pointing to the user with the
+ * specified name in the system graph. Returns null if the user does not
+ * exist.
+ *
+ * @param name The username of the user
+ * @return GraphNode represing the user in the system graph
+ */
+ public GraphNode getUserInSystemGraph(String name);
+
+ /**
+ * Returns the <code>GraphNode</code> pointing to the user with the
+ * specified name in the content graph. If the user does not exist in the
+ * content graph, but in the system graph, then the it is created with the
+ * PLATFORM.userName property copied from the system graph. Returns null if
+ * the user does not exist.
+ *
+ * @param name The username of the user
+ * @return GraphNode representing the user in the content graph
+ */
+ public GraphNode getUserInContentGraph(String name);
+
+ /**
* Returns all users.
*
- * @return Iterator defining all users.
+ * @return Iterator of users in the system Graph.
*/
public Iterator<NonLiteral> getUsers();
@@ -215,12 +251,4 @@
* @param name specifies the username of the user, may not be null
*/
public void deleteAllPermissionsOfUser(String name);
-
- /**
- * Retrieves all information associated with a user as GraphNode.
- *
- * @param name specifies the username of the user, may not be null
- * @return GraphNode
- */
- public GraphNode getUserGraphNode(String name);
}
Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/src/main/java/org/apache/clerezza/platform/usermanager/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/src/main/java/org/apache/clerezza/platform/usermanager/UserManagerImpl.java?rev=911408&r1=911407&r2=911408&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/src/main/java/org/apache/clerezza/platform/usermanager/UserManagerImpl.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/src/main/java/org/apache/clerezza/platform/usermanager/UserManagerImpl.java Thu Feb 18 14:09:43 2010
@@ -32,6 +32,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.clerezza.platform.config.SystemConfig;
+import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider;
import org.apache.clerezza.rdf.core.BNode;
import org.apache.clerezza.rdf.core.MGraph;
import org.apache.clerezza.rdf.core.NonLiteral;
@@ -61,6 +62,9 @@
@Reference(target=SystemConfig.SYSTEM_GRAPH_FILTER)
private MGraph systemGraph;
+ @Reference
+ private ContentGraphProvider cgProvider;
+
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
@@ -304,7 +308,7 @@
return;
}
- if (getUserByName(name) != null) {
+ if (getUserByUserName(name) != null) {
throw new UserAlreadyExistsException(name);
}
if (email != null) {
@@ -388,7 +392,7 @@
return;
}
- NonLiteral user = getUserByName(name);
+ NonLiteral user = getUserByUserName(name);
if (user == null) {
throw new UserNotExistsException(name);
}
@@ -451,12 +455,7 @@
@Override
public NonLiteral getUserByName( String name) {
- Iterator<Triple> triples = systemGraph.filter(null, PLATFORM.userName,
- new PlainLiteralImpl(name));
- if (triples.hasNext()) {
- return triples.next().getSubject();
- }
- return null;
+ return getUserByUserName(name);
}
@Override
@@ -470,7 +469,7 @@
return;
}
- NonLiteral user = getUserByName(name);
+ NonLiteral user = getUserByUserName(name);
if (user != null) {
deleteTriplesOfASubject(user);
}
@@ -485,7 +484,7 @@
}
addPermissionEntriesForARole(
- getUserByName(name), name,
+ getUserByUserName(name), name,
permissionEntries);
}
@@ -503,7 +502,7 @@
}
deletePermissionEntriesOfARole(
- getUserByName(name), name,
+ getUserByUserName(name), name,
permissionEntries);
}
@@ -514,7 +513,7 @@
}
deleteAllPermissionEntriesOfARole(
- getUserByName(name));
+ getUserByUserName(name));
}
/**
@@ -535,21 +534,61 @@
}
@Override
- public GraphNode getUserGraphNode(final String name) {
- return AccessController.doPrivileged(new PrivilegedAction<GraphNode>() {
+ public GraphNode getUserInSystemGraph(final String name) {
+ NonLiteral user = getUserByUserName(name);
+ if (user != null) {
+ return new GraphNode(user, systemGraph);
+ } else {
+ return null;
+ }
+ }
- @Override
- public GraphNode run() {
- NonLiteral user = getUserByName(name);
- if(user != null) {
- GraphNode node = new GraphNode(user, new SimpleMGraph(
- new GraphNode(user, systemGraph).getNodeContext()));
- return node;
- } else {
- throw new RuntimeException("No user with username " + name + " exists");
- }
+ @Override
+ public GraphNode getUserInContentGraph(final String name) {
+ final MGraph contentGraph = cgProvider.getContentGraph();
+ Iterator<Triple> triples = contentGraph.filter(null, PLATFORM.userName,
+ new PlainLiteralImpl(name));
+ GraphNode resultNode = null;
+ if (triples.hasNext()) {
+ resultNode = new GraphNode(triples.next().getSubject(), contentGraph);
+ } else {
+ NonLiteral user = AccessController.doPrivileged(
+ new PrivilegedAction<NonLiteral>() {
+
+ @Override
+ public NonLiteral run() {
+ return getUserByUserName(name);
+ }
+ });
+ if (user != null) {
+ resultNode = new GraphNode(new BNode(), contentGraph);
+ resultNode.addProperty(PLATFORM.userName,
+ new PlainLiteralImpl(name));
}
- });
+ }
+ return resultNode;
+ }
+
+ @Override
+ public GraphNode getUserGraphNode(final String name) {
+ NonLiteral user = getUserByUserName(name);
+ if (user != null) {
+ GraphNode userNodeInSystemGraph =
+ new GraphNode(getUserByUserName(name), systemGraph);
+ MGraph copiedUserContext = new SimpleMGraph(userNodeInSystemGraph.getNodeContext());
+ return new GraphNode(userNodeInSystemGraph.getNode(),
+ copiedUserContext);
+ } else {
+ return null;
+ }
}
+ private NonLiteral getUserByUserName(String name) {
+ Iterator<Triple> triples = systemGraph.filter(null, PLATFORM.userName,
+ new PlainLiteralImpl(name));
+ if (triples.hasNext()) {
+ return triples.next().getSubject();
+ }
+ return null;
+ }
}