1 18 package org.apache.beehive.netui.pageflow.config; 19 20 import org.apache.struts.config.ControllerConfig; 21 import org.apache.struts.upload.CommonsMultipartRequestHandler; 22 import org.apache.struts.upload.DiskMultipartRequestHandler; 23 import org.apache.beehive.netui.util.config.bean.PageflowConfig; 24 import org.apache.beehive.netui.pageflow.internal.InternalUtils; 25 26 import java.util.LinkedHashMap ; 27 import java.util.Map ; 28 29 32 public class PageFlowControllerConfig extends ControllerConfig 33 { 34 private static final String MEMORY_MULTIPART_HANDLER_CLASS = CommonsMultipartRequestHandler.class.getName(); 35 private static final String DISK_MULTIPART_HANDLER_CLASS = DiskMultipartRequestHandler.class.getName(); 36 37 private boolean _isNestedPageFlow; 38 private boolean _isLongLivedPageFlow; 39 private boolean _isReturnToPageDisabled; 40 private boolean _isReturnToActionDisabled; 41 private boolean _isMissingDefaultMessages; 42 private LinkedHashMap _sharedFlowTypes; 43 private String _controllerClass; 44 private boolean _isSharedFlow; 45 private String _overrideMultipartClass = null; 46 private boolean _forceMultipartDisabled = false; 47 48 49 public boolean isNestedPageFlow() 50 { 51 return _isNestedPageFlow; 52 } 53 54 public void setIsNestedPageFlow( boolean nestedPageFlow ) 55 { 56 _isNestedPageFlow = nestedPageFlow; 57 } 58 59 public boolean isLongLivedPageFlow() 60 { 61 return _isLongLivedPageFlow; 62 } 63 64 public void setIsLongLivedPageFlow( boolean longLivedPageFlow ) 65 { 66 _isLongLivedPageFlow = longLivedPageFlow; 67 } 68 69 public boolean isReturnToPageDisabled() 70 { 71 return _isReturnToPageDisabled; 72 } 73 74 public void setIsReturnToPageDisabled( boolean returnToPageDisabled ) 75 { 76 _isReturnToPageDisabled = returnToPageDisabled; 77 } 78 79 public boolean isReturnToActionDisabled() 80 { 81 return _isReturnToActionDisabled; 82 } 83 84 public void setIsReturnToActionDisabled( boolean returnToActionDisabled ) 85 { 86 _isReturnToActionDisabled = returnToActionDisabled; 87 } 88 89 public boolean isMissingDefaultMessages() 90 { 91 return _isMissingDefaultMessages; 92 } 93 94 public void setIsMissingDefaultMessages( boolean missingDefaultMessages ) 95 { 96 _isMissingDefaultMessages = missingDefaultMessages; 97 } 98 99 public void setSharedFlows( String sharedFlows ) 100 { 101 if ( sharedFlows == null || sharedFlows.length() == 0 ) 102 { 103 _sharedFlowTypes = null; 104 return; 105 } 106 107 String [] keyValues = sharedFlows.split( "," ); 108 _sharedFlowTypes = new LinkedHashMap (); 109 110 for ( int i = 0; i < keyValues.length; i++ ) 111 { 112 String keyValue = keyValues[i]; 113 int delim = keyValue.indexOf( '=' ); 114 assert delim != -1 : "no delimiter in " + keyValue; 115 assert delim < keyValue.length() - 1 : "missing value in " + keyValue; 116 _sharedFlowTypes.put( keyValue.substring( 0, delim ), keyValue.substring( delim + 1 ) ); 117 } 118 } 119 120 public String getSharedFlows() 121 { 122 throw new UnsupportedOperationException ( "not implemented; uses getSharedFlowTypes" ); 123 } 124 125 public Map getSharedFlowTypes() 126 { 127 return _sharedFlowTypes; 128 } 129 130 public String getControllerClass() 131 { 132 return _controllerClass; 133 } 134 135 public void setControllerClass( String controllerClass ) 136 { 137 _controllerClass = controllerClass; 138 } 139 140 public boolean isSharedFlow() 141 { 142 return _isSharedFlow; 143 } 144 145 public void setIsSharedFlow( boolean sharedFlow ) 146 { 147 _isSharedFlow = sharedFlow; 148 } 149 150 public String getMultipartClass() 151 { 152 if ( _forceMultipartDisabled ) return null; 153 if ( _overrideMultipartClass != null ) return _overrideMultipartClass; 154 155 PageflowConfig.MultipartHandler.Enum mpHandler = InternalUtils.getMultipartHandlerType(); 156 157 if ( mpHandler != null ) 158 { 159 switch ( mpHandler.intValue() ) 160 { 161 case PageflowConfig.MultipartHandler.INT_DISABLED: return null; 162 case PageflowConfig.MultipartHandler.INT_MEMORY: return MEMORY_MULTIPART_HANDLER_CLASS; 163 case PageflowConfig.MultipartHandler.INT_DISK: return DISK_MULTIPART_HANDLER_CLASS; 164 default: assert false : "unknown value for multipart handler: " + mpHandler.toString(); 165 } 166 } 167 168 return null; 169 } 170 171 175 public String getTempDir() 176 { 177 return tempDir != null ? tempDir : System.getProperty( "java.io.tmpdir" ); 180 } 181 182 public void setMultipartClass( String overrideMultipartClass ) 183 { 184 if ( overrideMultipartClass.equals( "none" ) ) 185 { 186 _forceMultipartDisabled = true; 187 } 188 else 189 { 190 _overrideMultipartClass = overrideMultipartClass; 191 } 192 } 193 } 194 | Popular Tags |