jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1412067 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeMigrator.java
Date Wed, 21 Nov 2012 11:47:21 GMT
Author: angela
Date: Wed Nov 21 11:47:20 2012
New Revision: 1412067

URL: http://svn.apache.org/viewvc?rev=1412067&view=rev
Log:
OAK-64 : Privilege Management  (WIP)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeMigrator.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeMigrator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeMigrator.java?rev=1412067&r1=1412066&r2=1412067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeMigrator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeMigrator.java
Wed Nov 21 11:47:20 2012
@@ -48,6 +48,9 @@ import org.xml.sax.helpers.DefaultHandle
 /**
  * PrivilegeMigrator is a utility to migrate custom privilege definitions from
  * a jackrabbit 2 project to oak.
+ *
+ * TODO: this is an initial draft of a migration tool from jr2 custom privileges
+ * TODO: to oak. might need to be adjusted once we have defined a upgrade path (see OAK-458)
  */
 public class PrivilegeMigrator {
 
@@ -57,37 +60,25 @@ public class PrivilegeMigrator {
         this.contentSession = contentSession;
     }
 
-    public void migrateCustomPrivileges() throws RepositoryException {
+    public void migrateCustomPrivileges(InputStream privilegeStream) throws RepositoryException
{
         final Root root = contentSession.getLatestRoot();
         PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(root);
-        InputStream stream = null;
-        // FIXME: user proper path to jr2 custom privileges stored in fs
-        // jr2 used to be:
-        // new FileSystemResource(fs, "/privileges/custom_privileges.xml").getInputStream()
-        if (stream != null) {
-            try {
-                NamespaceRegistry nsRegistry = new ReadWriteNamespaceRegistry() {
-                    @Override
-                    protected Root getWriteRoot() {
-                        return root;
-                    }
+        try {
+            NamespaceRegistry nsRegistry = new ReadWriteNamespaceRegistry() {
+                @Override
+                protected Root getWriteRoot() {
+                    return root;
+                }
 
-                    @Override
-                    protected Tree getReadTree() {
-                        return root.getTree("/");
-                    }
-                };
-                Iterable<PrivilegeDefinition> custom = readCustomDefinitons(stream,
nsRegistry);
-                writer.writeDefinitions(custom);
-            } catch (IOException e) {
-                throw new RepositoryException(e);
-            } finally {
-                try {
-                    stream.close();
-                } catch (IOException e) {
-                    // ignore.
+                @Override
+                protected Tree getReadTree() {
+                    return root.getTree("/");
                 }
-            }
+            };
+            Iterable<PrivilegeDefinition> custom = readCustomDefinitons(privilegeStream,
nsRegistry);
+            writer.writeDefinitions(custom);
+        } catch (IOException e) {
+            throw new RepositoryException(e);
         }
     }
 
@@ -263,4 +254,4 @@ public class PrivilegeMigrator {
             return n.getNodeType() == Node.ELEMENT_NODE;
         }
     }
-}
\ No newline at end of file
+}



Mime
View raw message