unico 2004/03/10 09:58:05
Modified: src/java/org/apache/cocoon/servlet CocoonServlet.java
src/java/org/apache/cocoon/bean OldCocoonBean.java
CocoonBean.java ProcessorBean.java
OldCocoonWrapper.java BatchProcessorBean.java
src/java/org/apache/cocoon Cocoon.java
src/java/org/apache/cocoon/transformation
SimpleFormTransformer.java
Added: src/java/org/apache/cocoon ModifiableProcessor.java
src/java/org/apache/cocoon/transformation/helpers
FormValidatorHelper.java
Removed: src/java/org/apache/cocoon/components/language/markup/xsp
SOAPHelper.java XSLTExtension.java
XSPMarkupLanguage.java XSPGenerator.java
XSPSessionHelper.java JSGenerator.java
XSPModuleHelper.java XSPFormValidatorHelper.java
XSPCookieHelper.java XSPResponseHelper.java
XSPObjectHelper.java XSPRequestHelper.java
XSPUtil.java
src/java/org/apache/cocoon/components/language/markup
Logicsheet.java MarkupLanguage.java
CocoonMarkupLanguage.java
LogicsheetCodeGenerator.java NamedLogicsheet.java
AbstractMarkupLanguage.java
MarkupCodeGenerator.java
src/java/org/apache/cocoon/components/language/markup/xsp/javascript
response.xsl session.xsl request.xsl xsp.xsl
src/java/org/apache/cocoon/components/language/generator
CompiledComponent.java ProgramGeneratorImpl.java
ProgramGenerator.java
src/java/org/apache/cocoon/components/language/programming
CompiledProgrammingLanguage.java Program.java
CodeFormatter.java CompilerError.java
AbstractProgrammingLanguage.java
ProgrammingLanguage.java LanguageCompiler.java
src/java/org/apache/cocoon/components/language/markup/xsp/java
request.xsl capture.xsl soap.xsl util.xsl
action.xsl cookie.xsl session.xsl log.xsl
form-validator.xsl sel.xsl response.xsl xscript.xsl
xsp.xsl logicsheet-util.xsl input.xsl
xscript-lib.xsl jpath.xsl
src/java/org/apache/cocoon CompilingProcessor.java
src/java/org/apache/cocoon/generation
ServerPagesGenerator.java AbstractServerPage.java
src/java/org/apache/cocoon/components/language/programming/java
NullFormatter.java AbstractJavaCompiler.java
JavaProgram.java JavaLanguage.java Jikes.java
Pizza.java EclipseJavaCompiler.java Javac.java
src/java/org/apache/cocoon/acting ServerPagesAction.java
InputModuleAction.java
src/java/org/apache/cocoon/components/language/programming/javascript
JavascriptProgram.java JavascriptLanguage.java
CompiledJavascriptLanguage.java
src/java/org/apache/cocoon/components/language
LanguageException.java
Log:
xsp moved to a block
Revision Changes Path
1.29 +5 -12
cocoon-2.2/src/java/org/apache/cocoon/servlet/CocoonServlet.java
Index: CocoonServlet.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/servlet/CocoonServlet.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- CocoonServlet.java 8 Mar 2004 14:03:29 -0000 1.28
+++ CocoonServlet.java 10 Mar 2004 17:58:04 -0000 1.29
@@ -50,7 +50,7 @@
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
-import org.apache.cocoon.CompilingProcessor;
+import org.apache.cocoon.ModifiableProcessor;
import org.apache.cocoon.ConnectionResetException;
import org.apache.cocoon.Constants;
import org.apache.cocoon.ResourceNotFoundException;
@@ -70,13 +70,6 @@
/**
* This is the entry point for Cocoon execution as an HTTP Servlet.
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
- * (Apache Software Foundation)
- * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Nicola Ken Barozzi</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Leo Sutic</a>
* @version CVS $Id$
*/
public class CocoonServlet extends HttpServlet {
@@ -989,7 +982,7 @@
}
// Get the cocoon engine instance
- CompilingProcessor processor = getProcessor(request.getPathInfo(),
request.getParameter(Constants.RELOAD_PARAM));
+ ModifiableProcessor processor = getProcessor(request.getPathInfo(),
request.getParameter(Constants.RELOAD_PARAM));
// We got it... Process the request
String uri = request.getServletPath();
@@ -1317,10 +1310,10 @@
* Gets the processor. Reload cocoon if configuration
* changed or we are reloading.
*/
- private CompilingProcessor getProcessor(final String pathInfo, final
String reloadParam)
+ private ModifiableProcessor getProcessor(final String pathInfo, final
String reloadParam)
throws ServletException {
- CompilingProcessor processor = cocoonBean.getRootProcessor();
+ ModifiableProcessor processor = cocoonBean.getRootProcessor();
if (this.allowReload) {
boolean reload = false;
1.6 +5 -13
cocoon-2.2/src/java/org/apache/cocoon/bean/OldCocoonBean.java
Index: OldCocoonBean.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/bean/OldCocoonBean.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- OldCocoonBean.java 8 Mar 2004 13:57:38 -0000 1.5
+++ OldCocoonBean.java 10 Mar 2004 17:58:04 -0000 1.6
@@ -330,18 +330,10 @@
readChecksumFile();
- if (crawler.getRemainingCount()==0) {
- super.precompile();
- } else {
- Iterator iterator = crawler.iterator();
- while (iterator.hasNext()) {
- Target target = (Target) iterator.next();
- if (precompileOnly) {
- processXSP(target.getSourceURI());
- } else {
- processTarget(crawler, target);
- }
- }
+ Iterator iterator = crawler.iterator();
+ while (iterator.hasNext()) {
+ Target target = (Target) iterator.next();
+ processTarget(crawler, target);
}
writeChecksumFile();
1.51 +5 -4
cocoon-2.2/src/java/org/apache/cocoon/bean/CocoonBean.java
Index: CocoonBean.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/bean/CocoonBean.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- CocoonBean.java 8 Mar 2004 13:57:38 -0000 1.50
+++ CocoonBean.java 10 Mar 2004 17:58:04 -0000 1.51
@@ -33,7 +33,8 @@
import org.apache.avalon.framework.logger.NullLogger;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.cocoon.CompilingProcessor;
+import org.apache.cocoon.ModifiableProcessor;
+import org.apache.cocoon.Processor;
import org.apache.cocoon.Constants;
import org.apache.cocoon.components.container.CocoonContainer;
import org.apache.cocoon.components.container.ComponentContext;
@@ -73,13 +74,13 @@
m_properties = new HashMap();
}
- public CompilingProcessor getRootProcessor() {
+ public ModifiableProcessor getRootProcessor() {
// TODO - the rootProcessor is never released
ServiceManager manager = getServiceManager();
- CompilingProcessor rootProcessor = null;
+ ModifiableProcessor rootProcessor = null;
try {
- rootProcessor = (CompilingProcessor)manager.lookup(
CompilingProcessor.ROLE);
+ rootProcessor = (ModifiableProcessor)
manager.lookup(ModifiableProcessor.ROLE);
} catch ( ServiceException e ) {
throw new CascadingRuntimeException("Error retrieving root
processor", e);
}
1.4 +0 -63
cocoon-2.2/src/java/org/apache/cocoon/bean/ProcessorBean.java
Index: ProcessorBean.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/bean/ProcessorBean.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ProcessorBean.java 8 Mar 2004 13:57:38 -0000 1.3
+++ ProcessorBean.java 10 Mar 2004 17:58:04 -0000 1.4
@@ -21,7 +21,6 @@
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.Constants;
import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.util.IOUtils;
import java.util.Map;
import java.util.HashMap;
@@ -53,68 +52,6 @@
m_cliContext = new CommandLineContext( getContextURI() );
m_cliContext.enableLogging( getInitializationLogger() );
}
-
- /**
- * Allow subclasses to recursively precompile XSPs.
- */
- protected void precompile() {
- recursivelyPrecompile( new File(getContextURI()), new
File(getContextURI()) );
- }
-
- /**
- * Recurse the directory hierarchy and process the XSP's.
- * @param contextDir a <code>File</code> value for the context directory
- * @param file a <code>File</code> value for a single XSP file or a
directory to scan recursively
- */
- private void recursivelyPrecompile( File contextDir, File file ) {
- if ( file.isDirectory() ) {
- String entries[] = file.list();
- for ( int i = 0; i < entries.length; i++ ) {
- recursivelyPrecompile( contextDir, new File( file,
entries[i] ) );
- }
- } else if ( file.getName().toLowerCase().endsWith( ".xmap" ) ) {
- try {
- this.processXMAP( IOUtils.getContextFilePath(
contextDir.getCanonicalPath(), file.getCanonicalPath() ) );
- } catch ( Exception e ) {
- //Ignore for now.
- }
- } else if ( file.getName().toLowerCase().endsWith( ".xsp" ) ) {
- try {
- this.processXSP( IOUtils.getContextFilePath(
contextDir.getCanonicalPath(), file.getCanonicalPath() ) );
- } catch ( Exception e ) {
- //Ignore for now.
- }
- }
- }
-
- /**
- * Process a single XSP file
- *
- * @param uri a <code>String</code> pointing to an xsp URI
- * @exception Exception if an error occurs
- */
- protected void processXSP( String uri ) throws Exception {
- String markupLanguage = "xsp";
- String programmingLanguage = "java";
- Environment env = new LinkSamplingEnvironment( "/", new File(
getContextURI() ), m_attributes,
- null, m_cliContext, getInitializationLogger() );
- getRootProcessor().precompile( uri, env, markupLanguage,
programmingLanguage );
- }
-
- /**
- * Process a single XMAP file
- *
- * @param uri a <code>String</code> pointing to an xmap URI
- * @exception Exception if an error occurs
- */
- protected void processXMAP( String uri ) throws Exception {
- String markupLanguage = "sitemap";
- String programmingLanguage = "java";
- Environment env = new LinkSamplingEnvironment( "/", new
File(getContextURI()), m_attributes,
- null, m_cliContext, getInitializationLogger() );
- getRootProcessor().precompile( uri, env, markupLanguage,
programmingLanguage );
- }
-
/**
* Samples an URI for its links.
1.4 +3 -3
cocoon-2.2/src/java/org/apache/cocoon/bean/OldCocoonWrapper.java
Index: OldCocoonWrapper.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/bean/OldCocoonWrapper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- OldCocoonWrapper.java 8 Mar 2004 13:57:38 -0000 1.3
+++ OldCocoonWrapper.java 10 Mar 2004 17:58:04 -0000 1.4
@@ -430,7 +430,7 @@
String programmingLanguage = "java";
Environment env = new LinkSamplingEnvironment("/", context,
attributes,
null, cliContext, log);
- cocoon.precompile(uri, env, markupLanguage, programmingLanguage);
+// cocoon.precompile(uri, env, markupLanguage, programmingLanguage);
}
/**
@@ -444,7 +444,7 @@
String programmingLanguage = "java";
Environment env = new LinkSamplingEnvironment("/", context,
attributes,
null, cliContext, log);
- cocoon.precompile(uri, env, markupLanguage, programmingLanguage);
+// cocoon.precompile(uri, env, markupLanguage, programmingLanguage);
}
1.4 +2 -2
cocoon-2.2/src/java/org/apache/cocoon/bean/BatchProcessorBean.java
Index: BatchProcessorBean.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/bean/BatchProcessorBean.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BatchProcessorBean.java 8 Mar 2004 13:57:38 -0000 1.3
+++ BatchProcessorBean.java 10 Mar 2004 17:58:04 -0000 1.4
@@ -324,13 +324,13 @@
readChecksumFile();
if (m_crawler.getRemainingCount() == 0) {
- precompile();
+// precompile();
} else {
Iterator iterator = m_crawler.iterator();
while (iterator.hasNext()) {
Target target = (Target) iterator.next();
if (isPrecompileOnly()) {
- processXSP(target.getSourceURI());
+// processXSP(target.getSourceURI());
} else {
processTarget(m_crawler, target);
}
1.40 +3 -43 cocoon-2.2/src/java/org/apache/cocoon/Cocoon.java
Index: Cocoon.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/Cocoon.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- Cocoon.java 8 Mar 2004 13:57:35 -0000 1.39
+++ Cocoon.java 10 Mar 2004 17:58:04 -0000 1.40
@@ -33,7 +33,6 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
-import org.apache.cocoon.components.language.generator.ProgramGenerator;
import org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.ObjectModelHelper;
@@ -53,13 +52,13 @@
* @version CVS $Id$
*
* @avalon.component
- * @avalon.service type=CompilingProcessor
+ * @avalon.service type=ModifiableProcessor
* @x-avalon.lifestyle type=singleton
* @x-avalon.info name=cocoon
*/
public class Cocoon
extends AbstractLogEnabled
- implements CompilingProcessor,
+ implements ModifiableProcessor,
Contextualizable,
Serviceable,
Configurable,
@@ -419,45 +418,6 @@
*/
public Processor getRootProcessor() {
return this;
- }
-
- /**
- * Process the given <code>Environment</code> to generate Java code for
specified XSP files.
- *
- * @param fileName a <code>String</code> value
- * @param environment an <code>Environment</code> value
- * @exception Exception if an error occurs
- */
- public void precompile(String fileName,
- Environment environment,
- String markupLanguage,
- String programmingLanguage)
- throws Exception {
- ProgramGenerator programGenerator = null;
- Source source = null;
- environment.startingProcessing();
- EnvironmentHelper.enterProcessor(this, this.serviceManager,
environment);
-
- try {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("XSP generation begin:" + fileName);
- }
-
- programGenerator = (ProgramGenerator)
this.serviceManager.lookup(ProgramGenerator.ROLE);
- source = this.sourceResolver.resolveURI(fileName);
- /* CompiledComponent xsp =
programGenerator.load(this.serviceManager,
- source,
- markupLanguage, programmingLanguage, environment);
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("XSP generation complete:" + xsp);
- }
- */
- } finally {
- EnvironmentHelper.leaveProcessor();
- environment.finishingProcessing();
- this.sourceResolver.release(source);
- this.serviceManager.release(programGenerator);
- }
}
/**
1.1
cocoon-2.2/src/java/org/apache/cocoon/ModifiableProcessor.java
Index: ModifiableProcessor.java
===================================================================
/*
* 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;
/**
* TODO: describe class
*
* @version CVS $Revision: 1.1 $
*/
public interface ModifiableProcessor extends Processor, Modifiable {
String ROLE = ModifiableProcessor.class.getName();
}
1.11 +53 -43
cocoon-2.2/src/java/org/apache/cocoon/transformation/SimpleFormTransformer.java
Index: SimpleFormTransformer.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/SimpleFormTransformer.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SimpleFormTransformer.java 8 Mar 2004 14:03:31 -0000 1.10
+++ SimpleFormTransformer.java 10 Mar 2004 17:58:05 -0000 1.11
@@ -15,16 +15,17 @@
*/
package org.apache.cocoon.transformation;
-import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.avalon.excalibur.pool.Recyclable;
+
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.acting.ValidatorActionResult;
-import
org.apache.cocoon.components.language.markup.xsp.XSPFormValidatorHelper;
+import org.apache.cocoon.transformation.helpers.FormValidatorHelper;
import org.apache.cocoon.components.modules.input.InputModule;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.util.HashMap;
@@ -41,8 +42,8 @@
import java.util.List;
import java.util.Map;
-/**
- * Eliminates the need for XSP to use FormValidatorAction or HTML forms.
+/**
+ * Eliminates the need for XSP to use FormValidatorAction or HTML forms.
* Caveat: Select options need a value attribute to work correctly.
*
* <p>This transformer fills all HTML 4 form elements with values from
@@ -70,13 +71,13 @@
*
* <p><em>Names of error elements are never augmented by prefix, suffix or
* form name.</em></p>
- *
+ *
* <p>Page parts with multiple occurrences depending on the number of
* actual parameters can be enclosed in <repeat on="expr" using="var"/>
* elements. <em>expr</em> is used to determine the number of occurrences
* and <em>var</em> will be expanded with the ordinary number. Repeat
elements
* can be nested.</p>
- *
+ *
* <p>Example:</p>
* <pre>
* <repeat on="mult" using="i"><input type="text"
name="mult[${i}]"/></repeat>
@@ -93,9 +94,9 @@
*
* <p>Configuration elements:
* <table>
- * <tr><td>input-module</td><td>(String) InputModule configuration,
+ * <tr><td>input-module</td><td>(String) InputModule configuration,
* defaults to an empty configuration and the "request-param"
module</td></tr>
- * <tr><td>fixed-attribute</td><td>(String) Name of the attribute used to
+ * <tr><td>fixed-attribute</td><td>(String) Name of the attribute used to
* indicate that this element should not be changed.
("fixed")</td></tr>
* <tr><td>use-form-name</td><td>(boolean) Add the name of the form to the
* name of form elements. Uses default Separator , if default
separator is null
@@ -103,7 +104,7 @@
* <tr><td>use-form-name-twice</td><td>(boolean) Add the name of the form
twice to the
* name of form elements. This is useful when the form instance
has no
* all enclosing root tag and the form name is used instead
<em>and</em> the
- * form name needs to be used to find the form data. Uses default
Separator ,
+ * form name needs to be used to find the form data. Uses default
Separator ,
* if default separator is null or empty, separator is set to
"/".("false")</td></tr>
* <tr><td>separator</td><td>(String) Separator between form name and
element name ("/")
* </td></tr>
@@ -270,7 +271,7 @@
protected Map formValues = null;
/**
- * Keep track of repeater status.
+ * Keep track of repeater status.
*/
protected class RepeaterStatus {
public String var = null;
@@ -289,7 +290,7 @@
}
/**
- * Keep track of multiple values.
+ * Keep track of multiple values.
*/
protected class ValueList {
private int current = -1;
@@ -317,8 +318,7 @@
}
/** set per instance variables to defaults */
- public void recycle() {
- super.recycle();
+ private void reset() {
this.skipChildrenOnly = false;
this.values = null;
this.validationResults = null;
@@ -386,7 +386,7 @@
public void setup(SourceResolver resolver, Map objectModel, String src,
Parameters par)
throws ProcessingException, SAXException, IOException {
- this.recycle();
+ this.reset();
super.setup(resolver, objectModel, src, par);
@@ -407,7 +407,7 @@
if (this.ignoreValidation) {
this.validationResults = null;
} else {
- this.validationResults =
XSPFormValidatorHelper.getResults(this.objectModel);
+ this.validationResults =
FormValidatorHelper.getResults(this.objectModel);
}
if (this.inputName == null) {
@@ -451,6 +451,14 @@
}
/**
+ * Recycle this component.
+ */
+ public void recycle() {
+ super.recycle();
+ this.reset();
+ }
+
+ /**
* Generate string representation of attributes. For debug only.
*/
protected String printAttributes(Attributes attr) {
@@ -715,7 +723,7 @@
this.relayStartElement(uri, name, raw, attr);
} else {
ValidatorActionResult validation =
- XSPFormValidatorHelper.getParamResult(this.objectModel,
aName);
+ FormValidatorHelper.getParamResult(this.objectModel,
aName);
String when = attr.getValue("when");
String when_ge = attr.getValue("when-ge");
@@ -747,8 +755,8 @@
/**
* Start processing a form element. Sets protection indicator if
attribute
- * "fixed" is present and either "true" or "yes". Removes attribute
"fixed"
- * if present.
+ * "fixed" is present and either "true" or "yes". Removes attribute
"fixed"
+ * if present.
* @param uri The namespace of the element.
* @param name The local name of the element.
* @param raw The qualified name of the element.
@@ -783,7 +791,7 @@
* Start recording repeat element contents and push repeat expression and
* variable to repeater stack. Only start recording, if no other
recorder is
* currently running.
- *
+ *
* @param uri
* @param name
* @param raw
@@ -812,7 +820,7 @@
/**
* Stop recording repeat contents and replay required number of times.
* Stop only if outmost repeat element is ending.
- *
+ *
* @param uri
* @param name
* @param raw
@@ -957,7 +965,7 @@
/**
* Remove extra information from element's attributes. Currently only
removes
* the repeater variable from the element's name attribute if present.
- *
+ *
* @param attr
* @return modified attributes
*/
@@ -1036,7 +1044,7 @@
/**
* Obtain values from used InputModule if not done already and return the
* next value. If no more values exist, returns null.
- *
+ *
* @param name
* @return
*/
@@ -1066,17 +1074,13 @@
// thus we still have a reference to it
values = input.getAttributeValues(name, this.inputConf,
objectModel);
if (getLogger().isDebugEnabled())
- getLogger().debug(
- "cached module "
- + this.input
- + " attribute "
- + name
- + " returns "
- + values);
+ getLogger().debug("cached module " + this.input
+ + " attribute " + name
+ + " returns " + values);
} else {
// input was not thread safe
// so acquire it again
- iputSelector = (ServiceSelector)
this.manager.lookup(INPUT_MODULE_SELECTOR);
+ iputSelector =
(ServiceSelector)this.manager.lookup(INPUT_MODULE_SELECTOR);
if (this.inputName != null
&& iputSelector != null
&& iputSelector.isSelectable(this.inputName)) {
@@ -1113,7 +1117,7 @@
/**
* Calls the super's method startTransformingElement.
- *
+ *
* @param uri
* @param name
* @param raw
@@ -1130,8 +1134,9 @@
* ignoreEventsCount if skip is true. Increment can be done either before
* invoking super's method, so that the element itself is skipped, or
afterwards,
* so that only the children are skipped.
- *
- * @param skip only children
+ *
+ * @param skip
+ * @param skipChildrenOnly
* @param uri
* @param name
* @param raw
@@ -1140,32 +1145,37 @@
*/
protected void relayStartElement(
boolean skip,
- boolean children,
+ boolean skipChildrenOnly,
String uri,
String name,
String raw,
Attributes attr)
throws SAXException {
- if (skip)
- this.skipChildrenOnly = children;
- if (skip && !children)
- this.ignoreEventsCount++;
try {
- super.startTransformingElement(uri, name, raw, attr);
+ if (this.ignoreEventsCount > 0) {
+ this.ignoreEventsCount++;
+ super.startTransformingElement(uri, name, raw, attr);
+ } else {
+ if (skip)
+ this.skipChildrenOnly = skipChildrenOnly;
+ if (skip && !skipChildrenOnly)
+ this.ignoreEventsCount++;
+ super.startTransformingElement(uri, name, raw, attr);
+ if (skip && skipChildrenOnly)
+ this.ignoreEventsCount++;
+ }
} catch (ProcessingException e) {
throw new SAXException(e);
} catch (IOException e) {
throw new SAXException(e);
}
- if (skip && children)
- this.ignoreEventsCount++;
}
/**
* Calls the super's method endTransformingElement and decrements the
* ignoreEventsCount if larger than zero.
- *
+ *
* @param uri
* @param name
* @param raw
1.1
cocoon-2.2/src/java/org/apache/cocoon/transformation/helpers/FormValidatorHelper.java
Index: FormValidatorHelper.java
===================================================================
/*
* 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.transformation.helpers;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
import org.apache.excalibur.source.Source;
import org.apache.cocoon.Constants;
import org.apache.cocoon.acting.ConfigurationHelper;
import org.apache.cocoon.acting.ValidatorActionResult;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.avalon.framework.logger.Logger;
import java.util.HashMap;
import java.util.Map;
/**
* The <code>ValidatorActionResult</code> object helper
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
* @version CVS $Id: FormValidatorHelper.java,v 1.1 2004/03/10 17:58:05 unico
Exp $
*/
public class FormValidatorHelper {
private static Map configurations = new HashMap();
/**
* these make it easier for the xsl
*/
String current_descriptor = null;
boolean current_reloadable = true;
Logger current_logger = null;
String current_constraint_set = null;
String current_parameter = null;
SourceResolver current_resolver = null;
public FormValidatorHelper(String descriptor, boolean reloadable,
Logger logger, SourceResolver resolver) {
current_descriptor = descriptor;
current_reloadable = reloadable;
current_logger = logger;
current_resolver = resolver;
}
public FormValidatorHelper(String descriptor, boolean reloadable,
Logger logger, SourceResolver resolver,
String constraintset) {
current_descriptor = descriptor;
current_reloadable = reloadable;
current_logger = logger;
current_resolver = resolver;
current_constraint_set = constraintset;
}
/**
* keep track of current parameter context
*/
public void setParameter(String parameter) {
current_parameter = parameter;
}
/**
* keep track of current constraint-set context
* (probably this is not needed?)
*/
public void setConstraintSet(String constraintset) {
current_constraint_set = constraintset;
}
/**
* Get the specified attribute
*
* @param objectModel The Map objectModel
* @param name The parameter name
*/
public static Object getAttribute(Map objectModel, String name) {
Request request = ObjectModelHelper.getRequest(objectModel);
return request.getAttribute(name);
}
/**
* Extracts the validation results from the request attribute
*
* @param objectModel The Map objectModel
* @return Map with ValidatorActionResults
* @see org.apache.cocoon.acting.ValidatorActionResult
*/
public static Map getResults(Map objectModel) {
Request request = ObjectModelHelper.getRequest(objectModel);
return (Map) request.getAttribute(Constants.XSP_FORMVALIDATOR_PATH);
}
/**
* Extracts the validation results from the request attribute
* for a specific request parameter
*
* @param objectModel The Map objectModel
* @param name Request parameter's name
* @see org.apache.cocoon.acting.ValidatorActionResult
*/
public static ValidatorActionResult getParamResult(Map objectModel,
String name) {
ValidatorActionResult result = ValidatorActionResult.NOTPRESENT;
Map param_result = getResults(objectModel);
if (param_result != null) {
result = (ValidatorActionResult) param_result.get(name);
}
return (result != null? result : ValidatorActionResult.NOTPRESENT);
}
/**
* Extracts the validation results from the request attribute
* for the context's current request parameter
*
* @param objectModel The Map objectModel
* @see org.apache.cocoon.acting.ValidatorActionResult
*/
public ValidatorActionResult getParamResult(Map objectModel) {
ValidatorActionResult result = ValidatorActionResult.NOTPRESENT;
Map param_result = getResults(objectModel);
if (param_result != null) {
result = (ValidatorActionResult)
param_result.get(current_parameter);
}
return (result != null? result : ValidatorActionResult.NOTPRESENT);
}
/**
* Test whether the validation returned no error for this
* parameter.
*
* @param objectModel The Map objectModel
* @param name Request parameter's name
* @return true only if the parameter was validated and the validation
* did not return an error.
*/
public static boolean isOK(Map objectModel, String name) {
return getParamResult(objectModel,
name).equals(ValidatorActionResult.OK);
}
/**
* Test whether the validation returned no error for the
* context's current parameter.
*
* @param objectModel The Map objectModel
* @return true only if the parameter was validated and the validation
* did not return an error.
*/
public boolean isOK(Map objectModel) {
return isOK(objectModel, current_parameter);
}
/**
* Test whether the validation returned an error for this
* parameter.
*
* @param objectModel The Map objectModel
* @param name Request parameter's name
* @return true if the parameter was either not validated or the
validation
* returned an error.
*/
public static boolean isError(Map objectModel, String name) {
return getParamResult(objectModel,
name).ge(ValidatorActionResult.ERROR);
}
/**
* Test whether the validation returned an error for the
* context's current parameter.
*
* @param objectModel The Map objectModel
* @return true if the parameter was either not validated or the
validation
* returned an error.
*/
public boolean isError(Map objectModel) {
return isError(objectModel, current_parameter);
}
/**
* Test whether the validated parameter was null but wasn't allowed to.
*
* @param objectModel The Map objectModel
* @param name Request parameter's name
* @return true if the parameter was validated and the validation
* returned an error because the parameter was null but wasn't allowd to.
*/
public static boolean isNull(Map objectModel, String name) {
return getParamResult(objectModel,
name).equals(ValidatorActionResult.ISNULL);
}
/**
* Test whether the context's current parameter as validated was null but
* wasn't allowed to.
*
* @param objectModel The Map objectModel
* @return true if the parameter was validated and the validation
* returned an error because the parameter was null but wasn't allowd to.
*/
public boolean isNull(Map objectModel) {
return isNull(objectModel, current_parameter);
}
/**
* Test whether the validated parameter was too small.
*
* @param objectModel The Map objectModel
* @param name Request parameter's name
* @return true if the parameter was validated and the validation
* returned an error because either its value or its length was
* too small.
*/
public static boolean isTooSmall(Map objectModel, String name) {
boolean ok = getParamResult(objectModel,
name).equals(ValidatorActionResult.TOOSMALL);
if (!ok) {
ok = isNull(objectModel, name);
}
return ok;
}
/**
* Test whether the context's current parameter was too small.
*
* @param objectModel The Map objectModel
* @return true if the parameter was validated and the validation
* returned an error because either its value or its length was
* too small.
*/
public boolean isTooSmall(Map objectModel) {
return isTooSmall(objectModel, current_parameter);
}
/**
* Test whether the validated parameter was too large.
*
* @param objectModel The Map objectModel
* @param name Request parameter's name
* @return true if the parameter was validated and the validation
* returned an error because either its value or its length was
* too large.
*/
public static boolean isTooLarge(Map objectModel, String name) {
return (getParamResult(objectModel, name) ==
ValidatorActionResult.TOOLARGE);
}
/**
* Test whether the context's current parameter was too large.
*
* @param objectModel The Map objectModel
* @return true if the parameter was validated and the validation
* returned an error because either its value or its length was
* too large.
*/
public boolean isTooLarge(Map objectModel) {
return isTooLarge(objectModel, current_parameter);
}
/**
* Test whether the validated parameter wasn't matched by the requested
* regular expression.
*
* @param objectModel The Map objectModel
* @param name Request parameter's name
* @return true if the parameter was validated and the validation
* returned an error because its value wasn't matched by the requested
* regular expression.
*/
public static boolean isNoMatch(Map objectModel, String name) {
return getParamResult(objectModel,
name).equals(ValidatorActionResult.NOMATCH);
}
/**
* Test whether the context's current parameter wasn't matched by the
requested
* regular expression.
*
* @param objectModel The Map objectModel
* @return true if the parameter was validated and the validation
* returned an error because its value wasn't matched by the requested
* regular expression.
*/
public boolean isNoMatch(Map objectModel) {
return isNoMatch(objectModel, current_parameter);
}
/**
* Test whether the validated parameter wasn't validated
*
* @param objectModel The Map objectModel
* @param name Request parameter's name
* @return true if the parameter was not validated.
*/
public static boolean isNotPresent(Map objectModel, String name) {
return getParamResult(objectModel,
name).equals(ValidatorActionResult.NOTPRESENT);
}
/**
* Test whether the context's current parameter wasn't validated
*
* @param objectModel The Map objectModel
* @return true if the parameter was not validated.
*/
public boolean isNotPresent(Map objectModel) {
return isNotPresent(objectModel, current_parameter);
}
/**
* Set up the complementary configuration file. Please note that
* multiple Actions can share the same configurations. By using
* this approach, we can limit the number of config files.
* Also note that the configuration file does not have to be a file.
*
* This is based on the similar named functions in
* org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
* with the addition of reloadable configuration files, reloadable
* flagg, manager, and logger parameter.
*
* @param descriptor URL of descriptor.xml file @see
org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
* @param resolver
* @param reloadable set to <code>true</code> if changes of
* <code>descriptor</code> should trigger a reload. Note that this
* only works if <code>Source</code> is able to determine the
* modification time @see org.apache.cocoon.environment.Source
* @param logger used to send debug and error messages to
* @return up-to-date configuration, either (re)loaded or cached.
*/
protected static Configuration getConfiguration(String descriptor,
SourceResolver resolver,
boolean reloadable,
Logger logger)
throws ConfigurationException {
if (descriptor == null) {
throw new ConfigurationException("The form descriptor is not
set!");
}
ConfigurationHelper conf = null;
synchronized (FormValidatorHelper.configurations) {
Source source = null;
try {
source = resolver.resolveURI(descriptor);
conf = (ConfigurationHelper)
FormValidatorHelper.configurations.get(source.getURI());
if (conf == null || (reloadable && conf.lastModified !=
source.getLastModified())) {
logger.debug("(Re)Loading " + descriptor);
if (conf == null) {
conf = new ConfigurationHelper();
}
SAXConfigurationHandler builder = new
SAXConfigurationHandler();
SourceUtil.toSAX(source, builder);
conf.lastModified = source.getLastModified();
conf.configuration = builder.getConfiguration();
FormValidatorHelper.cacheConfiguration(source.getURI(),
conf);
} else {
logger.debug("Using cached configuration for " +
descriptor);
}
} catch (Exception e) {
logger.error("Could not configure Database mapping
environment", e);
throw new ConfigurationException("Error trying to load
configurations for resource: " + source.getURI());
} finally {
resolver.release(source);
}
}
return conf.configuration;
}
/**
* Cache the configuration so that we can use it later.
*/
private static void cacheConfiguration(String descriptor,
ConfigurationHelper conf) {
synchronized (FormValidatorHelper.configurations) {
FormValidatorHelper.configurations.put(descriptor, conf);
}
}
/**
* Iterate over a set of configurations and return the one whose
* name matches the given one.
*
* @param conf set of configurations
* @param name name of configuration
* @param logger
* @return specified configuration or <code>null</code> if not found.
*/
protected static Configuration getConfigurationByName(Configuration[]
conf,
String name,
Logger logger
) {
int j = 0;
boolean found = false;
String setname = null;
for (j = 0; j < conf.length; j++) {
setname = conf[j].getAttribute("name", "");
if (name.trim().equals(setname.trim())) {
found = true;
break;
}
}
if (!found) {
logger.debug("FormValidatorHelper.getConfigurationByName:
configuration " + name + " not found.");
return null;
}
return conf[j];
}
/**
* Get an attribute for a parameter as specified in
* descriptor.xml.
*
* @param descriptor URL of descriptor.xml file @see
org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
* @param resolver
* @param reloadable set to <code>true</code> if changes of
* <code>descriptor</code> should trigger a reload. Note that this
* only works if <code>Source</code> is able to determine the
* modification time @see org.apache.cocoon.environment.Source
* @param logger used to send debug and error messages to
* @param attribute attribute name
* @return attribute value or <code>null</code>
*/
public static String getParameterAttributes(String descriptor,
SourceResolver resolver,
boolean reloadable,
String constraintset,
String parameter,
String attribute,
Logger logger
) {
try {
Configuration conf = getConfiguration(descriptor, resolver,
reloadable, logger);
Configuration[] desc = conf.getChildren("parameter");
Configuration[] csets = conf.getChildren("constraint-set");
Configuration cset = getConfigurationByName(csets, constraintset,
logger);
Configuration[] set = cset.getChildren("validate");
Configuration constraints = getConfigurationByName(set,
parameter, logger);
Configuration descr = getConfigurationByName(desc, parameter,
logger);
return constraints.getAttribute(attribute,
descr.getAttribute(attribute, ""));
} catch (Exception e) {
logger.debug("FormValidatorHelper.getParameterAttributes
Exception " + e);
}
return "";
}
/**
* Get an attribute for the context's current parameter as specified in
* descriptor.xml.
*
* @param attribute attribute name
* @return attribute value or <code>null</code>
*/
public String getParameterAttribute(String attribute) {
return FormValidatorHelper.getParameterAttributes(current_descriptor,
current_resolver,
current_reloadable,
current_constraint_set,
current_parameter,
attribute,
current_logger);
}
/**
* Get an attribute for a parameter as specified in
* descriptor.xml.
*
* @param attribute attribute name
* @return attribute value or <code>null</code>
*/
public String getParameterAttribute(String parameter, String attribute) {
return FormValidatorHelper.getParameterAttributes(current_descriptor,
current_resolver,
current_reloadable,
current_constraint_set,
parameter,
attribute,
current_logger);
}
}