cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r421187 - in /cocoon/trunk: core/cocoon-bootstrap/src/main/java/org/apache/cocoon/bootstrap/servlet/ core/cocoon-core/src/main/java/org/apache/cocoon/configuration/impl/ core/cocoon-core/src/main/java/org/apache/cocoon/servlet/ tools/cocoon...
Date Wed, 12 Jul 2006 08:25:58 GMT
Author: cziegeler
Date: Wed Jul 12 01:25:58 2006
New Revision: 421187

URL: http://svn.apache.org/viewvc?rev=421187&view=rev
Log:
Add missing class
Move classes and lib to cocoon sub directory
Move properties to cocoon sub directory
Check for security exceptions when access system properties

Added:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java
  (with props)
Modified:
    cocoon/trunk/core/cocoon-bootstrap/src/main/java/org/apache/cocoon/bootstrap/servlet/BootstrapClassLoaderManager.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/configuration/impl/SettingsHelper.java
    cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java

Modified: cocoon/trunk/core/cocoon-bootstrap/src/main/java/org/apache/cocoon/bootstrap/servlet/BootstrapClassLoaderManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-bootstrap/src/main/java/org/apache/cocoon/bootstrap/servlet/BootstrapClassLoaderManager.java?rev=421187&r1=421186&r2=421187&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-bootstrap/src/main/java/org/apache/cocoon/bootstrap/servlet/BootstrapClassLoaderManager.java
(original)
+++ cocoon/trunk/core/cocoon-bootstrap/src/main/java/org/apache/cocoon/bootstrap/servlet/BootstrapClassLoaderManager.java
Wed Jul 12 01:25:58 2006
@@ -39,9 +39,9 @@
  */
 public class BootstrapClassLoaderManager {
 
-    private static final String WEB_INF_COCOON_LIB = "WEB-INF/cocoon-lib";
+    private static final String WEB_INF_COCOON_LIB = "WEB-INF/cocoon/lib";
 
-    private static final String WEB_INF_COCOON_CLASSES = "WEB-INF/cocoon-classes";
+    private static final String WEB_INF_COCOON_CLASSES = "WEB-INF/cocoon/classes";
 
     private static final String WEB_INF_LIB = "WEB-INF/lib";
 

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/configuration/impl/SettingsHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/configuration/impl/SettingsHelper.java?rev=421187&r1=421186&r2=421187&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/configuration/impl/SettingsHelper.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/configuration/impl/SettingsHelper.java
Wed Jul 12 01:25:58 2006
@@ -56,9 +56,9 @@
      * This method reads several property files and merges the result. If there
      * is more than one definition for a property, the last one wins.
      * The property files are read in the following order:
-     * 1) context://WEB-INF/properties/*.properties
+     * 1) context://WEB-INF/cocoon/properties/*.properties
      *    Default values for the core and each block - the order in which the files are read
is not guaranteed.
-     * 2) context://WEB-INF/properties/[RUNNING_MODE]/*.properties
+     * 2) context://WEB-INF/cocoon/properties/[RUNNING_MODE]/*.properties
      *    Default values for the running mode - the order in which the files are read is
not guaranteed.
      * 3) Property providers (ToBeDocumented)
      * 4) The environment (CLI, Servlet etc.) adds own properties (e.g. from web.xml)
@@ -74,16 +74,16 @@
                                                  final Logger           logger,
                                                  final PropertyProvider externalPropertyProvider)
{
         // get the running mode
-        final String mode = System.getProperty(Settings.PROPERTY_RUNNING_MODE, SettingsDefaults.DEFAULT_RUNNING_MODE);
+        final String mode = SettingsHelper.getSystemProperty(Settings.PROPERTY_RUNNING_MODE,
SettingsDefaults.DEFAULT_RUNNING_MODE);
         logger.info("Running in mode: " + mode);
 
         // create an empty settings objects
         final MutableSettings s = new MutableSettings();
 
         // now read all properties from the properties directory
-        readProperties("context://WEB-INF/properties", s, resolver, logger);
+        readProperties("context://WEB-INF/cocoon/properties", s, resolver, logger);
         // read all properties from the mode dependent directory
-        readProperties("context://WEB-INF/properties/" + mode, s, resolver, logger);
+        readProperties("context://WEB-INF/cocoon/properties/" + mode, s, resolver, logger);
 
         // Next look for a custom property provider in the spring root context
         BeanFactory rootContext = BeanFactoryUtil.getWebApplicationContext(servletContext);
@@ -103,13 +103,16 @@
 
         // read additional properties file
         String additionalPropertyFile = s.getProperty(Settings.PROPERTY_USER_SETTINGS, 
-                                                      System.getProperty(Settings.PROPERTY_USER_SETTINGS));
+                                                      SettingsHelper.getSystemProperty(Settings.PROPERTY_USER_SETTINGS));
         // if there is no property defining the addition file, we try it in the home directory
         if ( additionalPropertyFile == null ) {
-            additionalPropertyFile = System.getProperty("user.home") + File.separator + ".cocoon/settings.properties";
-            final File testFile = new File(additionalPropertyFile);
-            if ( !testFile.exists() ) {
-                additionalPropertyFile = null;
+            final String homeDir = SettingsHelper.getSystemProperty("user.home");
+            if ( homeDir != null ) {
+                additionalPropertyFile = homeDir + File.separator + ".cocoon/settings.properties";
+                final File testFile = new File(additionalPropertyFile);
+                if ( !testFile.exists() ) {
+                    additionalPropertyFile = null;
+                }
             }
         }
         if ( additionalPropertyFile != null ) {
@@ -125,7 +128,11 @@
             }
         }
         // now overwrite with system properties
-        s.fill(System.getProperties());
+        try {
+            s.fill(System.getProperties());
+        } catch (SecurityException se) {
+            // we ignore this
+        }
 
         return s;
     }
@@ -178,6 +185,18 @@
         return new SourceComparator();
     }
 
+    protected static String getSystemProperty(String key) {
+        return SettingsHelper.getSystemProperty(key, null);
+    }
+
+    protected static String getSystemProperty(String key, String defaultValue) {
+        try {
+            return System.getProperty(key, defaultValue);
+        } catch (SecurityException se) {
+            // we ignore this
+            return defaultValue;
+        }
+    }
     protected final static class SourceComparator implements Comparator {
 
         /**

Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java?rev=421187&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java
(added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java
Wed Jul 12 01:25:58 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servlet;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 
+ * @version $Id$
+ */
+public class RequestUtil {
+
+    public static String getCompleteUri(HttpServletRequest request,
+                                        HttpServletResponse response)
+    throws IOException {
+        String uri = request.getServletPath();
+        if (uri == null) {
+            uri = "";
+        }
+        String pathInfo = request.getPathInfo();
+        if (pathInfo != null) {
+            // VG: WebLogic fix: Both uri and pathInfo starts with '/'
+            // This problem exists only in WL6.1sp2, not in WL6.0sp2 or WL7.0b.
+            if (uri.length() > 0 && uri.charAt(0) == '/') {
+                uri = uri.substring(1);
+            }
+            uri += pathInfo;
+        }
+
+        if (uri.length() == 0) {
+            /* empty relative URI
+                 -> HTTP-redirect from /cocoon to /cocoon/ to avoid
+                    StringIndexOutOfBoundsException when calling
+                    "".charAt(0)
+               else process URI normally
+            */
+            String prefix = request.getRequestURI();
+            if (prefix == null) {
+                prefix = "";
+            }
+
+            response.sendRedirect(response.encodeRedirectURL(prefix + "/"));
+            return null;
+        }
+        if (uri.charAt(0) == '/') {
+            uri = uri.substring(1);
+        }
+        return uri;
+    }
+}

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestUtil.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java?rev=421187&r1=421186&r2=421187&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
(original)
+++ cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
Wed Jul 12 01:25:58 2006
@@ -1,12 +1,12 @@
 /*
  * Copyright 2006 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,14 +43,14 @@
 
 /**
  * Create a Cocoon web application based on a block deployment descriptor.
- * 
+ *
  * @version $Id$
  */
 abstract class AbstractDeployMojo extends AbstractWarMojo {
 
-    private static final String COCOON_CLASSES = "cocoon-classes";
+    private static final String COCOON_CLASSES = "cocoon" + File.separator + "classes";
 
-    private static final String COCOON_LIB = "cocoon-lib";
+    private static final String COCOON_LIB = "cocoon" + File.separator + "lib";
 
     /**
      * Artifact factory, needed to download source jars for inclusion in classpath.
@@ -60,7 +60,7 @@
      * @readonly
      */
     private ArtifactFactory artifactFactory;	
-    
+
     /**
      * Artifact resolver, needed to download source jars for inclusion in classpath.
      *
@@ -69,7 +69,7 @@
      * @readonly
      */
     private ArtifactResolver artifactResolver;   
-    
+
     /**
      * Artifact resolver, needed to download source jars for inclusion in classpath.
      *
@@ -78,7 +78,7 @@
      * @readonly
      */
     private MavenMetadataSource metadataSource;    
-    
+
     /**
      * Local maven repository.
      *
@@ -87,7 +87,7 @@
      * @readonly
      */
     private ArtifactRepository localRepository;    
-    
+
     /**
      * Remote repositories which will be searched for blocks.
      *
@@ -96,17 +96,17 @@
      * @readonly
      */
     private List remoteArtifactRepositories;  
-    
+
     /**
      * The deploy descriptor
      * 
      * @parameter expression="${basedir}/cocoon-deploy.xml"
      */
     private File deploymentDescriptor;     
-    
+
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     // set properties: necessary because DeployMojo is not in the same package as AbstractWarMojo
-    
+
     /**
      * The project whose project files to create.
      *
@@ -114,7 +114,7 @@
      * @required
      */
     private MavenProject project;	    
-    
+
     /**
      * The directory containing generated classes.
      *
@@ -146,7 +146,7 @@
      * @parameter expression="${maven.war.webxml}"
      */
     private String webXml;
-    
+
     /**
      * Use shielded classloading
      *
@@ -167,21 +167,21 @@
 	 */
 	protected void deployMonolithicCocoonAppAsWebapp(final String blocksdir)  throws MojoExecutionException
{
     	File webappDirectory_ = getWebappDirectory();
-    	
+
     	// build the web application
         this.buildExplodedWebapp(webappDirectory_);
-        
+
         MonolithicCocoonDeployer deployer = new MonolithicCocoonDeployer(this.getLog());
       
         deployer.deploy(getBlockArtifactsAsMap(null), webappDirectory_, 
                 blocksdir, new DevelopmentBlock[0], new DevelopmentProperty[0]);
-        
+
         // make sure that all configuration files available in the webapp override block
configuration files
         try {
             copyResources( getWarSourceDirectory(), webappDirectory_, getWebXml() );
         } catch (IOException e) {
             throw new MojoExecutionException("A problem occurred while copying webapp resources.",
e);
         }
-        
+
         // take care of paranoid classloading
         if ( this.useShieldingClassloader ) {
             shieldCocoonWebapp();
@@ -194,10 +194,10 @@
     protected void blockDeploymentMonolithicCocoon(final String blocksdir, final DevelopmentBlock[]
blocks, 
             final DevelopmentProperty[] properties) throws MojoExecutionException {
         File webappDirectory_ = getWebappDirectory();        
-        
+
         File webinfDir = new File(webappDirectory_, WEB_INF);
         webinfDir.mkdirs();
-        
+
         // add current block to the development blocks
         // it is important that the current block is put at the end of the array - the 
         // MonotlithicCocoonDeployer expects this
@@ -212,16 +212,16 @@
         DevelopmentBlock[] extBlocks = new DevelopmentBlock[blocks.length + 1];
         System.arraycopy(blocks, 0, extBlocks, 0, blocks.length);
         extBlocks[blocks.length] = curBlock;
-        
+
         // deploy all blocks
         MonolithicCocoonDeployer deployer = new MonolithicCocoonDeployer(this.getLog());
         deployer.deploy(getBlockArtifactsAsMap(blocks), webappDirectory_, 
                 blocksdir, extBlocks, properties);
-        
-        // deploy all libraries to WEB-INF/cocoon-lib and cocoon-bootstrap to WEB-INF/lib
+
+        // deploy all libraries to WEB-INF/cocoon/lib and cocoon-bootstrap to WEB-INF/lib
         copyLibs();        
     }   
-    
+
     /**
      * Create a <code>Map</code> of <code>java.io.File</code> objects
pointing to artifacts.
      */
@@ -242,7 +242,7 @@
         }
         return files;
     }     
-    
+
     /**
      * @return true if the DevelopmentBlock array contains a block with the passed artifactId
and groupId
      */
@@ -260,7 +260,7 @@
     // ~~~~~~~~~~ utility methods ~~~~~~~~~~~
     /**
      * Make a Cocoon webapp using the ShieldingClassloader. This method rewrites the web.xml
and moves
-     * all libs from WEB-INF/lib to WEB-INF/cocoon-lib, except cocoon-bootstrap which remains
in WEB-INF/lib.
+     * all libs from WEB-INF/lib to WEB-INF/cocoon/lib, except cocoon-bootstrap which remains
in WEB-INF/lib.
      */
     private void shieldCocoonWebapp() throws MojoExecutionException {
         File webappDirectory_ = getWebappDirectory();
@@ -288,20 +288,19 @@
     }  
 
     /**
-     * Copy all libs that don't have the scope provided or system to WEB-INF/cocoon-lib,
except
+     * Copy all libs that don't have the scope provided or system to WEB-INF/cocoon/lib,
except
      * cocoon-bootstrap, which is copied to WEB-INF/lib
      */
     private void copyLibs() throws MojoExecutionException {
         File webappDirectory_ = this.getWebappDirectory();
-        for ( Iterator iter = this.getProject().getArtifacts().iterator(); iter.hasNext();
)
-        {
+        for ( Iterator iter = this.getProject().getArtifacts().iterator(); iter.hasNext();
) {
             Artifact artifact = (Artifact) iter.next();
             // Include runtime and compile time libraries
             if (!Artifact.SCOPE_PROVIDED.equals(artifact.getScope())
                     && !Artifact.SCOPE_TEST.equals(artifact.getScope()) 
                     && "jar".equals(artifact.getType())) {
                 try {
-                    if(artifact.getArtifactId().equals("cocoon-bootstrap")) {
+                    if (artifact.getArtifactId().equals("cocoon-bootstrap")) {
                         FileUtils.copyFileToDirectory(artifact.getFile(), new File(webappDirectory_,
"WEB-INF/lib"));       
                         this.getLog().info("Deploying artifact to WEB-INF/lib/" + artifact.getFile().getName());
                      
                     } else {
@@ -317,9 +316,9 @@
             }
         }
     }       
-    
+
     /**
-     * Move all libs from one directory (WEB-INF/lib) to another (WEB-INF/cocoon-lib).
+     * Move all libs from one directory (WEB-INF/lib) to another (WEB-INF/cocoon/lib).
      */
     private void move(String parentDir, String srcDir, String destDir) {
         final File srcDirectory = new File(parentDir, srcDir);
@@ -333,7 +332,7 @@
             if ( this.getLog().isDebugEnabled() ) {
                 this.getLog().debug("Recreating directory " + destDirectory);
             }
-            destDirectory.mkdir();
+            destDirectory.mkdirs();
             final File[] files = srcDirectory.listFiles();
             if (files != null && files.length > 0) {
                 for (int i = 0; i < files.length; i++) {
@@ -356,5 +355,4 @@
             }
         }
     }    
-    
 }



Mime
View raw message