Compare commits

..

4 Commits

Author SHA1 Message Date
Lukasz Lenart e903739624 [maven-release-plugin] prepare release STRUTS_6_1_2 2023-03-08 17:27:52 +01:00
Lukasz Lenart a85328e74e Sets proper SNAPSHOT version to start release process 2023-03-08 17:23:24 +01:00
Lukasz Lenart c3deb39237 WW-5285 Uses Long and null to check if option has been defined 2023-03-08 17:15:40 +01:00
Lukasz Lenart 483a0c8d01 WW-5285 Limits max number of files to upload at once
Upgrades commons-fileupload to ver. 1.5 and sets default limit to 256 files
2023-03-08 17:15:29 +01:00
2874 changed files with 120552 additions and 84704 deletions
+4 -23
View File
@@ -3,33 +3,14 @@ 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 new/closed PR notifications to dev@
pullrequests_status: dev@struts.apache.org
# Send individual PR comments/reviews to issues@
pullrequests_comment: notifications@struts.apache.org
pullrequests_comment: issues@struts.apache.org
# Link opened PRs with JIRA
jira_options: link label worklog
github:
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/*:
# 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
master: { }
-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
-10
View File
@@ -1,10 +0,0 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"
+6 -22
View File
@@ -17,19 +17,9 @@ name: "CodeQL"
on:
push:
branches:
- 'main'
- 'release/*'
branches: [ "master" ]
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
@@ -44,20 +34,14 @@ jobs:
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'
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v3.27.7
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v3.27.7
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3.27.7
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
+22 -12
View File
@@ -13,16 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
name: Java Maven
name: Java Build
on:
pull_request:
push:
branches:
- 'main'
- 'release/*'
permissions: read-all
- master
env:
MAVEN_OPTS: -Xmx2048m -Xms1024m
@@ -30,18 +27,31 @@ env:
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '17', '21' ]
java: [ '8', '11', '17' ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/setup-java@v4
uses: actions/checkout@v3.0.2
- name: Set up cache
uses: actions/cache@v3.0.8
with:
distribution: temurin
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: adopt
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Build with Maven on Java ${{ matrix.java }}
run: mvn -B -V -DskipAssembly verify --no-transfer-progress
if: matrix.java != '11'
run: mvn -B -V -DskipAssembly test --no-transfer-progress
- name: Code coverage on Java ${{ matrix.java }}
if: matrix.java == '11'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
run: mvn -B -V -Pcoverage -DskipAssembly verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar --no-transfer-progress
+5 -6
View File
@@ -20,8 +20,7 @@ on:
schedule:
- cron: "30 1 * * 6" # Weekly on Saturdays
push:
branches:
- "main"
branches: [ "master" ]
permissions: read-all
@@ -41,12 +40,12 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@v4 # 3.1.0
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # 3.1.0
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # 2.4.0
uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # 2.0.6
with:
results_file: results.sarif
results_format: sarif
@@ -58,13 +57,13 @@ jobs:
publish_results: true
- name: "Upload artifact"
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # 4.4.3
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # 3.1.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@89757925c7adddb19b7a2f28e3e1b27da88b7304 # 2.22.11
uses: github/codeql-action/upload-sarif@b398f525a5587552e573b247ac661067fafa920b # 2.1.22
with:
sarif_file: results.sarif
-49
View File
@@ -1,49 +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 }}
MAIN_BRANCH: ${{ github.ref || github.base_ref || github.ref || github.base_ref }}
if: ${{ github.ref == 'main' || github.base_ref == 'main' }}
run: ./mvnw -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.branch.name=${{ env.MAIN_BRANCH }} -Pcoverage -DskipAssembly
+117
View File
@@ -0,0 +1,117 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* 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/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".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 directory '" + 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 {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
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();
}
}
+4 -5
View File
@@ -5,15 +5,14 @@
# 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.8.6/apache-maven-3.8.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
-2
View File
@@ -1,2 +0,0 @@
# Request PR review from any Apache Struts committer
* @apache/struts-committers
Vendored
+67 -21
View File
@@ -25,21 +25,26 @@ pipeline {
}
}
}
stage('JDK 21') {
stage('JDK 17') {
agent {
label 'ubuntu'
}
tools {
jdk 'jdk_21_latest'
jdk 'jdk_17_latest'
maven 'maven_3_latest'
}
environment {
MAVEN_OPTS = "-Xmx1024m"
}
stages {
stage('Build') {
steps {
sh './mvnw -B clean install -DskipTests -DskipAssembly'
}
}
stage('Test') {
steps {
sh './mvnw -B -DskipAssembly verify'
sh './mvnw -B test'
}
post {
always {
@@ -55,21 +60,21 @@ pipeline {
}
}
}
stage('JDK 17') {
stage('JDK 11') {
agent {
label 'ubuntu'
}
tools {
jdk 'jdk_17_latest'
jdk 'jdk_11_latest'
maven 'maven_3_latest'
}
environment {
MAVEN_OPTS = "-Xmx2048m"
MAVEN_OPTS = "-Xmx1024m"
}
stages {
stage('Install') {
stage('Build') {
steps {
sh './mvnw -B install -DskipTests -DskipAssembly'
sh './mvnw -B clean install -DskipTests -DskipAssembly'
}
}
stage('Test') {
@@ -83,11 +88,55 @@ pipeline {
}
}
}
stage('Code Quality') {
when {
branch 'master'
}
steps {
withCredentials([string(credentialsId: 'asf-struts-sonarcloud', variable: 'SONARCLOUD_TOKEN')]) {
sh './mvnw -B -Pcoverage -DskipAssembly -Dsonar.login=${SONARCLOUD_TOKEN} verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar'
}
}
}
}
post {
always {
cleanWs deleteDirs: true, patterns: [[pattern: '**/target/**', type: 'INCLUDE']]
}
}
}
stage('JDK 8') {
agent {
label 'ubuntu'
}
tools {
jdk 'jdk_1.8_latest'
maven 'maven_3_latest'
}
environment {
MAVEN_OPTS = "-Xmx1024m"
}
stages {
stage('Build') {
steps {
sh './mvnw -B clean install -DskipTests -DskipAssembly'
}
}
stage('Test') {
steps {
sh './mvnw -B test'
// step([$class: 'JiraIssueUpdater', issueSelector: [$class: 'DefaultIssueSelector'], scm: scm])
}
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 'master'
}
steps {
dir("local-snapshots-dir/") {
@@ -98,9 +147,7 @@ pipeline {
}
stage('Deploy Snapshot') {
when {
anyOf {
branch 'main'
}
branch 'master'
}
steps {
withCredentials([file(credentialsId: 'lukaszlenart-repository-access-token', variable: 'CUSTOM_SETTINGS')]) {
@@ -110,9 +157,7 @@ pipeline {
}
stage('Upload nightlies') {
when {
anyOf {
branch 'main'
}
branch 'master'
}
steps {
sh './mvnw -B package -DskipTests'
@@ -123,7 +168,8 @@ pipeline {
sshTransfer(
remoteDirectory: '/struts/snapshot',
removePrefix: 'assembly/target/assembly/out',
sourceFiles: 'assembly/target/assembly/out/struts-*.zip'
sourceFiles: 'assembly/target/assembly/out/struts-*.zip',
cleanRemote: true
)
],
verbose: true
@@ -144,7 +190,7 @@ pipeline {
failure {
script {
emailext(
to: "notifications@struts.apache.org",
to: "dev@struts.apache.org",
recipientProviders: [[$class: 'DevelopersRecipientProvider']],
from: "Mr. Jenkins <jenkins@builds.apache.org>",
subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} failed",
@@ -167,7 +213,7 @@ Director of Continuous Integration
unstable {
script {
emailext(
to: "notifications@struts.apache.org",
to: "dev@struts.apache.org",
recipientProviders: [[$class: 'DevelopersRecipientProvider']],
from: "Mr. Jenkins <jenkins@builds.apache.org>",
subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} unstable",
@@ -190,7 +236,7 @@ Director of Continuous Integration
fixed {
script {
emailext(
to: "notifications@struts.apache.org",
to: "dev@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",
+1 -1
View File
@@ -17,7 +17,7 @@
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/)
[![Jenkins Build](https://builds.apache.org/buildStatus/icon?job=Struts%2FStruts+Core%2Fmaster)](https://ci-builds.apache.org/job/Struts/job/Struts%20Core/job/master/)
[![Java Build](https://github.com/apache/struts/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/struts/actions/workflows/maven.yml)
[![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)
+6 -6
View File
@@ -2,13 +2,13 @@
## Supported Versions
Please visit the [Releases](https://struts.apache.org/releases.html#prior-releases) page to see full information about each version
Please vist 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 |
|---------|--------------------|
| 6.x | :white_check_mark: |
| 2.5.x | :white_check_mark: |
| ------- | ------------------ |
| 6.0.0 | :white_check_mark: |
| 2.5.30 | :white_check_mark: |
## Reporting New Security Issues with thr Apache Struts
@@ -28,8 +28,8 @@ All mail sent to this address that does not relate to security problems in the A
```
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
workarounds to generic problems (such as a client streaming lots of data to your server, or re-requesting
the same URL repeatedly). In general our philosophy is to avoid any attacks which 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)
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>7.0.0</version>
<version>6.1.2</version>
</parent>
<artifactId>struts2-apps</artifactId>
<packaging>pom</packaging>
+7 -4
View File
@@ -24,12 +24,12 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>7.0.0</version>
<version>6.1.2</version>
</parent>
<artifactId>struts2-rest-showcase</artifactId>
<packaging>war</packaging>
<version>7.0.0</version>
<version>6.1.2</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>
@@ -76,8 +78,9 @@
</dependency>
<dependency>
<groupId>org.htmlunit</groupId>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.39.0</version>
<scope>test</scope>
</dependency>
@@ -107,7 +110,7 @@
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>11.0.18</version>
<version>9.4.46.v20220331</version>
<configuration>
<stopKey>CTRL+C</stopKey>
<stopPort>8999</stopPort>
@@ -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"
"https://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
@@ -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,23 @@
*/
package it.org.apache.struts2.rest.example;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import net.sourceforge.jwebunit.junit.WebTestCase;
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 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;
public class PostOrderTest extends WebTestCase {
public class PostOrderTest {
@Before
public void setUp() throws Exception {
getTestContext().setBaseUrl(ParameterUtils.getBaseUrl());
}
@Test
public void testPostOrder() {
beginAt("/orders/new");
setWorkingForm(0);
@@ -59,7 +45,6 @@ public class PostOrderTest {
assertLinkNotPresentWithText("Back to Orders");
}
@Test
public void testPostOrderWithErrors() {
beginAt("/orders/new");
setWorkingForm(0);
@@ -73,7 +58,6 @@ public class PostOrderTest {
assertTextFieldEquals("amount", "321");
}
@Test
public void testPostOrderInHtml() {
beginAt("/orders/new.xhtml");
setWorkingForm(0);
@@ -88,7 +72,6 @@ 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");
@@ -102,7 +85,6 @@ public class PostOrderTest {
client.close();
}
@Test
public void testPostOrderInXmlWithBadData() throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(ParameterUtils.getBaseUrl() + "/orders.xml");
@@ -116,7 +98,6 @@ public class PostOrderTest {
client.close();
}
@Test
public void testPostOrderInJson() throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(ParameterUtils.getBaseUrl() + "/orders.json");
@@ -127,7 +108,6 @@ public class PostOrderTest {
client.close();
}
@Test
public void testPostOrderInJsonWithBadData() throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(ParameterUtils.getBaseUrl() + "/orders.json");
+45 -88
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>7.0.0</version>
<version>6.1.2</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>
@@ -82,23 +98,10 @@
<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>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
@@ -106,24 +109,35 @@
<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>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.sitemesh</groupId>
<artifactId>sitemesh</artifactId>
<version>3.2.1</version>
<groupId>opensymphony</groupId>
<artifactId>sitemesh</artifactId>
</dependency>
<dependency>
<groupId>org.directwebremoting</groupId>
<artifactId>dwr</artifactId>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
<dependency>
@@ -132,82 +146,28 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.61.0</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>
<exclusions>
<exclusion>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</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
-->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-jsr223</artifactId>
<version>3.0.22</version>
</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.1</version>
<version>3.0.0-M6</version>
<configuration>
<includes>
<include>it.org.apache.struts2.showcase.*Test</include>
@@ -234,7 +194,7 @@
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>11.0.18</version>
<version>9.4.46.v20220331</version>
<configuration>
<stopKey>CTRL+C</stopKey>
<stopPort>8999</stopPort>
@@ -247,15 +207,12 @@
<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>
@@ -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;
@@ -76,11 +75,11 @@ public class MoreSelectsAction extends ActionSupport {
return list;
}
public List getPrioritisedFavouriteCartoonCharacters() {
return _prioritisedFavouriteCartoonCharacters;
}
@StrutsParameter
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
}
@@ -89,16 +88,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 +105,6 @@ public class MoreSelectsAction extends ActionSupport {
return favouriteNumbers;
}
@StrutsParameter
public void setFavouriteNumbers(List favouriteNumbers) {
this.favouriteNumbers = favouriteNumbers;
}
@@ -132,13 +129,12 @@ public class MoreSelectsAction 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;
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();
}
}
@@ -18,13 +18,13 @@
*/
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 javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
@@ -18,8 +18,7 @@
*/
package org.apache.struts2.showcase.async;
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;
@@ -35,12 +34,10 @@ public class ChatRoomAction extends ActionSupport {
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;
}
@@ -50,12 +47,15 @@ public class ChatRoomAction extends ActionSupport {
}
public Callable<String> receiveNewMessages() throws Exception {
return () -> {
while (lastIndex >= messages.size()) {
Thread.sleep(3000);
return new Callable<String>() {
@Override
public String call() throws Exception {
while (lastIndex >= messages.size()) {
Thread.sleep(3000);
}
newMessages = messages.subList(lastIndex, messages.size());
return SUCCESS;
}
newMessages = messages.subList(lastIndex, messages.size());
return SUCCESS;
};
}
@@ -21,10 +21,10 @@
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 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.LogManager;
import org.apache.logging.log4j.Logger;
@@ -20,10 +20,10 @@
*/
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 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.LogManager;
import org.apache.logging.log4j.Logger;
@@ -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,8 @@
*/
package org.apache.struts2.showcase.chat;
import org.apache.struts2.conversion.impl.XWorkConverter;
import org.apache.struts2.inject.Inject;
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.struts2.util.StrutsTypeConverter;
@@ -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,76 @@
*/
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;
}
public void setUpload(File upload) {
this.upload = upload;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
public long getUploadSize() {
if (upload != null) {
return upload.length();
} else {
return 0;
}
}
}
@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();
}
}
@@ -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 = new File[0];
private String[] uploadFileNames = new String[0];
private String[] uploadContentTypes = new String[0];
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));
}
}
@@ -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,12 +20,11 @@
*/
package org.apache.struts2.showcase.source;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.util.ClassLoaderUtil;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ClassLoaderUtil;
import org.apache.struts2.action.ServletContextAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import jakarta.servlet.ServletContext;
import javax.servlet.ServletContext;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -99,9 +98,8 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
/**
* @param className the className to set
*/
@StrutsParameter
public void setClassName(String className) {
if (className != null && !className.trim().isEmpty()) {
if (className != null && className.trim().length() > 0) {
this.className = className;
}
}
@@ -109,9 +107,8 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
/**
* @param config the config to set
*/
@StrutsParameter
public void setConfig(String config) {
if (config != null && !config.trim().isEmpty()) {
if (config != null && config.trim().length() > 0) {
this.config = config;
}
}
@@ -119,9 +116,8 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
/**
* @param page the page to set
*/
@StrutsParameter
public void setPage(String page) {
if (page != null && !page.trim().isEmpty()) {
if (page != null && page.trim().length() > 0) {
this.page = page;
}
}
@@ -129,7 +125,6 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
/**
* @param padding the padding to set
*/
@StrutsParameter
public void setPadding(int padding) {
this.padding = padding;
}
@@ -227,7 +222,6 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
return snippet;
}
@Override
public void withServletContext(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;
}
@@ -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;
/**
@@ -34,7 +33,7 @@ public class MergeIteratorTagDemo extends ActionSupport implements Validateable
private String iteratorValue1;
private String iteratorValue2;
@Override
public void validate() {
if (iteratorValue1 == null || iteratorValue1.trim().length() <= 0) {
addFieldError("iteratorValue1", "iterator value 1 cannot be empty");
@@ -48,25 +47,25 @@ public class MergeIteratorTagDemo extends ActionSupport implements Validateable
}
}
public String getIteratorValue1() {
return this.iteratorValue1;
}
@StrutsParameter
public void setIteratorValue1(String iteratorValue1) {
this.iteratorValue1 = iteratorValue1;
}
public String getIteratorValue2() {
return this.iteratorValue2;
}
@StrutsParameter
public void setIteratorValue2(String iteratorValue2) {
this.iteratorValue2 = iteratorValue2;
}
@Override
public String input() throws Exception {
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;
/**
*
@@ -35,7 +34,7 @@ public class SubsetIteratorTagDemo extends ActionSupport implements Validateable
private Integer count;
private Integer start;
@Override
public void validate() {
if (iteratorValue == null || iteratorValue.trim().length() <= 0) {
addFieldError("iteratorValue1", "iterator value 1 cannot be empty");
@@ -44,34 +43,34 @@ public class SubsetIteratorTagDemo extends ActionSupport implements Validateable
}
}
public String getIteratorValue() {
return this.iteratorValue;
}
@StrutsParameter
public void setIteratorValue(String iteratorValue) {
this.iteratorValue = iteratorValue;
}
public Integer getCount() {
return this.count;
}
@StrutsParameter
public void setCount(Integer count) {
this.count = count;
}
public Integer getStart() {
return this.start;
}
@StrutsParameter
public void setStart(Integer start) {
this.start = start;
}
@Override
public String input() throws Exception {
return SUCCESS;
}
@@ -79,4 +78,6 @@ public class SubsetIteratorTagDemo extends ActionSupport implements Validateable
public String submit() throws Exception {
return SUCCESS;
}
}
@@ -24,7 +24,7 @@ import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.tiles.annotation.TilesDefinition;
import org.apache.struts2.tiles.annotation.TilesPutAttribute;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
@Namespace("/tiles")
@ParentPackage("tiles")
@@ -20,9 +20,8 @@
*/
package org.apache.struts2.showcase.token;
import org.apache.struts2.ActionContext;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Date;
@@ -77,7 +76,6 @@ public class TokenAction extends ActionSupport {
return amount;
}
@StrutsParameter
public void setAmount(int amount) {
this.amount = amount;
}
@@ -20,7 +20,7 @@
*/
package org.apache.struts2.showcase.validation;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
/**
*/
@@ -30,7 +30,6 @@ public abstract class AbstractValidationActionSupport extends ActionSupport {
return "success";
}
@Override
public String input() throws Exception {
return "input";
}
@@ -18,19 +18,18 @@
*/
package org.apache.struts2.showcase.validation;
import org.apache.struts2.validator.annotations.DateRangeFieldValidator;
import org.apache.struts2.validator.annotations.EmailValidator;
import org.apache.struts2.validator.annotations.FieldExpressionValidator;
import org.apache.struts2.validator.annotations.IntRangeFieldValidator;
import org.apache.struts2.validator.annotations.RegexFieldValidator;
import org.apache.struts2.validator.annotations.RequiredFieldValidator;
import org.apache.struts2.validator.annotations.RequiredStringValidator;
import org.apache.struts2.validator.annotations.StringLengthFieldValidator;
import org.apache.struts2.validator.annotations.UrlValidator;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.sql.Date;
import com.opensymphony.xwork2.validator.annotations.DateRangeFieldValidator;
import com.opensymphony.xwork2.validator.annotations.EmailValidator;
import com.opensymphony.xwork2.validator.annotations.FieldExpressionValidator;
import com.opensymphony.xwork2.validator.annotations.IntRangeFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RegexFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
import com.opensymphony.xwork2.validator.annotations.UrlValidator;
/**
* <!-- START SNIPPET: ajaxFormSubmit -->
* Example Action that shows how forms can be validated and submitted via AJAX
@@ -73,10 +72,9 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@DateRangeFieldValidator(
min="01/01/1990",
max="01/01/2000",
min="01/01/1990",
max="01/01/2000",
message="must be a min 01-01-1990 max 01-01-2000 if supplied")
@StrutsParameter
public void setDateValidatorField(Date dateValidatorField) {
this.dateValidatorField = dateValidatorField;
}
@@ -86,7 +84,6 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@EmailValidator(message="must be a valid email if supplied")
@StrutsParameter
public void setEmailValidatorField(String emailValidatorField) {
this.emailValidatorField = emailValidatorField;
}
@@ -96,7 +93,6 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@IntRangeFieldValidator(min="1", max="10", message="must be integer min 1 max 10 if supplied")
@StrutsParameter
public void setIntegerValidatorField(Integer integerValidatorField) {
this.integerValidatorField = integerValidatorField;
}
@@ -106,9 +102,8 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@RegexFieldValidator(
regex="[^<>]+",
regex="[^<>]+",
message="regexValidatorField must match a regexp (.*\\.txt) if specified")
@StrutsParameter
public void setRegexValidatorField(String regexValidatorField) {
this.regexValidatorField = regexValidatorField;
}
@@ -118,7 +113,6 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@RequiredStringValidator(trim=true, message="required and must be string")
@StrutsParameter
public void setRequiredStringValidatorField(String requiredStringValidatorField) {
this.requiredStringValidatorField = requiredStringValidatorField;
}
@@ -128,7 +122,6 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@RequiredFieldValidator(message="required")
@StrutsParameter
public void setRequiredValidatorField(String requiredValidatorField) {
this.requiredValidatorField = requiredValidatorField;
}
@@ -138,11 +131,10 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@StringLengthFieldValidator(
minLength="2",
maxLength="4",
trim=true,
minLength="2",
maxLength="4",
trim=true,
message="must be a String of a specific greater than 1 less than 5 if specified")
@StrutsParameter
public void setStringLengthValidatorField(String stringLengthValidatorField) {
this.stringLengthValidatorField = stringLengthValidatorField;
}
@@ -152,10 +144,10 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@FieldExpressionValidator(
expression = "(fieldExpressionValidatorField == requiredValidatorField)",
expression = "(fieldExpressionValidatorField == requiredValidatorField)",
message = "must be the same as the Required Validator Field if specified")
@StrutsParameter
public void setFieldExpressionValidatorField(String fieldExpressionValidatorField) {
public void setFieldExpressionValidatorField(
String fieldExpressionValidatorField) {
this.fieldExpressionValidatorField = fieldExpressionValidatorField;
}
@@ -164,7 +156,6 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
}
@UrlValidator(message="must be a valid url if supplied")
@StrutsParameter
public void setUrlValidatorField(String urlValidatorField) {
this.urlValidatorField = urlValidatorField;
}
@@ -20,24 +20,23 @@
*/
package org.apache.struts2.showcase.validation;
import org.apache.struts2.ActionSupport;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts.beanvalidation.constraints.FieldMatch;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import org.apache.struts2.interceptor.validation.SkipValidation;
import org.hibernate.validator.constraints.ScriptAssert;
import org.hibernate.validator.constraints.URL;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import javax.validation.constraints.Email;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Date;
// <!-- START SNIPPET: beanValidationExample -->
@@ -96,7 +95,6 @@ public class BeanValidationExampleAction extends ActionSupport {
return dateValidatorField;
}
@StrutsParameter
public void setDateValidatorField(Date dateValidatorField) {
this.dateValidatorField = dateValidatorField;
}
@@ -105,7 +103,6 @@ public class BeanValidationExampleAction extends ActionSupport {
return emailValidatorField;
}
@StrutsParameter
public void setEmailValidatorField(String emailValidatorField) {
this.emailValidatorField = emailValidatorField;
}
@@ -114,7 +111,6 @@ public class BeanValidationExampleAction extends ActionSupport {
return integerValidatorField;
}
@StrutsParameter
public void setIntegerValidatorField(Integer integerValidatorField) {
this.integerValidatorField = integerValidatorField;
}
@@ -123,7 +119,6 @@ public class BeanValidationExampleAction extends ActionSupport {
return regexValidatorField;
}
@StrutsParameter
public void setRegexValidatorField(String regexValidatorField) {
this.regexValidatorField = regexValidatorField;
}
@@ -132,7 +127,6 @@ public class BeanValidationExampleAction extends ActionSupport {
return requiredStringValidatorField;
}
@StrutsParameter
public void setRequiredStringValidatorField(String requiredStringValidatorField) {
this.requiredStringValidatorField = requiredStringValidatorField;
}
@@ -141,7 +135,6 @@ public class BeanValidationExampleAction extends ActionSupport {
return requiredValidatorField;
}
@StrutsParameter
public void setRequiredValidatorField(String requiredValidatorField) {
this.requiredValidatorField = requiredValidatorField;
}
@@ -150,7 +143,6 @@ public class BeanValidationExampleAction extends ActionSupport {
return stringLengthValidatorField;
}
@StrutsParameter
public void setStringLengthValidatorField(String stringLengthValidatorField) {
this.stringLengthValidatorField = stringLengthValidatorField;
}
@@ -159,8 +151,8 @@ public class BeanValidationExampleAction extends ActionSupport {
return fieldExpressionValidatorField;
}
@StrutsParameter
public void setFieldExpressionValidatorField(String fieldExpressionValidatorField) {
public void setFieldExpressionValidatorField(
String fieldExpressionValidatorField) {
this.fieldExpressionValidatorField = fieldExpressionValidatorField;
}
@@ -168,7 +160,6 @@ public class BeanValidationExampleAction extends ActionSupport {
return urlValidatorField;
}
@StrutsParameter
public void setUrlValidatorField(String urlValidatorField) {
this.urlValidatorField = urlValidatorField;
}
@@ -20,8 +20,6 @@
*/
package org.apache.struts2.showcase.validation;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.sql.Date;
/**
@@ -46,7 +44,6 @@ public class FieldValidatorsExampleAction extends AbstractValidationActionSuppor
return dateValidatorField;
}
@StrutsParameter
public void setDateValidatorField(Date dateValidatorField) {
this.dateValidatorField = dateValidatorField;
}
@@ -55,7 +52,6 @@ public class FieldValidatorsExampleAction extends AbstractValidationActionSuppor
return emailValidatorField;
}
@StrutsParameter
public void setEmailValidatorField(String emailValidatorField) {
this.emailValidatorField = emailValidatorField;
}
@@ -64,7 +60,6 @@ public class FieldValidatorsExampleAction extends AbstractValidationActionSuppor
return integerValidatorField;
}
@StrutsParameter
public void setIntegerValidatorField(Integer integerValidatorField) {
this.integerValidatorField = integerValidatorField;
}
@@ -73,7 +68,6 @@ public class FieldValidatorsExampleAction extends AbstractValidationActionSuppor
return regexValidatorField;
}
@StrutsParameter
public void setRegexValidatorField(String regexValidatorField) {
this.regexValidatorField = regexValidatorField;
}
@@ -82,7 +76,6 @@ public class FieldValidatorsExampleAction extends AbstractValidationActionSuppor
return requiredStringValidatorField;
}
@StrutsParameter
public void setRequiredStringValidatorField(String requiredStringValidatorField) {
this.requiredStringValidatorField = requiredStringValidatorField;
}
@@ -91,7 +84,6 @@ public class FieldValidatorsExampleAction extends AbstractValidationActionSuppor
return requiredValidatorField;
}
@StrutsParameter
public void setRequiredValidatorField(String requiredValidatorField) {
this.requiredValidatorField = requiredValidatorField;
}
@@ -100,7 +92,6 @@ public class FieldValidatorsExampleAction extends AbstractValidationActionSuppor
return stringLengthValidatorField;
}
@StrutsParameter
public void setStringLengthValidatorField(String stringLengthValidatorField) {
this.stringLengthValidatorField = stringLengthValidatorField;
}
@@ -109,7 +100,6 @@ public class FieldValidatorsExampleAction extends AbstractValidationActionSuppor
return fieldExpressionValidatorField;
}
@StrutsParameter
public void setFieldExpressionValidatorField(
String fieldExpressionValidatorField) {
this.fieldExpressionValidatorField = fieldExpressionValidatorField;
@@ -119,7 +109,6 @@ public class FieldValidatorsExampleAction extends AbstractValidationActionSuppor
return urlValidatorField;
}
@StrutsParameter
public void setUrlValidatorField(String urlValidatorField) {
this.urlValidatorField = urlValidatorField;
}
@@ -20,8 +20,6 @@
*/
package org.apache.struts2.showcase.validation;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
*/
@@ -39,7 +37,6 @@ public class NonFieldValidatorsExampleAction extends AbstractValidationActionSup
return someText;
}
@StrutsParameter
public void setSomeText(String someText) {
this.someText = someText;
}
@@ -48,7 +45,6 @@ public class NonFieldValidatorsExampleAction extends AbstractValidationActionSup
return someTextRetype;
}
@StrutsParameter
public void setSomeTextRetype(String someTextRetype) {
this.someTextRetype = someTextRetype;
}
@@ -57,7 +53,6 @@ public class NonFieldValidatorsExampleAction extends AbstractValidationActionSup
return someTextRetypeAgain;
}
@StrutsParameter
public void setSomeTextRetypeAgain(String someTextRetypeAgain) {
this.someTextRetypeAgain = someTextRetypeAgain;
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.validation;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
/**
*/
@@ -40,7 +39,6 @@ public class QuizAction extends ActionSupport {
return name;
}
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -49,7 +47,6 @@ public class QuizAction extends ActionSupport {
return age;
}
@StrutsParameter
public void setAge(int age) {
this.age = age;
}
@@ -58,7 +55,6 @@ public class QuizAction extends ActionSupport {
return answer;
}
@StrutsParameter
public void setAnswer(String answer) {
this.answer = answer;
}
@@ -20,8 +20,7 @@
*/
package org.apache.struts2.showcase.validation;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import com.opensymphony.xwork2.ActionSupport;
/**
* @version $Date$ $Id$
@@ -31,7 +30,6 @@ public class SubmitApplication extends ActionSupport {
private String name;
private Integer age;
@StrutsParameter
public void setName(String name) {
this.name = name;
}
@@ -40,7 +38,6 @@ public class SubmitApplication extends ActionSupport {
return this.name;
}
@StrutsParameter
public void setAge(Integer age) {
this.age = age;
}

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