diff artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java @ 157:6e6965873a48

Simplified creation of users. artifacts/trunk@1382 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 03 Mar 2011 10:33:49 +0000
parents a76de72ad6d1
children d718a4d55662
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Thu Mar 03 09:53:02 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Thu Mar 03 10:33:49 2011 +0000
@@ -8,10 +8,12 @@
 
 package de.intevation.artifactdatabase;
 
+import de.intevation.artifacts.ArtifactCollection;
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.ArtifactFactory;
 import de.intevation.artifacts.ArtifactSerializer;
 import de.intevation.artifacts.User;
+import de.intevation.artifacts.UserFactory;
 
 import de.intevation.artifacts.common.utils.XMLUtils;
 
@@ -818,8 +820,10 @@
     }
 
     public User createUser(
-        String   name, 
-        Document role
+        String      name, 
+        Document    role,
+        UserFactory factory,
+        Object      context
     ) {
         Connection        connection    = null;
         PreparedStatement stmnt_next_id = null;
@@ -864,7 +868,7 @@
 
                 connection.commit();
 
-                return new DefaultUser(identifier, name, role);
+                return factory.createUser(identifier, name, role, context);
             }
             catch (SQLException sqle) {
                 connection.rollback();
@@ -985,8 +989,11 @@
         return false;
     }
 
-    public User getUser(String identifier) {
-
+    public User getUser(
+        String      identifier, 
+        UserFactory factory,
+        Object      context
+    ) {
         Connection        conn   = null;
         ResultSet         result = null;
         PreparedStatement stmnt  = null;
@@ -1011,7 +1018,7 @@
 
             Document role = XMLUtils.fromByteArray(roleData);
 
-            return new DefaultUser(identifier, name, role);
+            return factory.createUser(identifier, name, role, context);
         }
         catch (SQLException sqle) {
             logger.error(sqle.getLocalizedMessage(), sqle);
@@ -1034,7 +1041,7 @@
         return null;
     }
 
-    public User [] getUsers() {
+    public User [] getUsers(UserFactory factory, Object context) {
         Connection        conn   = null;
         ResultSet         result = null;
         PreparedStatement stmnt  = null;
@@ -1054,7 +1061,8 @@
                 byte [] roleData   = result.getBytes(4);
 
                 Document role = XMLUtils.fromByteArray(roleData);
-                User     user = new DefaultUser(identifier, name, role);
+                User     user =
+                    factory.createUser(identifier, name, role, context);
                 users.add(user);
             }
 
@@ -1081,12 +1089,12 @@
         return null;
     }
 
-    public Collection [] listCollections(String userId) {
+    public ArtifactCollection [] listCollections(String userId) {
         // TODO: Implement me!
         return null;
     }
 
-    public Collection createCollection(String ownerId, Document data) {
+    public ArtifactCollection createCollection(String ownerId, Document data) {
         // TODO: Implement me!
         return null;
     }
@@ -1129,7 +1137,7 @@
         return false;
     }
 
-    public Collection [] listCollectionArtifacts(String collectionId) {
+    public ArtifactCollection [] listCollectionArtifacts(String collectionId) {
         // TODO: Implement me!
         return null;
     }

http://dive4elements.wald.intevation.org