Compare commits

..

149 Commits

Author SHA1 Message Date
Lukasz Lenart a6edb0d5df [maven-release-plugin] prepare release STRUTS_2_5_22 2019-11-17 20:17:20 +01:00
JCgH4164838Gh792C124B5 3dfc5a4074 Disable expressionMaxLength by default for Struts 2.5.x. (#380)
* Disable struts.ognl.expressionMaxLength by default for Struts 2.5.x.
- Commented out struts.ognl.expressionMaxLength line in default.properties
and provided in-place comments about its usage.
- Changed OgnlValueStack.handleOgnlException() methods to output error
instead of warn for failures to evaluate expressions due to security
constraints.
- Updated existing unit tests to compensate for change in default
behaviour.
- Added a unit test to confirm default behaviour for
struts.ognl.expressionMaxLength is disabled.

* Updated commit for disable struts.ognl.expressionMaxLength by default for
Struts 2.5.x
- Additional unit test requested by Y. Zamani for code coverage.
- Corrected accidental use of wrong (static) toString method in one test.
- Addition of a minimum struts.ognl.expressionMaxLength value permitted
by Struts 2 (128).  Any value smaller than that is likely to be a
configuration error and if a user really wishes to force it they may go to
OGNL directly to do so.

* Updated commit for disable struts.ognl.expressionMaxLength by default for
Struts 2.5.x
- Removed minimum struts.ognl.expressionMaxLength (restored to previous
behaviour) as requested by Y. Zamani and L. Lenart.
- Updated unit tests to compensate for the above change.
- Changed log output from warn to error in applyExpressionMaxLength() on
exception since it will likely be considered a fatal condition.
2019-11-16 20:09:19 +03:30
Lukasz Lenart fdfeb3233a Uses the latest struts-master 2019-11-07 20:41:58 +01:00
Lukasz Lenart ae3ae2be76 [maven-release-plugin] prepare for next development iteration 2019-11-07 20:18:06 +01:00
Lukasz Lenart 8dface4fcb [maven-release-plugin] prepare release STRUTS_2_5_21 2019-11-07 20:17:01 +01:00
Lukasz Lenart 1348971d40 Merge pull request #378 from JCgH4164838Gh792C124B5/local_25x_CfgChg1
Minor follow-up changes to PR #371
2019-11-04 08:32:03 +01:00
JCgH4164838Gh792C124B5 dd6d206d78 Additional change
- added unit test (hoping to make coveralls happy).
2019-11-02 14:11:21 -04:00
JCgH4164838Gh792C124B5 e2b644a4fb Minor follow-up changes to PR #371
- added some additional exclusions in struts-default.xml.
- added log warning that specifies the value of maxLength involved if
  applyExpressionMaxLength(maxLength) fails.
- added null guards to two handleOgnlException() methods that could
  result in an NPE with #371 changes (a null OgnlException parameter
  was permissible previously, correct or not).
2019-11-02 13:31:09 -04:00
Lukasz Lenart 13cfba86f8 Merge pull request #371 from yasserzamani/WW-5041
WW-5041 Upgrade to OGNL 3.1.26 and adapt to its new features
2019-10-30 08:18:01 +01:00
Lukasz Lenart d84d59f53c Merge branch 'struts-2-5-x' into WW-5041 2019-10-30 07:50:01 +01:00
Lukasz Lenart 3651f55869 Merge pull request #376 from sepe81/update-jackson-to-210
WW-5042 Upgrade jackson-databind to version 2.10.0
2019-10-16 13:39:13 +02:00
Sebastian Peters 7ffa750c68 WW-5042 Upgrade jackson-databind to version 2.10.0
(cherry picked from commit 4556f404bd)
2019-10-15 18:40:33 +02:00
Lukasz Lenart 313876aa3c Merge pull request #372 from JCgH4164838Gh792C124B5/local_25x_LibUpd4
Update multiple Struts 2.5.x libraries to more recent versions.
2019-10-09 07:24:42 +02:00
JCgH4164838Gh792C124B5 9d7a9f81db Remove jackson-databind 2.9.9.x comment from pom.xml as requested by
S. Peters and L. Lenart.
2019-10-08 21:01:14 -04:00
JCgH4164838Gh792C124B5 fe98223724 Update multiple Struts 2.5.x libraries to more recent versions.
Relates to WW-5033 and PRs: #356, #362.  Updated libraries:

Spring Platform 4.3.24 -> 4.3.25
Log4j2 2.11.2 -> 2.12.1
Jackson 2.9.9 -> 2.9.10 (allows removal of jackson 2.9.9.3 "micro patch"
entry, taking care of pom.xml FIXME).
stax2-api 4.1 -> 4.2 (noted during Jackson update)
Fluido Skin 1.7 -> 1.8
SLF4J 1.7.26 -> 1.7.28
2019-10-06 18:29:57 -04:00
Yasser Zamani 1de94b2092 WW-5041 Upgrade to OGNL 3.1.26 and adapt to its new features 2019-10-01 14:57:46 +03:30
Lukasz Lenart 706bb560e4 Merge pull request #367 from JCgH4164838Gh792C124B5/local_25x_SendRedirectEnh
Minor improvement proposed for ServletRedirectResult sendRedirect()
2019-09-23 08:54:14 +02:00
Lukasz Lenart 12d4feaf8f Merge pull request #366 from JCgH4164838Gh792C124B5/local_25x_SendErrorEnh
Improved logging for DefaultDispatcherErrorHandler, DefaultStaticContentLoader
2019-09-23 08:54:02 +02:00
JCgH4164838Gh792C124B5 d88a8382d4 Changed the styling of log outputs (as suggested by A. Mashchenko and
L. Lenart).
Added comment to explain why the log output avoids a stacktrace (due to
exceptions being re-thrown).
Updated existing ServletRedirectResultTest to supply tests that exercise
the new code paths and demonstrate expected logging.
2019-09-22 21:45:44 -04:00
JCgH4164838Gh792C124B5 73809eae54 Changed the styling of log outputs (as suggested by A. Mashchenko).
Changed the log outputs to output full stacktraces (as suggested by
A. Mashchenko and L. Lenart).
Updated existing DefaultStaticContentLoaderTest and created a new
DefaultDispatcherErrorHandlerTest to supply tests that exercise the new
code paths and demonstrate expected logging.
2019-09-21 23:29:24 -04:00
JCgH4164838Gh792C124B5 5b4b554d11 Minor improvement proposed for ServletRedirectResult sendRedirect()
Supply log warning when an IOException or IllegalStateException occurs to
better allow developers to track the failed redirect location and status
details.  The exceptions are re-thrown to ensure existing flow-control
behaviour is preserved.

When getWriter() is called, utilize a finally block to ensure close is
called.
2019-09-17 22:22:41 -04:00
JCgH4164838Gh792C124B5 fcbd29b7f9 Changed the log outputs in this PR to utilize log4j2 {} notation (as per
suggestion by A. Mashchenko and L. Lenart)
Changed the log outputs in this PR from info level to warn level (as per
 suggestion by L. Lenart).
Note: The info level was originally chosen to make it easier to filter out
in the very unlikely case of log flood.
2019-09-17 21:10:34 -04:00
JCgH4164838Gh792C124B5 220896a0cf Improved logging for DefaultDispatcherErrorHandler and
DefaultStaticContentLoader.

Provide informational logging for the processing of the two dispatcher
classes when an http sendError fails for the two known failure types
(IOException, IllegalStateException).

In both circumstances it is beneficial to have the developer aware of the
failures via the logs.  These are not events that should be happening on a
regular basis, so there is little risk of a log flood.

DefaultStaticContentLoader didn't catch either exception type previously,
so changing it to make handling the same as DefaultDispatcherErrorHandler.

For DefaultDispatcherErrorHandler the IOException was caught with no
notice of failure previously.  Now there will be an info level log output.
Previously the IllegalStateException was not caught, which resulted in the
unrecoverable exception being thrown up to the calling thread, usually
resulting in an ugly stacktrace to stdout/stderr.  Now there will be an
info level log output instead.

If devMode is true, the info log outputs will include the exception
parameter to the log, so a stacktrace can be viewed for more details.  If
devMode is false (production mode), then only the exception's tostring()
output will be produced.
2019-09-15 20:48:15 -04:00
Lukasz Lenart 632f19eab3 WW-5038 Upgrades jackson-databind to version 2.9.9.3
plus upgrades jackson-core to 2.9.9

(cherry picked from commit 8187006)
2019-09-07 16:39:12 +04:30
Sebastian Haas 50a145152d Fix typo in MultiselectInterceptor javadoc
(cherry picked from commit dca0dd2)
2019-09-07 15:31:38 +04:30
JCgH4164838Gh792C124B5 f7b191f782 WW-5033 - Update to latest versions for some Struts 2.5.x dependencies: (#362)
* WW-5033 - Update to latests versions for some Struts 2.5.x dependencies:
- ASM 7 -> 7.1
- Spring 4.3.20.RELEASE -> 4.3.24.RELEASE

* fix Travis build
2019-09-07 14:33:34 +04:30
Yasser Zamani 4ae1a6a26d Merge pull request #361 from JCgH4164838Gh792C124B5/localS2_25x_OgnlCachecontrol
Proposed WW-5035 enhancement:
2019-09-07 14:32:03 +04:30
Lukasz Lenart 79e598f360 WW-5037 Upgrades commons-beanutils to version 1.9.4 2019-09-02 12:20:23 +02:00
JCgH4164838Gh792C124B5 9216e8e22c Proposed WW-5035 enhancement:
- Provide cache clearing methods for OgnlUtil (expression cache, BeanInfo
cache).
- Provide methods to check the cache sizes (entry number for expression
cache, BeanInfo cache).
- Provide static method to clear the OgnlRuntime cache (convenience
method).
2019-06-15 11:44:28 -04:00
Lukasz Lenart 651eac2c57 Merge pull request #358 from yasserzamani/WW-4999
fix logMissingProperties (WW-4999)
2019-06-03 08:25:32 +02:00
Yasser Zamani a50af87644 test false for logMissingProperties (WW-4999) 2019-06-02 17:22:28 +04:30
Yasser Zamani 9e01fbd2dd decouple logMissingProperties from devMode (WW-4999) 2019-06-01 12:52:22 +04:30
Yasser Zamani d4dd3386cc test not throw exception on top missing property (WW-4999)
instead continue to next objects in stack

Also tests not skip returned null values by user method
2019-06-01 09:37:19 +04:30
Yasser Zamani 0999fba8c4 not log user exceptions as missing properties (WW-4999)
Also reaks loop on user method exceptions - but continue to next objects in stack on NoSuchMethodException.
2019-05-31 17:57:25 +04:30
Yasser Zamani 3ac6835c5c fix logMissingProperties (WW-4999)
Moves checking OgnlValueStack.THROW_EXCEPTION_ON_FAILURE outside loop because it shouldn't throw exception on first failure while is trying all root objects.

Returns on first successful call because it's not rational and is confusing user to skip when user method successfully returns null as an actual result.

Fixes WW-4999 via honoring (devMode && logMissingProperties) for OgnlValueStack.THROW_EXCEPTION_ON_FAILURE and REPORT_ERRORS_ON_NO_PROP.
2019-05-30 16:36:54 +04:30
Yasser Zamani b0dd7c1c0d include ref in path as WW-5011 workaround (#353)
* include ref in path for StrutsApplicationResource as WW-5011 workaround

* add license to newly added xml files in previous commit

* WW-5011 include ref in path via .toURI().getPath()

* WW-5011 check protocol and not throw exception due to lazy file existence

* decrease log file size to pass travis build
2019-05-28 09:53:27 +04:30
Lukasz Lenart a63beef1f8 Merge pull request #355 from JCgH4164838Gh792C124B5/localS2_25x_TextProviderFix
Minor enhancement/fix to AbstractLocalizedTextProvider:
2019-05-27 09:45:50 +02:00
Aleksandr Mashchenko e74e5539dd Merge pull request #356 from JCgH4164838Gh792C124B5/local_25x_LibUpd3
Update Three Struts 2.5.x dependencies to latest versions
2019-05-26 20:16:49 +03:00
JCgH4164838Gh792C124B5 2226fcc168 Update Three Struts 2.5.x dependencies to latest versions:
- Jackson 2.9.8 -> 2.9.9
- Log4j2 2.11.1 -> 2.11.2
- OGNL 3.1.22 -> 3.1.23
Struts 2.5.21-SNAPSHOT builds successfully with these versions.
2019-05-25 17:09:33 -04:00
JCgH4164838Gh792C124B5 865b8a20df Update PR with unit test:
- Add a unit test to include test coverage and confirm no failures
in the new methods.
2019-05-11 16:28:34 -04:00
JCgH4164838Gh792C124B5 3c6956116e Minor enhancement/fix to AbstractLocalizedTextProvider:
- Made "constant" RELOADED static to save an initialization every time.
- Updated clearBundle(final String bundleName) method comment as it
  seemed inaccurate, added debug log output when called.
- Introduced protected clearBundle(final String bundleName, Locale locale)
  method for use by descendants, with debug log output when called.
- Introduced protected clearMissingBundlesCache() method for use by
  descendants, with debug log when called.
2019-05-11 13:19:35 -04:00
Lukasz Lenart bb9ce7582b Merge pull request #354 from JCgH4164838Gh792C124B5/localS2_25x_B10
Minor consistency update correction for WW-5029 fix to the 2.5.x branch
2019-04-29 07:42:13 +02:00
JCgH4164838Gh792C124B5 11d373f8b4 Minor consistency update correction for WW-5029 fix to the 2.5.x branch:
- Correct missing verification in buildAllowedMethods()/loadGlobalAllowedMethods() that the nodes are
  of type Node.TEXT_NODE (as buildResults() does).
- Made two class fields final, as suggested by IDE.
2019-04-27 12:35:40 -04:00
Lukasz Lenart b23bfd42d2 Merge pull request #350 from yasserzamani/WW-4958
fix multipart request RegEx (relates to WW-4958)
2019-04-23 08:25:40 +02:00
Yasser Zamani f94b681050 fix multipart request RegEx
Note: Unlike some similar constructs in other header fields, media
type parameters do not allow whitespace (even "bad" whitespace)
around the "=" character.

Reference: https://tools.ietf.org/html/rfc7231#section-3.1.1.1
See also: WW-4958
2019-04-23 09:32:43 +04:30
JCgH4164838Gh792C124B5 fb38a919c9 Proposed fix for WW-5029 for the 2.5.x branch (#347)
* Proposed fix for WW-5029 for the 2.5.x branch:
- NOTE: If the PR is accepted please credit Maxime Clement for this change as they found
        the issue, identified the probable cause/related details and opened the JIRA.
- Updated XWorkConfigurationProvider buildAllowedMethods(), loadGlobalAllowedMethods() so that
  they now handle situations when a SAX parser produces multiple elements to represent the tag
  body value.
- No changes to unit tests.

* Update commit to fix weakness identified by Maxime Clement:
- Implementation should now properly concatenate the node children values together (as a single unified string)
  in both buildAllowedMethods(), loadGlobalAllowedMethods() - before generating the method Set to be added.
- Made some eligible variables final.

* Update commit to provide new unit tests:
- Added unit tests to confirm the fixes for buildAllowedMethods(), loadGlobalAllowedMethods()
- Added Mock DOM classes sufficient for these tests.
- Added unit tests to cover buildResults() and loadGlobalResults().
2019-04-20 09:54:36 +04:30
Yasser Zamani e25c826167 Merge pull request #349 from JCgH4164838Gh792C124B5/localS2_25x_B9
Proposed fix for WW-5028 for the 2.5.x branch:
2019-04-20 08:58:07 +04:30
JCgH4164838Gh792C124B5 4815744eaf (Amended commit based on feedback)
Proposed fix for WW-5028 for the 2.5.x branch:
- Disable printing stacktrace on exceptions by the Dispatcher by default.
- Printing stacktrace on exception is only enabled with devMode set to true, as suggested by L. Lenart.
- Now prints stacktrace on exception using LOG, as suggested by A. Mashchenko and the the JIRA reporter.
  Log level set to debug as recommended by Y. Zamani.
- Added two additional unit tests for Dispatcher devMode and handleException states.
2019-04-16 22:26:46 -04:00
Yasser Zamani f5a7776854 Merge pull request #344 from lukaszlenart/WW-4958
[WW-4958] Uses less restrictive RegEx to check if it's a multipart request
2019-04-14 14:06:35 +04:30
Lukasz Lenart f45d2752bb WW-4958 Uses less restrictive Regex to check if it's a multipart request 2019-03-30 09:23:50 +01:00
JCgH4164838Gh792C124B5 0262574095 Proposed fix for WW-5024 in the 2.5.x branch: (#343)
- NOTE: If the PR is accepted please credit Robert Hollencamp (Github @rhollencamp) for this change
        as he found the issue, proposed a solution for 2.6 (master), and opened the JIRA.
- Updated HttpParameters, ActionMappingParametersInterceptor to prevent multi-level Parameter wrapping from occuring.
- Added a new ActionMappingParametersInterceptorTest to verify the fix.
2019-03-29 07:20:56 +01:00
Aleksandr Mashchenko 30cb56a414 Merge pull request #342 from JCgH4164838Gh792C124B5/localS2_25x_B5
WW-5026 TokenSessionStoreInterceptor double-submit failure
2019-03-26 22:55:42 +02:00
JCgH4164838Gh792C124B5 63dc85fd7a Updated commit with changes suggested by reviewers:
- Replace TokenSessionStoreInterceptor inline comment previously added with method comment blocks (better locatioh for explanation)
- Eliminate duplicate savedActionContext.setValueStack call in InvocationSessionStore (typo)
- Improve InvocationSessionStore.loadInvocation() by reording assignment statements to allow single-line assignments
2019-03-25 23:36:07 -04:00
JCgH4164838Gh792C124B5 5b0ec3400d Fix issue introduced with earlier WW-4873 fix:
- Fixes error 500 processing failures for double-submit results with TokenSessionStoreInterceptor processing
- Fix to InvocationSessionStore, new unit test confirming fix in InvocationSessionStoreTest
- Minor whitespace fix to TokenSessionStoreInterceptor
2019-03-25 01:00:10 -04:00
Yasser Zamani d460d71498 Merge pull request #341 from JCgH4164838Gh792C124B5/localS2_25x_Testfix
Backport OgnlValueStackTest test fix and unit test additions from master
2019-03-18 09:55:17 +03:30
JCgH4164838Gh792C124B5 53f64cdecf Backport applicable OgnlValueStackTest test fix and unit test additions from 2.6:
- This backport resulted from a review inspired/suggested by Y. Zamani in discussions for PR#334.
- Backports fix of error in testNullMethod().
- Backports applicable static access tests (static method access only), cleanup of unused imports.
- As with 2.6, it uses Y. Zamani's improved/enhanced reload mechanism.
2019-03-16 17:50:18 -04:00
Lukasz Lenart aff4d46835 Merge pull request #336 from JCgH4164838Gh792C124B5/local_25x_LibUpd2
Upgrade SLF4J to 1.7.26 (WW-5023)
2019-02-25 08:40:42 +01:00
Yasser Zamani a15c12a051 add properties support to XWorkTestCase.loadButAdd
also includes cleanups for PRs #292 and #320
2019-02-24 17:53:45 +03:30
JCgH4164838Gh792C124B5 e62155c460 Upgrade SLF4J to 1.7.26 (WW-5023) 2019-02-21 12:25:23 -05:00
Lukasz Lenart f7f4fbd47f Merge pull request #333 from JCgH4164838Gh792C124B5/localS2_25x_Appfix
Minor config fixes for the Showcase Application in 2.5.x:
2019-02-12 09:33:18 +01:00
JCgH4164838Gh792C124B5 2d81439553 Minor config fixes for the Showcase Application in 2.5.x:
1) Token examples. Examples 2 and 3 previously resulted in 403's upon submit (config issue).
2) Token examples. Example 4 resulted in error 500 when selected from the menu (FTL param type issue).
3) Validation examples.  Examples quizBasic, quizClient and quizClientCss resulted in 404's when selected from menu (config issue).
4) File upload examples.  Multiple file upload missing result page (list and array), added missing JSP.  Added missing input results in configuration.
5) Add manual test for public constant access via expression (to If tag JSP).
Similar to PR#255 for 2.6.x.
2019-02-11 19:37:11 -05:00
Lukasz Lenart 7afe35cb96 Adds a Jenkinsfile to allow build this branch as well 2019-02-11 09:32:49 +01:00
Yasser Zamani fdd1054070 Merge pull request #328 from aleksandr-m/feature/WW-5009
WW-5009 EmptyStackException in JSON plugin due to concurrency
2019-02-05 14:37:57 +03:30
Aleksandr Mashchenko 32e88d1a2e Merge pull request #322 from aleksandr-m/feature/WW-4991
WW-4991 Not existing property in listValueKey throws exception
2019-02-04 21:52:26 +02:00
Lukasz Lenart 6403de4516 Merge pull request #315 from yasserzamani/WW-5005
WW-5005 upgrade to ASM 7
2019-02-04 10:57:33 +01:00
Yasser Zamani 13c517fc3c Merge branch 'struts-2-5-x' into WW-5005 2019-02-04 12:47:23 +03:30
Aleksandr Mashchenko 7242a87165 WW-5009 Fix tests 2019-02-03 12:58:43 +02:00
Aleksandr Mashchenko 0323795d67 WW-5009 EmptyStackException in JSON plugin due to concurrency 2019-02-03 12:41:18 +02:00
Aleksandr Mashchenko 71267a9b4b Revert some changes to be more consistent with 2.6 version 2019-01-31 17:32:36 +02:00
JCgH4164838Gh792C124B5 5524c579d2 Fix for NPE issue discovered in WW-5004. (#316)
* Fix for NPE issue discovered in WW-5004.
- Guard fix for a NPE that can arise under certain conditions, identified by A. Mashchenko.

* Fix for NPE issue discovered in WW-5004 (amended commit).
- Guard fix for a NPE that can arise under certain conditions, identified by A. Mashchenko.
- Requires the following elements to implement a fuller fix:
  - Back-port relevant guard logic in ProxyUtil from master into 2.5.x to deal with the NPE.
  - Update SecurityMemberAccess to block access to static fields.
  - Upgrade to OGNL 3.1.22 (re-enables access to public static fields w/out access checks).
  - Add unit test to confirm proper functionality of the fix.
  - Correct missing entry in 4 test configuration XML files (needed for new unit test).
- Replaced literal injection parameter name for setStaticFieldAccessLevel in OgnlValueStackFactory with the appropriate constant.
  Note: Even though a constant was defined in StrutsConstants, the value for the injection name in all places is the XWorkConstants.
        It has to remain the same to avoid breaking anything.
2019-01-31 18:01:41 +03:30
Aleksandr Mashchenko 873ca8fa20 WW-4991 Not existing property in listValueKey throws exception 2019-01-30 23:10:06 +02:00
Yasser Zamani 8988d57644 Merge pull request #318 from lukaszlenart/WW-5007-jackson-ugrade-s25
[WW-5007] Upgrades Jackson libraries to version 2.9.8
2019-01-25 15:23:18 +03:30
Lukasz Lenart 2e7cf63964 WW-5007 Upgrades Jackson libraries to version 2.9.8 2019-01-25 12:29:48 +01:00
Yasser Zamani 3eb68be674 upgrade to ASM 7
fixes WW-5005
2019-01-23 16:24:40 +03:30
Yasser Zamani c9f279ec2e Merge pull request #314 from JCgH4164838Gh792C124B5/localS2_25x_B2
Minor cleanup/consistency changes for 3 modules.
2019-01-23 11:51:58 +03:30
JCgH4164838Gh792C124B5 881e1b2580 Minor cleanup/consistency changes for 3 modules.
- Made a private ConcurrentMap reference final, made initial sets immutable (consistency).
- Made sets for Accepted and Excluded patterns checkers immutable in 2 modules (consistency).
- Added @Override annotations missing from a few methods in 2 modules.
- Updated the 3 relevant unit tests to verify immutable states of various sets.
2019-01-18 00:09:29 -05:00
Lukasz Lenart cb0ac7c440 [maven-release-plugin] prepare for next development iteration 2019-01-09 09:00:04 +01:00
Lukasz Lenart 96c38b27e4 [maven-release-plugin] prepare release STRUTS_2_5_20 2019-01-09 08:59:40 +01:00
Lukasz Lenart e9108f0feb Merge pull request #310 from aleksandr-m/feature/WW-4998_i18ninterceptor
WW-4998 I18nInterceptor's default storage should store locale
2019-01-09 08:45:23 +01:00
Lukasz Lenart 3653f6e9e1 Merge pull request #309 from JCgH4164838Gh792C124B5/localS2_25x_B1
Address devMode log flooding concern raised by Greg Huber (on Dev List)
2019-01-09 08:43:49 +01:00
JCgH4164838Gh792C124B5 5a2323a19f Update after comments by Y. Zamani and L. Lenart
- Reverted the 6 modified files back to 2.5.19 baseline.
- Removed most of the logging added in PR#291.
- Left the added logging for the setExcludedPatterns and setAcceptedPatterns methods in their respective modules.
  L. Lenart's comment indicated their benefit outweighs overhead (not something that changes often).
  Made the if-else blocks consistent with preferred styling for the log blocks.
- Removed a dangling "/**" start comment tag with no proper close (and the whitespace between it and the next "/**"
  in the OgnlValueStack module.
(Note: Amended previous commit)
2019-01-07 23:29:32 -05:00
Aleksandr Mashchenko ea09a8828b WW-4998 I18nInterceptor's default storage should store locale 2019-01-07 17:29:46 +02:00
JCgH4164838Gh792C124B5 17fe42c0f7 Update revision after comments by A. Mashchenko and S. Peters.
- Change to produce only one warn before switching to trace mode.
- Moved literal string to constant DEVMODE_WARN_STR to avoid duplication.
- Replaced two duplicate strings in logLookupFailure() with EXCEPTION_EVALUATING_EXPRESSION_STR to avoid duplication.
2019-01-05 15:34:38 -05:00
JCgH4164838Gh792C124B5 87fa5bddf2 Address dev<Mode log flooding concern raised by Greg Huber
in the Struts Dev List review of 2.5.19.
- Introduce a static count-limiter for the devMode set warning in
OgnlValueStack.  Limit warnings to 250 total, after which it switches
to trace level logs to avoid log flooding.
2019-01-04 16:31:06 -05:00
Lukasz Lenart 45161e88f9 [maven-release-plugin] prepare for next development iteration 2018-12-30 15:24:15 +01:00
Lukasz Lenart 4456620b51 [maven-release-plugin] prepare release STRUTS_2_5_19 2018-12-30 15:23:53 +01:00
Yasser Zamani f4a8f42ca4 Merge pull request #304 from lukaszlenart/WW-4975-struts25x
[WW-4975] Upgrades commons-fileupload to version 1.4 - Struts 2.5.x
2018-12-29 20:20:12 +03:30
Lukasz Lenart a6f8895c90 WW-4975 Upgrades commons-fileupload to version 1.4 2018-12-29 17:11:45 +01:00
Aleksandr Mashchenko 46dbdbe018 Add generated tag html 2018-12-21 21:30:31 +02:00
JCgH4164838Gh792C124B5 6f176cc5a7 Enhancement for s:set tag for 2.5.x to allow better tag body whitespace control. (#296)
WW-4995 Add trimBody attribute to set tag
2018-12-20 17:59:30 +02:00
JCgH4164838Gh792C124B5 db085dbeef Updates and cleanup for some configuration-related items (2.5.x). (#291)
* Updates and cleanup for some configuration-related items.
- Made several attributes final.
- Added limiter logic to the setting of certain configuration elements, and increased logging around them.
- Updated unit tests impacted by the limiter logic, including minor typo fixes and locale consistency.
- Minor cleanup while making the changes.

* Update core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStackFactory.java

Whitespace cleanup

Co-Authored-By: JCgH4164838Gh792C124B5 <43964333+JCgH4164838Gh792C124B5@users.noreply.github.com>

* Updates and cleanup for some configuration-related items (1st revision).
- Reworked this PR, taking into account feedback and suggestions.
- Removed the if LOG.isxxxEnabled level checks that were added.
- Removed the limiter logic and instead reduced access level of most of the injectable methods to protected.
- Updated the previous unit test changes following removal of limiter logic.

* Minor correction to two debug log statements (as requested by reviewer).

* Update debug messages for pattern checkers, as requested by reviewers.
Avoids confusing users when replacing an empty exclusion set (which improves safety).
Still provides a (slightly milder) message when replacing an empty accepted set (which can reduce safety).
2018-12-20 15:25:34 +03:30
Lukasz Lenart c3205888b4 Merge pull request #293 from JCgH4164838Gh792C124B5/local_25x_LibUpd
Update Struts 2.5.19 to use latest OGNL 3.1.x release available.
2018-12-17 15:42:52 +01:00
JCgH4164838Gh792C124B5 ce9789c4c9 Update Struts 2.5.19 to use latest OGNL 3.1.x release available. 2018-12-13 23:52:29 -05:00
Aleksandr Mashchenko b431755332 Improve optgroup list attributes test
(cherry picked from commit 48d40ae6ac)
2018-12-13 22:42:53 +02:00
Aleksandr Mashchenko c694c6fdfb Improve optgroup template
(cherry picked from commit 60dfc4d141)
2018-12-13 22:42:52 +02:00
Aleksandr Mashchenko 1d49a06272 Add listTitle to optgroup tag
(cherry picked from commit 123a0906ce)
2018-12-13 22:42:52 +02:00
Aleksandr Mashchenko 264e03b7ed Add listCssStyle to optgroup tag
(cherry picked from commit 3c24bae87f)
2018-12-13 22:42:51 +02:00
Aleksandr Mashchenko 2f99110189 WW-4987 Add test for listCssClass in optgroup tag
(cherry picked from commit 94210a02e7)
2018-12-13 22:42:51 +02:00
Aleksandr Mashchenko d33930f3bd WW-4987 Add listCssClass to optgroup tag 2018-12-13 22:42:11 +02:00
Sebastian Peters 360927931c Enhance after_success for Travis CI
Use default bash if-then-else block with semicolon after each command
and fix spelling for "incompatibility".

Don't do `mvn clean` b/c we need the test results for the following
tasks and don't need to rebuild everything.

(cherry picked from commit 352f509)
2018-11-22 14:26:21 +03:30
Lukasz Lenart bff033e6a3 Merge pull request #281 from JCgH4164838Gh792C124B5/localS2_2_5_x_Branch
Minor update to Struts 2.5.x SecurityMemberAccess.
2018-11-22 08:31:34 +01:00
JCgH4164838Gh792C124B5 536d2db4b8 Minor update to Struts 2.5.x SecurityMemberAccess.
Code changes:
- updated SecurityMemberAccess for compatibility with future OGNL 3.1.19+ versions
- updated SecurityMemberAccess constructor (minor cleanup and added comment)
2018-11-21 23:45:13 -05:00
Yasser Zamani 32c8f6f811 [WW-4981] Adds support for JDK11 (#270) 2018-11-19 14:27:21 +03:30
Yasser Zamani 06e5dfc2ab delete not-supported picked from master system property test 2018-11-18 16:30:54 +03:30
Sebastian Peters fe630db5f2 Refactor environment dependant tests
* use org.apache.commons.lang3.SystemUtils for env detection
* use assertThat for more concise assertions
* move setup code to setUp
* some formatting

(cherry picked from commit 8d341df)
2018-11-18 16:01:44 +03:30
Lukasz Lenart b75c0ba5e1 WW-4866 Includes 9+ JDKs
(cherry picked from commit af3ee07)
2018-11-18 15:57:03 +03:30
Lukasz Lenart 8ab102209f WW-4866 Includes 1.8+ JDKs
(cherry picked from commit 2d86cc6)
2018-11-18 15:56:54 +03:30
ORDTesters d7a7c909ea [WW-4977] Fixing flaky test in Jsr168DispatcherTest and Jsr286DispatcherTest.
(cherry picked from commit 2d4e26f)
2018-11-18 15:39:41 +03:30
Yasser Zamani 24e151143e Merge pull request #271 from JCgH4164838Gh792C124B5/localS2_2_5_x_Branch
Back-port enhancement/fix to 2.5.19 unit tests (permits build on Windows)
2018-11-18 12:55:48 +03:30
JCgH4164838Gh792C124B5 c5272d2a0d Backport enhancement/fix from 2.6 to 2.5.19 unit tests to allow Struts 2.5.x build to complete sucessfully on Windows.
- Involves changes to: EnvsValueSubstitutorTest, XmlConfigurationProviderEnvsSubstitutionTest, xwork-test-envs-substitution.xml.
- Note: 2.5.x EnvValueSubstitutor doesn't support system properties (only env properties) so some tests were not backported.
2018-11-17 13:21:20 -05:00
Yasser Zamani 11de8810e4 satisfy coveralls via testing with a not URLClassLoader
See also WW-4845

(cherry picked from commit 02abab3)
2018-11-16 17:30:27 +03:30
Yasser Zamani 75dc4c00d2 pass all current tests with java 9
See also WW-4845

(cherry picked from commit a5d888a)
2018-11-16 17:29:37 +03:30
Lukasz Lenart 415ce3e165 Merge pull request #264 from JCgH4164838Gh792C124B5/localS2_2_5_x_Branch
Update Struts 2.5.19 build with some newer (compatible) library versions
2018-11-14 20:54:19 +01:00
JCgH4164838Gh792C124B5 fe6257b995 Merge branch 'localS2_2_5_x_Branch' of https://github.com/JCgH4164838Gh792C124B5/struts into localS2_2_5_x_Branch
# Conflicts:
#	pom.xml
2018-11-12 15:13:18 -05:00
JCgH4164838Gh792C124B5 3b81a9edaa Update Struts 2.5.19 build with some newer (compatible) library versions.
- Fix SCM tag entry typo in main pom.xml.
- Enhance main pom.xml maven-surefire-plugin configuration to avoid some test-ng related duplication failures:  "Cannot find JUnit method class junit.framework.TestSuite$1.warning".
- Remove unnecessary plugins/embeddedjsp/pom.xml (struts2-embeddedjsp-plugin) maven-surefire-plugin version override (noted with preceding change).
- Update Struts 2.5.19 build to use some newer (compatible) library versions.
  Change the main pom.xml library versions for the following:
  - spring.platformVersion 4.3.13.RELEASE -> 4.3.20.RELEASE
  - ognl 3.1.15 -> 3.1.18  (Note: newest version that passes unit tests)
  - oval 1.31 -> 1.90      (Note: required unit test fix for OValValidationInterceptorTest.java)
  - tiles 3.0.7 -> 3.0.8
  - tiles-request 1.0.6 -> 1.0.7
  - log4j 2.10.0 -> 2.11.1
  - jackson 2.9.5 -> 2.9.7
  - fluido-skin.version 1.6 -> 1.7
  - slf4j 1.7.12 -> 1.7.25
  - xtream 1.4.10 -> 1.4.11.1
  - jetty 6.1.9 -> 6.1.26 (last in 6.1.x line)
  - xerces 2.10.0 - > 2.12.0
  - org.owasp 3.1.1 -> 3.3.4
  - versions-maven-plugin 2.5 -> 2.7
  - doxia-core 1.7 -> 1.8
  - doxia-markdown 1.3 -> 1.7
  - freemarker 2.3.26-incubating -> 2.3.28
  - org.apache.felix.main 4.0.3 -> 4.6.1  (Note: most recent 4.x)
  - easymock 3.4 -> 3.5.1
  - javax.el 3.0 -> 3.0.1-b10
  - jasper 6.0.18 -> 6.0.53  (Note: most recent 6.0.x)
  - juli 6.0.18 -> 6.0.53    (Note: most recent 6.0.x)
  - commons-logging 1.1.3 -> 1.2
  - commons-collections4 4.1 -> 4.2
  - commons-io 2.5 -> 2.6
  - commons-lang 3.6 -> 3.8.1
  - commons-beanutils 1.9.2 -> 1.9.3
  - commons-validator 1.5.1 -> 1.6
  - mockito 1.9.5 -> 1.10.19            (Note: most recent 1.x)
  - cdi-api 1.0-SP1 -> 1.0-SP4          (Note: most recent 1.0.x)
  - weld-core 1.0.1-Final -> 1.0.1-SP4  (Note: most recent 1.0.x)
  Note for cglib-nodep:  Build succeeded with cglib-nodep 2.2.2 and 3.2.5.  Although
    cglib 3.2.5 matches ASM 5.2, jmock-cglib 1.2.0 identifies cglib-nodep 2.1_3 as its
    requirement (on the JMock http://jmock.org/download.html download page) so it should
    remain as long as JMock 1.2.0 is used.
2018-11-12 14:49:56 -05:00
JCgH4164838Gh792C124B5 478a9b8f1c Update Struts 2.5.19 build to use some newer (compatible) library versions.
- Fix SCM tag entry typo in main pom.xml.
- Enhance main pom.xml maven-surefire-plugin configuration to avoid some test-ng related duplication failures:
  "Cannot find JUnit method class junit.framework.TestSuite$1.warning".
- Remove unnecessary plugins/embeddedjsp/pom.xml (struts2-embeddedjsp-plugin) maven-surefire-plugin version override (noted with preceding change).
- Update Struts 2.5.19 build to use some newer (compatible) library versions.
  Change the main pom.xml library versions for the following:
  - spring.platformVersion 4.3.13.RELEASE -> 4.3.20.RELEASE
  - ognl 3.1.15 -> 3.1.18 (Note: newest version that passes unit tests)
  - oval 1.31 -> 1.90     (required unit test fix for OValValidationInterceptorTest.java)
  - tiles 3.0.7 -> 3.0.8
  - tiles-request 1.0.6 -> 1.0.7
  - log4j 2.10.0 -> 2.11.1
  - jackson 2.9.5 -> 2.9.7
  - fluido-skin.version 1.6 -> 1.7
  - slf4j 1.7.12 -> 1.7.25
  - xtream 1.4.10 -> 1.4.11.1
  - jetty 6.1.9 -> 6.1.26 (last in 6.1.x line)
  - xerces 2.10.0 - > 2.12.0
  - org.owasp 3.1.1 -> 3.3.4
  - versions-maven-plugin 2.5 -> 2.7
  - doxia-core 1.7 -> 1.8
  - doxia-markdown 1.3 -> 1.7
  - freemarker 2.3.26-incubating -> 2.3.28
  - org.apache.felix.main 4.0.3 -> 4.6.1  (most recent 4.x)
  - cglib 2.1_3 -> 3.2.5 (match for ASM 5.2)
  - easymock 3.4 -> 3.5.1
  - javax.el 3.0 -> 3.0.1-b10
  - jasper 6.0.18 -> 6.0.53 (most recent 6.0.x)
  - juli 6.0.18 -> 6.0.53 (most recent 6.0.x)
  - commons-logging 1.1.3 -> 1.2
  - commons-collections4 4.1 -> 4.2
  - commons-io 2.5 -> 2.6
  - commons-lang 3.6 -> 3.8.1
  - commons-beanutils 1.9.2 -> 1.9.3
  - commons-validator 1.5.1 -> 1.6
  - mockito 1.9.5 -> 1.10.19 (most recent 1.x)
  - cdi-api 1.0-SP1 -> 1.0-SP4 (most recent 1.0.x)
  - weld-core 1.0.1-Final -> 1.0.1-SP4 (most recent 1.0.x)
2018-11-12 13:49:51 -05:00
Lukasz Lenart 12c3d23bdf Merge pull request #260 from yasserzamani/WW-4974
WW-4974 monitor not-monitored loaded files on demand
2018-11-03 10:47:09 +01:00
Aleksandr Mashchenko 8293add6aa Merge pull request #257 from JCgH4164838Gh792C124B5/localS2_2_5_x_Branch
Fix WW-4971 (broken includes for non-UTF8 content).
2018-11-01 21:53:04 +02:00
Yasser Zamani ecb7beef38 not miss container provided fileUrl and ...
lazy monitoring for performance. Fix and test stopping reload configs at runtime.

Fixes WW-4974
2018-11-01 15:17:02 +03:30
Yasser Zamani bac0f2953c monitor not-monitored loaded files on demand
See WW-4974
2018-10-31 19:51:37 +03:30
JCgH4164838Gh792C124B5 7bca98205d Fix typos and whitespace (on top of WW-4971 Fix broken s:includes for non-UTF8 content). 2018-10-25 00:13:35 -04:00
JCgH4164838Gh792C124B5 567fae9dfc WW-4971 Fix broken s:includes for non-UTF8 content. The low-risk fix retains existing behaviour by default, but provides a configuration flag users can set (to true) in order to enable usage of response (page) encoding for s:include tags. A WARN level log output is also generated for failed FastByteArrayOutputStream decoding (can be suppressed by log configuration). 2018-10-24 23:41:38 -04:00
Lukasz Lenart f4d7dbe88e [maven-release-plugin] prepare for next development iteration 2018-09-18 11:23:59 +02:00
Lukasz Lenart 289782c583 [maven-release-plugin] prepare release STRUTS_2_5_18 2018-09-18 11:23:36 +02:00
Lukasz Lenart 1e33df947a WW-4951 Upgrades to the latest struts master to support SHA256/512 2018-09-18 09:49:27 +02:00
Lukasz Lenart de1a42d34a Merge pull request #250 from yasserzamani/WW-4948
WW-4948 delete temp files on close instead of on JVM exists
2018-09-17 08:02:35 +02:00
Yasser Zamani b816cc1374 monitor file only if needed
See also: WW-4948
2018-09-10 18:18:42 +04:30
Yasser Zamani b802baa4a9 delete temp files on close instead of on JVM exists 2018-09-06 12:59:21 +04:30
Aleksandr Mashchenko daac47ee62 Improve log messages in SecurityMemberAccess
(cherry picked from commit be1a93b0d5)
2018-09-03 21:51:30 +03:00
Aleksandr Mashchenko b1709c5208 Better logging message (for WW-4954)
(cherry picked from commit b213d58f54)
2018-09-03 21:51:17 +03:00
Yasser Zamani daf6f6f749 Merge pull request #244 from apache/WW-4954
WW-4954 Moves XWorkList out of util package
2018-08-31 16:23:02 +04:30
Lukasz Lenart 029892d656 WW-4954 Moves XWorkList out of util package 2018-08-30 08:39:11 +02:00
Lukasz Lenart 65fb0d4a44 Merge pull request #242 from benelog/fix-log-2-5-x
Fix logging  message (for 2.5.x)
2018-08-27 14:17:38 +02:00
Sanghyuk Jung 58d87025e9 Fix logging messages 2018-08-27 20:59:00 +09:00
Yaser Zamani 83c0f1cd1e [maven-release-plugin] prepare for next development iteration 2018-08-13 17:13:52 +04:30
Yaser Zamani eacc002334 [maven-release-plugin] prepare release STRUTS_2_5_17 2018-08-13 17:12:34 +04:30
Yasser Zamani 45effc3822 add an extra unit test 2018-06-29 16:28:23 +04:30
Lukasz Lenart bad9a49060 Fixes how dependencies are injected into constructor 2018-06-27 08:15:21 +02:00
Yasser Zamani a75eddb515 delete redundant code for performance 2018-06-21 12:00:46 +04:30
Lukasz Lenart 6e87474f9a Validates action, namespace and method in the same way 2018-06-21 09:19:57 +02:00
Lukasz Lenart 9fcbd912bc Adds more general exclusion 2018-06-21 08:20:11 +02:00
Lukasz Lenart fbc780e779 Adds proper handling of primitive types 2018-06-20 11:47:53 +02:00
Lukasz Lenart 6eb83016e3 Fixes wrong version in bom 2018-06-15 09:31:57 +02:00
Lukasz Lenart 3ec7fa9d80 Makes OgnlUtil more immutable 2018-05-29 12:58:44 +02:00
Lukasz Lenart f9806ee4e1 Adds Maven wrapper to allow use the latest Maven version 2018-05-29 11:48:39 +02:00
Lukasz Lenart d175836757 Changes version to snapshot 2018-05-02 08:45:44 +02:00
Lukasz Lenart e55ad3fb45 Upgrades Jackson libs to version 2.9.5 2018-05-02 08:35:52 +02:00
Lukasz Lenart 6efaf900d4 Increases scope when location parsing is avoided 2018-05-02 08:25:06 +02:00
Lukasz Lenart b3bad5ea44 Avoids parsing namespace when using existing namespace 2018-05-02 08:04:15 +02:00
3324 changed files with 150627 additions and 159555 deletions
-37
View File
@@ -1,37 +0,0 @@
# Documentation https://s.apache.org/asfyaml
notifications:
commits: commits@struts.apache.org
# Send all issue emails (new, closed, comments) to issues@
issues: issues@struts.apache.org
# Send new/closed PR notifications to commits@
pullrequests_status: notifications@struts.apache.org
# Send individual PR comments/reviews to issues@
pullrequests_comment: notifications@struts.apache.org
# Link opened PRs with JIRA
jira_options: link label worklog
github:
description: "Apache Struts is a free, open-source, MVC framework for creating elegant, modern Java web applications"
homepage: https://struts.apache.org/
del_branch_on_merge: true
protected_branches:
main:
# contexts are the names of checks that must pass.
contexts:
- build
required_pull_request_reviews:
# it does not work because our github teams are private/secret, see INFRA-25666
require_code_owner_reviews: false
required_approving_review_count: 0
release/struts-6-7-x:
# contexts are the names of checks that must pass.
contexts:
- build
required_pull_request_reviews:
# it does not work because our github teams are private/secret, see INFRA-25666
require_code_owner_reviews: false
required_approving_review_count: 0
autolink_jira:
- WW
dependabot_alerts: true
dependabot_updates: true
-5
View File
@@ -1,5 +0,0 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
*.bat eol=crlf
*.cmd eol=crlf
*.sh eol=lf
-11
View File
@@ -1,11 +0,0 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"
ignore: []
-63
View File
@@ -1,63 +0,0 @@
# 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.
name: "CodeQL"
on:
push:
branches:
- 'main'
- 'release/*'
pull_request:
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
actions: read
contents: read
# Needed to access OIDC token.
id-token: write
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'java' ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: 'maven'
- name: Initialize CodeQL
uses: github/codeql-action/init@v3.28.9
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v3.28.9
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3.28.9
with:
category: "/language:${{matrix.language}}"
-47
View File
@@ -1,47 +0,0 @@
# 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.
name: Java Maven
on:
pull_request:
push:
branches:
- 'main'
- 'release/*'
permissions: read-all
env:
MAVEN_OPTS: -Xmx2048m -Xms1024m
LANG: en_US.utf8
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '17', '21' ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Build with Maven on Java ${{ matrix.java }}
run: mvn -B -V -DskipAssembly verify --no-transfer-progress
@@ -1,70 +0,0 @@
# 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.
name: "Scorecards supply-chain security"
on:
branch_protection_rule:
schedule:
- cron: "30 1 * * 6" # Weekly on Saturdays
push:
branches:
- "main"
permissions: read-all
jobs:
analysis:
name: "Scorecards analysis"
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to the code-scanning dashboard.
security-events: write
actions: read
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
steps:
- name: "Checkout code"
uses: actions/checkout@v4 # 3.1.0
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # 2.4.0
with:
results_file: results.sarif
results_format: sarif
# A read-only PAT token, which is sufficient for the action to function.
# The relevant discussion: https://github.com/ossf/scorecard-action/issues/188
repo_token: ${{ secrets.GITHUB_TOKEN }}
# Publish the results for public repositories to enable scorecard badges.
# For more details: https://github.com/ossf/scorecard-action#publishing-results
publish_results: true
- name: "Upload artifact"
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # 4.6.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@0a35e8f6866a39b001e5f7ad1d0daf9836786896 # 2.22.11
with:
sarif_file: results.sarif
-47
View File
@@ -1,47 +0,0 @@
# 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.
name: SonarCloud
on:
pull_request:
push:
branches:
- 'main'
permissions: read-all
env:
MAVEN_OPTS: -Xmx2048m -Xms1024m
LANG: en_US.utf8
jobs:
sonarcloud:
name: Scan
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.base.repo.fork && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
cache: 'maven'
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
run: ./mvnw -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Pcoverage -DskipAssembly
+37 -20
View File
@@ -11,9 +11,6 @@
.metadata/
Servers/
# Java annotation processor (APT)
.factorypath
#VSCode
.vscode
@@ -27,22 +24,42 @@ Servers/
.java-version
# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
core/target
plugins/convention/target
plugins/embeddedjsp/target
plugins/osgi/target
plugins/cdi/target
plugins/spring/target
plugins/jfreechart/target
apps/rest-showcase/target
apps/mailreader/target
apps/portlet/target
apps/blank/target
apps/jboss-blank/target
apps/mailreader/target
apps/portlet/target
apps/showcase/target
apps/target
bundles/admin/target
plugins/config-browser/target
plugins/jasperreports/target
plugins/json/target
plugins/portlet-tiles/target
plugins/portlet/target
plugins/sitegraph/target
plugins/sitemesh/target
plugins/javatemplates/target
bundles/demo/target
plugins/rest/target
plugins/plexus/target
plugins/testng/target
plugins/dwr/target
plugins/gxp/target
plugins/oval/target
plugins/junit/target
plugins/tiles/target
bundles/target
plugins/target
target
plugins/testng/test-output
test-output
# Sonar
/.sonar/
# Tidelift CLI scanner
.tidelift
+110
View File
@@ -0,0 +1,110 @@
/*
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.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: : " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
BIN
View File
Binary file not shown.
Vendored Regular → Executable
+1 -19
View File
@@ -1,19 +1 @@
# 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.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
+29
View File
@@ -0,0 +1,29 @@
dist: trusty
language: java
sudo: false
jdk:
- openjdk7
- oraclejdk8
- oraclejdk9
- oraclejdk11
install: true
script: mvn test -DskipAssembly -B
after_success:
# TODO delete following if statement after fix of https://github.com/cobertura/cobertura/issues/271
- if [ "$TRAVIS_JDK_VERSION" == "openjdk8" ] || [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ]; then
mvn cobertura:cobertura org.eluder.coveralls:coveralls-maven-plugin:report com.updateimpact:updateimpact-maven-plugin:submit -Ptravis-coveralls,update-impact -DskipAssembly -B;
else
echo "Not reporting coverage for $TRAVIS_JDK_VERSION due to incompatibility or to save performance";
fi;
env:
global:
secure: DusDFL9cuX+mj64tXQfrYVbUVYnxlXmad4nuIMj0/lgDbwJ6kxYasJmR99bdvwu08gS9D5b7a+m7WJTN0FNATzEiiGDXcM+TiDPlYDh7dcalU4QGiLmMuCCEw1r7hp2XE4BWVgDfFhCsHhStgjE4RXzHIyPowoPXr4ugPf8at6w=
cache:
directories:
- $HOME/.m2
-2
View File
@@ -1,2 +0,0 @@
# Request PR review from any Apache Struts committer
* @apache/struts-committers
Vendored
+14 -200
View File
@@ -1,214 +1,28 @@
#!groovy
pipeline {
agent none
agent {
label 'ubuntu'
}
options {
buildDiscarder logRotator(daysToKeepStr: '14', numToKeepStr: '10')
timeout(80)
disableConcurrentBuilds()
skipStagesAfterUnstable()
quietPeriod(30)
}
tools {
jdk 'JDK 1.7 (latest)'
maven 'Maven 3 (latest)'
}
triggers {
pollSCM 'H/15 * * * *'
}
stages {
stage('Prepare') {
agent {
label 'ubuntu'
}
stages {
stage('Clean up') {
steps {
cleanWs deleteDirs: true, patterns: [[pattern: '**/target/**', type: 'INCLUDE']]
}
}
}
}
stage('JDK 21') {
agent {
label 'ubuntu'
}
tools {
jdk 'jdk_21_latest'
maven 'maven_3_latest'
}
environment {
MAVEN_OPTS = "-Xmx1024m"
}
stages {
stage('Test') {
steps {
sh './mvnw -B -DskipAssembly verify'
}
post {
always {
junit(testResults: '**/surefire-reports/*.xml', allowEmptyResults: true)
junit(testResults: '**/failsafe-reports/*.xml', allowEmptyResults: true)
}
}
}
}
post {
always {
cleanWs deleteDirs: true, patterns: [[pattern: '**/target/**', type: 'INCLUDE']]
}
}
}
stage('JDK 17') {
agent {
label 'ubuntu'
}
tools {
jdk 'jdk_17_latest'
maven 'maven_3_latest'
}
environment {
MAVEN_OPTS = "-Xmx2048m"
}
stages {
stage('Install') {
steps {
sh './mvnw -B install -DskipTests -DskipAssembly'
}
}
stage('Test') {
steps {
sh './mvnw -B verify -Pcoverage -DskipAssembly'
}
post {
always {
junit(testResults: '**/surefire-reports/*.xml', allowEmptyResults: true)
junit(testResults: '**/failsafe-reports/*.xml', allowEmptyResults: true)
}
}
}
stage('Build Source & JavaDoc') {
when {
anyOf {
branch 'main'
branch 'release/struts-6-7-x'
}
}
steps {
dir("local-snapshots-dir/") {
deleteDir()
}
sh './mvnw -B source:jar javadoc:jar -DskipTests -DskipAssembly'
}
}
stage('Deploy Snapshot') {
when {
anyOf {
branch 'main'
branch 'release/struts-6-7-x'
}
}
steps {
withCredentials([file(credentialsId: 'lukaszlenart-repository-access-token', variable: 'CUSTOM_SETTINGS')]) {
sh './mvnw -s \${CUSTOM_SETTINGS} deploy -DskipTests -DskipAssembly'
}
}
}
stage('Upload nightlies') {
when {
anyOf {
branch 'main'
branch 'release/struts-6-7-x'
}
}
steps {
sh './mvnw -B package -DskipTests'
sshPublisher(publishers: [
sshPublisherDesc(
configName: 'Nightlies',
transfers: [
sshTransfer(
remoteDirectory: '/struts/snapshot',
removePrefix: 'assembly/target/assembly/out',
sourceFiles: 'assembly/target/assembly/out/struts-*.zip'
)
],
verbose: true
)
])
}
}
}
post {
always {
cleanWs deleteDirs: true, patterns: [[pattern: '**/target/**', type: 'INCLUDE']]
}
}
}
environment {
MAVEN_OPTS = '-Xmx1024m -XX:MaxPermSize=256m'
}
post {
// If this build failed, send an email to the list.
failure {
script {
emailext(
to: "notifications@struts.apache.org",
recipientProviders: [[$class: 'DevelopersRecipientProvider']],
from: "Mr. Jenkins <jenkins@builds.apache.org>",
subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} failed",
body: """
There is a build failure in ${env.JOB_NAME}.
Build: ${env.BUILD_URL}
Logs: ${env.BUILD_URL}console
Changes: ${env.BUILD_URL}changes
--
Mr. Jenkins
Director of Continuous Integration
"""
)
}
}
// If this build didn't fail, but there were failing tests, send an email to the list.
unstable {
script {
emailext(
to: "notifications@struts.apache.org",
recipientProviders: [[$class: 'DevelopersRecipientProvider']],
from: "Mr. Jenkins <jenkins@builds.apache.org>",
subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} unstable",
body: """
Some tests have failed in ${env.JOB_NAME}.
Build: ${env.BUILD_URL}
Logs: ${env.BUILD_URL}console
Changes: ${env.BUILD_URL}changes
--
Mr. Jenkins
Director of Continuous Integration
"""
)
}
}
// Send an email, if the last build was not successful and this one is.
fixed {
script {
emailext(
to: "notifications@struts.apache.org",
recipientProviders: [[$class: 'DevelopersRecipientProvider']],
from: 'Mr. Jenkins <jenkins@builds.apache.org>',
subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} back to normal",
body: """
The build for ${env.JOB_NAME} completed successfully and is back to normal.
Build: ${env.BUILD_URL}
Logs: ${env.BUILD_URL}console
Changes: ${env.BUILD_URL}changes
--
Mr. Jenkins
Director of Continuous Integration
"""
)
stages {
stage('Build') {
steps {
sh 'mvn --version'
sh 'mvn clean source:jar javadoc:jar install deploy -DskipWiki -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2'
}
}
}
+22 -41
View File
@@ -17,22 +17,20 @@
The Apache Struts web framework
-------------------------------
[![Build Status](https://ci-builds.apache.org/buildStatus/icon?job=Struts%2FStruts+Core%2Fmain)](https://ci-builds.apache.org/job/Struts/job/Struts%20Core/job/main/)
[![Java Build](https://github.com/apache/struts/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/struts/actions/workflows/maven.yml)
[![Build Status @ Jenkins](https://builds.apache.org/buildStatus/icon?job=Struts-master-JDK7)](https://builds.apache.org/view/S-Z/view/Struts/job/Struts-master-JDK7/)
[![Build Status @ Travis](https://travis-ci.org/apache/struts.svg?branch=master)](https://travis-ci.org/apache/struts)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.struts/struts2-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.struts/struts2-core/)
[![Javadocs](https://javadoc.io/badge/org.apache.struts/struts2-core.svg)](https://javadoc.io/doc/org.apache.struts/struts2-core)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=apache_struts&metric=coverage)](https://sonarcloud.io/summary/new_code?id=apache_struts)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/apache/struts/badge)](https://deps.dev/maven/org.apache.struts%3Astruts2-core)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/6618/badge)](https://bestpractices.coreinfrastructure.org/projects/6618)
[![Coverage Status](https://coveralls.io/repos/github/apache/struts/badge.svg)](https://coveralls.io/github/apache/struts)
[![Dependencies](https://app.updateimpact.com/badge/713283867011846144/Struts%202.svg?config=test)](https://app.updateimpact.com/latest/713283867011846144/Struts%202)
[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
The Apache Struts web framework is a free open-source solution for creating Java web applications.
## Documentation
More information can be found on the [homepage](https://struts.apache.org/). Please read the [Security Guide](https://struts.apache.org/security/),
More information can be found on the [homepage](https://struts.apache.org/). Please read the [Security Guide](https://struts.apache.org/security/)
and the [JavaDocs](https://struts.apache.org/maven/struts2-core/apidocs/index.html) can be browsed.
Questions related to the usage of Apache Struts should be posted to the [user mailing list](https://struts.apache.org/mail.html).
Questions related to the usage of the Apache Struts should be posted to the [user mailing list](https://struts.apache.org/mail.html).
## Description
@@ -45,15 +43,13 @@ In practice, we find that unless these concerns are separated, larger applicatio
One way to separate concerns in a software application is to use a Model-View-Controller (MVC) architecture. The Model
represents the business or database code, the View represents the page design code, and the Controller represents
the navigational code. The Struts framework is designed to help developers create web applications that utilize
an MVC architecture.
a MVC architecture.
The framework provides three key components:
- A “request” handler provided by the application developer that is mapped to a standard URI.
- A “response” handler that transfers control to another resource which completes the response.
- A tag library that helps developers create interactive form-based applications with server pages.
The frameworks architecture and tags are buzzword compliant. Struts works well
A “request” handler provided by the application developer that is mapped to a standard URI. A “response” handler that
transfers control to another resource which completes the response. A tag library that helps developers create interactive
form-based applications with server pages. The frameworks architecture and tags are buzzword compliant. Struts works well
with conventional REST applications and with technologies like SOAP and AJAX.
## The Apache Struts Project
@@ -69,7 +65,7 @@ platform into a coherent whole. Our goal is to leverage existing standards by pr
enterprise-grade applications that are easy to maintain over time.
The Apache Struts Project offered two major versions of the Struts framework. Currently we are only maintaining the Struts 2
version. It is recommended to upgrade all Struts 1.x applications to Struts 2. Please do not start new application development
version. It is recommended to upgrade all Struts 1.x application to Struts 2. Please do not start new application development
using Struts 1.x, as we are no longer issuing security patches.
Struts 2 was originally known as WebWork 2. After working independently for several years, the WebWork and Struts
@@ -78,40 +74,25 @@ to difficult problems.
## Why should you use Apache Struts?
Apache Struts is a modern, maintained and full-featured web framework. As it has been around for years and grown a huge user
base it is unlikely it will go away anytime soon. Not only that, we have dedicated users and developers
on the project. Apache Struts is licensed under the Apache License 2.0 and this will not change. We maintain a clean IP
Apache Struts is a modern, maintained and full-featured web framework. It has been there for years and give the huge user
base it is unlikely it will go away anytime soon in the future. Not only that we have dedicated users and developers
on the project. Apache Struts is licensed to the Apache License 2.0 and this will not change. We maintain a clean IP
and you are “safe” to use the project. Sometimes you are not “safe” to use a project when a company controls the SCM.
Access to Source Code doesnt mean it is free. With Apache Struts, you are not only free to “do what you want with it”,
you can even contribute (which is not always the case). And best of all: you can become a part of the core team too.
you can even contribute (which is not always the case). And best of it: you can become a part of the core team too.
It is usually very easy to integrate other technologies with Apache Struts. If you are using an ORM like Apache Cayenne,
Hibernate or JDBC, you will not have any restrictions. Apache Struts is not even tied too much to a frontend technology.
Hibernate or JDBC you will not have any restrictions. Apache Struts is not even tied too much to a frontend technology.
In old days it was JSP, then came Velocity and Freemarker. Nowadays you might build your web application with just static
HTML and AngularJS. Or you might want to use Sitemesh or Tiles. This all is no problem due to Struts' elegant and easy-to-use
HTML and AngularJS. Or you want to use Sitemesh or Tiles. This all is no problem due to Struts elegant and easy to use
extension mechanisms.
Unlike other, component-oriented frameworks, we do not aim to hide the stateless nature of the web. We think it is
Unlike other, component oriented frameworks, we do not aim to hide the stateless nature of the web. We think it is
perfectly acceptable to build upon a Request/Response cycle. We also think the MVC pattern is not so bad, just because
it is old. In fact, we believe the Apache Struts architecture is clean and easy to understand.
Of course, if you wish to build components on the server side which render on the front end side, you will most likely
not want Struts. This is a different approach which promises to reduce the amount of HTML/JavaScript knowledge needed
Of course, if you wish to build components on the server side which render on the front end side, you are most likely
wrong with Struts. This is a different approach which promises to reduce the amount of HTML/JavaScript knowledge needed
and to create reusable components for the view layer. Projects like Wicket and Tapestry serve this purpose very well.
As with every framework, you need to decide if it makes sense for you to build components or if you prefer
the Struts approach.
## Commercial Support
The Apache Struts community does not offer commercial support by itself, but we maintain [a list of companies offering
commercial support on our website](https://struts.apache.org/commercial-support.html).
Some Apache Struts maintainers are working with [Tidelift](https://tidelift.com/) to provide commercial support and
invest paid working time in the improvement of the Apache Struts framework. For more information, visit
the [Tidelift resources regarding Apache Struts](https://tidelift.com/subscription/pkg/maven-org-apache-struts-struts2-core?utm_source=maven-org-apache-struts-struts2-core&utm_medium=referral&utm_campaign=readme)
## Thank you
[YourKit](https://www.yourkit.com/) is kindly supporting open source projects with its full-featured Java Profiler.
YourKit is the creator of innovative and intelligent tools for profiling Java and .NET applications.
As an Apache committer, you can get a free license at [YourKit's open source sponsorship program](https://www.yourkit.com/java/profiler/purchase/#os_license).
As with every framework you need to decide if it makes sense for you to build components or if you are better with
the Struts-approach.
-40
View File
@@ -1,40 +0,0 @@
# Security Policy
## Supported Versions
Please visit the [Releases](https://struts.apache.org/releases.html#prior-releases) page to see full information about each version
and what potential vulnerability it can have:
| Version | Supported |
|---------|--------------------|
| 7.x | :white_check_mark: |
| 6.7.x | :white_check_mark: |
| 2.5.x | ❌ |
## Reporting New Security Issues with thr Apache Struts
([original](https://struts.apache.org/security.html))
The Apache Struts project takes a very active stance in eliminating security problems
and denial of service attacks against applications using the Apache Struts framework.
**We strongly encourage folks to report such security problems to our private security mailing list first,
before disclosing them in a public forum**.
We cannot accept regular bug reports or other queries at this address, we ask that you use our
[issue tracker (JIRA)](https://issues.apache.org/jira/browse/WW) for those.
```
All mail sent to this address that does not relate to security problems in the Apache Struts source code will be ignored
```
Note that all networked servers are subject to denial of service attacks, and we cannot promise magic
workarounds to generic problems (such as a client streaming lots of data to your server, or requesting
the same URL repeatedly). In general, our philosophy is to avoid any attacks that can cause the server
to consume resources in a non-linear relationship to the size of inputs.
The mailing address is: [security@struts.apache.org](mailto:security@struts.apache.org)
[General network server security tips](http://httpd.apache.org/docs/trunk/misc/security_tips.html)
[The Apache Security Team](http://www.apache.org/security/)
-12
View File
@@ -1,12 +0,0 @@
# Struts 2 Apps
These module consists of two example applications, which were built using the Apache Struts project.
One is an old-fashioned Web application and another is a modern REST based single page app.
## Installation
Enter a given folder, either `showcase/` or `rest-showcase/` and start the app using Maven:
```
mvn jetty:run
```
then open your browser at http://localhost:8080 and navigate to a proper context.
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>7.0.3</version>
<version>2.5.22</version>
</parent>
<artifactId>struts2-apps</artifactId>
<packaging>pom</packaging>
+17 -15
View File
@@ -24,12 +24,12 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>7.0.3</version>
<version>2.5.22</version>
</parent>
<artifactId>struts2-rest-showcase</artifactId>
<packaging>war</packaging>
<version>7.0.3</version>
<version>2.5.22</version>
<name>Struts 2 Rest Showcase Webapp</name>
<description>Struts 2 Rest Showcase Example</description>
@@ -56,10 +56,12 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
@@ -71,31 +73,26 @@
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-core</artifactId>
<version>3.3</version>
<version>1.4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-htmlunit-plugin</artifactId>
<version>3.3</version>
<version>1.4.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
</exclusion>
<!-- not necessary to compile and it force dependency convergence issues -->
<exclusion>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
</exclusion>
</exclusions>
</dependency>
@@ -105,12 +102,18 @@
<finalName>struts2-rest-showcase</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>11.0.18</version>
<version>8.1.16.v20140903</version>
<configuration>
<stopKey>CTRL+C</stopKey>
<stopPort>8999</stopPort>
<systemProperties>
<systemProperty>
<name>xwork.loggerFactory</name>
<value>com.opensymphony.xwork2.util.logging.log4j2.Log4j2LoggerFactory</value>
</systemProperty>
</systemProperties>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppSourceDirectory>${basedir}/src/main/webapp/</webAppSourceDirectory>
<webAppConfig>
@@ -122,7 +125,6 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine}</argLine>
<excludes>
<exclude>it/**</exclude>
<exclude>**/*$*</exclude>
@@ -18,30 +18,30 @@
*/
package org.demo.rest.example;
import org.apache.struts2.ModelDriven;
import org.apache.struts2.Validateable;
import org.apache.struts2.ValidationAwareSupport;
import java.util.Collection;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.rest.DefaultHttpHeaders;
import org.apache.struts2.rest.HttpHeaders;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.convention.annotation.Result;
import java.util.Collection;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Validateable;
import com.opensymphony.xwork2.ValidationAwareSupport;
@Results({
@Result(name="success", type="redirectAction", params = {"actionName" , "orders"})
})
public class OrdersController extends ValidationAwareSupport implements ModelDriven<Object>, Validateable {
public class OrdersController extends ValidationAwareSupport implements ModelDriven<Object>, Validateable{
private static final Logger log = LogManager.getLogger(OrdersController.class);
private Order model = new Order();
private String id;
private Collection<Order> list;
private final OrdersService ordersService = new OrdersService();
private OrdersService ordersService = new OrdersService();
// GET /orders/1
public HttpHeaders show() {
@@ -54,7 +54,7 @@ public class OrdersController extends ValidationAwareSupport implements ModelDri
return new DefaultHttpHeaders("index")
.disableCaching();
}
// GET /orders/1/edit
public String edit() {
return "edit";
@@ -101,15 +101,13 @@ public class OrdersController extends ValidationAwareSupport implements ModelDri
}
}
@StrutsParameter
public void setId(String id) {
if (id != null) {
this.model = ordersService.get(id);
}
this.id = id;
}
@Override
public Object getModel() {
return (list != null ? list : model);
}
@@ -18,14 +18,11 @@
*/
package org.demo.rest.example;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public class OrdersService {
private static final Map<String,Order> orders = new HashMap<>();
private static Map<String,Order> orders = new HashMap<String,Order>();
private static int nextId = 6;
static {
orders.put("3", new Order("3", "Bob", 33));
@@ -26,6 +26,7 @@
</Console>
</Appenders>
<Loggers>
<Logger name="com.opensymphony.xwork2" level="info"/>
<Logger name="org.apache.struts2" level="info"/>
<Logger name="org.demo.rest" level="debug"/>
<Root level="warn">
@@ -20,8 +20,8 @@
*/
-->
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 6.0//EN"
"https://struts.apache.org/dtds/struts-6.0.dtd">
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
@@ -41,4 +41,4 @@
<package name="rest-showcase" extends="rest-default">
<global-allowed-methods>index,show,create,update,destroy,deleteConfirm,edit,editNew</global-allowed-methods>
</package>
</struts>
</struts>
@@ -27,16 +27,14 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Orders</title>
<!-- Using a standard HTML link tag with JSP EL to get the contextPath may be simpler, but this is an equivalent for s:link -->
<s:set var="pageContextPath"><%=((HttpServletRequest)request).getContextPath()%></s:set>
<s:link href="%{#pageContextPath}/css/bootstrap.min.css" rel="stylesheet"></s:link>
<s:link href="%{#pageContextPath}/css/app.css" rel="stylesheet"></s:link>
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/css/app.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<s:script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></s:script>
<s:script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></s:script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
@@ -27,16 +27,14 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Orders</title>
<!-- Using a standard HTML link tag with JSP EL to get the contextPath may be simpler, but this is an equivalent for s:link -->
<s:set var="pageContextPath"><%=((HttpServletRequest)request).getContextPath()%></s:set>
<s:link href="%{#pageContextPath}/css/bootstrap.min.css" rel="stylesheet"></s:link>
<s:link href="%{#pageContextPath}/css/app.css" rel="stylesheet"></s:link>
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/css/app.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<s:script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></s:script>
<s:script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></s:script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
@@ -27,16 +27,13 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Orders</title>
<!-- Using a standard HTML link tag with JSP EL to get the contextPath may be simpler, but this is an equivalent for s:link -->
<s:set var="pageContextPath"><%=((HttpServletRequest)request).getContextPath()%></s:set>
<s:link href="%{#pageContextPath}/css/bootstrap.min.css" rel="stylesheet"></s:link>
<s:link href="%{#pageContextPath}/css/app.css" rel="stylesheet"></s:link>
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/css/app.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<s:script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></s:script>
<s:script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></s:script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
@@ -27,16 +27,14 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Orders</title>
<!-- Using a standard HTML link tag with JSP EL to get the contextPath may be simpler, but this is an equivalent for s:link -->
<s:set var="pageContextPath"><%=((HttpServletRequest)request).getContextPath()%></s:set>
<s:link href="%{#pageContextPath}/css/bootstrap.min.css" rel="stylesheet"></s:link>
<s:link href="%{#pageContextPath}/css/app.css" rel="stylesheet"></s:link>
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/css/app.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<s:script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></s:script>
<s:script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></s:script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
@@ -27,16 +27,14 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Orders</title>
<!-- Using a standard HTML link tag with JSP EL to get the contextPath may be simpler, but this is an equivalent for s:link -->
<s:set var="pageContextPath"><%=((HttpServletRequest)request).getContextPath()%></s:set>
<s:link href="%{#pageContextPath}/css/bootstrap.min.css" rel="stylesheet"></s:link>
<s:link href="%{#pageContextPath}/css/app.css" rel="stylesheet"></s:link>
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/css/app.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<s:script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></s:script>
<s:script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></s:script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
@@ -19,16 +19,16 @@
* under the License.
*/
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
<web-app id="starter" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts 2 Rest Example</display-name>
<display-name>Struts 2 Rest Example</display-name>
<!-- Filters -->
<!-- START SNIPPET: filter -->
<!-- Filters -->
<!-- START SNIPPET: filter -->
<filter>
<filter-name>action2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
@@ -18,41 +18,31 @@
*/
package it.org.apache.struts2.rest.example;
import org.junit.Before;
import org.junit.Test;
import net.sourceforge.jwebunit.junit.WebTestCase;
import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextNotPresent;
import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextPresent;
import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
import static net.sourceforge.jwebunit.junit.JWebUnit.getTestContext;
public class GetOrdersTest extends WebTestCase {
public class GetOrdersTest {
@Before
public void setUp() throws Exception {
getTestContext().setBaseUrl(ParameterUtils.getBaseUrl());
}
@Test
public void testGetOrders() {
beginAt("/orders/3");
assertTextPresent("Bob");
assertTextNotPresent("Sarah");
}
@Test
public void testGetOrdersInHtml() {
beginAt("/orders/3.xhtml");
assertTextPresent("Bob");
}
@Test
public void testGetOrdersInXml() {
beginAt("/orders/3.xml");
assertTextPresent("<clientName>Bob");
}
@Test
public void testGetOrdersInJson() {
beginAt("/orders/3.json");
assertTextPresent("\"clientName\":\"Bob\"");
@@ -18,21 +18,15 @@
*/
package it.org.apache.struts2.rest.example;
import org.junit.Before;
import org.junit.Test;
import net.sourceforge.jwebunit.junit.WebTestCase;
import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextPresent;
import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
import static net.sourceforge.jwebunit.junit.JWebUnit.getTestContext;
public class ListOrdersTest extends WebTestCase {
public class ListOrdersTest {
@Before
public void setUp() throws Exception {
getTestContext().setBaseUrl(ParameterUtils.getBaseUrl());
}
@Test
public void testListOrders() {
beginAt("/orders");
assertTextPresent("Bob");
@@ -40,7 +34,6 @@ public class ListOrdersTest {
assertTextPresent("Jim");
}
@Test
public void testListOrdersInHtml() {
beginAt("/orders.xhtml");
assertTextPresent("Bob");
@@ -48,7 +41,6 @@ public class ListOrdersTest {
assertTextPresent("Jim");
}
@Test
public void testListOrdersInXml() {
beginAt("/orders.xml");
assertTextPresent("<clientName>Bob");
@@ -56,7 +48,6 @@ public class ListOrdersTest {
assertTextPresent("<clientName>Jim");
}
@Test
public void testListOrdersInJson() {
beginAt("/orders.json");
assertTextPresent("\"clientName\":\"Bob\"");
@@ -18,37 +18,22 @@
*/
package it.org.apache.struts2.rest.example;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.htmlunit.FailingHttpStatusCodeException;
import org.junit.Before;
import org.junit.Test;
import net.sourceforge.jwebunit.junit.WebTestCase;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import java.io.IOException;
import static net.sourceforge.jwebunit.junit.JWebUnit.assertLinkNotPresentWithText;
import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextFieldEquals;
import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextPresent;
import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
import static net.sourceforge.jwebunit.junit.JWebUnit.getTestContext;
import static net.sourceforge.jwebunit.junit.JWebUnit.setTextField;
import static net.sourceforge.jwebunit.junit.JWebUnit.setWorkingForm;
import static net.sourceforge.jwebunit.junit.JWebUnit.submit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
public class PostOrderTest {
public class PostOrderTest extends WebTestCase {
@Before
public void setUp() throws Exception {
getTestContext().setBaseUrl(ParameterUtils.getBaseUrl());
}
@Test
public void testPostOrder() {
beginAt("/orders/new");
setWorkingForm(0);
@@ -59,7 +44,6 @@ public class PostOrderTest {
assertLinkNotPresentWithText("Back to Orders");
}
@Test
public void testPostOrderWithErrors() {
beginAt("/orders/new");
setWorkingForm(0);
@@ -73,7 +57,6 @@ public class PostOrderTest {
assertTextFieldEquals("amount", "321");
}
@Test
public void testPostOrderInHtml() {
beginAt("/orders/new.xhtml");
setWorkingForm(0);
@@ -88,55 +71,69 @@ public class PostOrderTest {
assertLinkNotPresentWithText("Back to Orders");
}
@Test
public void testPostOrderInXml() throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(ParameterUtils.getBaseUrl() + "/orders.xml");
httpPost.setEntity(new StringEntity("<org.apache.struts2.rest.example.Order>\n" +
"<clientName>Test3</clientName>\n" +
"<amount>3342</amount>\n" +
"</org.apache.struts2.rest.example.Order>"));
CloseableHttpResponse response = client.execute(httpPost);
assertEquals(201, response.getStatusLine().getStatusCode());
assertTrue(response.getHeaders("Location")[0].getValue().startsWith(ParameterUtils.getBaseUrl() + "/orders/"));
client.close();
HttpClient client = new HttpClient();
PostMethod method = null;
try {
method = new PostMethod(ParameterUtils.getBaseUrl()+"/orders.xml");
method.setRequestEntity(new StringRequestEntity("<org.apache.struts2.rest.example.Order>\n" +
"<clientName>Test3</clientName>\n" +
"<amount>3342</amount>\n" +
"</org.apache.struts2.rest.example.Order>"));
client.executeMethod(method);
assertEquals(201, method.getStatusCode());
assertTrue(method.getResponseHeader("Location").getValue().startsWith(ParameterUtils.getBaseUrl()+"/orders/"));
} finally {
method.releaseConnection();
}
}
@Test
public void testPostOrderInXmlWithBadData() throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(ParameterUtils.getBaseUrl() + "/orders.xml");
httpPost.setEntity(new StringEntity("<org.apache.struts2.rest.example.Order>\n" +
"<amount>3342</amount>\n" +
"</org.apache.struts2.rest.example.Order>"));
CloseableHttpResponse response = client.execute(httpPost);
assertEquals(400, response.getStatusLine().getStatusCode());
assertTrue(response.toString().contains("<string>The client name is empty"));
assertNull(response.getHeaders("Location"));
client.close();
HttpClient client = new HttpClient();
PostMethod method = null;
try {
method = new PostMethod(ParameterUtils.getBaseUrl()+"/orders.xml");
method.setRequestEntity(new StringRequestEntity("<org.apache.struts2.rest.example.Order>\n" +
"<amount>3342</amount>\n" +
"</org.apache.struts2.rest.example.Order>"));
client.executeMethod(method);
assertEquals(400, method.getStatusCode());
String response = method.getResponseBodyAsString();
assertTrue(response.contains("<string>The client name is empty"));
assertNull(method.getResponseHeader("Location"));
} finally {
method.releaseConnection();
}
}
@Test
public void testPostOrderInJson() throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(ParameterUtils.getBaseUrl() + "/orders.json");
httpPost.setEntity(new StringEntity("{\"amount\":33,\"clientName\":\"Test4\"}"));
CloseableHttpResponse response = client.execute(httpPost);
assertEquals(201, response.getStatusLine().getStatusCode());
assertTrue(response.getHeaders("Location")[0].getValue().startsWith(ParameterUtils.getBaseUrl() + "/orders/"));
client.close();
HttpClient client = new HttpClient();
PostMethod method = null;
try {
method = new PostMethod(ParameterUtils.getBaseUrl()+"/orders.json");
method.setRequestEntity(new StringRequestEntity("{\"amount\":33,\"clientName\":\"Test4\"}"));
client.executeMethod(method);
assertEquals(201, method.getStatusCode());
assertTrue(method.getResponseHeader("Location").getValue().startsWith(ParameterUtils.getBaseUrl()+"/orders/"));
} finally {
method.releaseConnection();
}
}
@Test
public void testPostOrderInJsonWithBadData() throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(ParameterUtils.getBaseUrl() + "/orders.json");
httpPost.setEntity(new StringEntity("{\"amount\":33}"));
CloseableHttpResponse response = client.execute(httpPost);
assertEquals(400, response.getStatusLine().getStatusCode());
assertTrue(response.toString()
.contains("{\"actionErrors\":[],\"fieldErrors\":{\"clientName\":[\"The client name is empty\"]}}"));
assertNull(response.getHeaders("Location"));
client.close();
HttpClient client = new HttpClient();
PostMethod method = null;
try {
method = new PostMethod(ParameterUtils.getBaseUrl()+"/orders.json");
method.setRequestEntity(new StringRequestEntity("{\"amount\":33}"));
client.executeMethod(method);
String response = method.getResponseBodyAsString();
assertEquals(400, method.getStatusCode());
assertEquals("{\"actionErrors\":[],\"fieldErrors\":{\"clientName\":[\"The client name is empty\"]}}", response);
assertNull(method.getResponseHeader("Location"));
} finally {
method.releaseConnection();
}
}
}
+82 -151
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>7.0.3</version>
<version>2.5.22</version>
</parent>
<artifactId>struts2-showcase</artifactId>
@@ -48,16 +48,32 @@
<artifactId>struts2-config-browser-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-sitemesh-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-dwr-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
@@ -74,31 +90,8 @@
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-async-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-velocity-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-velocity-tools-view-jakarta</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-velocity-tools-jsp-jakarta</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-xslt-plugin</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
@@ -106,181 +99,119 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>${log4j2.version}</version>
</dependency>
<!-- Velocity -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
</dependency>
<dependency>
<groupId>org.sitemesh</groupId>
<artifactId>sitemesh</artifactId>
<version>3.2.2</version>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>opensymphony</groupId>
<artifactId>sitemesh</artifactId>
</dependency>
<dependency>
<groupId>uk.ltd.getahead</groupId>
<artifactId>dwr</artifactId>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-core</artifactId>
<version>1.4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<scope>test</scope>
</dependency>
<!-- BeanValidation Example -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate-validator.version}</version>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-htmlunit-plugin</artifactId>
<version>1.4.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--
Nashorn (the built-in JDK javascript engine) was deprecated in JDK 11 and removed in JDK 15
As a result attempting to use @ScriptAssert on JDK 17 leads to the exception
See more details
https://stackoverflow.com/questions/78008950/resolve-org-hibernate-validator-spi-scripting-scriptevaluatornotfoundexception
-->
<!-- BeanValidation Example -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-jsr223</artifactId>
<version>3.0.22</version>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.1.3.Final</version>
</dependency>
<!-- The Servlet API mocks in Spring Framework 4.x only supports Servlet 3.0 and higher.
This is only necessary in tests-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<?m2e ignore?>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/extraclasspath</outputDirectory>
<artifactItems>
<artifactItem>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-velocity-tools-view-jakarta</artifactId>
<destFileName>struts2-velocity-tools-view-jakarta.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-velocity-tools-jsp-jakarta</artifactId>
<destFileName>struts2-velocity-tools-jsp-jakarta.jar</destFileName>
</artifactItem>
</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<includes>
<include>it.org.apache.struts2.showcase.*Test</include>
</includes>
<systemPropertyVariables>
<http.port>8090</http.port>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>11.0.18</version>
<version>8.1.16.v20140903</version>
<configuration>
<stopKey>CTRL+C</stopKey>
<stopPort>8999</stopPort>
<systemProperties>
<systemProperty>
<name>log4j.configuration</name>
<value>file:${basedir}/src/main/resources/log4j.properties</value>
</systemProperty>
<systemProperty>
<name>slf4j</name>
<value>false</value>
</systemProperty>
</systemProperties>
<httpConnector>
<port>8090</port>
</httpConnector>
<scan>10</scan>
<webApp>
<extraClasspath>
${project.build.directory}/extraclasspath/struts2-velocity-tools-view-jakarta.jar,
${project.build.directory}/extraclasspath/struts2-velocity-tools-jsp-jakarta
</extraClasspath>
<contextPath>/struts2-showcase</contextPath>
<descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor>
</webApp>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppSourceDirectory>${basedir}/src/main/webapp/</webAppSourceDirectory>
<webAppConfig>
<contextPath>/struts2-showcase</contextPath>
<descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor>
</webAppConfig>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<!-- stop any previous instance to free up the port -->
<goal>stop</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine}</argLine>
<excludes>
<exclude>it/**</exclude>
<exclude>**/*$*</exclude>
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import java.text.DateFormat;
import java.util.Calendar;
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.showcase.ajax.tree.Category;
//START SNIPPET: treeExampleDynamicJavaSelected
@@ -31,7 +30,7 @@ public class DynamicTreeSelectAction extends ActionSupport {
private long nodeId;
private Category currentCategory;
@StrutsParameter
public void setNodeId(long nodeId) {
this.nodeId = nodeId;
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -75,7 +74,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _favouriteCartoonCharactersKeys;
}
@StrutsParameter
public void setFavouriteCartoonCharacters(List favouriteCartoonCharacters) {
_favouriteCartoonCharactersKeys = favouriteCartoonCharacters;
}
@@ -84,7 +82,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _notFavouriteCartoonCharactersKeys;
}
@StrutsParameter
public void setNotFavouriteCartoonCharacters(List notFavouriteCartoonCharacters) {
_notFavouriteCartoonCharactersKeys = notFavouriteCartoonCharacters;
}
@@ -111,7 +108,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _favouriteCarsKeys;
}
@StrutsParameter
public void setFavouriteCars(List favouriteCars) {
_favouriteCarsKeys = favouriteCars;
}
@@ -120,7 +116,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _notFavouriteCarsKeys;
}
@StrutsParameter
public void setNotFavouriteCars(List notFavouriteCars) {
_notFavouriteCarsKeys = notFavouriteCars;
}
@@ -147,7 +142,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _favouriteMotorcyclesKeys;
}
@StrutsParameter
public void setFavouriteMotorcycles(List favouriteMotorcycles) {
_favouriteMotorcyclesKeys = favouriteMotorcycles;
}
@@ -156,7 +150,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _notFavouriteMotorcyclesKeys;
}
@StrutsParameter
public void setNotFavouriteMotorcycles(List notFavouriteMotorcycles) {
_notFavouriteMotorcyclesKeys = notFavouriteMotorcycles;
}
@@ -183,7 +176,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _favouriteCountriesKeys;
}
@StrutsParameter
public void setFavouriteCountries(List favouriteCountries) {
_favouriteCountriesKeys = favouriteCountries;
}
@@ -192,7 +184,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _notFavouriteCountriesKeys;
}
@StrutsParameter
public void setNotFavouriteCountries(List notFavouriteCountries) {
_notFavouriteCountriesKeys = notFavouriteCountries;
}
@@ -214,7 +205,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _favouriteSportsKeys;
}
@StrutsParameter
public void setFavouriteSports(List favouriteSportsKeys) {
this._favouriteSportsKeys = favouriteSportsKeys;
}
@@ -223,7 +213,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _nonFavouriteSportsKeys;
}
@StrutsParameter
public void setNonFavouriteSports(List notFavouriteSportsKeys) {
this._nonFavouriteSportsKeys = notFavouriteSportsKeys;
}
@@ -233,7 +222,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _prioritisedFavouriteCartoonCharacters;
}
@StrutsParameter
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
}
@@ -242,7 +230,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _prioritisedFavouriteCars;
}
@StrutsParameter
public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) {
_prioritisedFavouriteCars = prioritisedFavouriteCars;
}
@@ -252,7 +239,6 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _prioritisedFavouriteCountries;
}
@StrutsParameter
public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) {
_prioritisedFavouriteCountries = prioritisedFavouriteCountries;
}
@@ -278,13 +264,12 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
return _favouriteCities;
}
@StrutsParameter
public void setFavouriteCities(List favouriteCities) {
this._favouriteCities = favouriteCities;
}
// actions
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
/**
*
@@ -37,7 +36,6 @@ public class LotsOfRichtexteditorAction extends ActionSupport {
return this.description1;
}
@StrutsParameter
public void setDescription1(String description1) {
this.description1 = description1;
}
@@ -47,7 +45,6 @@ public class LotsOfRichtexteditorAction extends ActionSupport {
return this.description2;
}
@StrutsParameter
public void setDescription2(String description2) {
this.description2 = description2;
}
@@ -57,7 +54,6 @@ public class LotsOfRichtexteditorAction extends ActionSupport {
return this.description3;
}
@StrutsParameter
public void setDescription3(String description3) {
this.description3 = description3;
}
@@ -67,12 +63,11 @@ public class LotsOfRichtexteditorAction extends ActionSupport {
return this.description4;
}
@StrutsParameter
public void setDescription4(String description4) {
this.description4 = description4;
}
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -37,7 +36,6 @@ public class MoreSelectsAction extends ActionSupport {
private List _prioritisedFavouriteCars;
private List _prioritisedFavouriteCountries;
private List favouriteNumbers;
private List favouriteCities;
// Cartoon Characters
@@ -76,11 +74,11 @@ public class MoreSelectsAction extends ActionSupport {
return list;
}
public List getPrioritisedFavouriteCartoonCharacters() {
return _prioritisedFavouriteCartoonCharacters;
}
@StrutsParameter
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
}
@@ -89,16 +87,15 @@ public class MoreSelectsAction extends ActionSupport {
return _prioritisedFavouriteCars;
}
@StrutsParameter
public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) {
_prioritisedFavouriteCars = prioritisedFavouriteCars;
}
public List getPrioritisedFavouriteCountries() {
return _prioritisedFavouriteCountries;
}
@StrutsParameter
public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) {
_prioritisedFavouriteCountries = prioritisedFavouriteCountries;
}
@@ -107,7 +104,6 @@ public class MoreSelectsAction extends ActionSupport {
return favouriteNumbers;
}
@StrutsParameter
public void setFavouriteNumbers(List favouriteNumbers) {
this.favouriteNumbers = favouriteNumbers;
}
@@ -128,17 +124,8 @@ public class MoreSelectsAction extends ActionSupport {
return list;
}
public List getFavouriteCities() {
return favouriteCities;
}
@StrutsParameter
public void setFavouriteCities(List favouriteCities) {
this.favouriteCities = favouriteCities;
}
// actions
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.showcase.ajax.tree.Category;
public class ShowAjaxDynamicTreeAction extends ActionSupport {
@@ -35,7 +34,6 @@ public class ShowAjaxDynamicTreeAction extends ActionSupport {
return nodeId;
}
@StrutsParameter
public void setNodeId(int nodeId) {
this.nodeId = nodeId;
}
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.showcase.ajax.tree.Category;
// START SNIPPET: treeExampleDynamicJavaShow
@@ -20,19 +20,13 @@
*/
package org.apache.struts2.showcase;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.Validateable;
import org.apache.struts2.util.ValueStack;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Validateable;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
*/
@@ -95,7 +89,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return leftSideCartoonCharacters;
}
@StrutsParameter
public void setLeftSideCartoonCharacters(List leftSideCartoonCharacters) {
this.leftSideCartoonCharacters = leftSideCartoonCharacters;
}
@@ -105,7 +98,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return rightSideCartoonCharacters;
}
@StrutsParameter
public void setRightSideCartoonCharacters(List rightSideCartoonCharacters) {
this.rightSideCartoonCharacters = rightSideCartoonCharacters;
}
@@ -115,7 +107,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return favouriteVehicalType;
}
@StrutsParameter
public void setFavouriteVehicalType(String favouriteVehicalType) {
this.favouriteVehicalType = favouriteVehicalType;
}
@@ -124,7 +115,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return favouriteVehicalSpecific;
}
@StrutsParameter
public void setFavouriteVehicalSpecific(String favouriteVehicalSpecific) {
this.favouriteVehicalSpecific = favouriteVehicalSpecific;
}
@@ -155,7 +145,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -164,7 +153,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return birthday;
}
@StrutsParameter
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
@@ -173,7 +161,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return bio;
}
@StrutsParameter
public void setBio(String bio) {
this.bio = bio;
}
@@ -182,7 +169,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return favouriteColor;
}
@StrutsParameter
public void setFavouriteColor(String favoriteColor) {
this.favouriteColor = favoriteColor;
}
@@ -191,7 +177,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return friends;
}
@StrutsParameter
public void setFriends(List friends) {
this.friends = friends;
}
@@ -200,7 +185,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return bestFriend;
}
@StrutsParameter
public void setBestFriend(String bestFriend) {
this.bestFriend = bestFriend;
}
@@ -209,7 +193,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return legalAge;
}
@StrutsParameter
public void setLegalAge(boolean legalAge) {
this.legalAge = legalAge;
}
@@ -218,7 +201,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return state;
}
@StrutsParameter
public void setState(String state) {
this.state = state;
}
@@ -227,12 +209,10 @@ public class UITagExample extends ActionSupport implements Validateable {
return region;
}
@StrutsParameter
public void setRegion(String region) {
this.region = region;
}
@StrutsParameter
public void setPicture(File picture) {
this.picture = picture;
}
@@ -241,17 +221,14 @@ public class UITagExample extends ActionSupport implements Validateable {
return this.picture;
}
@StrutsParameter
public void setPictureContentType(String pictureContentType) {
this.pictureContentType = pictureContentType;
}
@StrutsParameter
public void setPictureFileName(String pictureFileName) {
this.pictureFileName = pictureFileName;
}
@StrutsParameter
public void setFavouriteLanguage(String favouriteLanguage) {
this.favouriteLanguage = favouriteLanguage;
}
@@ -260,7 +237,7 @@ public class UITagExample extends ActionSupport implements Validateable {
return favouriteLanguage;
}
@StrutsParameter
public void setThoughts(String thoughts) {
this.thoughts = thoughts;
}
@@ -273,7 +250,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return wakeup;
}
@StrutsParameter
public void setWakeup(Date wakeup) {
this.wakeup = wakeup;
}
@@ -327,7 +303,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return this.description;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof VehicalType)) {
return false;
@@ -336,7 +311,6 @@ public class UITagExample extends ActionSupport implements Validateable {
}
}
@Override
public int hashCode() {
return key.hashCode();
}
@@ -360,7 +334,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return this.description;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof VehicalSpecific)) {
return false;
@@ -369,7 +342,6 @@ public class UITagExample extends ActionSupport implements Validateable {
}
}
@Override
public int hashCode() {
return key.hashCode();
}
@@ -18,10 +18,9 @@
*/
package org.apache.struts2.showcase.action;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.showcase.dao.Dao;
import org.apache.struts2.showcase.model.IdEntity;
@@ -34,62 +33,62 @@ import java.util.Collection;
public abstract class AbstractCRUDAction extends ActionSupport {
private static final Logger log = LogManager.getLogger(AbstractCRUDAction.class);
private static final Logger log = LogManager.getLogger(AbstractCRUDAction.class);
private Collection availableItems;
private String[] toDelete;
private Collection availableItems;
private String[] toDelete;
protected abstract Dao getDao();
protected abstract Dao getDao();
public Collection getAvailableItems() {
return availableItems;
}
public String[] getToDelete() {
return toDelete;
}
public Collection getAvailableItems() {
return availableItems;
}
@StrutsParameter
public void setToDelete(String[] toDelete) {
this.toDelete = toDelete;
}
public String[] getToDelete() {
return toDelete;
}
public String list() throws Exception {
this.availableItems = getDao().findAll();
if (log.isDebugEnabled()) {
log.debug("AbstractCRUDAction - [list]: " + (availableItems != null ? "" + availableItems.size() : "no") + " items found");
}
return execute();
}
public void setToDelete(String[] toDelete) {
this.toDelete = toDelete;
}
public String delete() throws Exception {
if (toDelete != null) {
int count = 0;
for (String s : toDelete) {
count = count + getDao().delete(s);
}
if (log.isDebugEnabled()) {
log.debug("AbstractCRUDAction - [delete]: {} items deleted.", count);
}
}
return SUCCESS;
}
public String list() throws Exception {
this.availableItems = getDao().findAll();
if (log.isDebugEnabled()) {
log.debug("AbstractCRUDAction - [list]: " + (availableItems != null ? "" + availableItems.size() : "no") + " items found");
}
return execute();
}
/**
* Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle.
*
* @param tryId The id to try to get persistent object for
* @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent
* object for
* @return The persistent object, if found. <tt>null</tt> otherwise.
*/
protected IdEntity fetch(Serializable tryId, IdEntity tryObject) {
IdEntity result = null;
if (tryId != null) {
result = getDao().get(tryId);
} else if (tryObject != null) {
result = getDao().get(tryObject.getId());
}
return result;
}
public String delete() throws Exception {
if (toDelete != null) {
int count = 0;
for (int i = 0, j = toDelete.length; i < j; i++) {
count = count + getDao().delete(toDelete[i]);
}
if (log.isDebugEnabled()) {
log.debug("AbstractCRUDAction - [delete]: " + count + " items deleted.");
}
}
return SUCCESS;
}
/**
* Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle.
*
* @param tryId The id to try to get persistent object for
* @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent
* object for
* @return The persistent object, if found. <tt>null</tt> otherwise.
*/
protected IdEntity fetch(Serializable tryId, IdEntity tryObject) {
IdEntity result = null;
if (tryId != null) {
result = getDao().get(tryId);
} else if (tryObject != null) {
result = getDao().get(tryObject.getId());
}
return result;
}
}
@@ -18,10 +18,9 @@
*/
package org.apache.struts2.showcase.action;
import org.apache.struts2.Preparable;
import com.opensymphony.xwork2.Preparable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.showcase.application.TestDataProvider;
import org.apache.struts2.showcase.dao.Dao;
import org.apache.struts2.showcase.dao.EmployeeDao;
@@ -53,7 +52,7 @@ public class EmployeeAction extends AbstractCRUDAction implements Preparable {
public String execute() throws Exception {
if (getCurrentEmployee() != null && getCurrentEmployee().getOtherSkills() != null) {
setSelectedSkills(new ArrayList<>());
setSelectedSkills(new ArrayList<String>());
Iterator it = getCurrentEmployee().getOtherSkills().iterator();
while (it.hasNext()) {
getSelectedSkills().add(((Skill) it.next()).getName());
@@ -74,12 +73,10 @@ public class EmployeeAction extends AbstractCRUDAction implements Preparable {
return empId;
}
@StrutsParameter
public void setEmpId(Long empId) {
this.empId = empId;
}
@StrutsParameter(depth = 2)
public Employee getCurrentEmployee() {
return currentEmployee;
}
@@ -18,13 +18,9 @@
*/
package org.apache.struts2.showcase.action;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public class ExampleAction extends ActionSupport {
public static final String CONSTANT = "Struts Rocks!";
@@ -50,7 +46,7 @@ public class ExampleAction extends ActionSupport {
}
public Map<String, Book> getBooks() {
Map<String, Book> books = new HashMap<>();
Map<String, Book> books = new HashMap<String, Book>();
books.put("Iliad", new Book("Iliad", "Homer"));
books.put("The Republic", new Book("The Replublic", "Plato"));
books.put("Thus Spake Zarathustra", new Book("Thus Spake Zarathustra",
@@ -83,4 +79,4 @@ class Book {
public void setAuthor(String author) {
this.author = author;
}
}
}
@@ -18,16 +18,11 @@
*/
package org.apache.struts2.showcase.action;
import org.apache.struts2.action.Action;
import org.apache.struts2.interceptor.annotations.After;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.interceptor.annotations.After;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.net.URL;
/**
@@ -67,7 +62,6 @@ public class JSPEvalAction extends ExampleAction {
}
}
@StrutsParameter
public void setJsp(String jsp) {
this.jsp = jsp;
}
@@ -1,133 +0,0 @@
/*
* 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.showcase.action;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.showcase.model.MyDto;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
/**
* This class supports {@link com.atlassian.confluence.stateless.webdriver.selenium3.security.StrutsParametersTest}
* which prevents critical security regressions. Do NOT modify without understanding the motivation behind the tests and
* the implications of any changes.
*/
public class ParamsAnnotationAction extends ActionSupport {
@StrutsParameter
public String varToPrint;
public String publicField = "no";
@StrutsParameter
public String publicFieldAnnotated = "no";
private String privateField = "no";
public int[] publicArray = new int[]{0};
@StrutsParameter(depth = 1)
public int[] publicArrayAnnotated = new int[]{0};
public List<String> publicList = new ArrayList<>(singletonList("no"));
@StrutsParameter(depth = 1)
public List<String> publicListAnnotated = new ArrayList<>(singletonList("no"));
private List<String> privateList = new ArrayList<>(singletonList("no"));
public Map<String, String> publicMap = new HashMap<>(singletonMap("key", "no"));
@StrutsParameter(depth = 1)
public Map<String, String> publicMapAnnotated = new HashMap<>(singletonMap("key", "no"));
public MyDto publicMyDto = new MyDto();
@StrutsParameter(depth = 2)
public MyDto publicMyDtoAnnotated = new MyDto();
@StrutsParameter(depth = 1)
public MyDto publicMyDtoAnnotatedDepthOne = new MyDto();
private MyDto privateMyDto = new MyDto();
public void setPrivateFieldMethod(String privateField) {
this.privateField = privateField;
}
@StrutsParameter
public void setPrivateFieldMethodAnnotated(String privateField) {
this.privateField = privateField;
}
public List<String> getPrivateListMethod() {
return privateList;
}
@StrutsParameter(depth = 1)
public List<String> getPrivateListMethodAnnotated() {
return privateList;
}
public MyDto getUnsafeMethodMyDto() {
return privateMyDto;
}
@StrutsParameter(depth = 2)
public MyDto getSafeMethodMyDto() {
return privateMyDto;
}
@StrutsParameter(depth = 1)
public MyDto getSafeMethodMyDtoDepthOne() {
return privateMyDto;
}
public String renderVarToPrint() throws ReflectiveOperationException {
if (varToPrint == null) {
return "null";
}
Field field = this.getClass().getDeclaredField(varToPrint);
field.setAccessible(true);
try {
return String.format("%s{%s}", varToPrint,
field.getType().isArray() ? stringifyArray(field.get(this)) : field.get(this));
} finally {
field.setAccessible(false);
}
}
private String stringifyArray(Object array) {
switch (array.getClass().getComponentType().getName()) {
case "int":
return Arrays.toString((int[]) array);
default:
return "TODO";
}
}
}
@@ -18,10 +18,9 @@
*/
package org.apache.struts2.showcase.action;
import org.apache.struts2.Preparable;
import com.opensymphony.xwork2.Preparable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.showcase.dao.Dao;
import org.apache.struts2.showcase.dao.SkillDao;
import org.apache.struts2.showcase.model.Skill;
@@ -46,7 +45,6 @@ public class SkillAction extends AbstractCRUDAction implements Preparable {
*
* @throws Exception thrown if a system level exception occurs.
*/
@Override
public void prepare() throws Exception {
Skill preFetched = (Skill) fetch(getSkillName(), getCurrentSkill());
if (preFetched != null) {
@@ -65,7 +63,6 @@ public class SkillAction extends AbstractCRUDAction implements Preparable {
return skillName;
}
@StrutsParameter
public void setSkillName(String skillName) {
this.skillName = skillName;
}
@@ -74,7 +71,6 @@ public class SkillAction extends AbstractCRUDAction implements Preparable {
return skillDao;
}
@StrutsParameter(depth = 1)
public Skill getCurrentSkill() {
return currentSkill;
}
@@ -18,8 +18,7 @@
*/
package org.apache.struts2.showcase.actionchaining;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
public class ActionChain1 extends ActionSupport {
@@ -27,7 +26,6 @@ public class ActionChain1 extends ActionSupport {
private String actionChain1Property1 = "Property Set In Action Chain 1";
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -36,7 +34,6 @@ public class ActionChain1 extends ActionSupport {
return actionChain1Property1;
}
@StrutsParameter
public void setActionChain1Property1(String actionChain1Property1) {
this.actionChain1Property1 = actionChain1Property1;
}
@@ -18,8 +18,7 @@
*/
package org.apache.struts2.showcase.actionchaining;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
public class ActionChain2 extends ActionSupport {
@@ -28,7 +27,6 @@ public class ActionChain2 extends ActionSupport {
private String actionChain1Property1;
private String actionChain2Property1 = "Property Set in Action Chain 2";
@Override
public String execute() throws Exception {
return SUCCESS;
}
@@ -37,16 +35,15 @@ public class ActionChain2 extends ActionSupport {
return actionChain1Property1;
}
@StrutsParameter
public void setActionChain1Property1(String actionChain1Property1) {
this.actionChain1Property1 = actionChain1Property1;
}
public String getActionChain2Property1() {
return actionChain2Property1;
}
@StrutsParameter
public void setActionChain2Property1(String actionChain2Property1) {
this.actionChain2Property1 = actionChain2Property1;
}
@@ -18,8 +18,7 @@
*/
package org.apache.struts2.showcase.actionchaining;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
public class ActionChain3 extends ActionSupport {
@@ -29,7 +28,7 @@ public class ActionChain3 extends ActionSupport {
private String actionChain2Property1;
private String actionChain3Property1 = "Property set in Action Chain 3";
@Override
public String execute() throws Exception {
return SUCCESS;
}
@@ -38,25 +37,24 @@ public class ActionChain3 extends ActionSupport {
return actionChain1Property1;
}
@StrutsParameter
public void setActionChain1Property1(String actionChain1Property1) {
this.actionChain1Property1 = actionChain1Property1;
}
public String getActionChain2Property1() {
return actionChain2Property1;
}
@StrutsParameter
public void setActionChain2Property1(String actionChain2Property1) {
this.actionChain2Property1 = actionChain2Property1;
}
public String getActionChain3Property1() {
return actionChain3Property1;
}
@StrutsParameter
public void setActionChain3Property1(String actionChain3Property1) {
this.actionChain3Property1 = actionChain3Property1;
}
@@ -20,11 +20,11 @@
*/
package org.apache.struts2.showcase.ajax;
import org.apache.struts2.action.Action;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.Action;
import java.io.Serializable;
public class AjaxTestAction implements Action, Serializable {
private static int counter = 0;
@@ -46,7 +46,6 @@ public class AjaxTestAction implements Action, Serializable {
return data;
}
@StrutsParameter
public void setData(String data) {
this.data = data;
}
@@ -20,19 +20,17 @@
*/
package org.apache.struts2.showcase.ajax;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;
import java.util.List;
public class AutocompleterExampleAction extends ActionSupport {
private String select;
private final List<String> options = new ArrayList<>();
private List<String> options = new ArrayList<String>();
private static final long serialVersionUID = -8481638176160014396L;
@Override
public String execute() throws Exception {
if ("fruits".equals(select)) {
options.add("apple");
@@ -51,7 +49,6 @@ public class AutocompleterExampleAction extends ActionSupport {
return select;
}
@StrutsParameter
public void setSelect(String select) {
this.select = select;
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.ajax;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -52,7 +51,6 @@ public class Example4ShowPanelAction extends ActionSupport {
return gender;
}
@StrutsParameter
public void setGender(String gender) {
this.gender = gender;
}
@@ -61,7 +59,6 @@ public class Example4ShowPanelAction extends ActionSupport {
return name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.ajax;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
public class Example5Action extends ActionSupport {
@@ -38,7 +37,6 @@ public class Example5Action extends ActionSupport {
return name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -47,7 +45,6 @@ public class Example5Action extends ActionSupport {
return age;
}
@StrutsParameter
public void setAge(Integer age) {
this.age = age;
}
@@ -46,7 +46,8 @@ public class Category {
new Category(15, "Dojo"),
new Category(16, "Prototype"),
new Category(17, "Scriptaculous"),
new Category(18, "OpenRico")));
new Category(18, "OpenRico"),
new Category(19, "DWR")));
}
public static Category getById(long id) {
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.ajax.tree;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
/**
*/
@@ -29,7 +28,6 @@ public class GetCategory extends ActionSupport {
private long catId;
private Category category;
@Override
public String execute() throws Exception {
if (catId < 1) {
// force the root
@@ -41,7 +39,6 @@ public class GetCategory extends ActionSupport {
return SUCCESS;
}
@StrutsParameter
public void setCatId(long catId) {
this.catId = catId;
}
@@ -24,8 +24,6 @@ package org.apache.struts2.showcase.ajax.tree;
/**
*/
public class Toggle extends GetCategory {
@Override
public String execute() throws Exception {
super.execute();
@@ -31,10 +31,9 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.Serial;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* TestDataProvider.
@@ -42,76 +41,74 @@ import java.util.List;
@Service
public class TestDataProvider implements Serializable, InitializingBean {
@Serial
private static final long serialVersionUID = 1L;
private static final Logger log = LogManager.getLogger(TestDataProvider.class);
private static final long serialVersionUID = 1L;
private static final Logger log = LogManager.getLogger(TestDataProvider.class);
public static final String[] POSITIONS = {
"Developer",
"System Architect",
"Sales Manager",
"CEO"
};
public static final String[] POSITIONS = {
"Developer",
"System Architect",
"Sales Manager",
"CEO"
};
public static final String[] LEVELS = {
"Junior",
"Senior",
"Master"
};
public static final String[] LEVELS = {
"Junior",
"Senior",
"Master"
};
private static final Skill[] TEST_SKILLS = {
new Skill("WW-SEN", "Struts Senior Developer"),
new Skill("WW-JUN", "Struts Junior Developer"),
new Skill("SPRING-DEV", "Spring Developer")
};
private static final Skill[] TEST_SKILLS = {
new Skill("WW-SEN", "Struts Senior Developer"),
new Skill("WW-JUN", "Struts Junior Developer"),
new Skill("SPRING-DEV", "Spring Developer")
};
public static final Employee[] TEST_EMPLOYEES = {
new Employee(1L, "Alan", "Smithee", new Date(), 2000f, true, POSITIONS[0],
TEST_SKILLS[0], null, "alan", LEVELS[0], "Nice guy"),
new Employee(2L, "Robert", "Robson", new Date(), 10000f, false, POSITIONS[1],
TEST_SKILLS[1], List.of(TEST_SKILLS).subList(1, TEST_SKILLS.length), "rob", LEVELS[1], "Smart guy")
};
public static final Employee[] TEST_EMPLOYEES = {
new Employee(new Long(1), "Alan", "Smithee", new Date(), new Float(2000f), true, POSITIONS[0],
TEST_SKILLS[0], null, "alan", LEVELS[0], "Nice guy"),
new Employee(new Long(2), "Robert", "Robson", new Date(), new Float(10000f), false, POSITIONS[1],
TEST_SKILLS[1], Arrays.asList(TEST_SKILLS).subList(1, TEST_SKILLS.length), "rob", LEVELS[1], "Smart guy")
};
@Autowired
private SkillDao skillDao;
@Autowired
private SkillDao skillDao;
@Autowired
private EmployeeDao employeeDao;
@Autowired
private EmployeeDao employeeDao;
protected void addTestSkills() {
try {
for (Skill testSkill : TEST_SKILLS) {
skillDao.merge(testSkill);
}
if (log.isInfoEnabled()) {
log.info("TestDataProvider - [addTestSkills]: Added test skill data.");
}
} catch (StorageException e) {
log.error("TestDataProvider - [addTestSkills]: Exception caught: {}", e.getMessage());
}
}
protected void addTestSkills() {
try {
for (int i = 0, j = TEST_SKILLS.length; i < j; i++) {
skillDao.merge(TEST_SKILLS[i]);
}
if (log.isInfoEnabled()) {
log.info("TestDataProvider - [addTestSkills]: Added test skill data.");
}
} catch (StorageException e) {
log.error("TestDataProvider - [addTestSkills]: Exception catched: " + e.getMessage());
}
}
protected void addTestEmployees() {
try {
for (Employee testEmployee : TEST_EMPLOYEES) {
employeeDao.merge(testEmployee);
}
if (log.isInfoEnabled()) {
log.info("TestDataProvider - [addTestEmployees]: Added test employee data.");
}
} catch (StorageException e) {
log.error("TestDataProvider - [addTestEmployees]: Exception caught: {}", e.getMessage());
}
}
protected void addTestEmployees() {
try {
for (int i = 0, j = TEST_EMPLOYEES.length; i < j; i++) {
employeeDao.merge(TEST_EMPLOYEES[i]);
}
if (log.isInfoEnabled()) {
log.info("TestDataProvider - [addTestEmployees]: Added test employee data.");
}
} catch (StorageException e) {
log.error("TestDataProvider - [addTestEmployees]: Exception catched: " + e.getMessage());
}
}
protected void addTestData() {
addTestSkills();
addTestEmployees();
}
protected void addTestData() {
addTestSkills();
addTestEmployees();
}
@Override
public void afterPropertiesSet() throws Exception {
addTestData();
}
public void afterPropertiesSet() throws Exception {
addTestData();
}
}
@@ -1,53 +0,0 @@
/*
* 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.showcase.async;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.FilterConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
* Filters async actions directly to Struts servlet
*/
public class AsyncFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
String requestURI = ((HttpServletRequest) servletRequest).getRequestURI();
if (!requestURI.contains("/async/receiveNewMessages")) {
filterChain.doFilter(servletRequest, servletResponse); // Just continue chain.
} else {
servletRequest.getRequestDispatcher("/async/receiveNewMessages").forward(servletRequest, servletResponse);
}
}
@Override
public void destroy() {
}
}
@@ -1,68 +0,0 @@
/*
* 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.showcase.async;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
/**
* Example to illustrate the <code>async</code> plugin.
*/
public class ChatRoomAction extends ActionSupport {
private String message;
private Integer lastIndex;
private List<String> newMessages;
private static final List<String> messages = new ArrayList<>();
@StrutsParameter
public void setMessage(String message) {
this.message = message;
}
@StrutsParameter
public void setLastIndex(Integer lastIndex) {
this.lastIndex = lastIndex;
}
public List<String> getNewMessages() {
return newMessages;
}
public Callable<String> receiveNewMessages() throws Exception {
return () -> {
while (lastIndex >= messages.size()) {
Thread.sleep(3000);
}
newMessages = messages.subList(lastIndex, messages.size());
return SUCCESS;
};
}
public String sendMessage() {
synchronized (messages) {
messages.add(message);
}
return SUCCESS;
}
}
@@ -21,32 +21,31 @@
package org.apache.struts2.showcase.chat;
import org.apache.struts2.action.Action;
import org.apache.struts2.ActionContext;
import org.apache.struts2.ActionInvocation;
import org.apache.struts2.interceptor.AbstractInterceptor;
import org.apache.logging.log4j.LogManager;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.logging.log4j.Logger;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.struts2.dispatcher.SessionMap;
public class ChatAuthenticationInterceptor extends AbstractInterceptor {
private static final long serialVersionUID = 1L;
private static final Logger LOG = LogManager.getLogger(ChatAuthenticationInterceptor.class);
public static final String USER_SESSION_KEY = "chatUserSessionKey";
private static final long serialVersionUID = 1L;
private static final Logger LOG = LogManager.getLogger(ChatAuthenticationInterceptor.class);
public static final String USER_SESSION_KEY = "chatUserSessionKey";
public String intercept(ActionInvocation invocation) throws Exception {
public String intercept(ActionInvocation invocation) throws Exception {
LOG.debug("Authenticating chat user");
LOG.debug("Authenticating chat user");
Map<String, Object> session = ActionContext.getContext().getSession();
User user = (User) session.get(USER_SESSION_KEY);
SessionMap session = (SessionMap) ActionContext.getContext().get(ActionContext.SESSION);
User user = (User) session.get(USER_SESSION_KEY);
if (user == null) {
return Action.LOGIN;
}
return invocation.invoke();
}
if (user == null) {
return Action.LOGIN;
}
return invocation.invoke();
}
}
@@ -20,35 +20,35 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.action.Action;
import org.apache.struts2.ActionContext;
import org.apache.struts2.ActionInvocation;
import org.apache.struts2.interceptor.AbstractInterceptor;
import org.apache.logging.log4j.LogManager;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import java.util.Map;
import javax.servlet.http.HttpSession;
/**
* Authenticate showcase chat example, make sure everyone have a username.
*/
public class ChatInterceptor extends AbstractInterceptor {
private static final Logger LOG = LogManager.getLogger(ChatInterceptor.class);
private static final Logger LOG = LogManager.getLogger(ChatInterceptor.class);
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public static final String CHAT_USER_SESSION_KEY = "ChatUserSessionKey";
public static final String CHAT_USER_SESSION_KEY = "ChatUserSessionKey";
public String intercept(ActionInvocation invocation) throws Exception {
Map<String, Object> session = ActionContext.getContext().getSession();
User chatUser = (User) session.get(CHAT_USER_SESSION_KEY);
if (chatUser == null) {
LOG.debug("Chat user not logged in");
return Action.LOGIN;
}
return invocation.invoke();
}
public String intercept(ActionInvocation invocation) throws Exception {
HttpSession session = (HttpSession) ActionContext.getContext().get(ActionContext.SESSION);
User chatUser = (User) session.getAttribute(CHAT_USER_SESSION_KEY);
if (chatUser == null) {
LOG.debug("Chat user not logged in");
return Action.LOGIN;
}
return invocation.invoke();
}
}
@@ -20,9 +20,8 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
@@ -31,7 +30,7 @@ public class ChatLoginAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private ChatService chatService;
private Map<String, Object> session;
private Map session;
private String name;
@@ -43,7 +42,6 @@ public class ChatLoginAction extends ActionSupport implements SessionAware {
return this.name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -62,8 +60,8 @@ public class ChatLoginAction extends ActionSupport implements SessionAware {
}
@Override
public void withSession(Map<String, Object> session) {
this.session = session;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
}
@@ -20,19 +20,18 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
import org.apache.struts2.action.SessionAware;
public class ChatLogoutAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private ChatService chatService;
private Map<String, Object> session;
private Map session;
public ChatLogoutAction(ChatService chatService) {
@@ -51,8 +50,8 @@ public class ChatLogoutAction extends ActionSupport implements SessionAware {
}
@Override
public void withSession(Map<String, Object> session) {
this.session = session;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
}
@@ -25,9 +25,9 @@ import org.apache.logging.log4j.LogManager;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.HttpSessionEvent;
import jakarta.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
public class ChatSessionListener implements HttpSessionListener {
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
public class CrudRoomAction extends ActionSupport {
@@ -37,7 +36,6 @@ public class CrudRoomAction extends ActionSupport {
return description;
}
@StrutsParameter
public void setDescription(String description) {
this.description = description;
}
@@ -46,7 +44,6 @@ public class CrudRoomAction extends ActionSupport {
return name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -20,8 +20,6 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.conversion.impl.XWorkConverter;
import org.apache.struts2.inject.Inject;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.struts2.util.StrutsTypeConverter;
@@ -35,13 +33,6 @@ public class DateConverter extends StrutsTypeConverter {
private static final Logger LOG = LogManager.getLogger(DateConverter.class);
private XWorkConverter fallbackConverter;
@Inject
public void setXWorkConverter(XWorkConverter fallbackConverter) {
this.fallbackConverter = fallbackConverter;
}
public Object convertFromString(Map context, String[] values, Class toClass) {
if (values.length > 0 && values[0] != null && values[0].trim().length() > 0) {
@@ -49,8 +40,7 @@ public class DateConverter extends StrutsTypeConverter {
try {
return sdf.parse(values[0]);
} catch (ParseException e) {
LOG.warn("error converting value [" + values[0] + "] to Date. Trying fallback converter.");
return this.fallbackConverter.convertValue(context, values[0], toClass);
LOG.error("error converting value [" + values[0] + "] to Date ", e);
}
}
return null;
@@ -20,9 +20,8 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
@@ -31,14 +30,13 @@ public class EnterRoomAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private ChatService chatService;
private Map<String, Object> session;
private Map session;
private String roomName;
public String getRoomName() {
return this.roomName;
}
@StrutsParameter
public void setRoomName(String roomName) {
this.roomName = roomName;
}
@@ -58,9 +56,10 @@ public class EnterRoomAction extends ActionSupport implements SessionAware {
return SUCCESS;
}
@Override
public void withSession(Map<String, Object> session) {
this.session = session;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
}
@@ -20,9 +20,8 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
@@ -32,13 +31,12 @@ public class ExitRoomAction extends ActionSupport implements SessionAware {
private String roomName;
private Map<String, Object> session;
private Map session;
public String getRoomName() {
return roomName;
}
@StrutsParameter
public void setRoomName(String roomName) {
this.roomName = roomName;
}
@@ -56,9 +54,9 @@ public class ExitRoomAction extends ActionSupport implements SessionAware {
return SUCCESS;
}
@Override
public void withSession(Map<String, Object> session) {
this.session = session;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;
import java.util.List;
@@ -31,14 +30,13 @@ public class MessagesAvailableInRoomAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private String roomName;
private final ChatService chatService;
private List<ChatMessage> messagesAvailableInRoom = new ArrayList<>();
private ChatService chatService;
private List<ChatMessage> messagesAvailableInRoom = new ArrayList<ChatMessage>();
public String getRoomName() {
return this.roomName;
}
@StrutsParameter
public void setRoomName(String roomName) {
this.roomName = roomName;
}
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;
import java.util.List;
@@ -20,9 +20,8 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
@@ -30,11 +29,11 @@ public class SendMessageToRoomAction extends ActionSupport implements SessionAwa
private static final long serialVersionUID = 1L;
private final ChatService chatService;
private ChatService chatService;
private String roomName;
private String message;
private Map<String, Object> session;
private Map session;
public SendMessageToRoomAction(ChatService chatService) {
@@ -45,7 +44,6 @@ public class SendMessageToRoomAction extends ActionSupport implements SessionAwa
return this.roomName;
}
@StrutsParameter
public void setRoomName(String roomName) {
this.roomName = roomName;
}
@@ -54,12 +52,11 @@ public class SendMessageToRoomAction extends ActionSupport implements SessionAwa
return this.message;
}
@StrutsParameter
public void setMessage(String message) {
this.message = message;
}
@Override
public String execute() throws Exception {
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
try {
@@ -70,10 +67,9 @@ public class SendMessageToRoomAction extends ActionSupport implements SessionAwa
return SUCCESS;
}
@Override
public void withSession(Map<String, Object> session) {
this.session = session;
}
public void setSession(Map session) {
this.session = session;
}
}
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;
import java.util.List;
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;
import java.util.List;
@@ -30,8 +29,8 @@ public class UsersAvailableInRoomAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private final ChatService chatService;
private List<User> usersAvailableInRoom = new ArrayList<>();
private ChatService chatService;
private List<User> usersAvailableInRoom = new ArrayList<User>();
private String roomName;
@@ -44,7 +43,6 @@ public class UsersAvailableInRoomAction extends ActionSupport {
return this.roomName;
}
@StrutsParameter
public void setRoomName(String roomName) {
this.roomName = roomName;
}
@@ -53,7 +51,6 @@ public class UsersAvailableInRoomAction extends ActionSupport {
return usersAvailableInRoom;
}
@Override
public String execute() throws Exception {
try {
usersAvailableInRoom = chatService.getUsersAvailableInRoom(roomName);
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.conversion;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -31,7 +30,7 @@ import java.util.Set;
*/
public class AddressAction extends ActionSupport {
private Set<Address> addresses = new LinkedHashSet<>();
private Set<Address> addresses = new LinkedHashSet<Address>();
public String input() throws Exception {
return SUCCESS;
@@ -42,7 +41,6 @@ public class AddressAction extends ActionSupport {
return SUCCESS;
}
@StrutsParameter(depth = 2)
public Set<Address> getAddresses() {
return addresses;
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.conversion;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Arrays;
import java.util.LinkedList;
@@ -34,7 +33,7 @@ public class OperationsEnumAction extends ActionSupport {
private static final long serialVersionUID = -2229489704988870318L;
private List<OperationsEnum> selectedOperations = new LinkedList<>();
private List<OperationsEnum> selectedOperations = new LinkedList<OperationsEnum>();
public String input() throws Exception {
return SUCCESS;
@@ -48,11 +47,11 @@ public class OperationsEnumAction extends ActionSupport {
return this.selectedOperations;
}
@StrutsParameter
public void setSelectedOperations(List<OperationsEnum> selectedOperations) {
this.selectedOperations = selectedOperations;
}
public List<OperationsEnum> getAvailableOperations() {
return Arrays.asList(OperationsEnum.values());
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.conversion;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import java.util.List;
@@ -37,7 +36,6 @@ public class PersonAction extends ActionSupport {
return SUCCESS;
}
@StrutsParameter(depth = 2)
public List<Person> getPersons() {
return persons;
}
@@ -20,9 +20,8 @@
*/
package org.apache.struts2.showcase.filedownload;
import org.apache.struts2.action.Action;
import com.opensymphony.xwork2.Action;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.io.InputStream;
@@ -39,7 +38,6 @@ public class FileDownloadAction implements Action {
return SUCCESS;
}
@StrutsParameter
public void setInputPath(String value) {
inputPath = sanitizeInputPath(value);
}
@@ -20,76 +20,68 @@
*/
package org.apache.struts2.showcase.fileupload;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.UploadedFilesAware;
import org.apache.struts2.dispatcher.multipart.UploadedFile;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import java.util.List;
import java.io.File;
/**
* Show case File Upload example's action. <code>FileUploadAction</code>
*/
public class FileUploadAction extends ActionSupport implements UploadedFilesAware {
public class FileUploadAction extends ActionSupport {
private String contentType;
private UploadedFile uploadedFile;
private String fileName;
private String caption;
private String originalName;
private String inputName;
private static final long serialVersionUID = 5156288255337069381L;
public String input() throws Exception {
return SUCCESS;
}
private String contentType;
private File upload;
private String fileName;
private String caption;
public String upload() throws Exception {
return SUCCESS;
}
public String input() throws Exception {
return SUCCESS;
}
public String getContentType() {
return contentType;
}
public String upload() throws Exception {
return SUCCESS;
}
public String getFileName() {
return fileName;
}
// since we are using <s:file name="upload" .../> the file name will be
// obtained through getter/setter of <file-tag-name>FileName
public String getUploadFileName() {
return fileName;
}
public String getOriginalName() {
return originalName;
}
public void setUploadFileName(String fileName) {
this.fileName = fileName;
}
public String getInputName() {
return inputName;
}
public Object getUploadedFile() {
return uploadedFile.getContent();
}
// since we are using <s:file name="upload" ... /> the content type will be
// obtained through getter/setter of <file-tag-name>ContentType
public String getUploadContentType() {
return contentType;
}
public String getCaption() {
return caption;
}
public void setUploadContentType(String contentType) {
this.contentType = contentType;
}
@StrutsParameter
public void setCaption(String caption) {
this.caption = caption;
}
public long getUploadSize() {
if (uploadedFile != null) {
return uploadedFile.length();
} else {
return 0;
}
}
// since we are using <s:file name="upload" ... /> the File itself will be
// obtained through getter/setter of <file-tag-name>
public File getUpload() {
return upload;
}
@Override
public void withUploadedFiles(List<UploadedFile> uploadedFiles) {
this.uploadedFile = uploadedFiles.get(0);
this.fileName = uploadedFile.getName();
this.contentType = uploadedFile.getContentType();
this.originalName = uploadedFile.getOriginalName();
this.inputName = uploadedFile.getInputName();
}
public void setUpload(File upload) {
this.upload = upload;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
}
@@ -21,56 +21,62 @@
// START SNIPPET: entire-file
package org.apache.struts2.showcase.fileupload;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.UploadedFilesAware;
import org.apache.struts2.dispatcher.multipart.UploadedFile;
import com.opensymphony.xwork2.ActionSupport;
import java.util.List;
import java.io.File;
/**
* Showcase action - multiple file upload using array.
* Showcase action - mutiple file upload using array.
*
* @version $Date$ $Id$
*/
public class MultipleFileUploadUsingArrayAction extends ActionSupport implements UploadedFilesAware {
public class MultipleFileUploadUsingArrayAction extends ActionSupport {
private List<UploadedFile> uploadedFiles;
private File[] uploads;
private String[] uploadFileNames;
private String[] uploadContentTypes;
public List<UploadedFile> getUpload() {
return this.uploadedFiles;
}
public String upload() throws Exception {
System.out.println("\n\n upload2");
System.out.println("files:");
for (UploadedFile u : uploadedFiles) {
System.out.println("*** " + u + "\t" + u.length());
}
System.out.println("filenames:");
for (String n : getUploadFileNames()) {
System.out.println("*** " + n);
}
System.out.println("content types:");
for (String c : getUploadContentTypes()) {
System.out.println("*** " + c);
}
System.out.println("\n\n");
return SUCCESS;
}
public String upload() throws Exception {
System.out.println("\n\n upload2");
System.out.println("files:");
for (File u : uploads) {
System.out.println("*** " + u + "\t" + u.length());
}
System.out.println("filenames:");
for (String n : uploadFileNames) {
System.out.println("*** " + n);
}
System.out.println("content types:");
for (String c : uploadContentTypes) {
System.out.println("*** " + c);
}
System.out.println("\n\n");
return SUCCESS;
}
@Override
public void withUploadedFiles(List<UploadedFile> uploadedFiles) {
this.uploadedFiles = uploadedFiles;
}
public File[] getUpload() {
return this.uploads;
}
private String[] getUploadFileNames() {
return this.uploadedFiles.stream()
.map(UploadedFile::getOriginalName)
.toArray(String[]::new);
}
public void setUpload(File[] upload) {
this.uploads = upload;
}
private String[] getUploadContentTypes() {
return this.uploadedFiles.stream()
.map(UploadedFile::getContentType)
.toArray(String[]::new);
}
public String[] getUploadFileName() {
return this.uploadFileNames;
}
public void setUploadFileName(String[] uploadFileName) {
this.uploadFileNames = uploadFileName;
}
public String[] getUploadContentType() {
return this.uploadContentTypes;
}
public void setUploadContentType(String[] uploadContentType) {
this.uploadContentTypes = uploadContentType;
}
}
// END SNIPPET: entire-file
@@ -21,57 +21,65 @@
// START SNIPPET: entire-file
package org.apache.struts2.showcase.fileupload;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.UploadedFilesAware;
import org.apache.struts2.dispatcher.multipart.UploadedFile;
import com.opensymphony.xwork2.ActionSupport;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* Showcase action - multiple file upload using List
*
* @version $Date$ $Id$
*/
public class MultipleFileUploadUsingListAction extends ActionSupport implements UploadedFilesAware {
public class MultipleFileUploadUsingListAction extends ActionSupport {
private List<UploadedFile> uploads = new ArrayList<>();
private List<File> uploads = new ArrayList<>();
private List<String> uploadFileNames = new ArrayList<>();
private List<String> uploadContentTypes = new ArrayList<>();
public List<UploadedFile> getUpload() {
return this.uploads;
}
@Override
public void withUploadedFiles(List<UploadedFile> uploads) {
this.uploads = uploads;
}
public List<File> getUpload() {
return this.uploads;
}
private List<String> getUploadFileNames() {
return this.uploads.stream()
.map(UploadedFile::getOriginalName)
.collect(Collectors.toList());
}
public void setUpload(List<File> uploads) {
this.uploads = uploads;
}
private List<String> getUploadContentTypes() {
return this.uploads.stream()
.map(UploadedFile::getContentType)
.collect(Collectors.toList());
}
public List<String> getUploadFileName() {
return this.uploadFileNames;
}
public String upload() throws Exception {
System.out.println("\n\n upload1");
System.out.println("files:");
for (UploadedFile u : uploads) {
System.out.println("*** " + u + "\t" + u.length());
}
System.out.println("filenames:");
for (String n : getUploadFileNames()) {
System.out.println("*** " + n);
}
System.out.println("content types:");
for (String c : getUploadContentTypes()) {
System.out.println("*** " + c);
}
System.out.println("\n\n");
return SUCCESS;
}
}
public void setUploadFileName(List<String> uploadFileNames) {
this.uploadFileNames = uploadFileNames;
}
public List<String> getUploadContentType() {
return this.uploadContentTypes;
}
public void setUploadContentType(List<String> contentTypes) {
this.uploadContentTypes = contentTypes;
}
public String upload() throws Exception {
System.out.println("\n\n upload1");
System.out.println("files:");
for (File u : uploads) {
System.out.println("*** " + u + "\t" + u.length());
}
System.out.println("filenames:");
for (String n : uploadFileNames) {
System.out.println("*** " + n);
}
System.out.println("content types:");
for (String c : uploadContentTypes) {
System.out.println("*** " + c);
}
System.out.println("\n\n");
return SUCCESS;
}
}
// END SNIPPET: entire-file
@@ -20,12 +20,12 @@
*/
package org.apache.struts2.showcase.freemarker;
import org.apache.struts2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.views.freemarker.FreemarkerManager;
import org.apache.struts2.views.freemarker.ScopesHashModel;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* <p>
@@ -20,9 +20,8 @@
*/
package org.apache.struts2.showcase.freemarker;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.Preparable;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;
import java.text.DateFormatSymbols;
@@ -35,7 +34,6 @@ public class StandardTagsAction extends ActionSupport implements Preparable {
private String[] gender;
private String[] months;
@Override
public void prepare() {
months = new DateFormatSymbols().getMonths();
name = StandardTagsAction.class.getName().substring(StandardTagsAction.class.getName().lastIndexOf(".") + 1);
@@ -46,7 +44,6 @@ public class StandardTagsAction extends ActionSupport implements Preparable {
return name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -55,16 +52,15 @@ public class StandardTagsAction extends ActionSupport implements Preparable {
return months;
}
@StrutsParameter
public void setMonths(String[] months) {
this.months = months;
}
public String[] getGender() {
return gender;
}
@StrutsParameter
public void setGender(String[] gender) {
this.gender = gender;
}
@@ -20,17 +20,16 @@
*/
package org.apache.struts2.showcase.hangman;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
import org.apache.struts2.action.SessionAware;
public class GetUpdatedHangmanAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 5506025785406043027L;
private Map<String, Object> session;
private Map session;
private Hangman hangman;
@@ -46,6 +45,10 @@ public class GetUpdatedHangmanAction extends ActionSupport implements SessionAwa
return SUCCESS;
}
public void setSession(Map session) {
this.session = session;
}
public Hangman getHangman() {
return hangman;
}
@@ -53,9 +56,4 @@ public class GetUpdatedHangmanAction extends ActionSupport implements SessionAwa
public void setHangman(Hangman hangman) {
this.hangman = hangman;
}
@Override
public void withSession(Map<String, Object> session) {
this.session = session;
}
}
@@ -20,9 +20,8 @@
*/
package org.apache.struts2.showcase.hangman;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
@@ -30,11 +29,10 @@ public class GuessCharacterAction extends ActionSupport implements SessionAware
private static final long serialVersionUID = 9050915577007590674L;
private Map<String, Object> session;
private Map session;
private Character character;
private Hangman hangman;
@Override
public String execute() throws Exception {
hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY);
hangman.guess(character);
@@ -46,7 +44,10 @@ public class GuessCharacterAction extends ActionSupport implements SessionAware
return hangman;
}
@StrutsParameter
public void setSession(Map session) {
this.session = session;
}
public void setCharacter(Character character) {
this.character = character;
}
@@ -54,9 +55,4 @@ public class GuessCharacterAction extends ActionSupport implements SessionAware
public Character getCharacter() {
return this.character;
}
@Override
public void withSession(Map<String, Object> session) {
this.session = session;
}
}
@@ -20,34 +20,40 @@
*/
package org.apache.struts2.showcase.hangman;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Hangman implements Serializable {
private static final Logger log = LogManager.getLogger(Hangman.class);
@Serial
private static final long serialVersionUID = 8566954355839652509L;
private final Vocab vocab;
private Vocab vocab;
private Boolean win = false;
private int guessLeft = 5;
public final List<Character> charactersAvailable;
public List<Character> charactersAvailable;
public List<Character> charactersGuessed;
public Hangman(Vocab vocab) {
charactersAvailable = new ArrayList<>(List.of(
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'));
charactersGuessed = new ArrayList<>();
// Arrays.asList(...) returns List that doesn't support remove(), hence
// we wrap it with an ArrayList to avoid UnsupportedOperationException
// when doing a remove()
charactersAvailable = new ArrayList<Character>(Arrays.asList(
new Character[]{
Character.valueOf('A'), Character.valueOf('B'), Character.valueOf('C'),
Character.valueOf('D'), Character.valueOf('E'), Character.valueOf('F'),
Character.valueOf('G'), Character.valueOf('H'), Character.valueOf('I'),
Character.valueOf('J'), Character.valueOf('K'), Character.valueOf('L'),
Character.valueOf('M'), Character.valueOf('N'), Character.valueOf('O'),
Character.valueOf('P'), Character.valueOf('Q'), Character.valueOf('R'),
Character.valueOf('S'), Character.valueOf('T'), Character.valueOf('U'),
Character.valueOf('V'), Character.valueOf('W'), Character.valueOf('X'),
Character.valueOf('Y'), Character.valueOf('Z')
}));
charactersGuessed = new ArrayList<Character>();
this.vocab = vocab;
}
@@ -69,8 +75,8 @@ public class Hangman implements Serializable {
}
if (vocab.containsAllCharacter(charactersGuessed)) {
win = true;
log.info("Game won");
}
System.out.println(" *********************************** " + win);
}
}
@@ -92,7 +98,7 @@ public class Hangman implements Serializable {
public List<Character> getCharactersAvailable() {
synchronized (charactersAvailable) {
return new ArrayList<>(charactersAvailable);
return new ArrayList<Character>(charactersAvailable);
//return charactersAvailable;
}
}
@@ -20,12 +20,11 @@
*/
package org.apache.struts2.showcase.hangman;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
import org.apache.struts2.action.SessionAware;
import static org.apache.struts2.showcase.hangman.HangmanConstants.HANGMAN_SESSION_KEY;
public class StartHangmanAction extends ActionSupport implements SessionAware {
@@ -34,7 +33,7 @@ public class StartHangmanAction extends ActionSupport implements SessionAware {
private HangmanService service;
private Hangman hangman;
private Map<String, Object> session;
private Map session;
public StartHangmanAction(HangmanService service) {
@@ -54,8 +53,8 @@ public class StartHangmanAction extends ActionSupport implements SessionAware {
}
@Override
public void withSession(Map<String, Object> session) {
this.session = session;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
}
@@ -20,19 +20,17 @@
*/
package org.apache.struts2.showcase.hangman;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
public class Vocab implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private final String vocab;
private final String hint;
private String vocab;
private String hint;
private Character[] characters; // character this vocab is made up of
public Vocab(String vocab, String hint) {
@@ -54,7 +52,7 @@ public class Vocab implements Serializable {
public Boolean containCharacter(Character character) {
assert (character != null);
return vocab.contains(character.toString());
return (vocab.contains(character.toString())) ? true : false;
}
public Character[] inCharacters() {
@@ -62,21 +60,32 @@ public class Vocab implements Serializable {
char[] c = vocab.toCharArray();
characters = new Character[c.length];
for (int a = 0; a < c.length; a++) {
characters[a] = c[a];
characters[a] = Character.valueOf(c[a]);
}
}
return characters;
}
public boolean containsAllCharacter(List<Character> charactersGuessed) {
return new HashSet<>(charactersGuessed).containsAll(Arrays.asList(inCharacters()));
Character[] chars = inCharacters();
List<Character> tmpChars = Arrays.asList(chars);
return charactersGuessed.containsAll(tmpChars);
}
public static void main(String[] args) throws Exception {
public static void main(String args[]) throws Exception {
Vocab v = new Vocab("JAVA", "a java word");
System.out.println(v.containsAllCharacter(List.of('J', 'V')));
System.out.println(v.containsAllCharacter(List.of('J', 'V', 'A')));
List<Character> list1 = new ArrayList<Character>();
list1.add(new Character('J'));
list1.add(new Character('V'));
List<Character> list2 = new ArrayList<Character>();
list2.add(new Character('J'));
list2.add(new Character('V'));
list2.add(new Character('A'));
System.out.println(v.containsAllCharacter(list1));
System.out.println(v.containsAllCharacter(list2));
}
}
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.model;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import java.io.Serializable;
@@ -18,7 +18,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.modelDriven.model;
package org.apache.struts2.showcase.modelDriven;
import java.io.Serializable;
@@ -20,9 +20,8 @@
*/
package org.apache.struts2.showcase.modelDriven;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.ModelDriven;
import org.apache.struts2.showcase.modelDriven.model.Gangster;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
/**
* Action to demonstrate simple model-driven feature of the framework.
@@ -31,18 +30,15 @@ public class ModelDrivenAction extends ActionSupport implements ModelDriven {
private static final long serialVersionUID = 1271130427666936592L;
@Override
public String input() throws Exception {
return SUCCESS;
}
@Override
public String execute() throws Exception {
return SUCCESS;
}
@Override
public Gangster getModel() {
public Object getModel() {
return new Gangster();
}
}
@@ -20,13 +20,13 @@
*/
package org.apache.struts2.showcase.person;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
@@ -42,14 +42,13 @@ public class EditPersonAction extends ActionSupport {
@Autowired
private PersonManager personManager;
private List<Person> persons = new ArrayList<>();
private List<Person> persons = new ArrayList<Person>();
/**
* A default implementation that does nothing an returns "success".
*
* @return {@link #INPUT}
*/
@Override
public String execute() throws Exception {
persons.addAll(personManager.getPeople());
return INPUT;
@@ -69,7 +68,6 @@ public class EditPersonAction extends ActionSupport {
return "list";
}
@StrutsParameter(depth = 2)
public List<Person> getPersons() {
return persons;
}
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.person;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,9 +35,8 @@ public class ListPeopleAction extends ActionSupport {
@Autowired
private PersonManager personManager;
private final List<Person> people = new ArrayList<>();
private List<Person> people = new ArrayList<Person>();
@Override
public String execute() {
people.addAll(personManager.getPeople());
@@ -20,10 +20,9 @@
*/
package org.apache.struts2.showcase.person;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.springframework.beans.factory.annotation.Autowired;
@@ -39,14 +38,12 @@ public class NewPersonAction extends ActionSupport {
private PersonManager personManager;
private Person person;
@Override
public String execute() {
personManager.createPerson(person);
return "list";
}
@StrutsParameter(depth = 1)
public Person getPerson() {
return person;
}
@@ -20,16 +20,17 @@
*/
package org.apache.struts2.showcase.source;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.util.ClassLoaderUtil;
import org.apache.struts2.action.ServletContextAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ClassLoaderUtil;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.util.ServletContextAware;
import jakarta.servlet.ServletContext;
import javax.servlet.ServletContext;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -40,197 +41,195 @@ import java.util.List;
*/
public class ViewSourceAction extends ActionSupport implements ServletContextAware {
private String page;
private String className;
private String config;
private String page;
private String className;
private String config;
private List<String> pageLines;
private List<String> classLines;
private List<String> configLines;
private List pageLines;
private List classLines;
private List configLines;
private int configLine;
private int padding = 10;
private int configLine;
private int padding = 10;
private ServletContext servletContext;
private ServletContext servletContext;
public String execute() throws IOException {
public String execute() throws MalformedURLException, IOException {
if (page != null) {
if (page != null) {
InputStream in = ClassLoaderUtil.getResourceAsStream(page.substring(page.indexOf("//") + 1), getClass());
page = page.replace("//", "/");
InputStream in = ClassLoaderUtil.getResourceAsStream(page.substring(page.indexOf("//") + 1), getClass());
page = page.replace("//", "/");
if (in == null) {
in = servletContext.getResourceAsStream(page);
while (in == null && page.indexOf('/', 1) > 0) {
page = page.substring(page.indexOf('/', 1));
in = servletContext.getResourceAsStream(page);
}
}
pageLines = read(in, -1);
if (in == null) {
in = servletContext.getResourceAsStream(page);
while (in == null && page.indexOf('/', 1) > 0) {
page = page.substring(page.indexOf('/', 1));
in = servletContext.getResourceAsStream(page);
}
}
pageLines = read(in, -1);
if (in != null) {
in.close();
}
}
if (in != null) {
in.close();
}
}
if (className != null) {
className = "/" + className.replace('.', '/') + ".java";
InputStream in = getClass().getResourceAsStream(className);
if (in == null) {
in = servletContext.getResourceAsStream("/WEB-INF/src/java" + className);
}
classLines = read(in, -1);
if (className != null) {
className = "/" + className.replace('.', '/') + ".java";
InputStream in = getClass().getResourceAsStream(className);
if (in == null) {
in = servletContext.getResourceAsStream("/WEB-INF/src" + className);
}
classLines = read(in, -1);
if (in != null) {
in.close();
}
}
if (in != null) {
in.close();
}
}
if (config != null && config.startsWith("file:/")) {
int pos = config.lastIndexOf(':');
configLine = Integer.parseInt(config.substring(pos + 1));
configLines = read(new URL(config.substring(0, pos)).openStream(), configLine);
}
return SUCCESS;
}
String rootPath = ServletActionContext.getServletContext().getRealPath("/");
if (config != null && (rootPath == null || config.startsWith(rootPath))) {
int pos = config.lastIndexOf(':');
configLine = Integer.parseInt(config.substring(pos + 1));
config = config.substring(0, pos).replace("//", "/");
configLines = read(new URL(config).openStream(), configLine);
}
return SUCCESS;
}
/**
* @param className the className to set
*/
@StrutsParameter
public void setClassName(String className) {
if (className != null && !className.trim().isEmpty()) {
this.className = className;
}
}
/**
* @param className the className to set
*/
public void setClassName(String className) {
if (className != null && className.trim().length() > 0) {
this.className = className;
}
}
/**
* @param config the config to set
*/
@StrutsParameter
public void setConfig(String config) {
if (config != null && !config.trim().isEmpty()) {
this.config = config;
}
}
/**
* @param config the config to set
*/
public void setConfig(String config) {
if (config != null && config.trim().length() > 0) {
this.config = config;
}
}
/**
* @param page the page to set
*/
@StrutsParameter
public void setPage(String page) {
if (page != null && !page.trim().isEmpty()) {
this.page = page;
}
}
/**
* @param page the page to set
*/
public void setPage(String page) {
if (page != null && page.trim().length() > 0) {
this.page = page;
}
}
/**
* @param padding the padding to set
*/
@StrutsParameter
public void setPadding(int padding) {
this.padding = padding;
}
/**
* @param padding the padding to set
*/
public void setPadding(int padding) {
this.padding = padding;
}
/**
* @return the classLines
*/
public List<String> getClassLines() {
return classLines;
}
/**
* @return the classLines
*/
public List getClassLines() {
return classLines;
}
/**
* @return the configLines
*/
public List<String> getConfigLines() {
return configLines;
}
/**
* @return the configLines
*/
public List getConfigLines() {
return configLines;
}
/**
* @return the pageLines
*/
public List<String> getPageLines() {
return pageLines;
}
/**
* @return the pageLines
*/
public List getPageLines() {
return pageLines;
}
/**
* @return the className
*/
public String getClassName() {
return className;
}
/**
* @return the className
*/
public String getClassName() {
return className;
}
/**
* @return the config
*/
public String getConfig() {
return config;
}
/**
* @return the config
*/
public String getConfig() {
return config;
}
/**
* @return the page
*/
public String getPage() {
return page;
}
/**
* @return the page
*/
public String getPage() {
return page;
}
/**
* @return the configLine
*/
public int getConfigLine() {
return configLine;
}
/**
* @return the configLine
*/
public int getConfigLine() {
return configLine;
}
/**
* @return the padding
*/
public int getPadding() {
return padding;
}
/**
* @return the padding
*/
public int getPadding() {
return padding;
}
/**
* Reads in a stream, optionally only including the target line number
* and its padding
*
* @param in The input stream
* @param targetLineNumber The target line number, negative to read all
* @return A list of lines
*/
private List<String> read(InputStream in, int targetLineNumber) {
List<String> snippet = null;
if (in != null) {
snippet = new ArrayList<>();
int startLine = 0;
int endLine = Integer.MAX_VALUE;
if (targetLineNumber > 0) {
startLine = targetLineNumber - padding;
endLine = targetLineNumber + padding;
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
/**
* Reads in a strea, optionally only including the target line number
* and its padding
*
* @param in The input stream
* @param targetLineNumber The target line number, negative to read all
* @return A list of lines
*/
private List read(InputStream in, int targetLineNumber) {
List snippet = null;
if (in != null) {
snippet = new ArrayList();
int startLine = 0;
int endLine = Integer.MAX_VALUE;
if (targetLineNumber > 0) {
startLine = targetLineNumber - padding;
endLine = targetLineNumber + padding;
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
int lineno = 0;
String line;
while ((line = reader.readLine()) != null) {
lineno++;
if (lineno >= startLine && lineno <= endLine) {
snippet.add(line);
}
}
} catch (Exception ex) {
// ignoring as snippet not available isn't a big deal
}
}
return snippet;
}
int lineno = 0;
String line;
while ((line = reader.readLine()) != null) {
lineno++;
if (lineno >= startLine && lineno <= endLine) {
snippet.add(line);
}
}
} catch (Exception ex) {
// ignoring as snippet not available isn't a big deal
}
}
return snippet;
}
@Override
public void withServletContext(ServletContext arg0) {
this.servletContext = arg0;
}
public void setServletContext(ServletContext arg0) {
this.servletContext = arg0;
}
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.tag.nonui.actionPrefix;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
public class SubmitAction extends ActionSupport {
@@ -33,12 +32,10 @@ public class SubmitAction extends ActionSupport {
return text;
}
@StrutsParameter
public void setText(String text) {
this.text = text;
}
@Override
public String execute() throws Exception {
return SUCCESS;
}
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.tag.nonui.actiontag;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
/**
*/
@@ -18,14 +18,13 @@
*/
package org.apache.struts2.showcase.tag.nonui.debugtag;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.dispatcher.PrepareOperations;
public class DebugTagAction extends ActionSupport {
@Override
public String execute() throws Exception {
PrepareOperations.overrideDevMode(true); // Just for Showcase, explicitly switch on for this action only
return SUCCESS;
}
}
}
@@ -20,9 +20,8 @@
*/
package org.apache.struts2.showcase.tag.nonui.iteratortag;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.Validateable;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Validateable;
/**
*
@@ -48,25 +47,25 @@ public class AppendIteratorTagDemo extends ActionSupport implements Validateable
}
}
public String getIteratorValue1() {
return iteratorValue1;
}
@StrutsParameter
public void setIteratorValue1(String iteratorValue1) {
this.iteratorValue1 = iteratorValue1;
}
public String getIteratorValue2() {
return iteratorValue2;
}
@StrutsParameter
public void setIteratorValue2(String iteratorValue2) {
this.iteratorValue2 = iteratorValue2;
}
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.tag.nonui.iteratortag;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
/**
*/
@@ -38,34 +37,34 @@ public class IteratorGeneratorTagDemo extends ActionSupport {
return value;
}
@StrutsParameter
public void setValue(String value) {
this.value = value;
}
public Integer getCount() {
return count;
}
@StrutsParameter
public void setCount(Integer count) {
this.count = count;
}
public String getSeparator() {
return this.separator;
}
@StrutsParameter
public void setSeparator(String separator) {
this.separator = separator;
}
public String submit() throws Exception {
return SUCCESS;
}
@Override
public String input() throws Exception {
return SUCCESS;
}

Some files were not shown because too many files have changed in this diff Show More