Author: rich
Date: Wed Sep 22 15:56:57 2004
New Revision: 47077
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ControllerGrammar.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/StrutsApp.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/MultipartRequestUtils.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowControllerConfig.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
incubator/beehive/trunk/netui/src/util/schema/netui-config.xsd
Log:
There is a new element for configuring multipart request handling in
netui-config.xml:
<pageflow-config>
<multipart-handler>HANDLER-TYPE</multipart-handler>
</pageflow-config>
...where HANDLER-TYPE can be:
- disabled (the default)
- memory
- disk
If this element is not present, the default is 'disabled'. This provides
better behavior (and more flexible options) for file uploads, which present a
security risk.
There is also a per-pageflow setting, which is configured in the page flow
source file like this:
@Jpf.Controller( multipartHandler=HANDLER-TYPE )
...where HANDLER-TYPE can be:
- Jpf.MultipartHandler.disabled
- Jpf.MultipartHandler.memory
- Jpf.MultipartHandler.disk
This setting overrides the value in netui-config.xml.
Note that the <controller> element in a page flow's generated Struts config
file can still be overridden/tailored using the Struts merge feature.
DRT: netui (WinXP)
BB: self (linux)
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java
Wed Sep 22 15:56:57 2004
@@ -152,6 +152,7 @@
public static final String VALIDATION_BEANS_ATTR = "validationBeans";
public static final String ACTION_ATTR = "action";
public static final String RAISE_ACTIONS_ATTR = "raiseActions";
+ public static final String MULTIPART_HANDLER_ATTR = "multipartHandler";
public static final String MIN_INT_ATTR = "minInt";
public static final String MAX_INT_ATTR = "maxInt";
@@ -172,8 +173,9 @@
public static final String RULE_ATTR = "rule";
public static final String VARIABLES_ATTR = "variables";
+ public static final String STRUTS_PACKAGE = "org.apache.struts";
public static final String FORWARD_CLASS_NAME = PAGEFLOW_PACKAGE +
".Forward";
- public static final String FORM_CLASS_NAME =
"org.apache.struts.action.ActionForm";
+ public static final String FORM_CLASS_NAME = STRUTS_PACKAGE +
".action.ActionForm";
public static final String BEA_XMLOBJECT_CLASS_NAME =
"com.bea.xml.XmlObject";
public static final String APACHE_XMLOBJECT_CLASS_NAME =
"org.apache.xmlbeans.XmlObject";
public static final String XML_FORM_CLASS_NAME = PAGEFLOW_PACKAGE +
".internal.XmlBeanActionForm";
@@ -187,6 +189,13 @@
public static final String NAVIGATE_TO_PREVIOUS_PAGE_STR = "previousPage";
public static final String NAVIGATE_TO_PAGE_LEGACY_STR = "page";
public static final String NAVIGATE_TO_PREVIOUS_ACTION_STR =
"previousAction";
+
+ public static final String MULTIPART_HANDLER_DISABLED_STR = "disabled";
+ public static final String MULTIPART_HANDLER_MEMORY_STR = "memory";
+ public static final String MULTIPART_HANDLER_DISK_STR = "disk";
+
+ public static final String MULTIPART_HANDLER_MEMORY_CLASSNAME =
STRUTS_PACKAGE + ".upload.CommonsMultipartRequestHandler";
+ public static final String MULTIPART_HANDLER_DISK_CLASSNAME =
STRUTS_PACKAGE + ".upload.DiskMultipartRequestHandler";
public static final String ARRAY_TYPE_SUFFIX = "[]";
public static final String GETTER_PREFIX = "get";
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java
Wed Sep 22 15:56:57 2004
@@ -91,7 +91,7 @@
File[] sharedFlowFiles = i.listFiles( SHARED_FLOW_FILE_FILTER );
boolean atWebappRoot = i.equals( getWebappRoot() );
- if ( sharedFlowFiles.length > 0 )
+ if ( sharedFlowFiles != null && sharedFlowFiles.length > 0 )
{
File sfFile = sharedFlowFiles[0];
TypeDeclaration sfType =
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java
Wed Sep 22 15:56:57 2004
@@ -95,6 +95,7 @@
addMessageResources( controllerAnnotation );
addValidationMessages( controllerAnnotation );
addSimpleActions( controllerAnnotation );
+ setMultipartHandler( controllerAnnotation );
GenForwardModel.addForwards( controllerAnnotation, this,
_jclass, this, null );
GenExceptionModel.addCatches( controllerAnnotation, this,
_jclass, this, this );
}
@@ -197,6 +198,28 @@
for ( AnnotationMirror ann : simpleActionAnnotations )
{
addActionMapping( new GenSimpleActionModel( ann, this, _jclass
) );
+ }
+ }
+ }
+
+ private void setMultipartHandler( AnnotationMirror controllerAnnotation )
+ {
+ String mpHandler = CompilerUtils.getEnumFieldName(
controllerAnnotation, MULTIPART_HANDLER_ATTR, true );
+
+ if ( mpHandler != null )
+ {
+ if ( mpHandler.equals( MULTIPART_HANDLER_MEMORY_STR ) )
+ {
+ setMultipartHandlerClassName(
MULTIPART_HANDLER_MEMORY_CLASSNAME );
+ }
+ else if ( mpHandler.equals( MULTIPART_HANDLER_DISK_STR ) )
+ {
+ setMultipartHandlerClassName( MULTIPART_HANDLER_DISK_CLASSNAME
);
+ }
+ else
+ {
+ assert mpHandler.equals( MULTIPART_HANDLER_DISABLED_STR );
+ setMultipartHandlerClassName( "none" );
}
}
}
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ControllerGrammar.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ControllerGrammar.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ControllerGrammar.java
Wed Sep 22 15:56:57 2004
@@ -40,9 +40,10 @@
addMemberType( LOGIN_REQUIRED_ATTR, new AnnotationMemberType( null,
this ) );
addMemberType( ROLES_ALLOWED_ATTR, new AnnotationMemberType( null,
this ) );
- addMemberType( READONLY_ATTR, new AnnotationMemberType(
VERSION_8_SP2_STRING, this ) );
+ addMemberType( READONLY_ATTR, new AnnotationMemberType( null, this ) );
addMemberType( STRUTSMERGE_ATTR, new ValidXmlFileType(
StrutsConfigDocument.type, null, this, fcInfo ) );
addMemberType( VALIDATOR_MERGE_ATTR, new ValidXmlFileType(
FormValidationDocument.type, null, this, fcInfo ) );
+ addMemberType( MULTIPART_HANDLER_ATTR, new AnnotationMemberType( null,
this ) );
addMemberArrayGrammar( FORWARDS_ATTR, new ForwardGrammar( env, diags,
null, rvc, fcInfo ) );
addMemberArrayGrammar( CATCHES_ATTR, new CatchGrammar( env, diags,
null, rvc, CONTROLLER_TAG_NAME, fcInfo ) );
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/StrutsApp.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/StrutsApp.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/StrutsApp.java
Wed Sep 22 15:56:57 2004
@@ -59,7 +59,8 @@
private boolean _isSingletonPageFlow = false;
private boolean _isSharedFlow = false;
private List< String > _sharedFlowTypeNames = null;
- private String _controllerClassName;
+ private String _controllerClassName = null;
+ private String _multipartHandlerClassName = null;
protected static final String DUPLICATE_ACTION_COMMENT = "Note that there
is more than one action with path \"{0}\"."
@@ -76,10 +77,10 @@
protected static final String STRUTS_CONFIG_EXTENSION = ".xml";
protected static final char STRUTS_CONFIG_SEPARATOR = '-';
protected static final String WEBINF_DIR_NAME = "WEB-INF";
- protected static final String STRUTSCONFIG_OUTPUT_DIR = "/" +
WEBINF_DIR_NAME + "/.pageflow-struts-generated";
+ protected static final String STRUTSCONFIG_OUTPUT_DIR = '/' +
WEBINF_DIR_NAME + "/.pageflow-struts-generated";
protected static final String VALIDATOR_PLUG_IN_CLASSNAME =
"org.apache.struts.validator.ValidatorPlugIn";
protected static final String VALIDATOR_PATHNAMES_PROPERTY = "pathnames";
- protected static final String DEFAULT_VALIDATOR_RULES_URI = "/" +
WEBINF_DIR_NAME + "/netui-validator-rules.xml";
+ protected static final String DEFAULT_VALIDATOR_RULES_URI = '/' +
WEBINF_DIR_NAME + "/netui-validator-rules.xml";
public StrutsApp( String controllerClassName )
@@ -163,7 +164,7 @@
if ( formName == null )
{
- return action.getPath() + "_";
+ return action.getPath() + '_';
}
else
{
@@ -176,7 +177,7 @@
beanName = bean.getType();
}
- return action.getPath() + "_" + makeFullyQualifiedBeanName(
beanName );
+ return action.getPath() + '_' + makeFullyQualifiedBeanName(
beanName );
}
}
@@ -275,10 +276,9 @@
public static File getWebappRootFromJpf( File jpf )
throws NoWebInfDirectoryException
{
- File dir = null;
File webappRoot = null;
- for ( dir = jpf.getAbsoluteFile().getParentFile(); dir != null &&
webappRoot == null; dir = dir.getParentFile() )
+ for ( File dir = jpf.getAbsoluteFile().getParentFile(); dir != null &&
webappRoot == null; dir = dir.getParentFile() )
{
if ( new File( dir, WEBINF_DIR_NAME ).isDirectory() )
{
@@ -352,7 +352,7 @@
return formBeanName;
}
- protected String makeFullyQualifiedBeanName( String formType )
+ protected static String makeFullyQualifiedBeanName( String formType )
{
return formType.replace( '.', '_' ).replace( '$', '_' );
}
@@ -443,7 +443,7 @@
Collections.sort( _actionMappings, new ActionMappingComparator() );
}
- protected class ActionMappingComparator implements Comparator
+ protected static class ActionMappingComparator implements Comparator
{
public int compare( Object o1, Object o2 )
{
@@ -780,6 +780,11 @@
controller.setProcessorClass( PAGEFLOW_REQUESTPROCESSOR_CLASSNAME
);
controller.setInputForward(
ControllerDocument.Controller.InputForward.TRUE );
+ if ( _multipartHandlerClassName != null )
+ {
+ controller.setMultipartClass( _multipartHandlerClassName );
+ }
+
if ( _isNestedPageFlow ) addSetProperty( controller,
"isNestedPageFlow", "true" );
if ( _isSingletonPageFlow ) addSetProperty( controller,
"isSingletonPageFlow", "true" );
if ( _isSharedFlow ) addSetProperty( controller, "isSharedFlow",
"true" );
@@ -794,7 +799,8 @@
{
String typeName = i.next();
int lastDot = typeName.lastIndexOf( '.' );
- String containingPackage = lastDot != -1 ?
typeName.substring( 0, lastDot ) : null;
+ assert lastDot != -1 : typeName;
+ String containingPackage = typeName.substring( 0, lastDot
);
if ( sharedFlowModules.length() > 0 )
sharedFlowModules.append( ';' );
sharedFlowModules.append( '/' );
sharedFlowModules.append( STRUTS_CONFIG_SEPARATOR );
@@ -868,7 +874,7 @@
SetPropertyDocument.SetProperty pathnamesProperty =
plugInElementToEdit.addNewSetProperty();
pathnamesProperty.setProperty( VALIDATOR_PATHNAMES_PROPERTY );
- pathnamesProperty.setValue( DEFAULT_VALIDATOR_RULES_URI + "," +
_validationModel.getOutputFileURI() );
+ pathnamesProperty.setValue( DEFAULT_VALIDATOR_RULES_URI + ',' +
_validationModel.getOutputFileURI() );
}
}
@@ -914,5 +920,15 @@
protected void setSharedFlowTypeNames( List< String > sharedFlowTypeNames )
{
_sharedFlowTypeNames = sharedFlowTypeNames;
+ }
+
+ public String getMultipartHandlerClassName()
+ {
+ return _multipartHandlerClassName;
+ }
+
+ protected void setMultipartHandlerClassName( String
multipartHandlerClassName )
+ {
+ _multipartHandlerClassName = multipartHandlerClassName;
}
}
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
Wed Sep 22 15:56:57 2004
@@ -19,7 +19,7 @@
import org.apache.beehive.netui.util.logging.Logger;
import org.apache.beehive.netui.util.config.ConfigUtil;
-import org.apache.beehive.netui.util.config.bean.PageflowOptions;
+import org.apache.beehive.netui.util.config.bean.PageflowConfig;
import org.apache.beehive.netui.pageflow.internal.InternalUtils;
import javax.servlet.http.HttpServletRequest;
@@ -279,9 +279,9 @@
if ( isNestable && pfStack != null )
{
- PageflowOptions options =
ConfigUtil.getConfig().getPageflowOptions();
+ PageflowConfig options =
ConfigUtil.getConfig().getPageflowConfig();
- if ( options == null || ! Boolean.parseBoolean(
options.getEnableRenesting() ) )
+ if ( options == null || ! options.getEnableRenesting() )
{
int lastIndexOfJpfClass = pfStack.lastIndexOf( request,
jpfClass );
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/MultipartRequestUtils.java
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/MultipartRequestUtils.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/MultipartRequestUtils.java
Wed Sep 22 15:56:57 2004
@@ -100,6 +100,11 @@
contentType.startsWith("multipart/form-data") &&
method.equalsIgnoreCase("POST"))
{
+ if ( ! InternalUtils.isMultipartHandlingEnabled( request ) )
+ {
+ throw new ServletException( "Received a multipart request, but
multipart handling is not enabled." );
+ }
+
ActionServletWrapper servlet;
if (bean != null)
@@ -125,7 +130,7 @@
if (multipartHandler == null)
{
- multipartHandler =
MultipartRequestUtils.getMultipartHandler(request);
+ multipartHandler = getMultipartHandler(request);
}
else
{
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/annotations/Jpf.java
Wed Sep 22 15:56:57 2004
@@ -17,7 +17,14 @@
*/
package org.apache.beehive.netui.pageflow.annotations;
-import java.lang.annotation.*;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
/**
@@ -28,8 +35,8 @@
/**
* Jpf.Controller; was jpf:controller
*/
- @Target( ElementType.TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( TYPE )
+ @Retention( RUNTIME )
public @interface Controller
{
/**
@@ -93,10 +100,19 @@
* message resources (optional )
*/
MessageResource[] messageResources() default {};
+
+ MultipartHandler multipartHandler() default MultipartHandler.disabled;
}
-
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+
+ public enum MultipartHandler
+ {
+ disabled,
+ memory,
+ disk
+ }
+
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ConditionalForward
{
/**
@@ -143,8 +159,8 @@
/**
* was jpf:view-properties
*/
- @Target( ElementType.TYPE )
- @Retention( RetentionPolicy.SOURCE )
+ @Target( TYPE )
+ @Retention( SOURCE )
public @interface ViewProperties
{
String[] value() default {};
@@ -153,8 +169,8 @@
/**
* was jpf:action
*/
- @Target( ElementType.METHOD )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( METHOD )
+ @Retention( RUNTIME )
public @interface Action
{
/**
@@ -200,8 +216,8 @@
Forward validationErrorForward() default @Jpf.Forward( name="" );
}
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface SimpleAction
{
/**
@@ -248,7 +264,7 @@
*/
Forward validationErrorForward() default @Jpf.Forward( name="" );
- /**
+ /**
* The forward path. Mutually-exclusive with
<code>returnAction</code> and <code>navigateTo</code>.
*/
String path() default "";
@@ -282,8 +298,8 @@
/**
* was jpf:catch
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface Catch
{
/**
@@ -319,8 +335,8 @@
/**
* was jpf:exception-handler
*/
- @Target( ElementType.METHOD )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( METHOD )
+ @Retention( RUNTIME )
public @interface ExceptionHandler
{
/**
@@ -338,8 +354,8 @@
/**
* was jpf:forward
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface Forward
{
/**
@@ -382,8 +398,8 @@
/**
* page input
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ActionOutput
{
String name();
@@ -396,8 +412,8 @@
/**
* Was jpf:message-resources
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface MessageResource
{
String name(); // required - no default
@@ -415,8 +431,8 @@
/**
* Validation rule: Required.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidateRequired
{
boolean enabled() default true;
@@ -435,8 +451,8 @@
/**
* Validation rule: MinLength.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidateMinLength
{
boolean enabled() default true;
@@ -456,8 +472,8 @@
/**
* Validation rule: MaxLength.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidateMaxLength
{
boolean enabled() default true;
@@ -477,8 +493,8 @@
/**
* Validation rule: Mask.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidateMask
{
boolean enabled() default true;
@@ -498,8 +514,8 @@
/**
* Validation rule: Byte.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidateType
{
boolean enabled() default true;
@@ -519,8 +535,8 @@
/**
* Validation rule: Date.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidateDate
{
boolean enabled() default true;
@@ -541,8 +557,8 @@
/**
* Validation rule: Range.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidateRange
{
boolean enabled() default true;
@@ -565,8 +581,8 @@
/**
* Validation rule: CreditCard.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidateCreditCard
{
boolean enabled() default true;
@@ -585,8 +601,8 @@
/**
* Validation rule: Email.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidateEmail
{
boolean enabled() default true;
@@ -605,8 +621,8 @@
/**
* Validation rule: ValidWhen.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidateValidWhen
{
boolean enabled() default true;
@@ -623,8 +639,8 @@
String arg3Key() default "";
}
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidateCustomVariable
{
String name();
@@ -634,8 +650,8 @@
/**
* Validation rule: Custom.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidateCustom
{
boolean enabled() default true;
@@ -657,8 +673,8 @@
* List of field validation rules. Can be present on a bean property
(method or field),
* or within a [EMAIL PROTECTED] ValidatableProperty}.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidationLocaleRules
{
ValidateRequired validateRequired() default
@ValidateRequired(enabled=false);
@@ -682,8 +698,8 @@
/**
* Validation rules associated with particular bean fields. Valid within
[EMAIL PROTECTED] ValidatableBean} or [EMAIL PROTECTED] Action}.
*/
- @Target( { ElementType.ANNOTATION_TYPE, ElementType.METHOD } )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( { ANNOTATION_TYPE, METHOD } )
+ @Retention( RUNTIME )
public @interface ValidatableProperty
{
String propertyName() default "";
@@ -707,48 +723,48 @@
* Validation fields (and associated rules) associated with a bean type.
Valid within
* [EMAIL PROTECTED] Controller}.
*/
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface ValidatableBean
{
Class type(); // required
ValidatableProperty[] validatableProperties(); // required
}
- @Target( ElementType.TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( TYPE )
+ @Retention( RUNTIME )
public @interface FormBean
{
String defaultMessageBundle() default "";
}
- @Target( ElementType.FIELD )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( FIELD )
+ @Retention( RUNTIME )
public @interface SharedFlowField
{
}
- @Target( ElementType.FIELD )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( FIELD )
+ @Retention( RUNTIME )
public @interface PageFlowField
{
}
- @Target( ElementType.TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( TYPE )
+ @Retention( RUNTIME )
public @interface FacesBacking
{
}
- @Target( ElementType.METHOD )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( METHOD )
+ @Retention( RUNTIME )
public @interface CommandHandler
{
RaiseAction[] raiseActions() default {};
}
- @Target( ElementType.ANNOTATION_TYPE )
- @Retention( RetentionPolicy.RUNTIME )
+ @Target( ANNOTATION_TYPE )
+ @Retention( RUNTIME )
public @interface RaiseAction
{
String action();
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowControllerConfig.java
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowControllerConfig.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowControllerConfig.java
Wed Sep 22 15:56:57 2004
@@ -18,12 +18,19 @@
package org.apache.beehive.netui.pageflow.config;
import org.apache.struts.config.ControllerConfig;
+import org.apache.struts.upload.CommonsMultipartRequestHandler;
+import org.apache.struts.upload.DiskMultipartRequestHandler;
+import org.apache.beehive.netui.util.config.bean.PageflowConfig;
+import org.apache.beehive.netui.pageflow.internal.InternalUtils;
import java.util.List;
import java.util.Arrays;
public class PageFlowControllerConfig extends ControllerConfig
{
+ private static final String MEMORY_MULTIPART_HANDLER_CLASS =
CommonsMultipartRequestHandler.class.getName();
+ private static final String DISK_MULTIPART_HANDLER_CLASS =
DiskMultipartRequestHandler.class.getName();
+
private boolean _isNestedPageFlow;
private boolean _isSingletonPageFlow;
private boolean _isReturnToPageDisabled;
@@ -32,6 +39,8 @@
private List< String > _sharedFlowModules;
private String _controllerClass;
private boolean _isSharedFlow;
+ private String _overrideMultipartClass = null;
+ private boolean _forceMultipartDisabled = false;
public boolean isNestedPageFlow()
@@ -117,5 +126,49 @@
public void setIsSharedFlow( boolean sharedFlow )
{
_isSharedFlow = sharedFlow;
+ }
+
+ public String getMultipartClass()
+ {
+ if ( _forceMultipartDisabled ) return null;
+ if ( _overrideMultipartClass != null ) return _overrideMultipartClass;
+
+ PageflowConfig.MultipartHandler.Enum mpHandler =
InternalUtils.getMultipartHandlerType();
+
+ if ( mpHandler != null )
+ {
+ switch ( mpHandler.intValue() )
+ {
+ case PageflowConfig.MultipartHandler.INT_DISABLED: return null;
+ case PageflowConfig.MultipartHandler.INT_MEMORY: return
MEMORY_MULTIPART_HANDLER_CLASS;
+ case PageflowConfig.MultipartHandler.INT_DISK: return
DISK_MULTIPART_HANDLER_CLASS;
+ default: assert false : "unknown value for multipart handler:
" + mpHandler.toString();
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Get the directory for DiskMultipartRequestHandler temporary files.
+ * @return
+ */
+ public String getTempDir()
+ {
+ // TODO: In the Struts 1.1 version of DiskMultipartRequestHandler,
there is an NPE on line 295
+ // (in retrieveTempDir). When this is fixed, we can remove our
override of getTempDir().
+ return tempDir != null ? tempDir : System.getProperty(
"java.io.tmpdir" );
+ }
+
+ public void setMultipartClass( String overrideMultipartClass )
+ {
+ if ( overrideMultipartClass.equals( "none" ) )
+ {
+ _forceMultipartDisabled = true;
+ }
+ else
+ {
+ _overrideMultipartClass = overrideMultipartClass;
+ }
}
}
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
Wed Sep 22 15:56:57 2004
@@ -24,6 +24,8 @@
import org.apache.beehive.netui.util.logging.Logger;
import org.apache.beehive.netui.util.Bundle;
import org.apache.beehive.netui.util.ServletUtils;
+import org.apache.beehive.netui.util.config.bean.PageflowConfig;
+import org.apache.beehive.netui.util.config.ConfigUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -1017,5 +1019,17 @@
{
return "";
}
+ }
+
+ public static boolean isMultipartHandlingEnabled( HttpServletRequest
request )
+ {
+ ModuleConfig moduleConfig = ( ModuleConfig ) request.getAttribute(
Globals.MODULE_KEY );
+ return moduleConfig.getControllerConfig().getMultipartClass() != null;
+ }
+
+ public static PageflowConfig.MultipartHandler.Enum
getMultipartHandlerType()
+ {
+ PageflowConfig pfConfig = ConfigUtil.getConfig().getPageflowConfig();
+ return pfConfig != null ? pfConfig.getMultipartHandler() : null;
}
}
Modified: incubator/beehive/trunk/netui/src/util/schema/netui-config.xsd
==============================================================================
--- incubator/beehive/trunk/netui/src/util/schema/netui-config.xsd
(original)
+++ incubator/beehive/trunk/netui/src/util/schema/netui-config.xsd Wed Sep
22 15:56:57 2004
@@ -13,7 +13,7 @@
<xsd:element name="expression-languages"
type="netui:expression-languages" minOccurs="1" maxOccurs="1"/>
<xsd:element name="pageflow-action-interceptors"
type="netui:pageflow-action-interceptors" minOccurs="0" maxOccurs="1"/>
<xsd:element name="pageflow-handlers"
type="netui:pageflow-handlers" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="pageflow-options"
type="netui:pageflow-options" minOccurs="0" maxOccurs="1"/>
+ <xsd:element name="pageflow-config"
type="netui:pageflow-config" minOccurs="0" maxOccurs="1"/>
<xsd:element name="type-converters"
type="netui:type-converters" minOccurs="0" maxOccurs="1"/>
<xsd:element name="iterator-factories"
type="netui:iterator-factories" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
@@ -60,9 +60,24 @@
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="pageflow-options">
+ <xsd:complexType name="pageflow-config">
<xsd:sequence>
- <xsd:element name="enable-renesting" type="xsd:string"
minOccurs="0" maxOccurs="1" default="false"/>
+ <xsd:element name="enable-renesting" type="xsd:boolean"
minOccurs="0" maxOccurs="1" default="false"/>
+ <xsd:element name="multipart-handler" minOccurs="0" maxOccurs="1"
default="disabled">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="disabled"/>
+ <xsd:enumeration value="memory"/>
+ <xsd:enumeration value="disk"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="jsp-tag-config">
+ <xsd:sequence>
+ <xsd:element name="doctype" type="xsd:string" minOccurs="0"
maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>