You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by hu...@apache.org on 2006/11/06 16:02:22 UTC
svn commit: r471756 [13/31] - in /struts/struts2/trunk: apps/blank/
apps/blank/src/main/java/example/ apps/blank/src/test/java/example/
apps/mailreader/src/main/java/mailreader2/
apps/portlet/src/main/java/org/apache/struts2/portlet/example/ apps/portl...
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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.
+ * 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.struts2.interceptor;
@@ -32,27 +35,27 @@
/**
* <!-- START SNIPPET: description -->
- *
- * An interceptor to store {@link ValidationAware} action's messages / errors and field errors into
+ *
+ * An interceptor to store {@link ValidationAware} action's messages / errors and field errors into
* Http Session, such that it will be retrieveable at a later stage. This allows the action's message /
* errors and field errors to be available longer that just the particular http request.
- *
+ *
* <p/>
- *
- * In the 'STORE' mode, the interceptor will store the {@link ValidationAware} action's message / errors
+ *
+ * In the 'STORE' mode, the interceptor will store the {@link ValidationAware} action's message / errors
* and field errors into Http session.
- *
+ *
* <p/>
- *
+ *
* In the 'RETRIEVE' mode, the interceptor will retrieve the stored action's message / errors and field
* errors and put them back into the {@link ValidationAware} action.
- *
+ *
* <p/>
- *
+ *
* The interceptor does nothing in the 'NONE' mode, which is the default.
- *
+ *
* <p/>
- *
+ *
* The operation mode could be switched using :- <p/>
* 1] Setting the iterceptor parameter eg.
* <pre>
@@ -64,267 +67,267 @@
* ....
* </action>
* </pre>
- *
+ *
* 2] Through request parameter (allowRequestParameterSwitch must be 'true' which is the default)
* <pre>
* // the request will have the operation mode in 'STORE'
* http://localhost:8080/context/submitApplication.action?operationMode=STORE
* </pre>
- *
+ *
* <!-- END SNIPPET: description -->
- *
- *
+ *
+ *
* <!-- START SNIPPET: parameters -->
- *
+ *
* <ul>
- * <li>allowRequestParameterSwitch - To enable request parameter that could switch the operation mode
- * of this interceptor. </li>
- * <li>requestParameterSwitch - The request parameter that will indicate what mode this
- * interceptor is in. </li>
- * <li>operationMode - The operation mode this interceptor should be in
- * (either 'STORE', 'RETRIEVE' or 'NONE'). 'NONE' being the default.</li>
+ * <li>allowRequestParameterSwitch - To enable request parameter that could switch the operation mode
+ * of this interceptor. </li>
+ * <li>requestParameterSwitch - The request parameter that will indicate what mode this
+ * interceptor is in. </li>
+ * <li>operationMode - The operation mode this interceptor should be in
+ * (either 'STORE', 'RETRIEVE' or 'NONE'). 'NONE' being the default.</li>
* </ul>
- *
+ *
* <!-- END SNIPPET: parameters -->
- *
+ *
* <p/>
- *
+ *
* <!-- START SNIPPET: extending -->
- *
+ *
* The following method could be overriden :-
* <ul>
- * <li>getRequestOperationMode - get the operation mode of this interceptor based on the request parameters</li>
+ * <li>getRequestOperationMode - get the operation mode of this interceptor based on the request parameters</li>
* <li>mergeCollection - merge two collections</li>
* <li>mergeMap - merge two map</li>
* </ul>
- *
+ *
* <!-- END SNIPPET: extending -->
- *
+ *
* <pre>
* <!-- START SNIPPET: example -->
- *
+ *
* <action name="submitApplication" ....>
* <interceptor-ref name="store">
- * <param name="operationMode">STORE</param>
+ * <param name="operationMode">STORE</param>
* </interceptor-ref>
* <interceptor-ref name="defaultStack" />
* <result name="input" type="redirect">applicationFailed.action</result>
* <result type="dispatcher">applicationSuccess.jsp</result>
* </action>
- *
+ *
* <action name="applicationFailed" ....>
* <interceptor-ref name="store">
* <param name="operationMode">RETRIEVE</param>
* </interceptor-ref>
* <result>applicationFailed.jsp</result>
* </action>
- *
+ *
* <!-- END SNIPPET: example -->
* </pre>
- *
+ *
* <!-- START SNIPPET: exampleDescription -->
- *
+ *
* With the example above, 'submitApplication.action' will have the action messages / errors / field errors stored
* in the Http Session. Later when needed, (in this case, when 'applicationFailed.action' is fired, it
- * will get the action messages / errors / field errors stored in the Http Session and put them back into
- * the action.
- *
+ * will get the action messages / errors / field errors stored in the Http Session and put them back into
+ * the action.
+ *
* <!-- END SNIPPET: exampleDescription -->
- *
+ *
* @version $Date$ $Id$
*/
public class MessageStoreInterceptor implements Interceptor {
- private static final long serialVersionUID = 4491997514314242420L;
-
- private static final Log _log = LogFactory.getLog(MessageStoreInterceptor.class);
-
-
- public static final String STORE_MODE = "STORE";
- public static final String RETRIEVE_MODE = "RETRIEVE";
- public static final String NONE = "NONE";
-
- private boolean allowRequestParameterSwitch = true;
- private String requestParameterSwitch = "operationMode";
- private String operationMode = NONE;
-
- public static String fieldErrorsSessionKey = "__MessageStoreInterceptor_FieldErrors_SessionKey";
- public static String actionErrorsSessionKey = "__MessageStoreInterceptor_ActionErrors_SessionKey";
- public static String actionMessagesSessionKey = "__MessageStoreInterceptor_ActionMessages_SessionKey";
-
-
-
- public void setAllowRequestParameterSwitch(boolean allowRequestParameterSwitch) {
- this.allowRequestParameterSwitch = allowRequestParameterSwitch;
- }
- public boolean getAllowRequestParameterSwitch() {
- return this.allowRequestParameterSwitch;
- }
-
-
- public void setRequestParameterSwitch(String requestParameterSwitch) {
- this.requestParameterSwitch = requestParameterSwitch;
- }
- public String getRequestParameterSwitch() {
- return this.requestParameterSwitch;
- }
-
-
-
- public void setOperationMode(String operationMode) {
- this.operationMode = operationMode;
- }
- public String getOperationModel() {
- return this.operationMode;
- }
-
-
- public void destroy() {
- }
-
- public void init() {
- }
-
- public String intercept(ActionInvocation invocation) throws Exception {
- _log.debug("entering MessageStoreInterceptor ...");
-
- before(invocation);
- String result = invocation.invoke();
- after(invocation, result);
-
- _log.debug("exit executing MessageStoreInterceptor");
- return result;
- }
-
- /**
- * Handle the retrieving of field errors / action messages / field errors, which is
- * done before action invocation, and the <code>operationMode</code> is 'RETRIEVE'.
- *
- * @param invocation
- * @throws Exception
- */
- protected void before(ActionInvocation invocation) throws Exception {
- String reqOperationMode = getRequestOperationMode(invocation);
-
- if (RETRIEVE_MODE.equalsIgnoreCase(reqOperationMode) ||
- RETRIEVE_MODE.equalsIgnoreCase(operationMode)) {
-
- Object action = invocation.getAction();
- if (action instanceof ValidationAware) {
- // retrieve error / message from session
- Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION);
- ValidationAware validationAwareAction = (ValidationAware) action;
-
- _log.debug("retrieve error / message from session to populate into action ["+action+"]");
-
- Collection actionErrors = (Collection) session.get(actionErrorsSessionKey);
- Collection actionMessages = (Collection) session.get(actionMessagesSessionKey);
- Map fieldErrors = (Map) session.get(fieldErrorsSessionKey);
-
- if (actionErrors != null && actionErrors.size() > 0) {
- Collection mergedActionErrors = mergeCollection(validationAwareAction.getActionErrors(), actionErrors);
- validationAwareAction.setActionErrors(mergedActionErrors);
- }
-
- if (actionMessages != null && actionMessages.size() > 0) {
- Collection mergedActionMessages = mergeCollection(validationAwareAction.getActionMessages(), actionMessages);
- validationAwareAction.setActionMessages(mergedActionMessages);
- }
-
- if (fieldErrors != null && fieldErrors.size() > 0) {
- Map mergedFieldErrors = mergeMap(validationAwareAction.getFieldErrors(), fieldErrors);
- validationAwareAction.setFieldErrors(mergedFieldErrors);
- }
- session.remove(actionErrorsSessionKey);
- session.remove(actionMessagesSessionKey);
- session.remove(fieldErrorsSessionKey);
- }
- }
- }
-
- /**
- * Handle the storing of field errors / action messages / field errors, which is
- * done after action invocation, and the <code>operationMode</code> is in 'STORE'.
- *
- * @param invocation
- * @param result
- * @throws Exception
- */
- protected void after(ActionInvocation invocation, String result) throws Exception {
-
- String reqOperationMode = getRequestOperationMode(invocation);
- if (STORE_MODE.equalsIgnoreCase(reqOperationMode) ||
- STORE_MODE.equalsIgnoreCase(operationMode)) {
-
- Object action = invocation.getAction();
- if (action instanceof ValidationAware) {
- // store error / messages into session
- Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION);
-
- _log.debug("store action ["+action+"] error/messages into session ");
-
- ValidationAware validationAwareAction = (ValidationAware) action;
- session.put(actionErrorsSessionKey, validationAwareAction.getActionErrors());
- session.put(actionMessagesSessionKey, validationAwareAction.getActionMessages());
- session.put(fieldErrorsSessionKey, validationAwareAction.getFieldErrors());
- }
- else {
- _log.debug("Action ["+action+"] is not ValidationAware, no message / error that are storeable");
- }
- }
- }
-
-
- /**
- * Get the operationMode through request paramter, if <code>allowRequestParameterSwitch</code>
- * is 'true', else it simply returns 'NONE', meaning its neither in the 'STORE_MODE' nor
- * 'RETRIEVE_MODE'.
- *
- * @return String
- */
- protected String getRequestOperationMode(ActionInvocation invocation) {
- String reqOperationMode = NONE;
- if (allowRequestParameterSwitch) {
- Map reqParams = (Map) invocation.getInvocationContext().get(ActionContext.PARAMETERS);
- boolean containsParameter = reqParams.containsKey(requestParameterSwitch);
- if (containsParameter) {
- String[] reqParamsArr = (String[]) reqParams.get(requestParameterSwitch);
- if (reqParamsArr != null && reqParamsArr.length > 0) {
- reqOperationMode = reqParamsArr[0];
- }
- }
- }
- return reqOperationMode;
- }
-
- /**
- * Merge <code>col1</code> and <code>col2</code> and return the composite
- * <code>Collection</code>.
- *
- * @param col1
- * @param col2
- * @return Collection
- */
- protected Collection mergeCollection(Collection col1, Collection col2) {
- Collection _col1 = (col1 == null ? new ArrayList() : col1);
- Collection _col2 = (col2 == null ? new ArrayList() : col2);
- _col1.addAll(_col2);
- return _col1;
- }
-
- /**
- * Merge <code>map1</code> and <code>map2</code> and return the composite
- * <code>Map</code>
- *
- * @param map1
- * @param map2
- * @return Map
- */
- protected Map mergeMap(Map map1, Map map2) {
- Map _map1 = (map1 == null ? new LinkedHashMap() : map1);
- Map _map2 = (map2 == null ? new LinkedHashMap() : map2);
- _map1.putAll(_map2);
- return _map1;
- }
+ private static final long serialVersionUID = 4491997514314242420L;
+
+ private static final Log _log = LogFactory.getLog(MessageStoreInterceptor.class);
+
+
+ public static final String STORE_MODE = "STORE";
+ public static final String RETRIEVE_MODE = "RETRIEVE";
+ public static final String NONE = "NONE";
+
+ private boolean allowRequestParameterSwitch = true;
+ private String requestParameterSwitch = "operationMode";
+ private String operationMode = NONE;
+
+ public static String fieldErrorsSessionKey = "__MessageStoreInterceptor_FieldErrors_SessionKey";
+ public static String actionErrorsSessionKey = "__MessageStoreInterceptor_ActionErrors_SessionKey";
+ public static String actionMessagesSessionKey = "__MessageStoreInterceptor_ActionMessages_SessionKey";
+
+
+
+ public void setAllowRequestParameterSwitch(boolean allowRequestParameterSwitch) {
+ this.allowRequestParameterSwitch = allowRequestParameterSwitch;
+ }
+ public boolean getAllowRequestParameterSwitch() {
+ return this.allowRequestParameterSwitch;
+ }
+
+
+ public void setRequestParameterSwitch(String requestParameterSwitch) {
+ this.requestParameterSwitch = requestParameterSwitch;
+ }
+ public String getRequestParameterSwitch() {
+ return this.requestParameterSwitch;
+ }
+
+
+
+ public void setOperationMode(String operationMode) {
+ this.operationMode = operationMode;
+ }
+ public String getOperationModel() {
+ return this.operationMode;
+ }
+
+
+ public void destroy() {
+ }
+
+ public void init() {
+ }
+
+ public String intercept(ActionInvocation invocation) throws Exception {
+ _log.debug("entering MessageStoreInterceptor ...");
+
+ before(invocation);
+ String result = invocation.invoke();
+ after(invocation, result);
+
+ _log.debug("exit executing MessageStoreInterceptor");
+ return result;
+ }
+
+ /**
+ * Handle the retrieving of field errors / action messages / field errors, which is
+ * done before action invocation, and the <code>operationMode</code> is 'RETRIEVE'.
+ *
+ * @param invocation
+ * @throws Exception
+ */
+ protected void before(ActionInvocation invocation) throws Exception {
+ String reqOperationMode = getRequestOperationMode(invocation);
+
+ if (RETRIEVE_MODE.equalsIgnoreCase(reqOperationMode) ||
+ RETRIEVE_MODE.equalsIgnoreCase(operationMode)) {
+
+ Object action = invocation.getAction();
+ if (action instanceof ValidationAware) {
+ // retrieve error / message from session
+ Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION);
+ ValidationAware validationAwareAction = (ValidationAware) action;
+
+ _log.debug("retrieve error / message from session to populate into action ["+action+"]");
+
+ Collection actionErrors = (Collection) session.get(actionErrorsSessionKey);
+ Collection actionMessages = (Collection) session.get(actionMessagesSessionKey);
+ Map fieldErrors = (Map) session.get(fieldErrorsSessionKey);
+
+ if (actionErrors != null && actionErrors.size() > 0) {
+ Collection mergedActionErrors = mergeCollection(validationAwareAction.getActionErrors(), actionErrors);
+ validationAwareAction.setActionErrors(mergedActionErrors);
+ }
+
+ if (actionMessages != null && actionMessages.size() > 0) {
+ Collection mergedActionMessages = mergeCollection(validationAwareAction.getActionMessages(), actionMessages);
+ validationAwareAction.setActionMessages(mergedActionMessages);
+ }
+
+ if (fieldErrors != null && fieldErrors.size() > 0) {
+ Map mergedFieldErrors = mergeMap(validationAwareAction.getFieldErrors(), fieldErrors);
+ validationAwareAction.setFieldErrors(mergedFieldErrors);
+ }
+ session.remove(actionErrorsSessionKey);
+ session.remove(actionMessagesSessionKey);
+ session.remove(fieldErrorsSessionKey);
+ }
+ }
+ }
+
+ /**
+ * Handle the storing of field errors / action messages / field errors, which is
+ * done after action invocation, and the <code>operationMode</code> is in 'STORE'.
+ *
+ * @param invocation
+ * @param result
+ * @throws Exception
+ */
+ protected void after(ActionInvocation invocation, String result) throws Exception {
+
+ String reqOperationMode = getRequestOperationMode(invocation);
+ if (STORE_MODE.equalsIgnoreCase(reqOperationMode) ||
+ STORE_MODE.equalsIgnoreCase(operationMode)) {
+
+ Object action = invocation.getAction();
+ if (action instanceof ValidationAware) {
+ // store error / messages into session
+ Map session = (Map) invocation.getInvocationContext().get(ActionContext.SESSION);
+
+ _log.debug("store action ["+action+"] error/messages into session ");
+
+ ValidationAware validationAwareAction = (ValidationAware) action;
+ session.put(actionErrorsSessionKey, validationAwareAction.getActionErrors());
+ session.put(actionMessagesSessionKey, validationAwareAction.getActionMessages());
+ session.put(fieldErrorsSessionKey, validationAwareAction.getFieldErrors());
+ }
+ else {
+ _log.debug("Action ["+action+"] is not ValidationAware, no message / error that are storeable");
+ }
+ }
+ }
+
+
+ /**
+ * Get the operationMode through request paramter, if <code>allowRequestParameterSwitch</code>
+ * is 'true', else it simply returns 'NONE', meaning its neither in the 'STORE_MODE' nor
+ * 'RETRIEVE_MODE'.
+ *
+ * @return String
+ */
+ protected String getRequestOperationMode(ActionInvocation invocation) {
+ String reqOperationMode = NONE;
+ if (allowRequestParameterSwitch) {
+ Map reqParams = (Map) invocation.getInvocationContext().get(ActionContext.PARAMETERS);
+ boolean containsParameter = reqParams.containsKey(requestParameterSwitch);
+ if (containsParameter) {
+ String[] reqParamsArr = (String[]) reqParams.get(requestParameterSwitch);
+ if (reqParamsArr != null && reqParamsArr.length > 0) {
+ reqOperationMode = reqParamsArr[0];
+ }
+ }
+ }
+ return reqOperationMode;
+ }
+
+ /**
+ * Merge <code>col1</code> and <code>col2</code> and return the composite
+ * <code>Collection</code>.
+ *
+ * @param col1
+ * @param col2
+ * @return Collection
+ */
+ protected Collection mergeCollection(Collection col1, Collection col2) {
+ Collection _col1 = (col1 == null ? new ArrayList() : col1);
+ Collection _col2 = (col2 == null ? new ArrayList() : col2);
+ _col1.addAll(_col2);
+ return _col1;
+ }
+
+ /**
+ * Merge <code>map1</code> and <code>map2</code> and return the composite
+ * <code>Map</code>
+ *
+ * @param map1
+ * @param map2
+ * @return Map
+ */
+ protected Map mergeMap(Map map1, Map map2) {
+ Map _map1 = (map1 == null ? new LinkedHashMap() : map1);
+ Map _map2 = (map2 == null ? new LinkedHashMap() : map2);
+ _map1.putAll(_map2);
+ return _map1;
+ }
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/NoParameters.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/NoParameters.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/NoParameters.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/NoParameters.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.interceptor;
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.interceptor;
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.interceptor;
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalProxy.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalProxy.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalProxy.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/PrincipalProxy.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.interceptor;
@@ -31,7 +34,7 @@
/**
* Constructs a proxy
- *
+ *
* @param request The underlying request
*/
public PrincipalProxy(HttpServletRequest request) {
@@ -40,7 +43,7 @@
/**
* True if the user is in the given role
- *
+ *
* @param role The role
* @return True if the user is in that role
*/
@@ -50,7 +53,7 @@
/**
* Gets the user principal
- *
+ *
* @return The principal
*/
public Principal getUserPrincipal() {
@@ -59,7 +62,7 @@
/**
* Gets the user id
- *
+ *
* @return The user id
*/
public String getRemoteUser() {
@@ -68,7 +71,7 @@
/**
* Is the request using https?
- *
+ *
* @return True if using https
*/
public boolean isRequestSecure() {
@@ -77,7 +80,7 @@
/**
* Gets the request
- *
+ *
* @return The request
*/
public HttpServletRequest getRequest() {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ProfilingActivationInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ProfilingActivationInterceptor.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ProfilingActivationInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ProfilingActivationInterceptor.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
- * $Id: CreateSessionInterceptor.java 439747 2006-09-03 09:22:46Z mrdon $
+ * $Id: $
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.interceptor;
@@ -25,30 +28,30 @@
/**
* <!-- START SNIPPET: description -->
- *
+ *
* Allows profiling to be enabled or disabled via request parameters, when
* devMode is enabled.
- *
+ *
* <!-- END SNIPPET: description -->
- *
- *
+ *
+ *
* <!-- START SNIPPET: parameters -->
- *
+ *
* <ul>
* <li>profilingKey</li>
* </ul>
- *
+ *
* <!-- END SNIPPET: parameters -->
- *
+ *
* <!-- START SNIPPET: extending -->
- *
+ *
* none
- *
+ *
* <!-- END SNIPPET: extending -->
- *
+ *
* <pre>
* <!-- START SNIPPET: example -->
- *
+ *
* // to change the profiling key
* <action ...>
* ...
@@ -57,16 +60,16 @@
* </interceptor-ref>
* ...
* </action>
- *
+ *
* <!-- END SNIPPET: example -->
* </pre>
- *
+ *
* @version $Date$ $Id$
*/
public class ProfilingActivationInterceptor extends AbstractInterceptor {
private String profilingKey = "profiling";
-
+
/**
* @return the profilingKey
*/
@@ -93,7 +96,7 @@
}
}
return invocation.invoke();
-
+
}
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java Mon Nov 6 07:01:43 2006
@@ -1,35 +1,39 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.interceptor;
import java.util.Map;
/**
* Actions that want access to the current serlvet request attributes should implement this interface.<p />
- *
+ *
* This interface is only relevant if the Action is used in a servlet environment.<p/>
- *
+ *
* Note that using this interface makes the Action tied to a servlet environment, so it should be
* avoided if possible since things like unit testing will become more difficult.
*/
public interface RequestAware {
- /**
+ /**
* Sets the Map of request attributes in the implementing class.
*
* @param request a Map of HTTP request attribute name/value pairs.
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RolesInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RolesInterceptor.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RolesInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RolesInterceptor.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
- * $Id: ScopeInterceptor.java 451544 2006-09-30 05:38:02Z mrdon $
+ * $Id: $
*
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.struts2.interceptor;
@@ -34,7 +37,7 @@
* <!-- START SNIPPET: description --> This interceptor ensures that the action
* will only be executed if the user has the correct role. <!--
* END SNIPPET: description -->
- *
+ *
* <p/> <u>Interceptor parameters:</u>
*
* <!-- START SNIPPET: parameters -->
@@ -48,7 +51,7 @@
* </ul>
*
* <!-- END SNIPPET: parameters -->
- *
+ *
* <!-- START SNIPPET: extending --> There are two extensions to the
* existing interceptor:
* <ul>
@@ -58,7 +61,7 @@
* request.</li>
* </ul>
* <!-- END SNIPPET: extending -->
- *
+ *
* <pre>
* <!-- START SNIPPET: example -->
* <!-- only allows the admin and member roles -->
@@ -96,7 +99,7 @@
}
return result;
}
-
+
/**
* Splits a string into a List
*/
@@ -111,7 +114,7 @@
/**
* Determines if the request should be allowed for the action
- *
+ *
* @param request The request
* @param action The action object
* @return True if allowed, false otherwise
@@ -137,7 +140,7 @@
/**
* Handles a rejection by sending a 403 HTTP error
- *
+ *
* @param invocation The invocation
* @return The result code
* @throws Exception
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.struts2.interceptor;
@@ -135,9 +138,9 @@
*/
public class ScopeInterceptor extends AbstractInterceptor implements PreResultListener {
- private static final long serialVersionUID = 9120762699600054395L;
+ private static final long serialVersionUID = 9120762699600054395L;
- private static final Log LOG = LogFactory.getLog(ScopeInterceptor.class);
+ private static final Log LOG = LogFactory.getLog(ScopeInterceptor.class);
private String[] application = null;
private String[] session = null;
@@ -149,7 +152,7 @@
/**
* Sets a list of application scoped properties
- *
+ *
* @param s A comma-delimited list
*/
public void setApplication(String s) {
@@ -160,7 +163,7 @@
/**
* Sets a list of session scoped properties
- *
+ *
* @param s A comma-delimited list
*/
public void setSession(String s) {
@@ -171,7 +174,7 @@
/**
* Sets if the session should be automatically created
- *
+ *
* @param value True if it should be created
*/
public void setAutoCreateSession(String value) {
@@ -373,14 +376,14 @@
/**
* @return The type of scope operation, "start" or "end"
- */
+ */
public String getType() {
return type;
}
/**
* Sets the type of scope operation
- *
+ *
* @param type Either "start" or "end"
*/
public void setType(String type) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.struts2.interceptor;
@@ -49,7 +52,7 @@
* <li>{@link ServletResponseAware}</li>
*
* <li>{@link ParameterAware}</li>
- *
+ *
* <li>{@link RequestAware}</li>
*
* <li>{@link SessionAware}</li>
@@ -105,8 +108,8 @@
* @see PrincipalAware
*/
public class ServletConfigInterceptor extends AbstractInterceptor implements StrutsStatics {
-
- private static final long serialVersionUID = 605261777858676638L;
+
+ private static final long serialVersionUID = 605261777858676638L;
/**
* Sets action properties based on the interfaces an action implements. Things like application properties,
@@ -132,9 +135,9 @@
if (action instanceof ParameterAware) {
((ParameterAware) action).setParameters(context.getParameters());
}
-
+
if (action instanceof RequestAware) {
- ((RequestAware) action).setRequest((Map) context.get("request"));
+ ((RequestAware) action).setRequest((Map) context.get("request"));
}
if (action instanceof SessionAware) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.interceptor;
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ServletResponseAware.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ServletResponseAware.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ServletResponseAware.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ServletResponseAware.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.interceptor;
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/SessionAware.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/SessionAware.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/SessionAware.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/SessionAware.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.interceptor;
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/StrutsConversionErrorInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/StrutsConversionErrorInterceptor.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/StrutsConversionErrorInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/StrutsConversionErrorInterceptor.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.struts2.interceptor;
@@ -67,10 +70,10 @@
* @see ConversionErrorInterceptor
*/
public class StrutsConversionErrorInterceptor extends ConversionErrorInterceptor {
-
- private static final long serialVersionUID = 2759744840082921602L;
- protected Object getOverrideExpr(ActionInvocation invocation, Object value) {
+ private static final long serialVersionUID = 2759744840082921602L;
+
+ protected Object getOverrideExpr(ActionInvocation invocation, Object value) {
ValueStack stack = invocation.getStack();
try {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.struts2.interceptor;
@@ -36,24 +39,24 @@
* invalid token is found: it returns the result <b>invalid.token</b>, which can be mapped in your action configuration.
* A more complex implementation, {@link TokenSessionStoreInterceptor}, can provide much better logic for when invalid
* tokens are found.
- *
+ *
* <p/>
*
* <b>Note:</b> To set a token in your form, you should use the <b>token tag</b>. This tag is required and must be used
* in the forms that submit to actions protected by this interceptor. Any request that does not provide a token (using
* the token tag) will be processed as a request with an invalid token.
- *
+ *
* <p/>
- *
+ *
* <b>Internationalization Note:</b> The following key could be used to internationalized the action errors generated
* by this token interceptor
- *
+ *
* <ul>
* <li>struts.messages.invalid.token</li>
* </ul>
- *
+ *
* <p/>
- *
+ *
* <b>NOTE:</b> As this method extends off MethodFilterInterceptor, it is capable of
* deciding if it is applicable only to selective methods in the action class. See
* <code>MethodFilterInterceptor</code> for more info.
@@ -88,23 +91,23 @@
*
* <pre>
* <!-- START SNIPPET: example -->
- *
+ *
* <action name="someAction" class="com.examples.SomeAction">
* <interceptor-ref name="token"/>
* <interceptor-ref name="basicStack"/>
* <result name="success">good_result.ftl</result>
* </action>
- *
- * <-- In this case, myMethod of the action class will not
+ *
+ * <-- In this case, myMethod of the action class will not
* get checked for invalidity of token -->
* <action name="someAction" class="com.examples.SomeAction">
* <interceptor-ref name="token">
- * <param name="excludeMethods">myMethod</param>
+ * <param name="excludeMethods">myMethod</param>
* </interceptor-ref name="token"/>
* <interceptor-ref name="basicStack"/>
* <result name="success">good_result.ftl</result>
* </action>
- *
+ *
* <!-- END SNIPPET: example -->
* </pre>
*
@@ -112,10 +115,10 @@
* @see TokenHelper
*/
public class TokenInterceptor extends MethodFilterInterceptor {
-
- private static final long serialVersionUID = -6680894220590585506L;
-
- public static final String INVALID_TOKEN_CODE = "invalid.token";
+
+ private static final long serialVersionUID = -6680894220590585506L;
+
+ public static final String INVALID_TOKEN_CODE = "invalid.token";
/**
* @see com.opensymphony.xwork2.interceptor.MethodFilterInterceptor#doIntercept(com.opensymphony.xwork2.ActionInvocation)
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.struts2.interceptor;
@@ -40,9 +43,9 @@
* complete, and then instead of returning the <i>invalid.token</i> code, it will attempt to display the same response
* that the original, valid action invocation would have displayed if no multiple requests were submitted in the first
* place.
- *
+ *
* <p/>
- *
+ *
* <b>NOTE:</b> As this method extends off MethodFilterInterceptor, it is capable of
* deciding if it is applicable only to selective methods in the action class. See
* <code>MethodFilterInterceptor</code> for more info.
@@ -75,14 +78,14 @@
*
* <pre>
* <!-- START SNIPPET: example -->
- *
+ *
* <action name="someAction" class="com.examples.SomeAction">
* <interceptor-ref name="token-session/>
* <interceptor-ref name="basicStack"/>
* <result name="success">good_result.ftl</result>
* </action>
- *
- * <-- In this case, myMethod of the action class will not
+ *
+ * <-- In this case, myMethod of the action class will not
* get checked for invalidity of token -->
* <action name="someAction" class="com.examples.SomeAction">
* <interceptor-ref name="token-session>
@@ -91,19 +94,19 @@
* <interceptor-ref name="basicStack"/>
* <result name="success">good_result.ftl</result>
* </action>
- *
+ *
* <!-- END SNIPPET: example -->
* </pre>
*
*/
public class TokenSessionStoreInterceptor extends TokenInterceptor {
-
- private static final long serialVersionUID = -9032347965469098195L;
- /* (non-Javadoc)
- * @see org.apache.struts2.interceptor.TokenInterceptor#handleInvalidToken(com.opensymphony.xwork2.ActionInvocation)
- */
- protected String handleInvalidToken(ActionInvocation invocation) throws Exception {
+ private static final long serialVersionUID = -9032347965469098195L;
+
+ /* (non-Javadoc)
+ * @see org.apache.struts2.interceptor.TokenInterceptor#handleInvalidToken(com.opensymphony.xwork2.ActionInvocation)
+ */
+ protected String handleInvalidToken(ActionInvocation invocation) throws Exception {
ActionContext ac = invocation.getInvocationContext();
HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.interceptor.debugging;
@@ -85,7 +88,7 @@
private final static String DEBUG_PARAM = "debug";
private final static String EXPRESSION_PARAM = "expression";
-
+
private boolean enableXmlWithConsole = false;
@@ -352,7 +355,7 @@
this.enableXmlWithConsole = enableXmlWithConsole;
}
-
-
+
+
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/PrettyPrintWriter.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/PrettyPrintWriter.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/PrettyPrintWriter.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/PrettyPrintWriter.java Mon Nov 6 07:01:43 2006
@@ -1,18 +1,22 @@
-package org.apache.struts2.interceptor.debugging;
-
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.Stack;
-
-/**
- * A simple writer that outputs XML in a pretty-printed indented stream.
+/*
+ * $Id$
*
- * <p>By default, the chars <code><xmp>& < > " ' \r</xmp></code> are escaped and replaced with a suitable XML entity.
- * To alter this behavior, override the the {@link #writeText(com.thoughtworks.xstream.core.util.QuickWriter, String)}
- * and {@link #writeAttributeValue(com.thoughtworks.xstream.core.util.QuickWriter, String)} methods.</p>
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * <p>This code was taken from the XStream project under the BSD license.</p>
+ * 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.
*/
public class PrettyPrintWriter {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/PortletActionConstants.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/PortletActionConstants.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/PortletActionConstants.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/PortletActionConstants.java Mon Nov 6 07:01:43 2006
@@ -1,44 +1,47 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.portlet;
/**
* Interface defining some constants used in the Struts portlet implementation
- *
+ *
*/
public interface PortletActionConstants {
- /**
- * Default action name to use when no default action has been configured in the portlet
- * init parameters.
- */
- String DEFAULT_ACTION_NAME = "default";
-
- /**
- * Action name parameter name
- */
- String ACTION_PARAM = "struts.portlet.action";
-
- /**
- * Key for parameter holding the last executed portlet mode.
- */
- String MODE_PARAM = "struts.portlet.mode";
-
- /**
+ /**
+ * Default action name to use when no default action has been configured in the portlet
+ * init parameters.
+ */
+ String DEFAULT_ACTION_NAME = "default";
+
+ /**
+ * Action name parameter name
+ */
+ String ACTION_PARAM = "struts.portlet.action";
+
+ /**
+ * Key for parameter holding the last executed portlet mode.
+ */
+ String MODE_PARAM = "struts.portlet.mode";
+
+ /**
* Key used for looking up and storing the portlet phase
*/
String PHASE = "struts.portlet.phase";
@@ -66,7 +69,7 @@
* {@link javax.portlet.PortletResponse}
*/
String RESPONSE = "struts.portlet.response";
-
+
/**
* Key used for looking up and storing the action that was invoked in the event phase.
*/
@@ -84,19 +87,19 @@
String ERROR_ACTION = "errorHandler";
/**
- * Key for the portlet namespace stored in the
+ * Key for the portlet namespace stored in the
* {@link org.apache.struts2.portlet.context.PortletActionContext}.
*/
String PORTLET_NAMESPACE = "struts.portlet.portletNamespace";
-
+
/**
- * Key for the mode-to-namespace map stored in the
+ * Key for the mode-to-namespace map stored in the
* {@link org.apache.struts2.portlet.context.PortletActionContext}.
*/
String MODE_NAMESPACE_MAP = "struts.portlet.modeNamespaceMap";
-
+
/**
- * Key for the default action name for the portlet, stored in the
+ * Key for the default action name for the portlet, stored in the
* {@link org.apache.struts2.portlet.context.PortletActionContext}.
*/
String DEFAULT_ACTION_FOR_MODE = "struts.portlet.defaultActionForMode";
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/PortletApplicationMap.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/PortletApplicationMap.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/PortletApplicationMap.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/PortletApplicationMap.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.portlet;
@@ -29,175 +32,175 @@
/**
* Portlet specific {@link java.util.Map} implementation representing the
* {@link javax.portlet.PortletContext} of a Portlet.
- *
+ *
*/
public class PortletApplicationMap extends AbstractMap implements Serializable {
- private static final long serialVersionUID = 2296107511063504414L;
+ private static final long serialVersionUID = 2296107511063504414L;
private PortletContext context;
- private Set<Object> entries;
+ private Set<Object> entries;
- /**
- * Creates a new map object given the {@link PortletContext}.
- *
- * @param ctx The portlet context.
- */
- public PortletApplicationMap(PortletContext ctx) {
- this.context = ctx;
- }
-
- /**
- * Removes all entries from the Map and removes all attributes from the
- * portlet context.
- */
- public void clear() {
- entries = null;
-
- Enumeration e = context.getAttributeNames();
-
- while (e.hasMoreElements()) {
- context.removeAttribute(e.nextElement().toString());
- }
- }
-
- /**
- * Creates a Set of all portlet context attributes as well as context init
- * parameters.
- *
- * @return a Set of all portlet context attributes as well as context init
- * parameters.
- */
- public Set entrySet() {
- if (entries == null) {
- entries = new HashSet<Object>();
-
- // Add portlet context attributes
- Enumeration enumeration = context.getAttributeNames();
-
- while (enumeration.hasMoreElements()) {
- final String key = enumeration.nextElement().toString();
- final Object value = context.getAttribute(key);
- entries.add(new Map.Entry() {
- public boolean equals(Object obj) {
- Map.Entry entry = (Map.Entry) obj;
-
- return ((key == null) ? (entry.getKey() == null) : key
- .equals(entry.getKey()))
- && ((value == null) ? (entry.getValue() == null)
- : value.equals(entry.getValue()));
- }
-
- public int hashCode() {
- return ((key == null) ? 0 : key.hashCode())
- ^ ((value == null) ? 0 : value.hashCode());
- }
-
- public Object getKey() {
- return key;
- }
-
- public Object getValue() {
- return value;
- }
-
- public Object setValue(Object obj) {
- context.setAttribute(key.toString(), obj);
-
- return value;
- }
- });
- }
-
- // Add portlet context init params
- enumeration = context.getInitParameterNames();
-
- while (enumeration.hasMoreElements()) {
- final String key = enumeration.nextElement().toString();
- final Object value = context.getInitParameter(key);
- entries.add(new Map.Entry() {
- public boolean equals(Object obj) {
- Map.Entry entry = (Map.Entry) obj;
-
- return ((key == null) ? (entry.getKey() == null) : key
- .equals(entry.getKey()))
- && ((value == null) ? (entry.getValue() == null)
- : value.equals(entry.getValue()));
- }
-
- public int hashCode() {
- return ((key == null) ? 0 : key.hashCode())
- ^ ((value == null) ? 0 : value.hashCode());
- }
-
- public Object getKey() {
- return key;
- }
-
- public Object getValue() {
- return value;
- }
-
- public Object setValue(Object obj) {
- context.setAttribute(key.toString(), obj);
-
- return value;
- }
- });
- }
- }
-
- return entries;
- }
-
- /**
- * Returns the portlet context attribute or init parameter based on the
- * given key. If the entry is not found, <tt>null</tt> is returned.
- *
- * @param key
- * the entry key.
- * @return the portlet context attribute or init parameter or <tt>null</tt>
- * if the entry is not found.
- */
- public Object get(Object key) {
- // Try context attributes first, then init params
- // This gives the proper shadowing effects
- String keyString = key.toString();
- Object value = context.getAttribute(keyString);
-
- return (value == null) ? context.getInitParameter(keyString) : value;
- }
-
- /**
- * Sets a portlet context attribute given a attribute name and value.
- *
- * @param key
- * the name of the attribute.
- * @param value
- * the value to set.
- * @return the attribute that was just set.
- */
- public Object put(Object key, Object value) {
- entries = null;
- context.setAttribute(key.toString(), value);
-
- return get(key);
- }
-
- /**
- * Removes the specified portlet context attribute.
- *
- * @param key
- * the attribute to remove.
- * @return the entry that was just removed.
- */
- public Object remove(Object key) {
- entries = null;
+ /**
+ * Creates a new map object given the {@link PortletContext}.
+ *
+ * @param ctx The portlet context.
+ */
+ public PortletApplicationMap(PortletContext ctx) {
+ this.context = ctx;
+ }
+
+ /**
+ * Removes all entries from the Map and removes all attributes from the
+ * portlet context.
+ */
+ public void clear() {
+ entries = null;
+
+ Enumeration e = context.getAttributeNames();
+
+ while (e.hasMoreElements()) {
+ context.removeAttribute(e.nextElement().toString());
+ }
+ }
+
+ /**
+ * Creates a Set of all portlet context attributes as well as context init
+ * parameters.
+ *
+ * @return a Set of all portlet context attributes as well as context init
+ * parameters.
+ */
+ public Set entrySet() {
+ if (entries == null) {
+ entries = new HashSet<Object>();
+
+ // Add portlet context attributes
+ Enumeration enumeration = context.getAttributeNames();
+
+ while (enumeration.hasMoreElements()) {
+ final String key = enumeration.nextElement().toString();
+ final Object value = context.getAttribute(key);
+ entries.add(new Map.Entry() {
+ public boolean equals(Object obj) {
+ Map.Entry entry = (Map.Entry) obj;
+
+ return ((key == null) ? (entry.getKey() == null) : key
+ .equals(entry.getKey()))
+ && ((value == null) ? (entry.getValue() == null)
+ : value.equals(entry.getValue()));
+ }
+
+ public int hashCode() {
+ return ((key == null) ? 0 : key.hashCode())
+ ^ ((value == null) ? 0 : value.hashCode());
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public Object setValue(Object obj) {
+ context.setAttribute(key.toString(), obj);
+
+ return value;
+ }
+ });
+ }
+
+ // Add portlet context init params
+ enumeration = context.getInitParameterNames();
+
+ while (enumeration.hasMoreElements()) {
+ final String key = enumeration.nextElement().toString();
+ final Object value = context.getInitParameter(key);
+ entries.add(new Map.Entry() {
+ public boolean equals(Object obj) {
+ Map.Entry entry = (Map.Entry) obj;
+
+ return ((key == null) ? (entry.getKey() == null) : key
+ .equals(entry.getKey()))
+ && ((value == null) ? (entry.getValue() == null)
+ : value.equals(entry.getValue()));
+ }
+
+ public int hashCode() {
+ return ((key == null) ? 0 : key.hashCode())
+ ^ ((value == null) ? 0 : value.hashCode());
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public Object setValue(Object obj) {
+ context.setAttribute(key.toString(), obj);
+
+ return value;
+ }
+ });
+ }
+ }
+
+ return entries;
+ }
+
+ /**
+ * Returns the portlet context attribute or init parameter based on the
+ * given key. If the entry is not found, <tt>null</tt> is returned.
+ *
+ * @param key
+ * the entry key.
+ * @return the portlet context attribute or init parameter or <tt>null</tt>
+ * if the entry is not found.
+ */
+ public Object get(Object key) {
+ // Try context attributes first, then init params
+ // This gives the proper shadowing effects
+ String keyString = key.toString();
+ Object value = context.getAttribute(keyString);
+
+ return (value == null) ? context.getInitParameter(keyString) : value;
+ }
+
+ /**
+ * Sets a portlet context attribute given a attribute name and value.
+ *
+ * @param key
+ * the name of the attribute.
+ * @param value
+ * the value to set.
+ * @return the attribute that was just set.
+ */
+ public Object put(Object key, Object value) {
+ entries = null;
+ context.setAttribute(key.toString(), value);
+
+ return get(key);
+ }
+
+ /**
+ * Removes the specified portlet context attribute.
+ *
+ * @param key
+ * the attribute to remove.
+ * @return the entry that was just removed.
+ */
+ public Object remove(Object key) {
+ entries = null;
- Object value = get(key);
- context.removeAttribute(key.toString());
+ Object value = get(key);
+ context.removeAttribute(key.toString());
- return value;
- }
+ return value;
+ }
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/PortletRequestMap.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/PortletRequestMap.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/PortletRequestMap.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/PortletRequestMap.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
- * 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
*
- * 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.
+ * 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.struts2.portlet;
@@ -30,12 +33,12 @@
/**
* A simple implementation of the {@link java.util.Map} interface to handle a collection of request attributes.
- *
+ *
*/
public class PortletRequestMap extends AbstractMap {
private static final Log LOG = LogFactory.getLog(PortletRequestMap.class);
-
+
private Set<Object> entries = null;
private PortletRequest request = null;
@@ -73,7 +76,7 @@
/**
* Returns a Set of attributes from the portlet request.
- *
+ *
* @return a Set of attributes from the portlet request.
*/
public Set entrySet() {
@@ -123,7 +126,7 @@
/**
* Returns the request attribute associated with the given key or
* <tt>null</tt> if it doesn't exist.
- *
+ *
* @param key the name of the request attribute.
* @return the request attribute or <tt>null</tt> if it doesn't exist.
*/
@@ -133,7 +136,7 @@
/**
* Saves an attribute in the request.
- *
+ *
* @param key the name of the request attribute.
* @param value the value to set.
* @return the object that was just set.
@@ -147,7 +150,7 @@
/**
* Removes the specified request attribute.
- *
+ *
* @param key the name of the attribute to remove.
* @return the value that was removed or <tt>null</tt> if the value was
* not found (and hence, not removed).