incubator-ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1042644 - in /incubator/ace/trunk/ace-resourceprocessor-useradmin: ./ src/main/java/org/apache/ace/resourceprocessor/useradmin/ src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/
Date Mon, 06 Dec 2010 13:52:52 GMT
Author: marrs
Date: Mon Dec  6 13:52:51 2010
New Revision: 1042644

URL: http://svn.apache.org/viewvc?rev=1042644&view=rev
Log:
Various bugfixes to get this processor running again.

Modified:
    incubator/ace/trunk/ace-resourceprocessor-useradmin/osgi.bnd
    incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/UserAdminConfigurator.java
    incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/Processor.java
    incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/ResourceStore.java
    incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/UserAdminStore.java

Modified: incubator/ace/trunk/ace-resourceprocessor-useradmin/osgi.bnd
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-resourceprocessor-useradmin/osgi.bnd?rev=1042644&r1=1042643&r2=1042644&view=diff
==============================================================================
--- incubator/ace/trunk/ace-resourceprocessor-useradmin/osgi.bnd (original)
+++ incubator/ace/trunk/ace-resourceprocessor-useradmin/osgi.bnd Mon Dec  6 13:52:51 2010
@@ -1,11 +1,9 @@
-Bundle-Version>:\
-  ${pom.version}
+Bundle-Version>: ${pom.version}
 
-Bundle-SymbolicName:\
-  ${bundle.symbolicName}
+Bundle-SymbolicName: ${bundle.symbolicName}
 
-Export-Package:\
-  ${bundle.namespace}; version="${pom.version}"
+Export-Package: ${bundle.namespace}; version="${pom.version}"
 
-Bundle-Activator: \
-  ${bundle.namespace}.impl.Activator
\ No newline at end of file
+Bundle-Activator: ${bundle.namespace}.impl.Activator
+  
+Deployment-ProvidesResourceProcessor: org.apache.ace.resourceprocessor.useradmin
\ No newline at end of file

Modified: incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/UserAdminConfigurator.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/UserAdminConfigurator.java?rev=1042644&r1=1042643&r2=1042644&view=diff
==============================================================================
--- incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/UserAdminConfigurator.java
(original)
+++ incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/UserAdminConfigurator.java
Mon Dec  6 13:52:51 2010
@@ -37,7 +37,7 @@ import org.w3c.dom.Document;
  *     <user name="user1">
  *         <properties>
  *             <realname type="String">Mr. U. One</realname>
- *             <address>1 Infinite Loop</realname>
+ *             <address>1 Infinite Loop</address>
  *         </properties>
  *         <credentials>
  *             <password type="byte[]">secret</password>

Modified: incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/Processor.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/Processor.java?rev=1042644&r1=1042643&r2=1042644&view=diff
==============================================================================
--- incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/Processor.java
(original)
+++ incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/Processor.java
Mon Dec  6 13:52:51 2010
@@ -41,7 +41,7 @@ public class Processor implements Resour
     private List<String> m_toInstall;
     private List<String> m_toRemove;
 
-    private ResourceStore m_resourceStore;
+    private final ResourceStore m_resourceStore;
 
     Processor(ResourceStore store) {
         m_resourceStore = store;
@@ -121,6 +121,8 @@ public class Processor implements Resour
 
     public void commit() {
         ensureSession();
+        m_resourceStore.begin();
+
         while (!m_toInstall.isEmpty()) {
             try {
                 m_resourceStore.install(m_toInstall.remove(0));
@@ -138,6 +140,7 @@ public class Processor implements Resour
             }
         }
 
+        m_resourceStore.end();
         endSession();
     }
 

Modified: incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/ResourceStore.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/ResourceStore.java?rev=1042644&r1=1042643&r2=1042644&view=diff
==============================================================================
--- incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/ResourceStore.java
(original)
+++ incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/ResourceStore.java
Mon Dec  6 13:52:51 2010
@@ -71,9 +71,10 @@ abstract class ResourceStore
 
     /**
      * Adds a resource to persistent storage and handles the administration.
-     * @param deploymentPackageName The name of a deployment package.
-     * @param name The name of the resource.
-     * @param stream A stream form which the resource with <code>name</code>
can be read.
+     *
+     * @param deploymentPackageName the name of a deployment package
+     * @param name the name of the resource
+     * @param stream a stream from which the resource with <code>name</code>
can be read
      */
     public void addResource(String deploymentPackageName, String name, InputStream stream)
throws IOException, ResourceProcessorException {
         synchronized (m_resources) {
@@ -122,25 +123,41 @@ abstract class ResourceStore
 
     /**
      * Checks the validity of a resource.
-     * @param resource A stream containing the resource
-     * @throws Exception Any exception can be thrown from this method, indicating 'what is
wrong' with the resource.
+     *
+     * @param resource a stream containing the resource
+     * @throws Exception when something is wrong with the resource
      */
     public abstract void validate(InputStream resource) throws Exception;
+    
     /**
-     * Installs a given resource
-     * @param resourceName The name of the resource.
+     * Marks the start of a deployment process.
+     */
+    public abstract void begin();
+
+    /**
+     * Marks the end of a deployment process.
+     */
+    public abstract void end();
+
+    /**
+     * Installs a given resource.
+     *
+     * @param resourceName the name of the resource
      */
     public abstract void install(String resourceName) throws IOException;
+
     /**
-     * Uninstalls a given resource
-     * @param resourceName The name of the resource.
+     * Uninstalls a given resource.
+     *
+     * @param resourceName the name of the resource
      */
     public abstract void uninstall(String resourceName) throws IOException;
 
     /**
      * Gets the names of all driver bundles that belong to a given deployment package.
-     * @param deploymentPackageName The name of a deployment package.
-     * @return A list of the names of all driver bundles that belong to <code>deploymentPackageName</code>.
+     *
+     * @param deploymentPackageName the name of a deployment package
+     * @return a list of the names of all driver bundles that belong to <code>deploymentPackageName</code>
      */
     public List<String> getResources(String deploymentPackageName) {
         synchronized (m_resources) {
@@ -156,9 +173,10 @@ abstract class ResourceStore
 
     /**
      * Gets the name of the deployment package to which a given resource belongs.
-     * @param resourceName The name of a resource.
-     * @return The name of the deployment package to which <code>resourceName</code>
-     * belongs, or <code>null</code> if this resource is unknown.
+     *
+     * @param resourceName the name of a resource
+     * @return the name of the deployment package to which <code>resourceName</code>
+     *     belongs, or <code>null</code> if this resource is unknown
      */
     public String getDeploymentPackage(String resourceName) {
         return m_resources.get(resourceName);
@@ -166,16 +184,14 @@ abstract class ResourceStore
 
     /**
      * Gets the stream belonging to a given resource.
-     * @param name The name of a the resource.
+     *
+     * @param name the name of a the resource
      * @return an InputStream providing access to the named resource. It is the caller's
      * task to close it.
-     * @throws java.io.IOException Thrown when an exception occurs accessing the resource.
+     * @throws java.io.IOException when an exception occurs accessing the resource
      */
     protected InputStream getResource(String name) throws IOException {
         File resource = new File(new File(m_context.getDataFile(TEMP_DIR), m_resources.get(name)),
name);
-
         return new FileInputStream(resource);
     }
-
-
-}
\ No newline at end of file
+}

Modified: incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/UserAdminStore.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/UserAdminStore.java?rev=1042644&r1=1042643&r2=1042644&view=diff
==============================================================================
--- incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/UserAdminStore.java
(original)
+++ incubator/ace/trunk/ace-resourceprocessor-useradmin/src/main/java/org/apache/ace/resourceprocessor/useradmin/impl/UserAdminStore.java
Mon Dec  6 13:52:51 2010
@@ -25,7 +25,6 @@ import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
-import java.util.ListIterator;
 import java.util.Map;
 import java.util.Map.Entry;
 
@@ -56,10 +55,24 @@ public class UserAdminStore extends Reso
     private Object m_installListLock = new Object();
     private boolean m_clear;
 
+    private List<String> m_installedUsers;
+    
     UserAdminStore(BundleContext context) {
         super(context);
     }
 
+    
+    
+    @Override
+    public void begin() {
+    	m_installedUsers = new ArrayList<String>();
+    }
+    
+    @Override
+    public void end() {
+    	m_installedUsers = new ArrayList<String>();
+    }
+    
     @Override
     public void install(String resourceName) throws IOException {
         InputStream input = getResource(resourceName);
@@ -95,7 +108,9 @@ public class UserAdminStore extends Reso
         m_toRemove.clear();
         installRoles(doc);
         m_clear = true;
+        begin();
         updateUserAdmin();
+        end();
     }
 
     public void setUsers(InputStream input) throws IOException {
@@ -122,12 +137,7 @@ public class UserAdminStore extends Reso
      */
     private void removeRoles(Document doc) {
         synchronized (m_installListLock) {
-            // do this backwards from the order in the file
-            List<ProcessRole> roles = getRoles(doc);
-            ListIterator<ProcessRole> i = roles.listIterator(roles.size());
-            for (ProcessRole role = i.previous(); i.hasPrevious(); i.previous()) {
-                m_toRemove.add(role);
-            }
+            m_toRemove.addAll(getRoles(doc));
         }
     }
 
@@ -142,13 +152,10 @@ public class UserAdminStore extends Reso
                     return;
                 }
 
-                List<String> updated = new ArrayList<String>();
-
                 // install or update all roles we have to update
                 while (!m_toInstall.isEmpty()) {
                     ProcessRole role = m_toInstall.remove(0);
                     updateRole(role);
-                    updated.add(role.getName());
                 }
 
                 // remove all roles that have not been updated if this install
@@ -162,7 +169,7 @@ public class UserAdminStore extends Reso
                         // Will not happen, since we pass in a null filter.
                     }
                     for (Role r : roles) {
-                        if (!updated.contains(r.getName())) {
+                        if (!m_installedUsers.contains(r.getName())) {
                             m_userAdmin.removeRole(r.getName());
                         }
                     }
@@ -172,8 +179,12 @@ public class UserAdminStore extends Reso
                 // removed
                 if (!m_clear) {
                     while (!m_toRemove.isEmpty()) {
-                        ProcessRole role = m_toRemove.remove(m_toRemove.size());
-                        m_userAdmin.removeRole(role.getName());
+                    	//do it tail to head
+                        ProcessRole role = m_toRemove.remove( m_toRemove.size() - 1 );
+                        
+                        if (!m_installedUsers.contains(role.getName())) {
+                        	m_userAdmin.removeRole(role.getName());
+                        }
                     }
                 }
 
@@ -188,6 +199,8 @@ public class UserAdminStore extends Reso
      */
     @SuppressWarnings("unchecked")
     private void updateRole(ProcessRole role) {
+        m_installedUsers.add(role.getName());
+        
         Role r = m_userAdmin.getRole(role.getName());
         if (r == null) {
             r = m_userAdmin.createRole(role.getName(), role.getType());
@@ -273,7 +286,9 @@ public class UserAdminStore extends Reso
                 throw new IllegalStateException("UserAdminStore is intended to work with
a single user admin.");
             }
             m_userAdmin = admin;
+            begin();
             updateUserAdmin();
+            end();
         }
     }
 



Mime
View raw message