sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r894398 - in /sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl: Activator.java security/PluggableDefaultAccessManager.java
Date Tue, 29 Dec 2009 14:21:09 GMT
Author: cziegeler
Date: Tue Dec 29 14:21:08 2009
New Revision: 894398

URL: http://svn.apache.org/viewvc?rev=894398&view=rev
Log:
Just code cleanup - no functional changes.

Modified:
    sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/Activator.java
    sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/security/PluggableDefaultAccessManager.java

Modified: sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/Activator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/Activator.java?rev=894398&r1=894397&r2=894398&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/Activator.java
(original)
+++ sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/Activator.java
Tue Dec 29 14:21:08 2009
@@ -69,13 +69,13 @@
     // the service tracker used by the PluggableDefaultLoginModule
     // this field is only set on the first call to getLoginModules()
     private static ServiceTracker loginModuleTracker;
-    
+
     // the tracking count when the moduleCache has been filled
     private static int lastTrackingCount = -1;
-    
+
     // the cache of login module services
     private static LoginModulePlugin[] moduleCache;
-    
+
     // empty list of login modules if there are none registered
     private static LoginModulePlugin[] EMPTY = new LoginModulePlugin[0];
 
@@ -85,10 +85,10 @@
 
     protected String getRepositoryName() {
     	String repoName = bundleContext.getProperty("sling.repository.name");
-    	if (repoName != null)
-    		return repoName; // the repository name is set
-    	else
-    		return "jackrabbit";
+    	if (repoName != null) {
+            return repoName; // the repository name is set
+    	}
+		return "jackrabbit";
     }
 
     public void start(BundleContext context) {
@@ -98,7 +98,7 @@
         // ensure the module cache is not set right now, this may
         // (theoretically) be non-null after the last bundle stop
         moduleCache = null;
-        
+
         // check the name of the default context, nothing to do if none
         slingContext = context.getProperty(SLING_CONTEXT_DEFAULT);
         if (slingContext == null) {
@@ -131,7 +131,7 @@
     }
 
     public void stop(BundleContext arg0) {
-        
+
         /*
          * when stopping Derby (which is used by Jackrabbit by default) a
          * derby.antiGC thread keeps running which prevents this bundle from
@@ -146,7 +146,7 @@
         } catch (Throwable t) {
             // exception is always thrown
         }
-        
+
         // drop module cache
         moduleCache = null;
 
@@ -160,7 +160,7 @@
             accessManagerFactoryTracker.close();
             accessManagerFactoryTracker = null;
         }
-        
+
         // clear the bundle context field
         bundleContext = null;
     }
@@ -179,7 +179,7 @@
     }
 
     // ---------- LoginModule tracker for PluggableDefaultLoginModule
-    
+
     private static BundleContext getBundleContext() {
         return bundleContext;
     }
@@ -197,7 +197,7 @@
             return moduleCache;
         }
         // invariant: moduleCache is null or modules have changed
-        
+
         // tracker may be null if moduleCache is null
         if (loginModuleTracker == null) {
             loginModuleTracker = new ServiceTracker(getBundleContext(),
@@ -250,15 +250,15 @@
             Hashtable<String, String> defaultConfig = new Hashtable<String, String>();
             final String overrideUrl = bundleContext.getProperty(RepositoryAccessor.REPOSITORY_URL_OVERRIDE_PROPERTY);
             if(overrideUrl != null && overrideUrl.length() > 0) {
-                // Ignore other parameters if override URL (SLING-254) is set 
+                // Ignore other parameters if override URL (SLING-254) is set
                 defaultConfig.put(RepositoryAccessor.REPOSITORY_URL_OVERRIDE_PROPERTY, overrideUrl);
-                log.info(RepositoryAccessor.REPOSITORY_URL_OVERRIDE_PROPERTY + "=" + overrideUrl
+ 
+                log.info(RepositoryAccessor.REPOSITORY_URL_OVERRIDE_PROPERTY + "=" + overrideUrl
+
                     ", using it to create the default configuration");
-                
+
             } else {
-               initDefaultConfig(defaultConfig, bundleContext); 
+               initDefaultConfig(defaultConfig, bundleContext);
             }
-            
+
             // create the factory and set the properties
             Configuration config = ca.createFactoryConfiguration(SERVER_REPOSITORY_FACTORY_PID);
             config.update(defaultConfig);
@@ -273,12 +273,12 @@
             bundleContext.ungetService(ref);
         }
     }
-    
+
     private void initDefaultConfig(Hashtable<String, String> props, BundleContext bundleContext)
throws IOException {
         File homeDir = getHomeDir(bundleContext);
         if (homeDir == null)
         	return;
-       
+
         File configFile = getConfigFile(bundleContext, homeDir);
 
         // default config values
@@ -290,21 +290,21 @@
         props.put(SlingServerRepository.REPOSITORY_REGISTRATION_NAME,
             this.getRepositoryName());
     }
-    
+
     private File getHomeDir(BundleContext bundleContext) throws IOException {
     	File homeDir;
-    	
+
     	String repoHomePath = bundleContext.getProperty("sling.repository.home");
     	String slingHomePath = bundleContext.getProperty("sling.home");
-    	
-    	if (repoHomePath != null) {     		
+
+    	if (repoHomePath != null) {
          	homeDir = new File(repoHomePath, getRepositoryName());
         } else if (slingHomePath != null) {
     		homeDir = new File(slingHomePath, getRepositoryName());
     	} else {
     		homeDir = new File(getRepositoryName());
-    	} 
-    	
+    	}
+
     	// make sure jackrabbit home exists
         log.info("Creating default config for Jackrabbit in " + homeDir);
         if (!homeDir.isDirectory()) {
@@ -313,14 +313,14 @@
                     + homeDir + ", failed creating default configuration");
                 return null;
             }
-        }	
-    	
+        }
+
     	return homeDir;
     }
-    
+
     private File getConfigFile(BundleContext bundleContext, File homeDir) throws IOException
{
     	File configFile;
-    	
+
     	String repoConfigFileUrl = bundleContext.getProperty("sling.repository.config.file.url");
     	if (repoConfigFileUrl != null) {
     		// the repository config file is set
@@ -331,13 +331,13 @@
 				// this not an url, trying with "file:"
 				configFileUrl = new URL("file:///" + repoConfigFileUrl);
 			}
-    		
+
     		// local support only
     		configFile = new File(configFileUrl.getFile());
     		if (configFile.canRead())
     			return configFile;
     	}
-    	
+
         // ensure the configuration file (inside the home Dir !)
         configFile = new File(homeDir, "repository.xml");
         SlingServerRepository.copyFile(bundleContext.getBundle(), "repository.xml", configFile);

Modified: sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/security/PluggableDefaultAccessManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/security/PluggableDefaultAccessManager.java?rev=894398&r1=894397&r2=894398&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/security/PluggableDefaultAccessManager.java
(original)
+++ sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/security/PluggableDefaultAccessManager.java
Tue Dec 29 14:21:08 2009
@@ -17,6 +17,12 @@
 
 package org.apache.sling.jcr.jackrabbit.server.impl.security;
 
+import javax.jcr.AccessDeniedException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.security.auth.Subject;
+
 import org.apache.jackrabbit.core.HierarchyManager;
 import org.apache.jackrabbit.core.ItemId;
 import org.apache.jackrabbit.core.security.AMContext;
@@ -26,20 +32,14 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.sling.jcr.jackrabbit.server.impl.AccessManagerFactoryTracker;
+import org.apache.sling.jcr.jackrabbit.server.impl.Activator;
 import org.apache.sling.jcr.jackrabbit.server.security.accessmanager.AccessManagerPlugin;
-import org.apache.sling.jcr.jackrabbit.server.security.accessmanager.WorkspaceAccessManagerPlugin;
 import org.apache.sling.jcr.jackrabbit.server.security.accessmanager.AccessManagerPluginFactory;
-import org.apache.sling.jcr.jackrabbit.server.impl.Activator;
-import org.apache.sling.jcr.jackrabbit.server.impl.AccessManagerFactoryTracker;
+import org.apache.sling.jcr.jackrabbit.server.security.accessmanager.WorkspaceAccessManagerPlugin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.AccessDeniedException;
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.security.auth.Subject;
-
 /**
  * Allows to plugin a custom <code>AccessManager</code> as an OSGi bundle:
  * <ol>
@@ -123,9 +123,8 @@
     public boolean isGranted(Path absPath, int permissions) throws RepositoryException {
         if (this.sanityCheck()) {
             return this.accessManagerPlugin.isGranted(namePathResolver.getJCRPath(absPath),
permissions);
-        } else {
-            return super.isGranted(absPath, permissions);
         }
+        return super.isGranted(absPath, permissions);
     }
 
     public boolean isGranted(Path parentPath, Name childName, int permissions) throws RepositoryException
{
@@ -135,9 +134,8 @@
     public boolean canRead(Path itemPath) throws RepositoryException {
         if (this.sanityCheck()) {
             return this.accessManagerPlugin.canRead(namePathResolver.getJCRPath(itemPath));
-        } else {
-            return super.canRead(itemPath);
         }
+        return super.canRead(itemPath);
     }
 
     public boolean canAccess(String workspaceName) throws RepositoryException {
@@ -147,9 +145,8 @@
         }
         if (plugin != null) {
             return plugin.canAccess(workspaceName);
-        } else {
-            return super.canAccess(workspaceName);
         }
+        return super.canAccess(workspaceName);
     }
 
     private boolean sanityCheck() throws RepositoryException {
@@ -160,17 +157,16 @@
                     pluginWarning++;
                     log.warn("No pluggable AccessManager available, falling back to DefaultAccessManager");
                 } else {
-                    log.debug("No pluggable AccessManager available, falling back to DefaultAccessManager");
                   
+                    log.debug("No pluggable AccessManager available, falling back to DefaultAccessManager");
                 }
                 return false;
 
-            } else {
-                this.accessManagerPlugin = factory.getAccessManager();
-                try {
-                    this.accessManagerPlugin.init(this.subject, this.session);
-                } catch (Exception e) {
-                    throw new RepositoryException(e);
-                }
+            }
+            this.accessManagerPlugin = factory.getAccessManager();
+            try {
+                this.accessManagerPlugin.init(this.subject, this.session);
+            } catch (Exception e) {
+                throw new RepositoryException(e);
             }
         }
         return true;



Mime
View raw message