Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 10135 invoked from network); 28 Sep 2005 06:46:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Sep 2005 06:46:36 -0000 Received: (qmail 23443 invoked by uid 500); 28 Sep 2005 06:46:35 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 23309 invoked by uid 500); 28 Sep 2005 06:46:34 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 23296 invoked by uid 99); 28 Sep 2005 06:46:34 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 27 Sep 2005 23:46:34 -0700 Received: (qmail 10013 invoked by uid 65534); 28 Sep 2005 06:46:14 -0000 Message-ID: <20050928064614.10011.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r292136 - /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/ProjectPathModule.java Date: Wed, 28 Sep 2005 06:46:13 -0000 To: cvs@cocoon.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: cziegeler Date: Tue Sep 27 23:46:06 2005 New Revision: 292136 URL: http://svn.apache.org/viewcvs?rev=292136&view=rev Log: Just code formatting Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/ProjectPathModule.java Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/ProjectPathModule.java URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/ProjectPathModule.java?rev=292136&r1=292135&r2=292136&view=diff ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/ProjectPathModule.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/ProjectPathModule.java Tue Sep 27 23:46:06 2005 @@ -1,19 +1,18 @@ /* * Copyright 1999-2004 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.components.modules.input; import org.apache.avalon.framework.configuration.Configurable; @@ -64,77 +63,101 @@ *

* */ -public class ProjectPathModule extends AbstractInputModule implements Configurable, ThreadSafe { +public class ProjectPathModule + extends AbstractInputModule + implements Configurable, ThreadSafe { - protected static String PROJECT_PARAM_NAME = "uri-prefix"; - protected static String PROJECT_PARAM_DEFAULT = "/"; + protected static String PROJECT_PARAM_NAME = "uri-prefix"; + protected static String PROJECT_PARAM_DEFAULT = "/"; + + protected String projectBase; - protected String projectBase; - final static Vector returnNames; static { - Vector tmp = new Vector(); - tmp.add("relative"); - tmp.add("path"); - tmp.add("folder"); - returnNames = tmp; + Vector tmp = new Vector(); + tmp.add("relative"); + tmp.add("path"); + tmp.add("folder"); + returnNames = tmp; } + /** + * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) + */ public void configure(Configuration conf) throws ConfigurationException { - this.projectBase = conf.getChild(PROJECT_PARAM_NAME).getValue(); - if (getLogger().isDebugEnabled()) getLogger().debug("Configuration supplied: " + this.projectBase); - if (this.projectBase == null) { - this.projectBase = PROJECT_PARAM_DEFAULT; - if (getLogger().isWarnEnabled()) getLogger().warn("No configuration supplied, using default: " + PROJECT_PARAM_DEFAULT); - } - if (this.projectBase.equals("")) { - this.projectBase = PROJECT_PARAM_DEFAULT; - if (getLogger().isWarnEnabled()) getLogger().warn("Empty configuration supplied, using default: " + PROJECT_PARAM_DEFAULT); - } + this.projectBase = conf.getChild(PROJECT_PARAM_NAME).getValue(); + if (getLogger().isDebugEnabled()) { + getLogger().debug("Configuration supplied: " + this.projectBase); + } + if (this.projectBase == null) { + this.projectBase = PROJECT_PARAM_DEFAULT; + if (getLogger().isWarnEnabled()) { + getLogger().warn("No configuration supplied, using default: " + PROJECT_PARAM_DEFAULT); + } + } + if (this.projectBase.equals("")) { + this.projectBase = PROJECT_PARAM_DEFAULT; + if (getLogger().isWarnEnabled()) { + getLogger().warn("Empty configuration supplied, using default: " + PROJECT_PARAM_DEFAULT); + } + } } - public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException { - String uri = ObjectModelHelper.getRequest(objectModel).getServletPath(); - StringBuffer result = new StringBuffer(uri.length()); - int baseIndex = uri.indexOf(this.projectBase); - if (baseIndex != -1) { - uri = uri.substring(baseIndex + this.projectBase.length()); - } else { - throw new ConfigurationException( "No project-base path found in URI"); - } - try { - // provide a relative path back to the project - if (name.startsWith("relative")) { - int nextIndex = 0; - while ((nextIndex = uri.indexOf('/', nextIndex) + 1) > 0) { - result.append("../"); - } - } else if (name.startsWith("path")) { // provide the full path from the project - result.append("/"); - result.append(uri); - } else if (name.startsWith("folder")) { // provide the folder path from the project - result.append("/"); - result.append(uri.substring(0,uri.lastIndexOf("/") + 1)); - } else { - if (getLogger().isWarnEnabled()) getLogger().warn("Invalid verb: " + name); - } - return result; - } catch( final Exception mue ) { - throw new ConfigurationException( "Problems resolving project path.", mue); - } + /** + * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map) + */ + public Object getAttribute(String name, Configuration modeConf, Map objectModel) + throws ConfigurationException { + String uri = ObjectModelHelper.getRequest(objectModel).getServletPath(); + StringBuffer result = new StringBuffer(uri.length()); + int baseIndex = uri.indexOf(this.projectBase); + if (baseIndex != -1) { + uri = uri.substring(baseIndex + this.projectBase.length()); + } else { + throw new ConfigurationException( "No project-base path found in URI"); + } + try { + // provide a relative path back to the project + if (name.startsWith("relative")) { + int nextIndex = 0; + while ((nextIndex = uri.indexOf('/', nextIndex) + 1) > 0) { + result.append("../"); + } + } else if (name.startsWith("path")) { + // provide the full path from the project + result.append("/"); + result.append(uri); + } else if (name.startsWith("folder")) { + // provide the folder path from the project + result.append("/"); + result.append(uri.substring(0,uri.lastIndexOf("/") + 1)); + } else { + if (getLogger().isWarnEnabled()) { + getLogger().warn("Invalid verb: " + name); + } + } + return result; + } catch( final Exception mue ) { + throw new ConfigurationException( "Problems resolving project path.", mue); + } } - public Iterator getAttributeNames( Configuration modeConf, Map objectModel ) throws ConfigurationException { - return ProjectPathModule.returnNames.iterator(); + /** + * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration, java.util.Map) + */ + public Iterator getAttributeNames( Configuration modeConf, Map objectModel ) + throws ConfigurationException { + return ProjectPathModule.returnNames.iterator(); } - + /** + * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map) + */ public Object[] getAttributeValues( String name, Configuration modeConf, Map objectModel ) - throws ConfigurationException { - - List values = new LinkedList(); - values.add( this.getAttribute(name, modeConf, objectModel) ); - - return values.toArray(); + throws ConfigurationException { + List values = new LinkedList(); + values.add( this.getAttribute(name, modeConf, objectModel) ); + + return values.toArray(); } }