Compare commits

..

4 Commits

Author SHA1 Message Date
Lukasz Lenart 9841b848c8 [maven-release-plugin] prepare for next development iteration 2023-12-05 07:04:12 +01:00
Lukasz Lenart ad95ab30f2 [maven-release-plugin] prepare release STRUTS_6_3_0_2 2023-12-05 07:04:02 +01:00
Lukasz Lenart 2eecd16888 Sets a proper SNAPSHOT version 2023-12-04 06:43:08 +01:00
Lukasz Lenart d8c69691ef Makes HttpParameters case-insensitive 2023-12-04 06:41:51 +01:00
1291 changed files with 100426 additions and 15337 deletions
+3 -10
View File
@@ -4,23 +4,16 @@ notifications:
# 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
pullrequests_status: commits@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:
master:
# 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
master: { }
autolink_jira:
- WW
dependabot_alerts: true
+4 -12
View File
@@ -17,9 +17,7 @@ name: "CodeQL"
on:
push:
branches:
- master
- release/struts-7-0-x
branches: [ "master" ]
pull_request:
permissions:
@@ -45,19 +43,13 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: 'maven'
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
+19 -7
View File
@@ -13,14 +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:
- master
- release/struts-7-0-x
permissions: read-all
@@ -30,18 +29,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
- name: Set up cache
uses: actions/cache@v3.3.1
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 }}
if: matrix.java != '17'
run: mvn -B -V -DskipAssembly verify --no-transfer-progress
- name: Code coverage on Java ${{ matrix.java }}
if: matrix.java == '17'
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
+4 -5
View File
@@ -20,8 +20,7 @@ on:
schedule:
- cron: "30 1 * * 6" # Weekly on Saturdays
push:
branches:
- master
branches: [ "master" ]
permissions: read-all
@@ -46,7 +45,7 @@ jobs:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # 2.3.3
uses: ossf/scorecard-action@08b4669551908b1024bb425080c797723083c031 # 2.2.0
with:
results_file: results.sarif
results_format: sarif
@@ -58,13 +57,13 @@ jobs:
publish_results: true
- name: "Upload artifact"
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # 4.3.4
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # 3.1.3
with:
name: SARIF file
path: results.sarif
retention-days: 5
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@03e7845b7bfcd5e7fb63d1ae8c61b0e791134fab # 2.22.11
uses: github/codeql-action/upload-sarif@b398f525a5587552e573b247ac661067fafa920b # 2.1.22
with:
sarif_file: results.sarif
-48
View File
@@ -1,48 +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:
- master
- release/struts-7-0-x
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.head.repo.fork }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: 'maven'
- 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
+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 -4
View File
@@ -5,14 +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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
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
Vendored
+73 -36
View File
@@ -25,21 +25,71 @@ 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 --no-transfer-progress'
sh './mvnw -B verify -Pcoverage -DskipAssembly'
}
post {
always {
junit(testResults: '**/surefire-reports/*.xml', allowEmptyResults: true)
junit(testResults: '**/failsafe-reports/*.xml', allowEmptyResults: true)
}
}
}
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 11') {
agent {
label 'ubuntu'
}
tools {
jdk 'jdk_11_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'
}
post {
always {
@@ -55,21 +105,26 @@ pipeline {
}
}
}
stage('JDK 17') {
stage('JDK 8') {
agent {
label 'ubuntu'
}
tools {
jdk 'jdk_17_latest'
jdk 'jdk_1.8_latest'
maven 'maven_3_latest'
}
environment {
MAVEN_OPTS = "-Xmx1024m"
}
stages {
stage('Test & Coverage') {
stage('Build') {
steps {
sh './mvnw -B verify -Pcoverage -DskipAssembly --no-transfer-progress'
sh './mvnw -B clean install -DskipTests -DskipAssembly'
}
}
stage('Test') {
steps {
sh './mvnw -B test'
}
post {
always {
@@ -78,52 +133,33 @@ pipeline {
}
}
}
stage('Code Quality') {
when {
anyOf {
branch 'master'; branch 'release/struts-7-0-x'
}
}
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 --no-transfer-progress'
}
}
}
stage('Build Source & JavaDoc') {
when {
anyOf {
branch 'master'; branch 'release/struts-7-0-x'
}
branch 'master'
}
steps {
dir("local-snapshots-dir/") {
deleteDir()
}
sh './mvnw -B source:jar javadoc:jar -DskipTests -DskipAssembly --no-transfer-progress'
sh './mvnw -B source:jar javadoc:jar -DskipTests -DskipAssembly'
}
}
stage('Deploy Snapshot') {
when {
anyOf {
branch 'master'; branch 'release/struts-7-0-x'
}
branch 'master'
}
steps {
withCredentials([file(credentialsId: 'lukaszlenart-repository-access-token', variable: 'CUSTOM_SETTINGS')]) {
sh './mvnw -s \${CUSTOM_SETTINGS} deploy -DskipTests -DskipAssembly --no-transfer-progress'
sh './mvnw -s \${CUSTOM_SETTINGS} deploy -DskipTests -DskipAssembly'
}
}
}
stage('Upload nightlies') {
when {
anyOf {
branch 'master'
branch 'release/struts-7-0-x'
}
branch 'master'
}
steps {
sh './mvnw -B package -DskipTests --no-transfer-progress'
sh './mvnw -B package -DskipTests'
sshPublisher(publishers: [
sshPublisherDesc(
configName: 'Nightlies',
@@ -131,7 +167,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
@@ -152,7 +189,7 @@ pipeline {
failure {
script {
emailext(
to: "notifications@struts.apache.org",
to: "commits@struts.apache.org",
recipientProviders: [[$class: 'DevelopersRecipientProvider']],
from: "Mr. Jenkins <jenkins@builds.apache.org>",
subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} failed",
@@ -175,7 +212,7 @@ Director of Continuous Integration
unstable {
script {
emailext(
to: "notifications@struts.apache.org",
to: "commits@struts.apache.org",
recipientProviders: [[$class: 'DevelopersRecipientProvider']],
from: "Mr. Jenkins <jenkins@builds.apache.org>",
subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} unstable",
@@ -198,7 +235,7 @@ Director of Continuous Integration
fixed {
script {
emailext(
to: "notifications@struts.apache.org",
to: "commits@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%2Fmaster)](https://ci-builds.apache.org/job/Struts/job/Struts%20Core/job/master/)
[![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-M8</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-apps</artifactId>
<packaging>pom</packaging>
+5 -4
View File
@@ -24,12 +24,12 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>7.0.0-M8</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-rest-showcase</artifactId>
<packaging>war</packaging>
<version>7.0.0-M8</version>
<version>6.3.0.3-SNAPSHOT</version>
<name>Struts 2 Rest Showcase Webapp</name>
<description>Struts 2 Rest Showcase Example</description>
@@ -76,8 +76,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 +108,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,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");
+26 -65
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>7.0.0-M8</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-showcase</artifactId>
@@ -58,6 +58,11 @@
<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>
@@ -94,8 +99,8 @@
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
@@ -118,9 +123,12 @@
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-sitemesh2-jakarta</artifactId>
<version>${project.version}</version>
<groupId>opensymphony</groupId>
<artifactId>sitemesh</artifactId>
</dependency>
<dependency>
<groupId>org.directwebremoting</groupId>
<artifactId>dwr</artifactId>
</dependency>
<dependency>
@@ -130,16 +138,11 @@
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<scope>test</scope>
</dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.61.0</version>
<scope>test</scope>
</dependency>
<!-- BeanValidation Example -->
<dependency>
@@ -152,47 +155,10 @@
<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-sitemesh2-jakarta</artifactId>
<destFileName>struts2-sitemesh2-jakarta.jar</destFileName>
</artifactItem>
<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.3.0</version>
<version>3.0.0-M6</version>
<configuration>
<includes>
<include>it.org.apache.struts2.showcase.*Test</include>
@@ -219,7 +185,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>
@@ -232,17 +198,12 @@
<httpConnector>
<port>8090</port>
</httpConnector>
<scan>10</scan>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppSourceDirectory>${basedir}/src/main/webapp/</webAppSourceDirectory>
<webApp>
<extraClasspath>
${project.build.directory}/extraclasspath/struts2-sitemesh2-jakarta.jar,
${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>
<webAppConfig>
<contextPath>/struts2-showcase</contextPath>
<descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor>
</webAppConfig>
</configuration>
<executions>
<execution>
@@ -24,15 +24,9 @@ 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;
}
@@ -208,7 +193,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return legalAge;
}
@StrutsParameter
public void setLegalAge(boolean legalAge) {
this.legalAge = legalAge;
}
@@ -217,7 +201,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return state;
}
@StrutsParameter
public void setState(String state) {
this.state = state;
}
@@ -226,7 +209,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return region;
}
@StrutsParameter
public void setRegion(String region) {
this.region = region;
}
@@ -247,7 +229,6 @@ public class UITagExample extends ActionSupport implements Validateable {
this.pictureFileName = pictureFileName;
}
@StrutsParameter
public void setFavouriteLanguage(String favouriteLanguage) {
this.favouriteLanguage = favouriteLanguage;
}
@@ -256,7 +237,7 @@ public class UITagExample extends ActionSupport implements Validateable {
return favouriteLanguage;
}
@StrutsParameter
public void setThoughts(String thoughts) {
this.thoughts = thoughts;
}
@@ -269,7 +250,6 @@ public class UITagExample extends ActionSupport implements Validateable {
return wakeup;
}
@StrutsParameter
public void setWakeup(Date wakeup) {
this.wakeup = wakeup;
}
@@ -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 com.opensymphony.xwork2.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";
}
}
}
@@ -21,7 +21,6 @@ package org.apache.struts2.showcase.action;
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;
@@ -72,7 +71,6 @@ public class SkillAction extends AbstractCRUDAction implements Preparable {
return skillDao;
}
@StrutsParameter(depth = 1)
public Skill getCurrentSkill() {
return currentSkill;
}
@@ -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) {
@@ -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;
/**
@@ -19,7 +19,6 @@
package org.apache.struts2.showcase.async;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
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;
}
@@ -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 {
@@ -21,7 +21,6 @@
package org.apache.struts2.showcase.conversion;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
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;
}
@@ -21,7 +21,6 @@
package org.apache.struts2.showcase.conversion;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.Arrays;
import java.util.LinkedList;
@@ -48,7 +47,6 @@ public class OperationsEnumAction extends ActionSupport {
return this.selectedOperations;
}
@StrutsParameter
public void setSelectedOperations(List<OperationsEnum> selectedOperations) {
this.selectedOperations = selectedOperations;
}
@@ -21,7 +21,6 @@
package org.apache.struts2.showcase.conversion;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.List;
@@ -37,7 +36,6 @@ public class PersonAction extends ActionSupport {
return SUCCESS;
}
@StrutsParameter(depth = 2)
public List<Person> getPersons() {
return persons;
}
@@ -22,7 +22,6 @@ package org.apache.struts2.showcase.filedownload;
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);
}
@@ -21,69 +21,75 @@
package org.apache.struts2.showcase.fileupload;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.action.UploadedFilesAware;
import org.apache.struts2.dispatcher.multipart.UploadedFile;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
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 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 Object getUploadedFile() {
return uploadedFile.getContent();
}
public String getCaption() {
return caption;
}
// 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;
}
@StrutsParameter
public void setCaption(String caption) {
this.caption = caption;
}
public void setUploadContentType(String contentType) {
this.contentType = contentType;
}
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();
}
}
@@ -22,51 +22,61 @@
package org.apache.struts2.showcase.fileupload;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.action.UploadedFilesAware;
import org.apache.struts2.dispatcher.multipart.UploadedFile;
import java.util.List;
import java.io.File;
/**
* 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 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;
}
@Override
public void withUploadedFiles(List<UploadedFile> uploadedFiles) {
this.uploadedFiles = uploadedFiles;
}
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;
}
private String[] getUploadFileNames() {
return this.uploadedFiles.stream()
.map(UploadedFile::getOriginalName)
.toArray(String[]::new);
}
public File[] getUpload() {
return this.uploads;
}
private String[] getUploadContentTypes() {
return this.uploadedFiles.stream()
.map(UploadedFile::getContentType)
.toArray(String[]::new);
}
public void setUpload(File[] upload) {
this.uploads = upload;
}
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
@@ -22,56 +22,64 @@
package org.apache.struts2.showcase.fileupload;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.action.UploadedFilesAware;
import org.apache.struts2.dispatcher.multipart.UploadedFile;
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
@@ -24,8 +24,8 @@ 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,10 +20,10 @@
*/
package org.apache.struts2.showcase.servlet;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class TestServlet extends HttpServlet {
@@ -24,7 +24,7 @@ import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ClassLoaderUtil;
import org.apache.struts2.action.ServletContextAware;
import jakarta.servlet.ServletContext;
import javax.servlet.ServletContext;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -30,13 +30,13 @@ 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 -->
@@ -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;
}
@@ -21,7 +21,6 @@
package org.apache.struts2.showcase.wait;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;
/**
* Example to illustrate the <code>execAndWait</code> interceptor.
@@ -42,7 +41,6 @@ public class LongProcessAction extends ActionSupport {
return time;
}
@StrutsParameter
public void setTime(int time) {
this.time = time;
}
@@ -22,7 +22,7 @@ package org.apache.struts2.showcase.xslt;
import com.opensymphony.xwork2.ActionSupport;
import jakarta.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.action.ServletRequestAware;
@@ -24,9 +24,6 @@
"https://struts.apache.org/dtds/struts-6.0.dtd">
<struts>
<constant name="struts.multipart.maxSize" value="10240" />
<package name="fileupload" extends="struts-default" namespace="/fileupload">
<action name="upload" class="org.apache.struts2.showcase.fileupload.FileUploadAction" method="input">
@@ -47,7 +47,12 @@
<result>/WEB-INF/validation/quiz-success.jsp</result>
</action>
<action name="quizClientCss" class="org.apache.struts2.showcase.validation.QuizAction">
<action name="quizDwr" class="org.apache.struts2.showcase.validation.QuizAction">
<result name="input">/WEB-INF/validation/quiz-dwr.jsp</result>
<result>/WEB-INF/validation/quiz-success.jsp</result>
</action>
<action name="quizClientCss" class="org.apache.struts2.showcase.validation.QuizAction">
<result name="input">/WEB-INF/validation/quiz-client-css.jsp</result>
<result>/WEB-INF/validation/quiz-success.jsp</result>
</action>
@@ -34,9 +34,6 @@
<constant name="struts.custom.i18n.resources" value="globalMessages" />
<constant name="struts.action.extension" value="action,," />
<constant name="struts.allowlist.enable" value="true" />
<constant name="struts.parameters.requireAnnotations" value="true" />
<constant name="struts.convention.package.locators.basePackage" value="org.apache.struts2.showcase" />
<constant name="struts.convention.result.path" value="/WEB-INF" />
@@ -83,8 +80,6 @@
<include file="struts-dispatcher.xml" />
<include file="struts-params-annotation.xml" />
<package name="default" extends="struts-default">
<interceptors>
<interceptor-stack name="crudStack">
@@ -72,7 +72,7 @@
<s:script src="%{jqueryJs}"/>
<s:url var="bootstrapJs" value='/js/bootstrap.min.js' encode='false' includeParams='none'/>
<s:script src="%{bootstrapJs}"/>
<s:script>
<s:script type="text/javascript">
$(function () {
var alerts = $('ul.alert').wrap('<div />');
alerts.prepend('<a class="close" data-dismiss="alert" href="#">&times;</a>');
@@ -226,6 +226,7 @@
<li><s:a href="%{storeMessageAcrossRequestExample}">Store across request using MessageStoreInterceptor (Example)</s:a></li>
<li><s:a href="%{quizBasic}">Validation (basic)</s:a></li>
<li><s:a href="%{quizClient}">Validation (client)</s:a></li>
<li><s:a href="%{quizDwr}">Validation (DWR)</s:a></li>
<li><s:a href="%{quizClientCss}">Validation (client using css_xhtml theme)</s:a></li>
<li><s:a href="%{visitorValidatorUrl}">Visitor Validator</s:a></li>
<li><s:a href="%{ajaxFormSubmitUrl}">AJAX Form Submit</s:a></li>
@@ -19,7 +19,7 @@
*/
-->
<%@ page
language="java"
language="java"
contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
@@ -37,12 +37,10 @@
<div class="row">
<div class="col-md-12">
<ul>
<li>ContentType: <s:property value="contentType" /></li>
<li>FileName: <s:property value="fileName" /></li>
<li>Original FileName: <s:property value="originalName" /></li>
<li>File: <s:property value="uploadedFile" /></li>
<li>Size: <s:property value="uploadSize" /></li>
<li>Caption: <s:property value="caption" /></li>
<li>ContentType: <s:property value="uploadContentType" /></li>
<li>FileName: <s:property value="uploadFileName" /></li>
<li>File: <s:property value="upload" /></li>
<li>Caption:<s:property value="caption" /></li>
</ul>
</div>
</div>
@@ -72,7 +72,7 @@
</div>
</div>
<s:script>
<s:script type="text/javascript">
/********************************************************************
* JS just used on this page.
* Usually this would be placed in a JS file
@@ -0,0 +1,92 @@
<!--
/*
* 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.
*/
-->
<%@ taglib prefix="s" uri="/struts-tags" %>
<!-- START SNIPPET: dwrValidation -->
<html>
<head>
<title>Struts2 Showcase - Validation - DWR</title>
<s:head/>
<s:script type='text/javascript' src='../dwr/engine.js'></s:script>
<s:script type='text/javascript' src='../dwr/util.js'></s:script>
<s:script type='text/javascript' src='../dwr/interface/validator.js'></s:script>
<s:script type='text/javascript'>
var dwrValidateReply = function(data) {
var validationResult = '';
for (index = 0; index < data.actionErrors.length; ++index) {
validationResult += (data.actionErrors[index] + '. ');
}
for (index = 0; index < data.actionMessages.length; ++index) {
validationResult += (data.actionMessages[index] + '. ');
}
if (typeof data.fieldErrors.name !== 'undefined') {
for (index = 0; index < data.fieldErrors.name.length; ++index) {
validationResult += (data.fieldErrors.name[index] + '. ');
}
}
if (typeof data.fieldErrors.age !== 'undefined') {
for (index = 0; index < data.fieldErrors.age.length; ++index) {
validationResult += (data.fieldErrors.age[index] + '. ');
}
}
if (validationResult === '') {
$('form').submit();
} else {
dwr.util.setValue('validationResult', validationResult);
}
};
function dwrFormValidation() {
var postData = {};
$('form').serializeArray().map(function (x) {
postData[x.name] = x.value;
});
validator.doPost('/validation', 'quizDwr', postData, dwrValidateReply);
return false;
}
</s:script>
</head>
<body>
<div class="page-header">
<h1>DWR validation Example</h1>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<s:form method="post">
<s:textfield label="Name" name="name"/>
<s:textfield label="Age" name="age"/>
<s:textfield label="Favorite color" name="answer"/>
<s:submit cssClass="btn btn-primary" onClick="return dwrFormValidation()"/>
</s:form>
<div id="validationResult" class="errorMessage"></div>
</div>
</div>
</div>
</body>
</html>
<!-- END SNIPPET: dwrValidation -->
+18 -1
View File
@@ -98,6 +98,16 @@
<listener-class>org.apache.struts2.dispatcher.listener.StrutsListener</listener-class>
</listener>
<!-- SNIPPET START: dwr -->
<servlet>
<servlet-name>dwr</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>JspSupportServlet</servlet-name>
<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
@@ -137,7 +147,12 @@
<servlet-class>org.apache.struts2.showcase.servlet.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-mapping>
<servlet-name>dwr</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>sitemesh-freemarker</servlet-name>
<url-pattern>*.ftl</url-pattern>
</servlet-mapping>
@@ -157,6 +172,8 @@
<url-pattern>/testServlet/*</url-pattern>
</servlet-mapping>
<!-- END SNIPPET: dwr -->
<!-- SNIPPET START: example.velocity.filter.chain
<filter>
<filter-name>struts-cleanup</filter-name>
@@ -20,11 +20,12 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlPage;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class ActionChainingTest {
@Test
public void test() throws Exception {
@@ -20,11 +20,12 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlPage;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class ActionTagExampleTest {
@Test
public void test() throws Exception {
@@ -18,15 +18,16 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.DomElement;
import org.htmlunit.html.HtmlForm;
import org.htmlunit.html.HtmlPage;
import org.htmlunit.html.HtmlSubmitInput;
import org.htmlunit.html.HtmlTextInput;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
public class AsyncTest {
@Test
public void testChatRoom() throws Exception {
@@ -20,14 +20,15 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlForm;
import org.htmlunit.html.HtmlPage;
import org.htmlunit.html.HtmlSubmitInput;
import org.htmlunit.html.HtmlTextInput;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
public class CRUDTest {
@Test
public void testCreate() throws Exception {
@@ -20,11 +20,12 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlPage;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class ComponentTagExampleTest {
@Test
public void test() throws Exception {
@@ -20,13 +20,14 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlForm;
import org.htmlunit.html.HtmlPage;
import org.htmlunit.html.HtmlSubmitInput;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
public class ConversionTest {
@Test
public void testList() throws Exception {
@@ -18,9 +18,9 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.DomElement;
import org.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import org.junit.Assert;
import org.junit.Test;
@@ -20,14 +20,15 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlForm;
import org.htmlunit.html.HtmlPage;
import org.htmlunit.html.HtmlSubmitInput;
import org.htmlunit.html.HtmlTextInput;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
public class ExecAndWaitTest {
@Test
public void testNodelay() throws Exception {
@@ -24,11 +24,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.htmlunit.Page;
import org.htmlunit.WebClient;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
public class FileDownloadTest {
@Test
public void testImage() throws Exception {
@@ -18,82 +18,36 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlFileInput;
import org.htmlunit.html.HtmlForm;
import org.htmlunit.html.HtmlInput;
import org.htmlunit.html.HtmlPage;
import org.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.HtmlFileInput;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import org.junit.Assert;
import org.junit.Test;
import java.io.File;
import java.io.FileWriter;
import java.security.SecureRandom;
import static org.assertj.core.api.Assertions.assertThat;
public class FileUploadTest {
@Test
public void testSimpleFileUpload() throws Exception {
public void testEmptyFile() throws Exception {
try (final WebClient webClient = new WebClient()) {
final HtmlPage page = webClient.getPage(ParameterUtils.getBaseUrl() + "/fileupload/doUpload.action");
final HtmlForm form = page.getFormByName("doUpload");
HtmlInput captionInput = form.getInputByName("caption");
HtmlFileInput uploadInput = form.getInputByName("upload");
captionInput.type("some caption");
File tempFile = File.createTempFile("testEmptyFile", ".txt");
File tempFile = File.createTempFile("testEmptyFile", ".tmp");
tempFile.deleteOnExit();
try (FileWriter writer = new FileWriter(tempFile)) {
writer.append("Some strings");
writer.flush();
}
uploadInput.setValue(tempFile.getAbsolutePath());
uploadInput.setValueAttribute(tempFile.getAbsolutePath());
final HtmlSubmitInput button = form.getInputByValue("Submit");
final HtmlPage resultPage = button.click();
String content = resultPage.getVisibleText();
assertThat(content).contains(
"ContentType: text/plain",
"Original FileName: " + tempFile.getName(),
"Caption: some caption",
"Size: 12"
);
}
}
@Test
public void testUploadOverMaxSize() throws Exception {
try (final WebClient webClient = new WebClient()) {
final HtmlPage page = webClient.getPage(ParameterUtils.getBaseUrl() + "/fileupload/doUpload.action");
final HtmlForm form = page.getFormByName("doUpload");
HtmlInput captionInput = form.getInputByName("caption");
HtmlFileInput uploadInput = form.getInputByName("upload");
captionInput.type("Large file");
File tempFile = File.createTempFile("testEmptyFile", ".txt");
SecureRandom rng = new SecureRandom();
tempFile.deleteOnExit();
try (FileWriter writer = new FileWriter(tempFile)) {
for (int i = 0; i < 10240; ++i) {
String line = String.format("%s %s%n", rng.nextInt(), rng.nextInt());
writer.append(line);
}
writer.flush();
}
uploadInput.setValue(tempFile.getAbsolutePath());
final HtmlSubmitInput button = form.getInputByValue("Submit");
final HtmlPage resultPage = button.click();
String content = resultPage.getVisibleText();
System.out.println(content);
assertThat(content).contains(
"Request exceeded allowed size limit! Max size allowed is: 10,240!"
);
DomElement errorMessage = resultPage.getFirstByXPath("//span[@class='errorMessage']");
Assert.assertNotNull(errorMessage);
Assert.assertEquals("File cannot be empty", errorMessage.getVisibleText());
}
}
@@ -20,9 +20,9 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.DomElement;
import org.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import org.junit.Assert;
import org.junit.Test;
@@ -20,12 +20,13 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.DomElement;
import org.htmlunit.html.HtmlPage;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class FreeMarkerManagerTest {
@Test
public void testCustomManager() throws Exception {
@@ -35,11 +36,11 @@ public class FreeMarkerManagerTest {
final DomElement date = page.getElementById("todaysDate");
Assert.assertNotNull(date);
Assert.assertFalse(date.asNormalizedText().isEmpty());
Assert.assertTrue(date.asNormalizedText().length() > 0);
final DomElement time = page.getElementById("timeNow");
Assert.assertNotNull(time);
Assert.assertFalse(time.asNormalizedText().isEmpty());
Assert.assertTrue(time.asNormalizedText().length() > 0);
}
}
@@ -18,15 +18,16 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.FailingHttpStatusCodeException;
import org.htmlunit.WebClient;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.WebClient;
public class StaticContentTest {
@Test
public void testInvalidResources1() throws Exception {
public void testInvalidRersources1() throws Exception {
try (final WebClient webClient = new WebClient()) {
try {
webClient.getPage(ParameterUtils.getBaseUrl() + "/struts..");
@@ -39,7 +40,7 @@ public class StaticContentTest {
}
@Test
public void testInvalidResources2() throws Exception {
public void testInvalidRersources2() throws Exception {
try (final WebClient webClient = new WebClient()) {
try {
webClient.getPage(ParameterUtils.getBaseUrl() + "/static/..%252f");
@@ -1,239 +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 it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlPage;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.web.util.UriComponentsBuilder;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
public class StrutsParametersTest {
private WebClient webClient;
@Before
public void setUp() throws Exception {
webClient = new WebClient();
}
@After
public void tearDown() throws Exception {
webClient.close();
}
@Test
public void public_StringField_WithoutGetterSetter_FieldNotAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicField", "yes");
params.put("varToPrint", "publicField");
assertText(params, "publicField{no}");
}
@Test
public void public_StringField_WithoutGetterSetter_FieldAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicFieldAnnotated", "yes");
params.put("varToPrint", "publicFieldAnnotated");
assertText(params, "publicFieldAnnotated{yes}");
}
@Test
public void private_StringField_WithSetter_MethodNotAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("privateFieldMethod", "yes");
params.put("varToPrint", "privateField");
assertText(params, "privateField{no}");
}
@Test
public void private_StringField_WithSetter_MethodAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("privateFieldMethodAnnotated", "yes");
params.put("varToPrint", "privateField");
assertText(params, "privateField{yes}");
}
@Test
public void public_ArrayField_WithoutGetterSetter_FieldNotAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicArray[0]", "1");
params.put("varToPrint", "publicArray");
assertText(params, "publicArray{[0]}");
}
@Test
public void public_ArrayField_WithoutGetterSetter_FieldAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicArrayAnnotated[0]", "1");
params.put("varToPrint", "publicArrayAnnotated");
assertText(params, "publicArrayAnnotated{[1]}");
}
@Test
public void public_ListField_WithoutGetterSetter_FieldNotAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicList[0]", "yes");
params.put("varToPrint", "publicList");
assertText(params, "publicList{[no]}");
}
@Test
public void public_ListField_WithoutGetterSetter_FieldAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicListAnnotated[0]", "yes");
params.put("varToPrint", "publicListAnnotated");
assertText(params, "publicListAnnotated{[yes]}");
}
@Test
public void private_ListField_WithGetterNoSetter_MethodNotAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("privateListMethod[0]", "yes");
params.put("varToPrint", "privateList");
assertText(params, "privateList{[no]}");
}
@Test
public void private_ListField_WithGetterNoSetter_MethodAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("privateListMethodAnnotated[0]", "yes");
params.put("varToPrint", "privateList");
assertText(params, "privateList{[yes]}");
}
@Test
public void public_MapField_WithoutGetterSetter_FieldNotAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicMap['key']", "yes");
params.put("varToPrint", "publicMap");
assertText(params, "publicMap{{key=no}}");
}
@Test
public void public_MapField_WithoutGetterSetter_FieldAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicMapAnnotated['key']", "yes");
params.put("varToPrint", "publicMapAnnotated");
assertText(params, "publicMapAnnotated{{key=yes}}");
}
@Test
public void public_MapField_Insert_WithoutGetterSetter_FieldNotAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicMap[999]", "yes");
params.put("varToPrint", "publicMap");
assertText(params, "publicMap{{key=no}}");
}
@Test
public void public_MapField_Insert_WithoutGetterSetter_FieldAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicMapAnnotated[999]", "yes");
params.put("varToPrint", "publicMapAnnotated");
assertText(params, "publicMapAnnotated{{999=yes, key=no}}");
}
@Test
public void public_MyDtoField_WithoutGetter_FieldNotAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicMyDto.str", "yes");
params.put("publicMyDto.map['key']", "yes");
params.put("publicMyDto.array[0]", "1");
params.put("varToPrint", "publicMyDto");
assertText(params, "publicMyDto{str=no, map={key=no}, array=[0]}");
}
@Test
public void public_MyDtoField_WithoutGetter_FieldAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicMyDtoAnnotated.str", "yes");
params.put("publicMyDtoAnnotated.map['key']", "yes");
params.put("publicMyDtoAnnotated.array[0]", "1");
params.put("varToPrint", "publicMyDtoAnnotated");
assertText(params, "publicMyDtoAnnotated{str=yes, map={key=yes}, array=[1]}");
}
@Test
public void public_MyDtoField_WithoutGetter_FieldAnnotatedDepthOne() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("publicMyDtoAnnotatedDepthOne.str", "yes");
params.put("publicMyDtoAnnotatedDepthOne.map['key']", "yes");
params.put("publicMyDtoAnnotatedDepthOne.array[0]", "1");
params.put("varToPrint", "publicMyDtoAnnotatedDepthOne");
assertText(params, "publicMyDtoAnnotatedDepthOne{str=yes, map={key=no}, array=[0]}");
}
@Test
public void private_MyDtoField_WithGetter_MethodNotAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("unsafeMethodMyDto.str", "yes");
params.put("unsafeMethodMyDto.map['key']", "yes");
params.put("unsafeMethodMyDto.array[0]", "1");
params.put("varToPrint", "privateMyDto");
assertText(params, "privateMyDto{str=no, map={key=no}, array=[0]}");
}
@Test
public void private_MyDtoField_WithGetter_MethodNotAnnotated_Alternate() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("unsafeMethodMyDto['str']", "yes");
params.put("unsafeMethodMyDto['map']['key']", "yes");
params.put("unsafeMethodMyDto['map'][999]", "yes");
params.put("unsafeMethodMyDto['array'][0]", "1");
params.put("varToPrint", "privateMyDto");
assertText(params, "privateMyDto{str=no, map={key=no}, array=[0]}");
}
@Test
public void private_MyDtoField_WithGetter_MethodAnnotated() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("safeMethodMyDto.str", "yes");
params.put("safeMethodMyDto.map['key']", "yes");
params.put("safeMethodMyDto.array[0]", "1");
params.put("varToPrint", "privateMyDto");
assertText(params, "privateMyDto{str=yes, map={key=yes}, array=[1]}");
}
@Test
public void private_MyDtoField_WithGetter_MethodAnnotatedDepthOne() throws Exception {
Map<String, String> params = new HashMap<>();
params.put("safeMethodMyDtoDepthOne.str", "yes");
params.put("safeMethodMyDtoDepthOne.map['key']", "yes");
params.put("safeMethodMyDtoDepthOne.array[0]", "1");
params.put("varToPrint", "privateMyDto");
assertText(params, "privateMyDto{str=yes, map={key=no}, array=[0]}");
}
private void assertText(Map<String, String> params, String text) throws IOException {
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(ParameterUtils.getBaseUrl()).path("/paramsannotation/test.action");
params.forEach(builder::queryParam);
String url = builder.toUriString();
HtmlPage page = webClient.getPage(url);
String output = page.getElementById("output").asNormalizedText();
assertEquals(text, output);
}
}
@@ -20,17 +20,18 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlCheckBoxInput;
import org.htmlunit.html.HtmlForm;
import org.htmlunit.html.HtmlPage;
import org.htmlunit.html.HtmlSelect;
import org.htmlunit.html.HtmlSubmitInput;
import org.htmlunit.html.HtmlTextArea;
import org.htmlunit.html.HtmlTextInput;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSelect;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextArea;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
public class UITagExampleTest {
@Test
public void testInputForm() throws Exception {
@@ -20,13 +20,14 @@
*/
package it.org.apache.struts2.showcase;
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlForm;
import org.htmlunit.html.HtmlPage;
import org.htmlunit.html.HtmlSubmitInput;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
public class ValidationTest {
@Test
public void testFieldValidators() throws Exception {
+54 -6
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>7.0.0-M8</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-assembly</artifactId>
@@ -104,9 +104,7 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<executions>
<execution>
<id>make-assembly</id>
@@ -117,7 +115,6 @@
</execution>
</executions>
<configuration>
<skipAssembly>false</skipAssembly>
<descriptors>
<descriptor>src/main/assembly/all.xml</descriptor>
<descriptor>src/main/assembly/lib.xml</descriptor>
@@ -127,8 +124,8 @@
<descriptor>src/main/assembly/docs.xml</descriptor>
</descriptors>
<finalName>struts-${project.version}</finalName>
<outputDirectory>${project.build.directory}/assembly/out</outputDirectory>
<workDirectory>${project.build.directory}/assembly/work</workDirectory>
<outputDirectory>target/assembly/out</outputDirectory>
<workDirectory>target/assembly/work</workDirectory>
</configuration>
</plugin>
</plugins>
@@ -166,6 +163,11 @@
<artifactId>struts2-config-browser-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-dwr-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-jasperreports-plugin</artifactId>
@@ -181,6 +183,21 @@
<artifactId>struts2-junit-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-pell-multipart-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plexus-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-portlet-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-rest-plugin</artifactId>
@@ -204,9 +221,40 @@
<artifactId>struts2-tiles-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-oval-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-embeddedjsp-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-gxp-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-osgi-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-osgi-admin-bundle</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-osgi-demo-bundle</artifactId>
</dependency>
</dependencies>
</project>
+256 -202
View File
@@ -23,210 +23,264 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>all</id>
<formats>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
<scope>runtime</scope>
<excludes>
<exclude>junit:junit</exclude>
<exclude>org.testng:testng</exclude>
</excludes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>README*</include>
<include>LICENSE*</include>
<include>NOTICE*</include>
</includes>
</fileSet>
<fileSet>
<directory>../core/src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>FREEMARKER-LICENSE.txt</include>
<include>OGNL-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins/rest/src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>XSTREAM-LICENSE.txt</include>
<include>XPP3-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins/sitemesh/src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>SITEMESH-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>target/apps</directory>
<outputDirectory>apps</outputDirectory>
<includes>
<include>*.war</include>
</includes>
</fileSet>
<id>all</id>
<formats>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
<scope>runtime</scope>
<excludes>
<exclude>junit:junit</exclude>
<exclude>org.testng:testng</exclude>
</excludes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>README*</include>
<include>LICENSE*</include>
<include>NOTICE*</include>
</includes>
</fileSet>
<fileSet>
<directory>../core/src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>FREEMARKER-LICENSE.txt</include>
<include>OGNL-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins/plexus/src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>CLASSWORLDS-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins/rest/src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>XSTREAM-LICENSE.txt</include>
<include>XPP3-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins/sitemesh/src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>SITEMESH-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins/oval/src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>OVAL-LICENSE.txt</include>
<include>XSTREAM-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>target/apps</directory>
<outputDirectory>apps</outputDirectory>
<includes>
<include>*.war</include>
</includes>
</fileSet>
<!-- Include the Struts 2 core Javadoc in the assembly -->
<fileSet>
<directory>../core/target/site</directory>
<outputDirectory>docs/struts2-core</outputDirectory>
</fileSet>
<fileSet>
<directory>../core/target/apidocs</directory>
<outputDirectory>docs/struts2-core-apidocs</outputDirectory>
</fileSet>
<!-- Include the Struts 2 core Javadoc in the assembly -->
<fileSet>
<directory>../core/target/site</directory>
<outputDirectory>docs/struts2-core</outputDirectory>
</fileSet>
<fileSet>
<directory>../core/target/apidocs</directory>
<outputDirectory>docs/struts2-core-apidocs</outputDirectory>
</fileSet>
<!-- Include the Confluence docs in the assembly -->
<fileSet>
<directory>target/docs</directory>
<outputDirectory>docs/docs</outputDirectory>
</fileSet>
<!-- Include the Confluence docs in the assembly -->
<fileSet>
<directory>target/docs</directory>
<outputDirectory>docs/docs</outputDirectory>
</fileSet>
<!-- Plugins -->
<!--
<fileSet>
<directory>../plugins/$plugin/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-$plugin-plugin</outputDirectory>
</fileSet>
-->
<fileSet>
<directory>../plugins/async/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-async-validation/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/bean-validation/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-bean-validation/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/cdi/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-cdi-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/config-browser/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-config-browser-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/convention/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-convention-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/jasperreports/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-jasperreports-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/javatemplates/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-javatemplates-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/jfreechart/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-jfreechart-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/json/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-json-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/junit/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-junit-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/rest/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-rest-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/sitemesh/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-sitemesh-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/spring/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-spring-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/testng/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-testng-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/tiles/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-tiles-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/velocity/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-velocity-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/xslt/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-xslt-plugin/apidocs</outputDirectory>
</fileSet>
<!-- Plugins -->
<!--
<fileSet>
<directory>../plugins/$plugin/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-$plugin-plugin</outputDirectory>
</fileSet>
-->
<fileSet>
<directory>../plugins/bean-validation/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-bean-validation/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/cdi/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-cdi-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/config-browser/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-config-browser-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/convention/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-convention-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/dwr/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-dwr-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/embeddedjsp/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-embeddedjsp-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/gxp/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-gxp-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/jasperreports/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-jasperreports-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/javatemplates/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-javatemplates-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/jfreechart/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-jfreechart-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/json/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-json-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/junit/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-junit-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/osgi/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-osgi-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/oval/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-oval-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/pell-multipart/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-pell-multipart-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/plexus/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-plexus-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/portlet/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-portlet-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/portlet-tiles/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-portlet-tiles-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/rest/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-rest-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/sitemesh/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-sitemesh-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/spring/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-spring-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/testng/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-testng-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/tiles/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-tiles-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/velocity/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-velocity-plugin/apidocs</outputDirectory>
</fileSet>
<!-- Include the source code in the assembly -->
<fileSet>
<directory>../</directory>
<outputDirectory>src/</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../apps</directory>
<outputDirectory>src/apps</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../apps/showcase</directory>
<outputDirectory>src/apps/showcase</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../apps/rest-showcase</directory>
<outputDirectory>src/apps/rest-showcase</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../assembly</directory>
<outputDirectory>src/assembly</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../core</directory>
<outputDirectory>src/core</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins</directory>
<outputDirectory>src/plugins</outputDirectory>
<excludes>
<exclude>*/target/**</exclude>
<exclude>target/**</exclude>
</excludes>
</fileSet>
</fileSets>
<!-- bundles -->
<fileSet>
<directory>../bundles/admin/target/site</directory>
<outputDirectory>docs/struts2-bundles/admin</outputDirectory>
</fileSet>
<fileSet>
<directory>../bundles/demo/target/site</directory>
<outputDirectory>docs/struts2-bundles/demo</outputDirectory>
</fileSet>
<!-- Include the source code in the assembly -->
<fileSet>
<directory>../</directory>
<outputDirectory>src/</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../apps</directory>
<outputDirectory>src/apps</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../apps/showcase</directory>
<outputDirectory>src/apps/showcase</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../apps/rest-showcase</directory>
<outputDirectory>src/apps/rest-showcase</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../assembly</directory>
<outputDirectory>src/assembly</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../core</directory>
<outputDirectory>src/core</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins</directory>
<outputDirectory>src/plugins</outputDirectory>
<excludes>
<exclude>*/target/**</exclude>
<exclude>target/**</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>
+7
View File
@@ -52,6 +52,13 @@
<include>OGNL-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins/plexus/src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>CLASSWORLDS-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins/rest/src/main/resources</directory>
<outputDirectory></outputDirectory>
+42 -12
View File
@@ -29,6 +29,12 @@
</formats>
<fileSets>
<!-- Include the XWork Javadoc in the assembly -->
<fileSet>
<directory>../xwork-core/target/apidocs</directory>
<outputDirectory>docs/xwork-core/apidocs</outputDirectory>
</fileSet>
<!-- Include the website in the assembly -->
<fileSet>
<directory>../target/site</directory>
@@ -46,10 +52,6 @@
</fileSet>
<!-- Plugins -->
<fileSet>
<directory>../plugins/async/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-async/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/bean-validation/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-bean-validation/apidocs</outputDirectory>
@@ -66,6 +68,18 @@
<directory>../plugins/convention/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-convention-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/dwr/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-dwr-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/embeddedjsp/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-embeddedjsp-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/gxp/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-gxp-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/jasperreports/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-jasperreports-plugin/apidocs</outputDirectory>
@@ -86,6 +100,30 @@
<directory>../plugins/junit/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-junit-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/osgi/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-osgi-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/oval/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-oval-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/pell-multipart/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-pell-multipart-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/plexus/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-plexus-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/portlet/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-portlet-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/portlet-tiles/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-portlet-tiles-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/rest/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-rest-plugin/apidocs</outputDirectory>
@@ -106,14 +144,6 @@
<directory>../plugins/tiles/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-tiles-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/velocity/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-velocity-plugin/apidocs</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/xslt/target/apidocs</directory>
<outputDirectory>docs/struts2-plugins/struts2-xslt-plugin/apidocs</outputDirectory>
</fileSet>
</fileSets>
</assembly>
+15
View File
@@ -56,6 +56,13 @@
<include>OGNL-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins/plexus/src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>CLASSWORLDS-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins/rest/src/main/resources</directory>
<outputDirectory></outputDirectory>
@@ -71,5 +78,13 @@
<include>SITEMESH-LICENSE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins/oval/src/main/resources</directory>
<outputDirectory></outputDirectory>
<includes>
<include>OVAL-LICENSE.txt</include>
<include>XSTREAM-LICENSE.txt</include>
</includes>
</fileSet>
</fileSets>
</assembly>
+1 -3
View File
@@ -39,10 +39,8 @@
<include>org.apache.commons:commons-text</include>
<include>org.apache.logging.log4j:log4j-api</include>
<include>ognl:ognl</include>
<include>org.apache.commons:commons-fileupload2-jakarta</include>
<include>commons-fileupload:commons-fileupload</include>
<include>org.apache.commons:commons-io</include>
<include>com.github.ben-manes.caffeine:caffeine</include>
<include>org.javassist:javassist</include>
</includes>
</dependencySet>
</dependencySets>
+16
View File
@@ -48,6 +48,14 @@
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../api</directory>
<outputDirectory>src/api</outputDirectory>
<includes>
<include>pom.xml</include>
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../apps</directory>
<outputDirectory>src/apps</outputDirectory>
@@ -99,6 +107,14 @@
<exclude>*.iws</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>../bundles</directory>
<outputDirectory>src/bundles</outputDirectory>
<excludes>
<exclude>*/target/**</exclude>
<exclude>target/**</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>
+4 -4
View File
@@ -1,6 +1,6 @@
#set ($stylebase = "https://struts.apache.org/css")
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
<!--
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
@@ -16,7 +16,7 @@ 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.
under the License.
-->
<html>
<head>
@@ -43,12 +43,12 @@ under the License.
<script src='http://struts.apache.org/highlighter/js/$hscript' type='text/javascript'></script>
#end
<script>
<script type="text/javascript">
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
</script>
#end
<script>
<script type="text/javascript" language="javascript">
var hide = null;
var show = null;
var children = null;
+29 -4
View File
@@ -25,11 +25,11 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>7.0.0-M8</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-bom</artifactId>
<version>7.0.0-M8</version>
<version>6.3.0.3-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Struts 2 Bill of Materials</name>
@@ -44,7 +44,7 @@
</licenses>
<properties>
<struts-version.version>7.0.0-M8</struts-version.version>
<struts-version.version>6.3.0.3-SNAPSHOT</struts-version.version>
<maven.site.skip>true</maven.site.skip>
<maven.site.deploy.skip>true</maven.site.deploy.skip>
</properties>
@@ -81,6 +81,11 @@
<artifactId>struts2-config-browser-plugin</artifactId>
<version>${struts-version.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-dwr-plugin</artifactId>
<version>${struts-version.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-embeddedjsp-plugin</artifactId>
@@ -121,11 +126,31 @@
<artifactId>struts2-osgi-plugin</artifactId>
<version>${struts-version.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-oval-plugin</artifactId>
<version>${struts-version.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-pell-multipart-plugin</artifactId>
<version>${struts-version.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plexus-plugin</artifactId>
<version>${struts-version.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-portlet-plugin</artifactId>
<version>${struts-version.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-portlet-tiles-plugin</artifactId>
<version>${struts-version.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-rest-plugin</artifactId>
@@ -165,7 +190,7 @@
</dependencyManagement>
<scm>
<tag>STRUTS_7_0_0_M8</tag>
<tag>STRUTS_6_3_0_1</tag>
<connection>scm:git:https://gitbox.apache.org/repos/asf/struts.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/struts.git</developerConnection>
<url>https://github.com/apache/struts/</url>
@@ -23,47 +23,40 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-jakarta</artifactId>
<version>7.0.0-M8</version>
<artifactId>struts2-osgi-bundles</artifactId>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-velocity-tools-view-jakarta</artifactId>
<packaging>jar</packaging>
<name>Struts 2 Jakarta EE Compatible Velocity Tools View</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.site.skip>true</maven.site.skip>
<maven.site.deploy.skip>true</maven.site.deploy.skip>
</properties>
<artifactId>struts2-osgi-admin-bundle</artifactId>
<packaging>bundle</packaging>
<name>DEPRECATED: Struts 2 OSGi Admin Bundle - since 6.0.0</name>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-osgi-plugin</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.transformer</groupId>
<artifactId>transformer-maven-plugin</artifactId>
<version>0.5.0</version>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<rules>
<jakartaDefaults>true</jakartaDefaults>
</rules>
<instructions>
<manifestLocation>META-INF</manifestLocation>
<Struts2-Enabled>true</Struts2-Enabled>
<Import-Package>*</Import-Package>
<Export-Package>org.apache.struts2.osgi.admin*</Export-Package>
<Spring-Context>*;create-asynchronously:=false</Spring-Context>
</instructions>
</configuration>
<executions>
<execution>
<id>eclipse-transformer-velocity-tools-view-jar</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<artifact>
<groupId>org.apache.velocity.tools</groupId>
<artifactId>velocity-tools-view</artifactId>
<version>${velocity-tools.version}</version>
</artifact>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
@@ -0,0 +1,215 @@
/*
* $Id$
*
* 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.osgi.admin.actions;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.entities.PackageConfig;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.osgi.BundleAccessor;
import org.apache.struts2.osgi.host.OsgiHost;
import org.apache.struts2.osgi.StrutsOsgiListener;
import org.apache.struts2.action.ServletContextAware;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import javax.servlet.ServletContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Collections;
import java.util.Comparator;
public class BundlesAction extends ActionSupport implements ServletContextAware {
private String id;
private BundleAccessor bundleAccessor;
private Configuration configuration;
private OsgiHost osgiHost;
public BundlesAction() {
}
public String index() {
return SUCCESS;
}
public String view() {
return SUCCESS;
}
public String start() throws BundleException {
clearErrorsAndMessages();
addActionMessage("Start - OSGi Host: " + osgiHost + ", ID: " + id);
Bundle bundle = osgiHost.getBundles().get(id);
try {
bundle.start();
//start() fires a BundleEvent.STARTED, which loads the config
//we need to wait until the config is loaded from that bundle but
//there no easy way/elegant way to know if the bundle was processed already
Thread.sleep(1000);
} catch (Exception e) {
addActionError("Exception: " + e.toString() + " (" + e.getMessage() + ")");
}
return view();
}
public String stop() throws BundleException {
clearErrorsAndMessages();
addActionMessage("Stop - OSGi Host: " + osgiHost + ", ID: " + id);
Bundle bundle = osgiHost.getBundles().get(id);
try {
bundle.stop();
} catch (Exception e) {
addActionError("Exception: " + e.toString() + " (" + e.getMessage() + ")");
}
return view();
}
public String update() throws BundleException {
clearErrorsAndMessages();
addActionMessage("Update - OSGi Host: " + osgiHost + ", ID: " + id);
Bundle bundle = osgiHost.getBundles().get(id);
try {
bundle.update();
} catch (Exception e) {
addActionError("Exception: " + e.toString() + " (" + e.getMessage() + ")");
}
return view();
}
public boolean isStrutsEnabled(Bundle bundle) {
return "true".equalsIgnoreCase((String) bundle.getHeaders().get(OsgiHost.OSGI_HEADER_STRUTS_ENABLED));
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Bundle getBundle() {
return osgiHost.getBundles().get(id);
}
public List<PackageConfig> getPackages() {
List<PackageConfig> pkgs = new ArrayList<>();
Bundle bundle = getBundle();
if (bundle.getState() == Bundle.ACTIVE) {
bundleAccessor.getPackagesByBundle(bundle).stream().map(
name -> configuration.getPackageConfig(name)).filter(
packageConfig -> (packageConfig != null)).forEachOrdered(packageConfig -> {
pkgs.add(packageConfig);
});
}
return pkgs;
}
public ArrayList<String> getHeaderKeys() {
return Collections.list(getBundle().getHeaders().keys());
}
public Collection<Bundle> getBundles() {
List<Bundle> bundles = new ArrayList(osgiHost.getBundles().values());
Collections.sort(bundles, (Bundle bundle1, Bundle bundle2) -> {
boolean bundle1StrutsEnabled = isStrutsEnabled(bundle1);
boolean bundle2StrutsEnabled = isStrutsEnabled(bundle2);
if ((bundle1StrutsEnabled && bundle2StrutsEnabled) || (!bundle1StrutsEnabled && !bundle2StrutsEnabled)) {
return bundle1.getSymbolicName().compareTo(bundle2.getSymbolicName());
} else {
return bundle1StrutsEnabled ? -1 : 1;
}
});
return bundles;
}
public String displayProperty(Object obj) {
if (obj.getClass().isArray()) {
return Arrays.asList((Object[])obj).toString();
} else {
return obj.toString();
}
}
public String getBundleState(Bundle bundle) {
switch (bundle.getState()) {
case Bundle.ACTIVE : return "Active";
case Bundle.INSTALLED : return "Installed";
case Bundle.RESOLVED : return "Resolved";
case Bundle.STARTING : return "Starting";
case Bundle.STOPPING : return "Stopping";
case Bundle.UNINSTALLED : return "Uninstalled";
default : throw new IllegalStateException("Invalid state");
}
}
public boolean isAllowedAction(Bundle bundle, String val) {
int state = -1;
try {
state = bundle.getState();
} catch (Exception e) {
addActionError("Unable to determine bundle state. Exception: " + e.toString() + " (" + e.getMessage() + ")");
return false;
}
if (val != null) {
switch (val) {
case "start":
return state == Bundle.RESOLVED;
case "stop":
return state == Bundle.ACTIVE;
case "update":
return state == Bundle.ACTIVE || state == Bundle.INSTALLED || state == Bundle.RESOLVED;
default:
break;
}
}
throw new IllegalArgumentException("Invalid state");
}
@Inject
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}
@Inject
public void setBundleAccessor(BundleAccessor bundleAccessor) {
this.bundleAccessor = bundleAccessor;
}
@Override
public void withServletContext(ServletContext servletContext) {
osgiHost = (OsgiHost) servletContext.getAttribute(StrutsOsgiListener.OSGI_HOST);
}
}
@@ -0,0 +1,144 @@
/*
* $Id$
*
* 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.osgi.admin.actions;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import org.apache.felix.shell.ShellService;
import org.apache.struts2.osgi.DefaultBundleAccessor;
import org.apache.struts2.osgi.interceptor.BundleContextAware;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
/**
* This action executes commands on the Felix Shell.
*
* The action is BundleContextAware so that if the OSGi interceptor is used the BundleContext
* can be provided for configurations where the DefaultBundleAccessor is insufficient.
*
*/
public class ShellAction extends ActionSupport implements BundleContextAware {
private String command;
private String output;
private BundleContext bundleContext;
@Override
public String execute() {
// get service
ByteArrayOutputStream outByteStream = new ByteArrayOutputStream();
ByteArrayOutputStream errByteStream = new ByteArrayOutputStream();
PrintStream outStream = new PrintStream(outByteStream);
PrintStream errStream = new PrintStream(errByteStream);
String outString = null;
String errString = null;
try {
executeCommand(command, outStream, errStream);
outString = outByteStream.toString().trim();
errString = errByteStream.toString().trim();
} catch (Exception e) {
outString = outByteStream.toString().trim();
errString = "Exception: " + e.toString() + " (" + e.getMessage() + "). Output:" + outString +
". Error: " + errByteStream.toString().trim(); // Full details for troubleshooting.
} finally {
outStream.close();
errStream.close();
}
output = errString != null && errString.length() > 0 ? errString : outString;
return Action.SUCCESS;
}
public String getCommand() {
return command;
}
public void setCommand(String command) {
this.command = command;
}
public String getOutput() {
return output;
}
public void executeCommand(String commandLine, PrintStream out, PrintStream err) throws Exception {
ShellService shellService = getShellService(out);
if (shellService != null) {
out.println("Attempting to execute command: " + commandLine);
shellService.executeCommand(commandLine, out, err);
}
else {
err.println("Apache Felix Shell service is not installed");
}
}
private ShellService getShellService(PrintStream out) {
//bundle can be de-activated, so keeping a reference aorund is not a good idea
final DefaultBundleAccessor bundleAccessor = DefaultBundleAccessor.getInstance();
ServiceReference ref = (bundleAccessor != null ? bundleAccessor.getServiceReference(ShellService.class.getName()) : null);
//out.println("DefaultBundleAccessor: " + bundleAcessor + ", ServiceReference [" + ShellService.class.getName() + "]: " + ref); // No logger, for debugging only.
if (ref == null && this.bundleContext != null) {
// Depending on OSGi and Felix bundle configurations, the DefaultBundleAccessor may not be able to locate the ShellService.
// In such cases, use the bundleContext (if available) to locate the ShellService in a "brute-force" manner.
final Bundle[] bundles = this.bundleContext.getBundles();
if (bundles != null && bundles.length > 0) {
for (Bundle currentBundle : bundles) {
if (currentBundle != null) {
//out.println("Bundle [" + index + "], SymbolicName: " + currentBundle.getSymbolicName() + ", Location: " + currentBundle.getLocation() + ", BundleID: " + currentBundle.getBundleId()); // No logger, for debugging only.
if (currentBundle.getSymbolicName().startsWith("org.apache.felix.shell")) {
BundleContext currentBundleContext = currentBundle.getBundleContext();
Object directShellServiceByClass = (currentBundleContext != null ? currentBundleContext.getServiceReference(org.apache.felix.shell.ShellService.class) : null);
Object directShellServiceByName = (currentBundleContext != null ? currentBundleContext.getServiceReference("org.apache.felix.shell.ShellService") : null);
//out.println(" ShellService reference (via bundle's context) by class: " + directShellServiceByClass); // No logger, for debugging only.
//out.println(" ShellService reference (via bundle's context) by name: " + directShellServiceByName); // No logger, for debugging only.
if (ref == null) {
ref = (directShellServiceByClass != null ? (ServiceReference) directShellServiceByClass : (ServiceReference) directShellServiceByName);
}
}
} else {
//out.println("Bundle [" + index + "] is null"); // No logger, for debugging only.
}
}
} else {
//out.println("OSGi Interceptor-provided BundleContext bundle array is null or empty"); // No logger, for debugging only.
}
}
if (ref == null) {
out.println("ShellService reference cannot be found (null), service lookup will fail.");
}
return (ShellService) (bundleAccessor != null ? bundleAccessor.getService(ref) : null);
}
@Override
public void setBundleContext(BundleContext bundleContext) {
//System.out.println("ShellAction - setBundleContext called. BundleContext: " + bundleContext); // No logger, for debugging only.
this.bundleContext = bundleContext;
}
}
@@ -0,0 +1,43 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery-ui
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
Copyright and related rights for sample code are waived via CC0. Sample
code is defined as all source code contained within the demos directory.
CC0: http://creativecommons.org/publicdomain/zero/1.0/
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.
@@ -0,0 +1,174 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
@@ -0,0 +1,9 @@
Apache Struts
Copyright 2000-2011 The Apache Software Foundation
This product includes software developed by
The Apache Software Foundation (https://www.apache.org/).
The binary distributions includes the following third party software:
jQuery (https://jquery.com/).
jQuery UI (https://jqueryui.com/).
@@ -0,0 +1,21 @@
<#--
/*
* 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.
*/
-->
${output!}
@@ -0,0 +1,60 @@
<#--
/*
* 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.
*/
-->
<html>
<head>
<title>OSGi Console</title>
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/shell.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/main.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/redmond/jquery-ui-1.12.1.redmond.css" />" />
<script src="<@s.url value="${parameters.staticContentPath}/js/shell.js" />"></script>
<script src="<@s.url value="${parameters.staticContentPath}/js/jquery-1.12.4.min.js" />"></script>
<script src="<@s.url value="${parameters.staticContentPath}/js/jquery-ui-1.12.1.min.js" />"></script>
</head>
<body>
<div class="menu">
<div style="float:right;">
<@s.url var="bundlesUrl" namespace="/osgi/admin" action="bundles" includeParams="none" />
<@s.url var="osgiShellUrl" namespace="/osgi/admin" action="shell" includeParams="none" />
<a href="${bundlesUrl}" class="ui-state-default ui-corner-all fg-button fg-button-icon-left">
<span class="ui-icon ui-icon-bullet"></span>
Bundles
</a>
<a href="${osgiShellUrl}" class="ui-state-default ui-corner-all fg-button fg-button-icon-left">
<span class="ui-icon ui-icon-transferthick-e-w"></span>
OSGi Shell
</a>
</div>
</div>
<div id="shell" >
<form onsubmit="return false" id="wc-form">
<div class="wc-results" id="wc-result">
Welcome to the OSGi console! Type 'help' to see the list of available commands.
<br />
</div>
<@s.url var="execUrl" namespace="/osgi/admin" action="execCommand" />
<label for"command">Command:</label>
<input name="command" onkeyup="keyEvent(event, '${execUrl}')" class="wc-command" id="wc-command" type="text" />
</form>
</div>
</body>
</html>
@@ -0,0 +1,170 @@
<#--
/*
* 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.
*/
-->
<html>
<head>
<title>${bundle.symbolicName!}</title>
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/main.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/redmond/jquery-ui-1.12.1.redmond.css" />" />
<script src="<@s.url value="${parameters.staticContentPath}/js/jquery-1.12.4.min.js" />"></script>
<script src="<@s.url value="${parameters.staticContentPath}/js/jquery-ui-1.12.1.min.js" />"></script>
<script type="text/javascript">
$(function() {
$("#tabs").tabs();
});
</script>
</head>
<body>
<div class="menu">
<div style="float:left;">
<#if action.isAllowedAction(bundle, "start")>
<a href="bundle_${bundle.symbolicName}!start.action" class="ui-state-default ui-corner-all fg-button fg-button-icon-left">
<span class="ui-icon ui-icon-play"></span>
Start
</a>
</#if>
<#if action.isAllowedAction(bundle, "stop")>
<a href="bundle_${bundle.symbolicName}!stop.action" class="ui-state-default ui-corner-all fg-button fg-button-icon-left">
<span class="ui-icon ui-icon-stop"></span>
Stop
</a>
</#if>
<#if action.isAllowedAction(bundle, "update")>
<a href="bundle_${bundle.symbolicName}!update.action" class="ui-state-default ui-corner-all fg-button fg-button-icon-left">
<span class="ui-icon ui-icon-refresh"></span>
Update
</a>
</#if>
</div>
<div style="float:right;">
<@s.url var="bundlesUrl" namespace="/osgi/admin" action="bundles" includeParams="none" />
<@s.url var="osgiShellUrl" namespace="/osgi/admin" action="shell" includeParams="none" />
<a href="${bundlesUrl}" class="ui-state-default ui-corner-all fg-button fg-button-icon-left">
<span class="ui-icon ui-icon-bullet"></span>
Bundles
</a>
<a href="${osgiShellUrl}" class="ui-state-default ui-corner-all fg-button fg-button-icon-left">
<span class="ui-icon ui-icon-transferthick-e-w"></span>
OSGi Shell
</a>
</div>
</div>
<@s.actionerror />
<div id="tabs" class="tabs">
<ul>
<li><a href="#tabs-1">OSGi Metadata</a></li>
<li><a href="#tabs-2">Resgistered Services</a></li>
<li><a href="#tabs-3">Services in Use</a></li>
<li><a href="#tabs-4">Packages</a></li>
<li><a href="#tabs-5">Headers</a></li>
</ul>
<div id="tabs-1">
<table class="properties">
<tr>
<td class="name">Id</td>
<td>${bundle.bundleId!}</td>
</tr>
<tr>
<td class="name">Name</td>
<td>${bundle.symbolicName!}</td>
</tr>
<tr>
<td class="name">Location</td>
<td>${bundle.location!}</td>
</tr>
<tr>
<td class="name">Status</td>
<td>${action.getBundleState(bundle)}</td>
</tr>
</table>
</div>
<div id="tabs-2">
<#list (bundle.registeredServices)! as service>
<table class="properties">
<#list (service.propertyKeys)! as key >
<tr>
<td class="name">${key}</td>
<td>${action.displayProperty(service.getProperty(key))}</td>
</tr>
</#list>
</table>
<br/>
</#list>
</div>
<div id="tabs-3">
<#list (bundle.servicesInUse)! as service>
<table class="properties">
<#list (service.propertyKeys)! as key >
<tr>
<td class="name">${key}</td>
<td>${action.displayProperty(service.getProperty(key))!}</td>
</tr>
</#list>
</table>
<br/>
</#list>
</div>
<div id="tabs-4">
<#list packages! as pkg>
<table class="properties">
<tr>
<td class="name">Name</td>
<td>${pkg.name}</td>
</tr>
<tr>
<td class="name">Actions</td>
<td>
<ul>
<#list (pkg.actionConfigs.keySet())! as name >
<li>${name}</li>
</#list>
</ul>
</td>
</tr>
</table>
<br/>
</#list>
</div>
<div id="tabs-5">
<table class="properties">
<#list headerKeys as header>
<tr>
<td class="name">${header}</td>
<td><div class="propertyValue">${bundle.headers.get(header)}</div> </td>
</tr>
</#list>
</table>
</div>
</div>
<@s.actionmessage />
</body>
</html>
@@ -0,0 +1,97 @@
<#--
/*
* 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.
*/
-->
<html>
<head>
<title>OSGi Bundles</title>
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/main.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/redmond/jquery-ui-1.12.1.redmond.css" />" />
<script src="<@s.url value="${parameters.staticContentPath}/js/jquery-1.12.4.min.js" />"></script>
<script src="<@s.url value="${parameters.staticContentPath}/js/jquery-ui-1.12.1.min.js" />"></script>
</head>
<body>
<div class="menu">
<div style="float:right;">
<@s.url var="bundlesUrl" namespace="/osgi/admin" action="bundles" includeParams="none" />
<@s.url var="osgiShellUrl" namespace="/osgi/admin" action="shell" includeParams="none" />
<a href="${bundlesUrl}" class="ui-state-default ui-corner-all fg-button fg-button-icon-left">
<span class="ui-icon ui-icon-bullet"></span>
Bundles
</a>
<a href="${osgiShellUrl}" class="ui-state-default ui-corner-all fg-button fg-button-icon-left">
<span class="ui-icon ui-icon-transferthick-e-w"></span>
OSGi Shell
</a>
</div>
</div>
<@s.actionerror />
<table class="properties" style="clear:both; width:700px">
<thead>
<tr>
<th>Name</th>
<th>Status</th>
<th>Struts Bundle</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<#list bundles as bundle>
<tr>
<td>
<a href="bundle_${bundle.symbolicName}!view.action">${bundle.symbolicName}</a>
</td>
<td>${action.getBundleState(bundle)}</td>
<td>${action.isStrutsEnabled(bundle)?string("yes", "no")}</td>
<td style="width:200px">
<#if action.isAllowedAction(bundle, "start")>
<a href="bundle_${bundle.symbolicName}!start.action" class="ui-state-default ui-corner-all fg-button-small fg-button-icon-left">
<span class="ui-icon ui-icon-play"></span>
Start
</a>
</#if>
<#if action.isAllowedAction(bundle, "stop")>
<a href="bundle_${bundle.symbolicName}!stop.action" class="ui-state-default ui-corner-all fg-button-small fg-button-icon-left">
<span class="ui-icon ui-icon-stop"></span>
Stop
</a>
</#if>
<#if action.isAllowedAction(bundle, "update")>
<a href="bundle_${bundle.symbolicName}!update.action" class="ui-state-default ui-corner-all fg-button-small fg-button-icon-left">
<span class="ui-icon ui-icon-refresh"></span>
Update
</a>
</#if>
</td>
</tr>
</#list>
</tbody>
</table>
<@s.actionmessage />
</body>
</html>
@@ -0,0 +1,103 @@
.right {
clear: both;
float: right;
}
.left {
clear: both;
float: left;
}
.bundleDetails td {
border: 1px solid #C8C8C8;
}
.rowTitle {
width: 141px;
font-weight: bold;
vertical-align: top;
}
table.properties {
border-style: solid;
border-width: 1px;
border-color: #3366CC;
}
table.properties td {
border-style: solid;
border-width: 1px;
border-color: #3366CC;
}
table.properties td.name {
background-color: #C3D9FF;
vertical-align: top;
}
table.properties th {
background-color: #C3D9FF;
}
img {
border-style: none;
}
.fg-button {
outline: 0;
margin: 0 4px 0 0;
padding: .4em 1em;
text-decoration: none !important;
cursor: pointer;
position: relative;
text-align: center;
zoom: 1;
}
.fg-button .ui-icon {
margin-left: -3px;
margin-top: -8px;
position: absolute;
top: 50%;
}
.fg-button-small {
outline: 0;
margin: 0 4px 0 0;
padding: 0em 1em;
text-decoration: none !important;
cursor: pointer;
position: relative;
text-align: center;
}
.fg-button-small .ui-icon {
margin-left: -3px;
margin-top: -8px;
position: absolute;
top: 50%;
}
.fg-button-icon-left .ui-icon {
left: 0em;
margin-left: 0;
right: auto;
}
.menu {
clear: both;
padding-bottom: 10px;
height:25px;
}
.tabs {
clear: both;
}
.propertyValue {
width: 600px;
overflow: auto;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

File diff suppressed because it is too large Load Diff
@@ -0,0 +1,43 @@
/*
* $Id: webconsole.css 590812 2007-10-31 20:32:54Z apetrelli $
*
* 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.
*/
#shell {
clear: both;
}
.wc-results {
overflow: auto;
margin: 0px;
padding: 5px;
font-family: courier;
color: white;
background-color: black;
height: 400px;
}
.wc-results pre {
display: inline;
}
.wc-command {
margin: 0px;
font-family: courier;
color: white;
background-color: black;
width: 100%;
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long

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