diff options
150 files changed, 1824 insertions, 907 deletions
diff --git a/.travis.yml b/.travis.yml index af5cacd71..e8ce223cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: java jdk: - - openjdk7 - - oraclejdk7 - oraclejdk8 before_install: "mvn clean install -DskipTests=true -B -V -Pci-build" diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..a585b5141 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,71 @@ +node { + // System Dependent Locations + def mvntool = tool name: 'maven3', type: 'hudson.tasks.Maven$MavenInstallation' + def jdktool = tool name: 'jdk8', type: 'hudson.model.JDK' + + // Environment + List mvnEnv = ["PATH+MVN=${mvntool}/bin", "PATH+JDK=${jdktool}/bin", "JAVA_HOME=${jdktool}/", "MAVEN_HOME=${mvntool}"] + mvnEnv.add("MAVEN_OPTS=-Xms256m -Xmx1024m -Djava.awt.headless=true") + + try + { + stage 'Checkout' + checkout scm + } catch (Exception e) { + //notifyBuild("Checkout Failure") + throw e + } + + try + { + stage 'Build' + withEnv(mvnEnv) { + timeout(60) { + // Run test phase / ignore test failures + sh "mvn -B clean install -Dmaven.test.failure.ignore=true" + // Report failures in the jenkins UI + step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml']) + } + if(isUnstable()) + { + //notifyBuild("Unstable / Test Errors") + } + } + } catch(Exception e) { + notifyBuild("Test Failure") + throw e + } +} + +// Test if the Jenkins Pipeline or Step has marked the +// current build as unstable +def isUnstable() +{ + return currentBuild.result == "UNSTABLE" +} + +// Send a notification about the build status +def notifyBuild(String buildStatus) +{ + // default the value + buildStatus = buildStatus ?: "UNKNOWN" + + def email = "${env.EMAILADDRESS}" + def summary = "${env.JOB_NAME}#${env.BUILD_NUMBER} - ${buildStatus}" + def detail = """<h4>Job: <a href='${env.JOB_URL}'>${env.JOB_NAME}</a> [#${env.BUILD_NUMBER}]</h4> + <p><b>${buildStatus}</b></p> + <table> + <tr><td>Build</td><td><a href='${env.BUILD_URL}'>${env.BUILD_URL}</a></td><tr> + <tr><td>Console</td><td><a href='${env.BUILD_URL}console'>${env.BUILD_URL}console</a></td><tr> + <tr><td>Test Report</td><td><a href='${env.BUILD_URL}testReport/'>${env.BUILD_URL}testReport/</a></td><tr> + </table> + """ + + emailext ( + to: email, + subject: summary, + body: detail + ) +} + +// vim: et:ts=2:sw=2:ft=groovy diff --git a/archiva-cli/pom.xml b/archiva-cli/pom.xml index 61c0f0c2a..da7b77994 100644 --- a/archiva-cli/pom.xml +++ b/archiva-cli/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-cli</artifactId> diff --git a/archiva-docs/pom.xml b/archiva-docs/pom.xml index f6b671551..c385c0b5a 100644 --- a/archiva-docs/pom.xml +++ b/archiva-docs/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-docs</artifactId> @@ -32,6 +32,8 @@ <properties> <siteFilePath>${user.home}/archiva-sites/archiva-docs-${project.version}/</siteFilePath> <scmPubCheckoutDirectory>${basedir}/.site-content</scmPubCheckoutDirectory> + <maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format> + <releaseDate>${maven.build.timestamp}</releaseDate> </properties> <build> diff --git a/archiva-docs/src/site/apt/adminguide/configuration-files.apt.vm b/archiva-docs/src/site/apt/adminguide/configuration-files.apt.vm index 7b7fe8e55..22f17dc16 100644 --- a/archiva-docs/src/site/apt/adminguide/configuration-files.apt.vm +++ b/archiva-docs/src/site/apt/adminguide/configuration-files.apt.vm @@ -31,7 +31,9 @@ Configuration Files of Apache Archiva * <<<archiva.xml>>> - this is the primary Archiva configuration file - * <<<security.properties>>> - this configures the security as described in the {{{./security.html} security configuration documentation}} + * <<<security.properties>>> - This file, if it exists, is only read once to populate the + Redback Runtime Configuration properties (see {{{./redback-runtime-configuration.html#Runtime_Properties}Redback Runtime Configuration}}, + stored in <<<archiva.xml>>>. The file will be ignored after this. This section will focus on the <<<archiva.xml>>> file. diff --git a/archiva-docs/src/site/apt/adminguide/customising-security.apt b/archiva-docs/src/site/apt/adminguide/customising-security.apt index b7a99dd9d..797b2f309 100644 --- a/archiva-docs/src/site/apt/adminguide/customising-security.apt +++ b/archiva-docs/src/site/apt/adminguide/customising-security.apt @@ -27,47 +27,24 @@ Archiva Security Configuration - Security properties and password rules can be configured in the - <<<security.properties>>> file, which by default is searched for in: + Security properties and password rules are configured now in the Redback Runtime Configuration + properties (see {{{./redback-runtime-configuration.html#Runtime_properties}Redback Runtime Configuration}}). - * <<<~/.m2/security.properties>>> - - * <<<conf/security.properties>>> in the Archiva installation + The Redback Runtime Configuration properties are stored in <<<archiva.xml>>>. + The former <<<security.properties>>> file, if it exists, is only used once for populating the + Runtime Configuration settings. After that, this file will be ignored. [] - (In the above list, <<<~>>> is the home directory of the user who is running - Archiva.) ~~TODO: Link to plexus-redback documentation when available - Following are some of the properties you can modify. For a complete list, - consult the default properties file in Redback's svn repo: + These are the default properties. The file can be found in in Redback's svn repo: {{{http://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk/redback-configuration/src/main/resources/org/apache/archiva/redback/config-defaults.properties} config-defaults.properties}} -+-----+ -# Security Policies -#security.policy.password.encoder= -security.policy.password.previous.count=6 -security.policy.password.expiration.days=90 -security.policy.password.expiration.enabled=true -security.policy.allowed.login.attempt=3 - -# Password Rules -security.policy.password.rule.alphanumeric.enabled=false -security.policy.password.rule.alphacount.enabled=true -security.policy.password.rule.alphacount.minimum=1 -security.policy.password.rule.characterlength.enabled=true -security.policy.password.rule.characterlength.minimum=1 -security.policy.password.rule.characterlength.maximum=8 -security.policy.password.rule.musthave.enabled=true -security.policy.password.rule.numericalcount.enabled=true -security.policy.password.rule.numericalcount.minimum=1 -security.policy.password.rule.reuse.enabled=true -security.policy.password.rule.nowhitespace.enabled=true -+-----+ - +%{snippet|ignoreDownloadError=true|url=https://raw.githubusercontent.com/apache/archiva-redback-core/master/redback-configuration/src/main/resources/org/apache/archiva/redback/config-defaults.properties} + <<Note:>> If installed standalone, Archiva's list of configuration files is <itself> configurable, and can be found in: <<<apps/archiva/WEB-INF/applicationContext.xml>>> diff --git a/archiva-docs/src/site/apt/adminguide/redback-runtime-configuration.apt b/archiva-docs/src/site/apt/adminguide/redback-runtime-configuration.apt index 143589a34..7e000aa7e 100644 --- a/archiva-docs/src/site/apt/adminguide/redback-runtime-configuration.apt +++ b/archiva-docs/src/site/apt/adminguide/redback-runtime-configuration.apt @@ -29,7 +29,7 @@ Apache Archiva Redback Runtime Configuration * Apache Redback User Manager/RbacManager Implementations - Since 1.4-M4, you can choose to switch dynamically + You can choose to switch dynamically * User Manager Implementations (from Database and/or LDAP). @@ -49,7 +49,7 @@ Apache Archiva Redback Runtime Configuration * LDAP Group-Roles mapping - Since 1.4-M4, you can map dynamically LDAP Group to Archiva Roles + You can map dynamically LDAP Group to Archiva Roles [../images/ldap-group-roles-mapping.png] diff --git a/archiva-docs/src/site/apt/adminguide/repositories.apt b/archiva-docs/src/site/apt/adminguide/repositories.apt index 850b30a3d..7ec7753af 100644 --- a/archiva-docs/src/site/apt/adminguide/repositories.apt +++ b/archiva-docs/src/site/apt/adminguide/repositories.apt @@ -42,56 +42,58 @@ Understanding Repository Configuration of Apache Archiva Managed repository fields: - * <<identifier>> - the id of the repository. This must be unique. - - * <<name>> - the name of the repository. - - * <<directory>> - the location of the repository. If the path specified does not - exist, Archiva will create the missing directories. - - * <<index directory>> - the location of the index files generated by Archiva. If - no location is specified, then the index directory (named <<<.indexer>>>) - will be created at the root of the repository directory. - This directory contains the packaged/bundled index which is consumed by different consumers of the index such as M2Eclipse. - - * <<type>> - the repository layout (maven 2 or maven 1) - - * <<cron>> - the - {{{http://quartz-scheduler.org/api/2.1.5/org/quartz/CronTrigger.html}cron schedule}} when - repository scanning will be executed. - - * <<repository purge by days older>> - the first option for repository purge. - Archiva will check how old the artifact is and if it is older than the set - number of days in this field, then the artifact will be deleted respecting - the retention count of course. In order to disable the purge by - number of days old and set Archiva to purge by retention count, just set the - repository purge field to 0. The maximum number of days which can be set - here is 1000. See the Repository Purge section below for more details. -~~ above was:the retention count (see #7) of course no idea what is was linkeed to - - * <<repository purge by retention count>> - the second option for repository - purge. When running the repository purge, Archiva will retain only the - number of artifacts set for this field for a specific snapshot version. See - the Repository Purge section below for more details. - - * <<releases included>> - specifies whether there are released artifacts in the - repository. - - * <<block re-deployment of released artifacts>> - specifies whether released - artifacts that are already existing in the repository can be overwritten. - Note that this only take effects for non-snapshot deployments. - - * <<snapshots included>> - specifies whether there are snapshot artifacts in the - repository. - - * <<scannable>> - specifies whether the repository can be scanned, meaning it is - a local repository which can be indexed, browsed, purged, etc. - - * <<delete released snapshots>> - specifies whether to remove those snapshot - artifacts which already has release versions of it in the repository during - repository purge. - - * << Skip Packed Index creation >> - avoid creation of compressed index for IDE usage. +*----------------------+----------------------------------------------------------------------------------+ +| <<Id>> | The identifier of the repository. This must be unique. +*----------------------+----------------------------------------------------------------------------------+ +| <<Name>> | The name of the repository. This is the display name. +*----------------------+----------------------------------------------------------------------------------+ +| <<Directory>> | The location of the repository. If the path specified does not +| | exist, Archiva will create the missing directories. +*----------------------+----------------------------------------------------------------------------------+ +| <<Index Directory>> | The location of the index files generated by Archiva. If +| | no location is specified, then the index directory (named <<<.indexer>>>) +| | will be created at the root of the repository directory. +| | This directory contains the packaged/bundled index which is consumed by different +| | consumers of the index such as M2Eclipse. +*----------------------+----------------------------------------------------------------------------------+ +| <<Type>> | The repository layout (maven 2 or maven 1) +*----------------------+----------------------------------------------------------------------------------+ +| <<Cron Expression>> | The +| | {{{http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html}cron schedule}} +| | when repository scanning will be executed. +*----------------------+----------------------------------------------------------------------------------+ +| <<Days Older>> | The first option for repository purge. +| | Archiva will check how old the artifact is and if it is older than the set +| | number of days in this field, then the artifact will be deleted respecting +| | the retention count of course. In order to disable the purge by +| | number of days old and set Archiva to purge by retention count, just set the +| | repository purge field to 0. The maximum number of days which can be set +| | here is 1000. See the Repository Purge section below for more details. +*----------------------+----------------------------------------------------------------------------------+ +| <<Retention Count>> | The second option for repository purge. When running the repository purge, +| | Archiva will retain only the number of artifacts set for this field for a +| | specific snapshot version. See the Repository Purge section below for more details. +*----------------------+----------------------------------------------------------------------------------+ +| <<Description>> | Additional information about the repository. +*----------------------+----------------------------------------------------------------------------------+ +| <<Releases>> | Specifies whether there are released artifacts in the repository. +*----------------------+----------------------------------------------------------------------------------+ +| <<Snapshots>> | Specifies whether there are snapshot artifacts in the repository. +*----------------------+----------------------------------------------------------------------------------+ +| <<Block Redeployments>> | Specifies whether released artifacts that are already existing in the +| | repository can be overwritten. Note that this only take effects for non-snapshot +| | deployments. +*----------------------+----------------------------------------------------------------------------------+ +| <<Scanned>> | Specifies whether the repository can be scanned, meaning it is a local repository +| | which should be indexed, purged, etc. +*----------------------+----------------------------------------------------------------------------------+ +| <<Delete Released Snapshots>> | Specifies whether to remove those snapshot artifacts which already has +| | release versions of it in the repository during repository purge. +*----------------------+----------------------------------------------------------------------------------+ +| <<Staging Repository>>| Automatic creation of a stage repository for this local repository. +*----------------------+----------------------------------------------------------------------------------+ +|<< Skip Packed Index Creation>> | Avoid creation of compressed index for IDE usage. +*----------------------+----------------------------------------------------------------------------------+ [] @@ -119,46 +121,57 @@ http://[URL TO ARCHIVA]/repository/[REPOSITORY ID] (e.g. http://localhost:8080/r Remote repository fields: - * <<identifier>> - the id of the remote repository. - - * <<name>> - the name of the remote repository. - - * <<url>> - the url of the remote repository. It is also possible to use a - 'file://' url to proxy a local repository. Be careful that if this local - repository is a managed repository of archiva which has some proxies - connectors, those ones won't be triggered. - - * <<username>> - the username (if authentication is needed) to be used to access - the repository. - - * <<password>> - the password (if authentication is needed) to be used to access - the repository. - - * <<type>> - the layout (maven 2 or maven 1) of the remote repository. - - * <<Activate download remote index>> - to activate downloading remote index to - add available remote artifacts in search queries. - - * <<Remote index url, can be relative to url>> - path of the remote index - directory. - - * <<Cron expression>> - cron expression for downloading remote index (default - weekly on sunday) - - * <<Directory index storage>> - path to store index directory, default will be - $\{appserver.base\}/data/remotes/$\{repositoryId\}/.indexer - - * <<Download Remote Index Timeout in seconds>> - read time out for downloading - remote index files (default 300) - - * <<Network Proxy to Use for download Remote Index>> - proxy to use for - downloading remote index files. - - * <<Download Remote Index on Startup>> - will download remote index on Archiva startup. - - * <<Additionnal url parameters>> - key/value pairs to add to url when querying remote repository. - - * <<Additionnal Http Headers>> - key/value pairs to add as http headers when querying remote repository. +*----------------------+----------------------------------------------------------------------------------+ +| <<Id>> | The identifier of the remote repository. | +*----------------------+----------------------------------------------------------------------------------+ +| <<Name>> | The name of the remote repository. | +*----------------------+----------------------------------------------------------------------------------+ +| <<Url>> | The url of the remote repository. It is also possible to use a +| | 'file://' url to proxy a local repository. Be careful that if this local +| | repository is a managed repository of archiva which has some proxies +| | connectors, those ones won't be triggered. | +*----------------------+----------------------------------------------------------------------------------+ +| <<Username>> | The username (if authentication is needed) to be used to access +| | the repository. +*----------------------+----------------------------------------------------------------------------------+ +| <<Password>> | The password (if authentication is needed) to be used to access +| | the repository. +*----------------------+----------------------------------------------------------------------------------+ +| <<Download Timeout>> | The time in seconds after which a download from the remote repository is stopped. +*----------------------+----------------------------------------------------------------------------------+ +| <<Type>> | The layout (maven 2 or maven 1) of the remote repository. +*----------------------+----------------------------------------------------------------------------------+ +| <<Download Remote Index>> | To activate downloading remote index to +| | add available remote artifacts in search queries. +*----------------------+----------------------------------------------------------------------------------+ +| <<Remote Index Url>> | Can be relative to Url - path of the remote index +| | directory. +*----------------------+----------------------------------------------------------------------------------+ +| <<Cron expression>> | Cron expression for downloading remote index (default +| | weekly on sunday) +*----------------------+----------------------------------------------------------------------------------+ +| <<Index Directory>> | Path to store index directory, default will be +| | $\{appserver.base\}/data/remotes/$\{repositoryId\}/.indexer +*----------------------+----------------------------------------------------------------------------------+ +| <<Download Remote Index Timeout>> | Time in seconds, after which download of remote index files will be +| | stopped (default 300). +*----------------------+----------------------------------------------------------------------------------+ +| <<Proxy for Remote Download Index>> | Proxy to use for downloading remote index files. +*----------------------+----------------------------------------------------------------------------------+ +| <<Download Remote Index on Startup>> | If selected, the remote index will be downloaded on Archiva +| | startup. +*----------------------+----------------------------------------------------------------------------------+ +| <<Description>> | Can be used to store additional information about the repository. +*----------------------+----------------------------------------------------------------------------------+ +| <<Connection Check Path>> | If set, the connection to the remote repository is checked by validating the +| | existence of the given file / artifact. Some repositories do not allow to browse +| | the base directory and the standard check may fail. The path is relative to the +| | repository Url. +*----------------------+----------------------------------------------------------------------------------+ +| <<Additionnal Url Parameters>> | Key/Value pairs to add to url when querying remote repository. +*----------------------+----------------------------------------------------------------------------------+ +| <<Additionnal Http Headers>> | Key/Value pairs to add as http headers when querying remote repository. +*----------------------+----------------------------------------------------------------------------------+ [] diff --git a/archiva-docs/src/site/apt/adminguide/webapp.apt b/archiva-docs/src/site/apt/adminguide/webapp.apt index e035e37d3..91cec16f3 100644 --- a/archiva-docs/src/site/apt/adminguide/webapp.apt +++ b/archiva-docs/src/site/apt/adminguide/webapp.apt @@ -25,10 +25,10 @@ Installing Apache Archiva as a Web Application -~~TODO: link to wiki location for other application servers - Archiva can be deployed as a web application into any Java EE application server. This document will show an - example of doing so with Apache Tomcat 5.5, 6.0.x and 7.0.x + example of doing so with Apache Tomcat 5.5, 6.0.x and 7.0.x. + + You can find information about additional application servers on {{{https://cwiki.apache.org/confluence/display/ARCHIVA/HOWTO+run+Archiva+on+your+Application+Server+or+Database} the archiva wiki}}. <<Note>>: When you first start Archiva, you will see an Exception that schema SA does not exist - however it doesn't cause a problem. If you use a username other than 'sa', such as 'archiva', then you seem to get the same error but diff --git a/archiva-docs/src/site/apt/adminguide/webservices/rest.apt.vm b/archiva-docs/src/site/apt/adminguide/webservices/rest.apt.vm index 874c3eaf2..0aedc6d49 100644 --- a/archiva-docs/src/site/apt/adminguide/webservices/rest.apt.vm +++ b/archiva-docs/src/site/apt/adminguide/webservices/rest.apt.vm @@ -38,6 +38,13 @@ Using REST Services * Redback REST api is available here: {{http://archiva.apache.org/docs/${project.version}/rest-docs-redback-rest-api/index.html}} +* Security related information + + Starting with version 2.2.2 we added HTTP verification techniques to avoid cross site request forgery attacks. The + updating services check Origin and Referer header and use a token provided by the login service. + If you use the webservices with a native client that is no browser or want to allow requests from different origin + URLs you have to change the configuration. For further information see the {{{/redback/integration/rest.html}Redback REST documentation}} + * Search Service Authentication headers for connect to your Archiva instance : @@ -114,11 +121,11 @@ Using REST Services Current versions use in Apache Archiva: - * $\{project.version}: ${project.version} + * <<<$\{project.version}>>>: ${project.version} - * $\{cxfVersion}: ${cxfVersion} + * <<<$\{cxfVersion}>>>: ${cxf.version} - * $\{jacksonVersion}: ${jacksonVersion} + * <<<$\{jacksonVersion}>>>: ${jacksonVersion} * Security Framework Services: diff --git a/archiva-docs/src/site/apt/customising/writing-consumer.apt.vm b/archiva-docs/src/site/apt/customising/writing-consumer.apt.vm index c7eee9ca3..32ebce67d 100644 --- a/archiva-docs/src/site/apt/customising/writing-consumer.apt.vm +++ b/archiva-docs/src/site/apt/customising/writing-consumer.apt.vm @@ -30,7 +30,7 @@ Writing a Consumer Plugin For a sample custom consumer, you can checkout the archiva-consumer-plugin at the archiva sandbox in the SVN repository: - Prior to release 1.4, plexus components are not anymore supported, you must use Spring components. + Starting with release 1.4, plexus components are not anymore supported, you must use Spring components. * Writing manually diff --git a/archiva-docs/src/site/apt/quick-start.apt b/archiva-docs/src/site/apt/quick-start.apt index 0f36e1a59..be132d011 100644 --- a/archiva-docs/src/site/apt/quick-start.apt +++ b/archiva-docs/src/site/apt/quick-start.apt @@ -42,8 +42,6 @@ Installing Archiva You will need to choose a different start command based on your platform. The <<<console>>> argument starts the server with the logs going to standard output, and waits for Ctrl+C to stop the server. - <<Note:>> A Derby exception "Schema 'SA' does not exist" occurs, but is not of concern. - Archiva is now running on <<<{{http://localhost:8080/}}>>> {Setting up your Archiva instance} diff --git a/archiva-docs/src/site/apt/release-notes.apt.vm b/archiva-docs/src/site/apt/release-notes.apt.vm index 4a783768c..c650c146a 100644 --- a/archiva-docs/src/site/apt/release-notes.apt.vm +++ b/archiva-docs/src/site/apt/release-notes.apt.vm @@ -36,28 +36,28 @@ Release Notes for Archiva ${project.version} * New in Archiva ${project.version} - Apache Archiva ${project.version} is a bugs fix release: + Apache Archiva ${project.version} is a bug fix release: - * NOTE: jdk 1.7 is now prerequisite with Apache Archiva ${project.version} + * Some fixes for the REST API were added to detect requests from unknown origin -* Compatibility Changes + * Some bugfixes were added - * If using the Cassandra backend, the metadatafacet column 'key' has been - renamed to 'facetKey' in 2.2.0 so you should copy the data to the new - column manually. +* Compatibility Changes - * If upgrading from earlier versions of Archiva, the list of libraries in - <<<wrapper.conf>>> has changed. If you have customized your copy of - <<<wrapper.conf>>>, please update it for compatibility with the version - distributed with the current release. + * The REST services are now checking for the origin of the requests by analysing Origin + and Referer header of the HTTP requests and adding an validation token to the Header. + This prevents requests from malicious sites if they are open in the same browser. If you use + the REST services from other clients you may change the behaviour with the new + configuration properties for the redback security (<<<rest.csrffilter.*>>>, <<<rest.baseUrl>>>). + For more information see {{{./adminguide/customising-security.html}Archiva Security Configuration}} and + the {{{/redback/integration/rest.html}Redback REST documentation }}. - * As the database storage has been removed, you can remove the JNDI entry - for <<<jdbc/archiva>>>. After upgrading from a previous version, you will - have to run a full scan to populate the new JCR Repository. This will be - done on first start of Archiva. + <<Note:>> If your archiva installation is behind a reverse proxy or load balancer, it may be possible + that the Archiva Web UI does not load after the upgrade. If this is the case you may access the WebUI + via localhost or edit archiva.xml manually. In the "Redback Runtime Configuration" properties you have to + enter the base URLs of your archiva installation to the <<<rest.baseUrl>>> field. - Refer to the {{{./adminguide/upgrade.html} Upgrading Archiva guide}} for more - information. + * Archiva uses redback for authentication and authorization in version 2.6 * Release Notes @@ -65,64 +65,45 @@ Release Notes for Archiva ${project.version} * Changes in Archiva ${project.version} - Released: <<???>> + Released: <<${releaseDate}>> -** New Feature - * [MRM-1867] - Adding a find jar by checksum functionality to the REST api +** New Feature ** Improvement - * [MRM-1390] - Generic metadata should be searcheable in Archiva search - - * [MRM-1844] - Allow LDAP groupOfNames - -** Bug - - * [MRM-770] - Archiva web client does not recognize classifier + * [MRM-1925] - Make User-Agent header configurable for HTTP requests - * [MRM-813] - Audit log is reporting "Modify File (proxied)" when no proxy connectors exist and the file has not changed + * [MRM-1861], [MRM-1924] - Increasing timeouts for repository check - * [MRM-837] - Cannot download SNAPSHOT version + * [MRM-1937] - Prevent creating initial admin user with wrong name. - * [MRM-935] - Archiva doesn't supports artifact with \<version\>SNAPSHOT\</version\> + * Adding origin header validation checks for REST requests - * [MRM-1145] - RSS tests do not correctly check responses +** Bugs fixed - * [MRM-1311] - Logging in ArtifactMissingChecksumsConsumer does not appear in the logs even if configured properly + * [MRM-1859] - Error upon viewing 'Artifacts' tab when browsing an artifact - * [MRM-1486] - ldap.config.mapper.attribute.user.filter using ldap not working correctly with commas. + * [MRM-1874] - Login Dialog triggers multiple events (+messages) - * [MRM-1767] - When selecting a specific repository to browse, I get an error that I don't have sufficient privileges. + * [MRM-1908] - Logged on users can write any repository - * [MRM-1807] - Archiva wrapper fail to start + * [MRM-1909] - Remote repository check fails for https://repo.maven.apache.org/maven2 - * [MRM-1810] - LDAP - groups config not available in Users Runtime Configuration - Properties + * [MRM-1923] - Fixing bind issue with certain ldap servers, when user not found - * [MRM-1811] - Users - Manage section: pagination needs to change + * [MRM-1926] - Invalid checksum files in Archiva repository after download from remote repository - * [MRM-1846] - Regression in 2.0.1 : uniqueVersion false not supported + * [MRM-1928] - Bad redirect URL when using Archiva through HTTP reverse proxy + + * [MRM-1933] - No message body writer has been found for class org.apache.archiva.rest.services.ArchivaRestError + + * [MRM-1940] - Slashes appended to remote repo url - * [MRM-1848] - download links for files mult-dot extensions incorrect in Browse view - - * [MRM-1851] - generic metadata GUI broken - - * [MRM-1860] - ClassNotFound exception with JBoss - - * [MRM-1863] - RepositoryGroup URL is not build using the Application URL - - * [MRM-1864] - Default configuration for central should now use SSL - - * [MRM-1871] - ConcurrentModificationException in DefaultRepositoryProxyConnectors - - * [MRM-1873] - archiva doesn't recognise ldap-group to ldap-users mapping ** Task - * [MRM-1359] - Remove Maven 1.x functionality - - * [MRM-1865] - remove isPermanent from Consumer API * History diff --git a/archiva-docs/src/site/resources/css/site.css b/archiva-docs/src/site/resources/css/site.css index 0a3ebda64..11f870b91 100755 --- a/archiva-docs/src/site/resources/css/site.css +++ b/archiva-docs/src/site/resources/css/site.css @@ -70,6 +70,15 @@ pre.commandline { color: gray; } +img { + border-style: solid ; + border-width: 1px; + border-color: #ddd; + padding: 5px; + margin-top: 10px; + border-radius: 5px; +} + pre.commandline .input { color: #55f; } diff --git a/archiva-jetty/pom.xml b/archiva-jetty/pom.xml index 66a710d2c..f5cbd3e8c 100644 --- a/archiva-jetty/pom.xml +++ b/archiva-jetty/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-jetty</artifactId> <packaging>pom</packaging> diff --git a/archiva-jetty/src/main/assembly/bin.xml b/archiva-jetty/src/main/assembly/bin.xml index d10f9aa65..1e18d9f57 100644 --- a/archiva-jetty/src/main/assembly/bin.xml +++ b/archiva-jetty/src/main/assembly/bin.xml @@ -106,10 +106,6 @@ <include>LICENSE</include> </includes> </fileSet> - <fileSet> - <directory>src/main/contexts</directory> - <outputDirectory>contexts</outputDirectory> - </fileSet> </fileSets> <dependencySets> <dependencySet> diff --git a/archiva-jetty/src/main/conf/jetty.xml b/archiva-jetty/src/main/conf/jetty.xml index 2881f23f8..b7e66d463 100644 --- a/archiva-jetty/src/main/conf/jetty.xml +++ b/archiva-jetty/src/main/conf/jetty.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> +<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements. See the NOTICE file @@ -19,226 +19,106 @@ ~ under the License. --> -<!-- =============================================================== --> -<!-- Configure the Jetty Server --> -<!-- --> -<!-- Documentation of this file format can be found at: --> -<!-- http://docs.codehaus.org/display/JETTY/jetty.xml --> -<!-- --> -<!-- =============================================================== --> +<!-- ============================================================================= --> +<!-- Configure the Jetty Server --> +<!-- --> +<!-- Documentation of this file format can be found at: --> +<!-- https://www.eclipse.org/jetty/documentation/9.4.x/reference-section.html --> +<!-- --> +<!-- ============================================================================= --> <Configure id="Server" class="org.eclipse.jetty.server.Server"> - <!-- =========================================================== --> - <!-- Server Thread Pool --> - <!-- =========================================================== --> - <Set name="ThreadPool"> - <!-- Default bounded blocking threadpool - --> - <New class="org.eclipse.jetty.util.thread.QueuedThreadPool"> - <Set name="minThreads">10</Set> - <Set name="maxThreads">250</Set> - </New> - - <!-- Optional Java 5 bounded threadpool with job queue - <New class="org.eclipse.jetty.util.thread.ExecutorThreadPool"> - <Set name="corePoolSize">250</Set> - <Set name="maximumPoolSize">250</Set> - </New> - --> - </Set> - <!-- =========================================================== --> - <!-- Set connectors --> - <!-- =========================================================== --> - <!-- One of each type! --> - <!-- =========================================================== --> + <Arg name="threadpool"> + <New id="threadpool" class="org.eclipse.jetty.util.thread.QueuedThreadPool"> + <Arg name="minThreads" type="int">10</Arg> + <Arg name="maxThreads" type="int">200</Arg> + <Arg name="idleTimeout" type="int">60000</Arg> + <Set name="detailedDump">false</Set> + </New> + </Arg> - <!-- Use this connector for many frequently idle connections - and for threadless continuations. - --> - <Call name="addConnector"> - <Arg> - <New class="org.eclipse.jetty.server.nio.SelectChannelConnector"> - <Set name="host"><SystemProperty name="jetty.host"/></Set> - <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set> - <Set name="maxIdleTime">30000</Set> - <Set name="Acceptors">2</Set> - <Set name="statsOn">false</Set> - <Set name="confidentialPort">8443</Set> - <Set name="lowResourcesConnections">5000</Set> - <Set name="lowResourcesMaxIdleTime">5000</Set> - </New> - </Arg> - </Call> + <Call name="addBean"> + <Arg> + <New class="org.eclipse.jetty.util.thread.ScheduledExecutorScheduler"/> + </Arg> + </Call> - <!-- Use this connector if NIO is not available. - <Call name="addConnector"> - <Arg> - <New class="org.mortbay.jetty.bio.SocketConnector"> - <Set name="port">8081</Set> - <Set name="maxIdleTime">50000</Set> - <Set name="lowResourceMaxIdleTime">1500</Set> - </New> - </Arg> - </Call> - --> + <!-- =========================================================== --> + <!-- Set connectors --> + <!-- =========================================================== --> + <!-- =========================================================== --> - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <!-- To add a HTTPS SSL listener --> - <!-- see jetty-ssl.xml to add an ssl connector. use --> - <!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml --> - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - - <!-- =========================================================== --> - <!-- Set up global session ID manager --> - <!-- =========================================================== --> - <!-- - <Set name="sessionIdManager"> - <New class="org.mortbay.jetty.servlet.HashSessionIdManager"> - <Set name="workerName">node1</Set> - </New> - </Set> - --> + <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration"> + <Set name="secureScheme">https</Set> + <Set name="securePort"><Property name="jetty.secure.port" default="8443" /></Set> + <Set name="outputBufferSize">32768</Set> + <Set name="requestHeaderSize">8192</Set> + <Set name="responseHeaderSize">8192</Set> + <Set name="headerCacheSize">512</Set> + </New> - <!-- =========================================================== --> - <!-- Set handler Collection Structure --> - <!-- =========================================================== --> - <Set name="handler"> - <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"> - <Set name="handlers"> - <Array type="org.eclipse.jetty.server.Handler"> - <Item> - <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/> - </Item> - <Item> - <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/> - </Item> - <Item> - <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/> - </Item> - </Array> - </Set> + <Call name="addConnector"> + <Arg> + <New class="org.eclipse.jetty.server.ServerConnector"> + <Arg name="server"><Ref refid="Server" /></Arg> + <Arg name="factories"> + <Array type="org.eclipse.jetty.server.ConnectionFactory"> + <Item> + <New class="org.eclipse.jetty.server.HttpConnectionFactory"> + <Arg name="config"><Ref refid="httpConfig" /></Arg> + </New> + </Item> + </Array> + </Arg> + <Set name="host"><Property name="jetty.host" /></Set> + <Set name="port"><Property name="jetty.port" default="8080" /></Set> + <Set name="idleTimeout">30000</Set> </New> - </Set> - - <!-- =========================================================== --> - <!-- Configure the context deployer --> - <!-- A context deployer will deploy contexts described in --> - <!-- configuration files discovered in a directory. --> - <!-- The configuration directory can be scanned for hot --> - <!-- deployments at the configured scanInterval. --> - <!-- --> - <!-- This deployer is configured to deploy contexts configured --> - <!-- in the $JETTY_HOME/contexts directory --> - <!-- --> - <!-- =========================================================== --> - <Call name="addLifeCycle"> - <Arg> - <New class="org.eclipse.jetty.deploy.ContextDeployer"> - <Set name="contexts"><Ref id="Contexts"/></Set> - <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts</Set> - <Set name="scanInterval">1</Set> - </New> - </Arg> - </Call> - - <!-- =========================================================== --> - <!-- Configure the webapp deployer. --> - <!-- A webapp deployer will deploy standard webapps discovered --> - <!-- in a directory at startup, without the need for additional --> - <!-- configuration files. It does not support hot deploy or --> - <!-- non standard contexts (see ContextDeployer above). --> - <!-- --> - <!-- This deployer is configured to deploy webapps from the --> - <!-- $JETTY_HOME/webapps directory --> - <!-- --> - <!-- Normally only one type of deployer need be used. --> - <!-- --> - <!-- =========================================================== --> - <Call name="addLifeCycle"> - <Arg> - <New class="org.eclipse.jetty.deploy.WebAppDeployer"> - <Set name="contexts"><Ref id="Contexts"/></Set> - <Set name="webAppDir"><SystemProperty name="jetty.home" default="."/>/apps</Set> - <Set name="parentLoaderPriority">false</Set> - <Set name="extract">true</Set> - <Set name="allowDuplicates">false</Set> - </New> - </Arg> - </Call> + </Arg> + </Call> - <!-- =========================================================== --> - <!-- Configure Request Log --> - <!-- Request logs may be configured for the entire server here, --> - <!-- or they can be configured for a specific web app in a --> - <!-- contexts configuration (see $(jetty.home)/contexts/test.xml --> - <!-- for an example). --> - <!-- =========================================================== --> - <Ref id="RequestLog"> - <Set name="requestLog"> - <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog"> - <Set name="filename"><SystemProperty name="jetty.logs" default="./logs"/>/request-yyyy_mm_dd.log</Set> - <Set name="filenameDateFormat">yyyyMMdd</Set> - <Set name="retainDays">90</Set> - <Set name="append">true</Set> - <Set name="extended">true</Set> - <Set name="logCookies">false</Set> - <Set name="LogTimeZone">GMT</Set> - </New> + <Set name="handler"> + <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"> + <Set name="handlers"> + <Array type="org.eclipse.jetty.server.Handler"> + <Item> + <New class="org.eclipse.jetty.webapp.WebAppContext"> + <Set name="contextPath">/</Set> + <Set name="war"><SystemProperty name="appserver.base" default="./apps/archiva"/>/apps/archiva</Set> + <Set name="extractWAR">false</Set> + <Set name="copyWebDir">false</Set> + </New> + </Item> + <Item> + <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/> + </Item> + </Array> </Set> - </Ref> + </New> + </Set> - <!-- =========================================================== --> - <!-- extra options --> - <!-- =========================================================== --> - <Set name="stopAtShutdown">true</Set> - <Set name="sendServerVersion">true</Set> - <Set name="sendDateHeader">true</Set> - <Set name="gracefulShutdown">1000</Set> + <Call name="setRequestLog"> + <Arg> + <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog"> + <Set name="filename"><SystemProperty name="jetty.logs" default="./logs"/>/request-yyyy_mm_dd.log</Set> + <Set name="filenameDateFormat">yyyyMMdd</Set> + <Set name="retainDays">90</Set> + <Set name="append">true</Set> + <Set name="extended">true</Set> + <Set name="logCookies">false</Set> + <Set name="LogTimeZone">GMT</Set> + </New> + </Arg> + </Call> - - <!-- =========================================================== --> - <!-- JNDI java:comp/env --> - <!-- To use JNDI with Jetty, you will need to tell your --> - <!-- WebAppContext to process the naming related items in --> - <!-- web.xml. For an example of how to do that, see the test --> - <!-- webapp below. More information can be found at --> - <!-- http://docs.codehaus.org/display/JETTY/Jetty+Wiki --> <!-- =========================================================== --> - - - <!-- Configuring <resource-ref> and <resource-env-ref>s --> - <!-- --> - <!-- The following are examples of setting up a resource that --> - <!-- can be referenced in a web.xml file as a <resource-ref> or --> - <!-- a <resource-env-ref>. The first argument is the name of the --> - <!-- resource relative to java:comp/env and must be the SAME as --> - <!-- the <res-ref-name> or <resource-env-ref-name> in web.xml. --> - <!-- The second argument is the construction of the resource --> - <!-- object. Any object at all can be configured. --> - - - <!-- These examples set up a javax.sql.DataSource around an --> - <!-- XADataSource that is provided by the Derby relational db. --> - <!-- The DataSource wrapper that is registered in JNDI is --> - <!-- provided by Atomikos, and works with the Atomikos --> - <!-- transaction manager configured further below. To use these --> - <!-- examples, download Atomikos http://www.atomikos.com and --> - <!-- Derby http://db.apache.org/derby --> - - - <!-- Configuring Transactions --> - <!-- --> - <!-- The following is a example of a setting up a JTA --> - <!-- transaction manager that can be referenced by looking up --> - <!-- java:comp/UserTransaction. Note that this is just an --> - <!-- example and if you uncomment it, you will need to download --> - <!-- the atomikos jar (see http://www.atomikos.com/download.html)--> - <!-- You can configure any transaction manager that implements --> - <!-- javax.transaction.UserTransaction. --> + <!-- extra options --> + <!-- =========================================================== --> + <Set name="stopAtShutdown">true</Set> <Call name="setAttribute"> @@ -252,24 +132,11 @@ <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item> <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item> <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item> - <Item>org.eclipse.jetty.webapp.TagLibConfiguration</Item> </Array> </Arg> </Call> - <!-- =========================================================== --> - <!-- Configurations for WebAppContexts --> - <!-- Sequence of configurations to be applied to a webapp. --> - <!-- =========================================================== --> - <Array id="plusConfig" type="java.lang.String"> - <Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item> - <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item> - <Item>org.eclipse.jetty.webapp.Configuration</Item> - <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item> - <Item>org.mortbay.jetty.webapp.TagLibConfiguration</Item> - </Array> - <!-- ARCHIVA CONFIG --> <New id="validation_mail" class="org.eclipse.jetty.plus.jndi.Resource"> @@ -287,30 +154,6 @@ </Arg> </New> - <!-- Users / Security Database --> - <!-- - <New id="users" class="org.eclipse.jetty.plus.jndi.Resource"> - <Arg>jdbc/users</Arg> - <Arg> - <New class="org.apache.derby.jdbc.EmbeddedDataSource"> - <Set name="DatabaseName"><SystemProperty name="appserver.base" default=".."/>/data/databases/users</Set> - <Set name="user">sa</Set> - <Set name="createDatabase">create</Set> - </New> - </Arg> - </New> - - <New id="usersShutdown" class="org.eclipse.jetty.plus.jndi.Resource"> - <Arg>jdbc/usersShutdown</Arg> - <Arg> - <New class="org.apache.derby.jdbc.EmbeddedDataSource"> - <Set name="DatabaseName"><SystemProperty name="appserver.base" default=".."/>/data/databases/users</Set> - <Set name="user">sa</Set> - <Set name="shutdownDatabase">shutdown</Set> - </New> - </Arg> - </New> - --> <New id="users" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg>jdbc/users</Arg> <Arg> @@ -341,14 +184,4 @@ </New> - <!-- - <New id="ArchivaWebAppContext" class="org.eclipse.jetty.webapp.WebAppContext"> - <Arg><Ref id="Handlers"/></Arg> - <Arg><SystemProperty name="jetty.home" default="."/>/apps/archiva</Arg> - <Arg>/</Arg> - <Set name="extractWAR">false</Set> - <Set name="throwUnavailableOnStartupException">true</Set> - </New> - --> - </Configure> diff --git a/archiva-modules/archiva-base/archiva-checksum/pom.xml b/archiva-modules/archiva-base/archiva-checksum/pom.xml index 09dbbd5e0..a027079a9 100644 --- a/archiva-modules/archiva-base/archiva-checksum/pom.xml +++ b/archiva-modules/archiva-base/archiva-checksum/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-checksum</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-base/archiva-common/pom.xml b/archiva-modules/archiva-base/archiva-common/pom.xml index f1d819e0e..a81e4c625 100644 --- a/archiva-modules/archiva-base/archiva-common/pom.xml +++ b/archiva-modules/archiva-base/archiva-common/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-common</artifactId> diff --git a/archiva-modules/archiva-base/archiva-configuration/pom.xml b/archiva-modules/archiva-base/archiva-configuration/pom.xml index d137199bd..6eb89237e 100644 --- a/archiva-modules/archiva-base/archiva-configuration/pom.xml +++ b/archiva-modules/archiva-base/archiva-configuration/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-configuration</artifactId> @@ -169,7 +169,7 @@ </execution> </executions> <configuration> - <version>1.4.1</version> + <version>1.4.2</version> <models> <model>src/main/mdo/configuration.mdo</model> </models> diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java index f37171afa..44f25212b 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java @@ -162,6 +162,9 @@ public class DefaultArchivaConfiguration private static final String KEY = "org.apache.archiva"; + // Section used for default only configuration + private static final String KEY_DEFAULT_ONLY = "org.apache.archiva_default"; + @Override public Configuration getConfiguration() { @@ -183,6 +186,11 @@ public class DefaultArchivaConfiguration return configuration; } + private boolean hasConfigVersionChanged(Configuration current, Registry defaultOnlyConfiguration) { + return current==null || current.getVersion()==null || + !current.getVersion().trim().equals(defaultOnlyConfiguration.getString("version","").trim()); + } + @SuppressWarnings("unchecked") private Configuration load() { @@ -200,6 +208,7 @@ public class DefaultArchivaConfiguration Configuration config = new ConfigurationRegistryReader().read( subset ); + config.getRepositoryGroups(); config.getRepositoryGroupsAsMap(); if ( !config.getRepositories().isEmpty() ) @@ -363,9 +372,63 @@ public class DefaultArchivaConfiguration } } + + return config; } + /* + * Updates the checkpath list for repositories. + * + * We are replacing existing ones and adding new ones. This allows to update the list with new releases. + * + * We are also updating existing remote repositories, if they exist already. + * + * This update method should only be called, if the config version changes to avoid overwriting + * user repository settings all the time. + */ + private void updateCheckPathDefaults(Configuration config, Registry defaultConfiguration) { + List<RepositoryCheckPath> existingCheckPathList = config.getArchivaDefaultConfiguration().getDefaultCheckPaths(); + HashMap<String, RepositoryCheckPath> existingCheckPaths = new HashMap<>(); + HashMap<String, RepositoryCheckPath> newCheckPaths = new HashMap<>(); + for (RepositoryCheckPath path : config.getArchivaDefaultConfiguration().getDefaultCheckPaths()) { + existingCheckPaths.put(path.getUrl(), path); + } + List defaultCheckPathsSubsets = defaultConfiguration.getSubsetList("archivaDefaultConfiguration.defaultCheckPaths.defaultCheckPath" ); + for ( Iterator i = defaultCheckPathsSubsets.iterator(); i.hasNext(); ) + { + RepositoryCheckPath v = readRepositoryCheckPath( (Registry) i.next() ); + if (existingCheckPaths.containsKey(v.getUrl())) { + existingCheckPathList.remove(existingCheckPaths.get(v.getUrl())); + } + existingCheckPathList.add(v); + newCheckPaths.put(v.getUrl(), v); + } + // Remote repositories update + for (RemoteRepositoryConfiguration remoteRepositoryConfiguration : config.getRemoteRepositories()) { + String url = remoteRepositoryConfiguration.getUrl().toLowerCase(); + if (newCheckPaths.containsKey(url)) { + String currentPath = remoteRepositoryConfiguration.getCheckPath(); + String newPath = newCheckPaths.get(url).getPath(); + log.info("Updating connection check path for repository {}, from '{}' to '{}'.", remoteRepositoryConfiguration.getId(), + currentPath, newPath); + remoteRepositoryConfiguration.setCheckPath(newPath); + } + } + } + + private RepositoryCheckPath readRepositoryCheckPath( Registry registry ) + { + RepositoryCheckPath value = new RepositoryCheckPath(); + + String url = registry.getString( "url", value.getUrl() ); + + value.setUrl( url ); + String path = registry.getString( "path", value.getPath() ); + value.setPath( path ); + return value; + } + private Policy findPolicy( String policyId ) { if ( MapUtils.isEmpty( prePolicies ) ) @@ -439,6 +502,25 @@ public class DefaultArchivaConfiguration return registry.getSubset( KEY ); } + /* + * Reads the default only configuration into a special prefix. This allows to check for changes + * of the default configuration. + */ + private Registry readDefaultOnlyConfiguration() + { + registry.removeSubset(KEY_DEFAULT_ONLY); + try + { + registry.addConfigurationFromResource( "org/apache/archiva/configuration/default-archiva.xml", KEY_DEFAULT_ONLY); + } + catch ( RegistryException e ) + { + throw new ConfigurationRuntimeException( + "Fatal error: Unable to find the built-in default configuration and load it into the registry", e ); + } + return registry.getSubset(KEY_DEFAULT_ONLY); + } + @SuppressWarnings("unchecked") @Override public synchronized void save( Configuration configuration ) @@ -527,6 +609,9 @@ public class DefaultArchivaConfiguration section.removeSubset( "repositoryScanning.invalidContentConsumers" ); } } + if (configuration.getArchivaRuntimeConfiguration()!=null) { + section.removeSubset("archivaRuntimeConfiguration.defaultCheckPaths"); + } new ConfigurationRegistryWriter().write( configuration, section ); section.save(); @@ -736,7 +821,7 @@ public class DefaultArchivaConfiguration } /** - * upgrade from 1.3 + * Handle upgrade to newer version */ private void handleUpgradeConfiguration() throws RegistryException, IndeterminateConfigurationException @@ -781,8 +866,24 @@ public class DefaultArchivaConfiguration knowContentConsumers.add( "duplicate-artifacts" ); configuration.getRepositoryScanning().setKnownContentConsumers( knowContentConsumers ); } - // save ?? - //save( configuration ); + + Registry defaultOnlyConfiguration = readDefaultOnlyConfiguration(); + // Currently we check only for configuration version change, not certain version numbers. + if (hasConfigVersionChanged(configuration, defaultOnlyConfiguration)) { + updateCheckPathDefaults(configuration, defaultOnlyConfiguration); + String newVersion = defaultOnlyConfiguration.getString("version"); + if (newVersion==null) { + throw new IndeterminateConfigurationException("The default configuration has no version information!"); + } + configuration.setVersion(newVersion); + try { + save(configuration); + } catch (IndeterminateConfigurationException e) { + log.error("Error occured during configuration update to new version: {}", e.getMessage()); + } catch (RegistryException e) { + log.error("Error occured during configuration update to new version: {}", e.getMessage()); + } + } } @Override diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo index fc5169ff2..494af1204 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -197,6 +197,15 @@ The list of ProxyConnectorRuleConfigurations. </description> </field> + <field> + <name>archivaDefaultConfiguration</name> + <version>1.4.2+</version> + <association> + <type>ArchivaDefaultConfiguration</type> + <multiplicity>1</multiplicity> + </association> + <description>Archiva default settings.</description> + </field> </fields> <codeSegments> <codeSegment> @@ -597,12 +606,18 @@ <name>extraHeaders</name> <version>1.4.0+</version> <type>Map</type> - <description>Additionnal http headers to add to url when requesting remote repositories.</description> + <description>Additional http headers to add to url when requesting remote repositories.</description> <association xml.mapStyle="inline"> <type>String</type> <multiplicity>*</multiplicity> </association> </field> + <field> + <name>checkPath</name> + <version>1.4.2+</version> + <type>String</type> + <description>The path to check the repository availability (relative to the repository URL). Some repositories do not allow browsing, so a certain artifact must be checked.</description> + </field> </fields> <codeSegments> <codeSegment> @@ -877,6 +892,30 @@ </field> </fields> </class> + <class> + <name>RepositoryCheckPath</name> + <version>1.4.2+</version> + <fields > + <field > + <name>url</name> + <version>1.4.2+</version> + <type>String</type> + <required>true</required> + <description> + The URL for which this path should be used + </description> + </field> + <field> + <name>path</name> + <version>1.4.2+</version> + <type>String</type> + <required>true</required> + <description> + The path to use for checking the repository connection. + </description> + </field> + </fields> + </class> <!-- ____ _ @@ -1584,6 +1623,25 @@ </class> <class> + <name>ArchivaDefaultConfiguration</name> + <version>1.4.2+</version> + <description> + Archiva default settings. + </description> + <fields> + <field> + <name>defaultCheckPaths</name> + <description>The default check paths for certain remote repositories</description> + <version>1.4.2+</version> + <association> + <type>RepositoryCheckPath</type> + <multiplicity>*</multiplicity> + </association> + </field> + </fields> + </class> + + <class> <name>LdapConfiguration</name> <version>1.4.0+</version> <description> @@ -1670,7 +1728,7 @@ <name>extraProperties</name> <version>1.4.0+</version> <type>Map</type> - <description>Additionnal properties to use for ldap connection.</description> + <description>Additional properties to use for ldap connection.</description> <association xml.mapStyle="inline"> <type>String</type> <multiplicity>*</multiplicity> diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/archiva/configuration/default-archiva.xml b/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/archiva/configuration/default-archiva.xml index a74f09ceb..877b6a59b 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/archiva/configuration/default-archiva.xml +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/archiva/configuration/default-archiva.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <configuration> - <version>2</version> + <version>3</version> <managedRepositories> <managedRepository> <id>internal</id> @@ -151,5 +151,17 @@ </rbacManagerImpls> </redbackRuntimeConfiguration> + <archivaDefaultConfiguration> + <defaultCheckPaths> + <defaultCheckPath> + <url>http://download.oracle.com/maven</url> + <path>com/sleepycat/je/license.txt</path> + </defaultCheckPath> + <defaultCheckPath> + <url>https://download.oracle.com/maven</url> + <path>com/sleepycat/je/license.txt</path> + </defaultCheckPath> + </defaultCheckPaths> + </archivaDefaultConfiguration> </configuration> diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java index 03bb489b2..15080d873 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java @@ -814,7 +814,6 @@ public class ArchivaConfigurationTest { ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-configuration" ); - archivaConfiguration.reload(); Configuration configuration = archivaConfiguration.getConfiguration(); assertConfiguration( configuration, 2, 2, 2 ); assertEquals( "check remote repositories", 2, configuration.getRemoteRepositories().size() ); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml index 44fbd4bc7..598ffa1f4 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-consumers</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-consumer-api</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/pom.xml index f171e6c09..f8af4626c 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-consumers</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-consumer-archetype</artifactId> <packaging>maven-archetype</packaging> @@ -31,7 +31,8 @@ <description>Simple archetype to create archiva consumers</description> <properties> <archivaVersion>${project.version}</archivaVersion> - <archetypeVersion>2.2</archetypeVersion> + <archetypeVersion>2.4</archetypeVersion> + <mavenInvokerVersion>2.2</mavenInvokerVersion> </properties> <dependencies> <!-- Used by the archetype, so needed to be built before integration @@ -78,11 +79,19 @@ <scope>test</scope> </dependency> + <!-- for some reasons needed by the archetype --> + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>1.9</version> + <scope>test</scope> + </dependency> + <!-- for some reasons this help sonar to run --> <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit4</artifactId> - <version>2.18.1</version> + <version>2.20</version> <scope>test</scope> </dependency> @@ -134,6 +143,13 @@ <settingsFile>${basedir}/src/test/test-settings.xml</settingsFile> <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath> </configuration> + <dependencies> + <dependency> + <groupId>org.apache.maven.shared</groupId> + <artifactId>maven-invoker</artifactId> + <version>${mavenInvokerVersion}</version> + </dependency> + </dependencies> </plugin> </plugins> </pluginManagement> @@ -152,6 +168,13 @@ <settingsFile>${basedir}/src/test/ci-test-settings.xml</settingsFile> <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath> </configuration> + <dependencies> + <dependency> + <groupId>org.apache.maven.shared</groupId> + <artifactId>maven-invoker</artifactId> + <version>${mavenInvokerVersion}</version> + </dependency> + </dependencies> </plugin> </plugins> </pluginManagement> diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resourcesstatic/archetype-resources/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resourcesstatic/archetype-resources/pom.xml index b4ce052e8..fb1586e88 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resourcesstatic/archetype-resources/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resourcesstatic/archetype-resources/pom.xml @@ -235,7 +235,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.2</version> + <version>3.5.1</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -250,7 +250,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.18.1</version> + <version>2.20</version> </plugin> </plugins> </pluginManagement> diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml index ea427f5c9..ff3eb2249 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-consumers</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-core-consumers</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml index dd4810e03..d71f5e1bb 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-consumers</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-lucene-consumers</artifactId> <packaging>bundle</packaging> diff --git a/archiva-jetty/src/main/contexts/archiva.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/log4j2-test.xml index 93728d8e6..282cfa5d9 100644 --- a/archiva-jetty/src/main/contexts/archiva.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/log4j2-test.xml @@ -1,6 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> - +<?xml version="1.0" encoding="UTF-8" ?> <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements. See the NOTICE file @@ -20,12 +18,24 @@ ~ under the License. --> -<Configure class="org.eclipse.jetty.webapp.WebAppContext"> - <Set name="contextPath">/</Set> - <Set name="war"><SystemProperty name="jetty.home" default="."/>/apps/archiva</Set> +<configuration> + <appenders> + <Console name="console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d [%t] %-5p %c %x - %m%n"/> + </Console> + </appenders> + <loggers> + + <logger name="org.springframework" level="error"/> + + <!-- + <logger name="org.apache.http" level="debug"/> + --> + <root level="info"> + <appender-ref ref="console"/> + </root> + </loggers> +</configuration> - <Set name="extractWAR">false</Set> - <Set name="copyWebDir">false</Set> -</Configure>
\ No newline at end of file diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml index 563bacba6..099d2b83c 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/pom.xml @@ -23,7 +23,7 @@ <parent> <artifactId>archiva-consumers</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-metadata-consumer</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-signature-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-signature-consumers/pom.xml index 78da54d36..88ffcaf20 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-signature-consumers/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-signature-consumers/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-consumers</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-signature-consumers</artifactId> diff --git a/archiva-modules/archiva-base/archiva-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/pom.xml index 44bc41fc3..f4cfc9053 100644 --- a/archiva-modules/archiva-base/archiva-consumers/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-consumers</artifactId> diff --git a/archiva-modules/archiva-base/archiva-converter/pom.xml b/archiva-modules/archiva-base/archiva-converter/pom.xml index a041773ed..8d729fbc5 100644 --- a/archiva-modules/archiva-base/archiva-converter/pom.xml +++ b/archiva-modules/archiva-base/archiva-converter/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-converter</artifactId> diff --git a/archiva-modules/archiva-base/archiva-filelock/pom.xml b/archiva-modules/archiva-base/archiva-filelock/pom.xml index d094b834a..5829da297 100644 --- a/archiva-modules/archiva-base/archiva-filelock/pom.xml +++ b/archiva-modules/archiva-base/archiva-filelock/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-filelock</artifactId> diff --git a/archiva-modules/archiva-base/archiva-filelock/src/test/java/org/apache/archiva/common/filelock/DefaultFileLockManagerTimeoutTest.java b/archiva-modules/archiva-base/archiva-filelock/src/test/java/org/apache/archiva/common/filelock/DefaultFileLockManagerTimeoutTest.java index 281d13105..666efee18 100644 --- a/archiva-modules/archiva-base/archiva-filelock/src/test/java/org/apache/archiva/common/filelock/DefaultFileLockManagerTimeoutTest.java +++ b/archiva-modules/archiva-base/archiva-filelock/src/test/java/org/apache/archiva/common/filelock/DefaultFileLockManagerTimeoutTest.java @@ -30,6 +30,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.inject.Inject; import javax.inject.Named; import java.io.File; +import java.io.IOException; +import java.nio.file.FileSystemException; import java.nio.file.Files; import java.nio.file.StandardCopyOption; @@ -62,17 +64,29 @@ public class DefaultFileLockManagerTimeoutTest throws Throwable { - File file = new File( System.getProperty( "buildDirectory" ), "foo.txt" ); + try { + File file = new File(System.getProperty("buildDirectory"), "foo.txt"); - Files.deleteIfExists( file.toPath() ); + Files.deleteIfExists(file.toPath()); - File largeJar = new File( System.getProperty( "basedir" ), "src/test/cassandra-all-2.0.3.jar" ); + File largeJar = new File(System.getProperty("basedir"), "src/test/cassandra-all-2.0.3.jar"); - Lock lock = fileLockManager.writeFileLock( file ); + Lock lock = fileLockManager.writeFileLock(file); - Files.copy( largeJar.toPath(), lock.getFile().toPath(), StandardCopyOption.REPLACE_EXISTING ); + try { + Files.copy(largeJar.toPath(), lock.getFile().toPath(), StandardCopyOption.REPLACE_EXISTING); + } catch (IOException e) { + logger.warn("Copy failed "+e.getMessage()); + // On windows a FileSystemException is thrown + // We ignore this + } - lock = fileLockManager.writeFileLock( file ); + lock = fileLockManager.writeFileLock(file); + } catch (FileSystemException ex) { + logger.error("Exception from filesystem "+ex.getMessage()); + ex.printStackTrace(); + throw ex; + } } diff --git a/archiva-modules/archiva-base/archiva-indexer/pom.xml b/archiva-modules/archiva-base/archiva-indexer/pom.xml index 99b4bc2ac..4e0a4d0ce 100644 --- a/archiva-modules/archiva-base/archiva-indexer/pom.xml +++ b/archiva-modules/archiva-base/archiva-indexer/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-indexer</artifactId> diff --git a/archiva-modules/archiva-base/archiva-maven2-metadata/pom.xml b/archiva-modules/archiva-base/archiva-maven2-metadata/pom.xml index 8127dcfd8..84edf97a6 100644 --- a/archiva-modules/archiva-base/archiva-maven2-metadata/pom.xml +++ b/archiva-modules/archiva-base/archiva-maven2-metadata/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-maven2-metadata</artifactId> diff --git a/archiva-modules/archiva-base/archiva-maven2-model/pom.xml b/archiva-modules/archiva-base/archiva-maven2-model/pom.xml index 82fcdc9cd..0198eb4ca 100644 --- a/archiva-modules/archiva-base/archiva-maven2-model/pom.xml +++ b/archiva-modules/archiva-base/archiva-maven2-model/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-maven2-model</artifactId> diff --git a/archiva-modules/archiva-base/archiva-mock/pom.xml b/archiva-modules/archiva-base/archiva-mock/pom.xml index da7bbd983..229eab4ff 100644 --- a/archiva-modules/archiva-base/archiva-mock/pom.xml +++ b/archiva-modules/archiva-base/archiva-mock/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-mock</artifactId> diff --git a/archiva-modules/archiva-base/archiva-model/pom.xml b/archiva-modules/archiva-base/archiva-model/pom.xml index 7b9cb4d9a..93e3e9ad6 100755 --- a/archiva-modules/archiva-base/archiva-model/pom.xml +++ b/archiva-modules/archiva-base/archiva-model/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-model</artifactId> diff --git a/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml b/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml index cb386290a..fe40f6284 100644 --- a/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml +++ b/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-plexus-bridge</artifactId> diff --git a/archiva-modules/archiva-base/archiva-policies/pom.xml b/archiva-modules/archiva-base/archiva-policies/pom.xml index 8f95a10a1..947daa4c5 100644 --- a/archiva-modules/archiva-base/archiva-policies/pom.xml +++ b/archiva-modules/archiva-base/archiva-policies/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-policies</artifactId> diff --git a/archiva-modules/archiva-base/archiva-proxy-api/pom.xml b/archiva-modules/archiva-base/archiva-proxy-api/pom.xml index d017dc809..f0d8ab086 100644 --- a/archiva-modules/archiva-base/archiva-proxy-api/pom.xml +++ b/archiva-modules/archiva-base/archiva-proxy-api/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>archiva-base</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-proxy-api</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-base/archiva-proxy-common/pom.xml b/archiva-modules/archiva-base/archiva-proxy-common/pom.xml index 8fcc96dcb..5fa20f65d 100644 --- a/archiva-modules/archiva-base/archiva-proxy-common/pom.xml +++ b/archiva-modules/archiva-base/archiva-proxy-common/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>archiva-base</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-proxy-common</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-base/archiva-proxy/pom.xml b/archiva-modules/archiva-base/archiva-proxy/pom.xml index c5ccbdfa0..a474f97e8 100644 --- a/archiva-modules/archiva-base/archiva-proxy/pom.xml +++ b/archiva-modules/archiva-base/archiva-proxy/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-proxy</artifactId> diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java index f0ca4f596..d85d5016e 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java @@ -38,8 +38,10 @@ import org.apache.archiva.policies.SnapshotsPolicy; import org.apache.archiva.repository.ManagedRepositoryContent; import org.assertj.core.api.Assertions; import org.eclipse.jetty.server.Handler; +import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.AbstractHandler; import org.junit.After; import org.junit.Before; @@ -164,11 +166,13 @@ public class HttpProxyTransferTest } }; - server = new Server( 0 ); + server = new Server( ); + ServerConnector serverConnector = new ServerConnector( server, new HttpConnectionFactory()); + server.addConnector( serverConnector ); server.setHandler( handler ); server.start(); - int port = server.getConnectors()[0].getLocalPort(); + int port = serverConnector.getLocalPort(); NetworkProxyConfiguration proxyConfig = new NetworkProxyConfiguration(); proxyConfig.setHost( "localhost" ); diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml index 9ef18f1a5..a57c21fb2 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-repository-admin</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-repository-admin-api</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RemoteRepository.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RemoteRepository.java index db8021d86..fd07ce9ac 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RemoteRepository.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RemoteRepository.java @@ -19,6 +19,8 @@ package org.apache.archiva.admin.model.beans; * under the License. */ +import org.apache.commons.lang.StringUtils; + import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; import java.util.ArrayList; @@ -45,6 +47,12 @@ public class RemoteRepository private int timeout = 60; /** + * @since 2.2.3 + * The path to use for checking availability of the remote repository + */ + private String checkPath; + + /** * Activate download of remote index if remoteIndexUrl is set too. */ private boolean downloadRemoteIndex = false; @@ -112,7 +120,7 @@ public class RemoteRepository int timeout ) { super( id, name, layout ); - this.url = url; + this.url = StringUtils.stripEnd(url,"/"); this.userName = userName; this.password = password; this.timeout = timeout; @@ -135,7 +143,7 @@ public class RemoteRepository public void setUrl( String url ) { - this.url = url; + this.url = StringUtils.stripEnd(url,"/"); } public String getUserName() @@ -314,6 +322,22 @@ public class RemoteRepository } } + public void setCheckPath(String checkPath) { + if (checkPath==null) { + this.checkPath=""; + } else if (checkPath.startsWith("/")) { + this.checkPath = StringUtils.removeStart(checkPath, "/"); + while(this.checkPath.startsWith("/")) { + this.checkPath = StringUtils.removeStart(checkPath, "/"); + } + } else { + this.checkPath = checkPath; + } + } + + public String getCheckPath() { + return checkPath; + } @Override public String toString() @@ -333,6 +357,7 @@ public class RemoteRepository sb.append( ", downloadRemoteIndexOnStartup=" ).append( downloadRemoteIndexOnStartup ); sb.append( ", extraParameters=" ).append( extraParameters ); sb.append( ", extraHeaders=" ).append( extraHeaders ); + sb.append( ", checkPath=").append(checkPath); sb.append( '}' ); return sb.toString(); } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml index cfee935fa..ae8230a51 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-repository-admin</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-repository-admin-default</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java index 9f6a20b9d..8f390530b 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java @@ -29,6 +29,7 @@ import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.ProxyConnectorConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; +import org.apache.archiva.configuration.RepositoryCheckPath; import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.commons.lang.StringUtils; import org.apache.maven.index.NexusIndexer; @@ -137,6 +138,7 @@ public class DefaultRemoteRepositoryAdmin remoteRepository.setDescription( repositoryConfiguration.getDescription() ); remoteRepository.setExtraHeaders( repositoryConfiguration.getExtraHeaders() ); remoteRepository.setExtraParameters( repositoryConfiguration.getExtraParameters() ); + remoteRepository.setCheckPath(repositoryConfiguration.getCheckPath()); remoteRepositories.add( remoteRepository ); } return remoteRepositories; @@ -170,7 +172,19 @@ public class DefaultRemoteRepositoryAdmin } //MRM-752 - url needs trimming - remoteRepository.setUrl( StringUtils.trim( remoteRepository.getUrl() ) ); + //MRM-1940 - URL should not end with a slash + remoteRepository.setUrl( StringUtils.stripEnd(StringUtils.trim( remoteRepository.getUrl() ), "/")); + + if (StringUtils.isEmpty(remoteRepository.getCheckPath())) { + String checkUrl = remoteRepository.getUrl().toLowerCase(); + for (RepositoryCheckPath path : getArchivaConfiguration ().getConfiguration().getArchivaDefaultConfiguration().getDefaultCheckPaths()) { + log.debug("Checking path for urls: {} <-> {}", checkUrl, path.getUrl()); + if (checkUrl.startsWith(path.getUrl())) { + remoteRepository.setCheckPath(path.getPath()); + break; + } + } + } RemoteRepositoryConfiguration remoteRepositoryConfiguration = getRemoteRepositoryConfiguration( remoteRepository ); @@ -365,6 +379,7 @@ public class DefaultRemoteRepositoryAdmin remoteRepositoryConfiguration.setDescription( remoteRepository.getDescription() ); remoteRepositoryConfiguration.setExtraHeaders( remoteRepository.getExtraHeaders() ); remoteRepositoryConfiguration.setExtraParameters( remoteRepository.getExtraParameters() ); + remoteRepositoryConfiguration.setCheckPath(remoteRepository.getCheckPath()); return remoteRepositoryConfiguration; } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java index 3da5a37ea..3ce727c71 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java @@ -42,6 +42,7 @@ import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -389,6 +390,7 @@ public class DefaultRedbackRuntimeConfigurationAdmin properties.remove( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD ); properties.remove( UserConfigurationKeys.LDAP_WRITABLE ); properties.remove( UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME ); + // cleanup groups <-> role mapping /**for ( Map.Entry<String, String> entry : new HashMap<String, String>( properties ).entrySet() ) { @@ -690,10 +692,13 @@ public class DefaultRedbackRuntimeConfigurationAdmin @Override public List<String> getList( String key ) { + RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration(); + if (conf.getConfigurationProperties().containsKey(key)) { + return Arrays.asList(conf.getConfigurationProperties().get(key).split(",")); + } + List<String> value = userConfiguration.getList( key ); - RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration(); - // TODO concat values conf.getConfigurationProperties().put( key, "" ); try { diff --git a/archiva-modules/archiva-base/archiva-repository-admin/pom.xml b/archiva-modules/archiva-base/archiva-repository-admin/pom.xml index 26897e99f..f7047344c 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-admin/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-repository-admin</artifactId> <name>Archiva Base :: Repository Admin</name> diff --git a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml index 5e3bffa99..2bfb418d6 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-repository-layer</artifactId> diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/pom.xml b/archiva-modules/archiva-base/archiva-repository-scanner/pom.xml index f56113330..8bb08b9f7 100644 --- a/archiva-modules/archiva-base/archiva-repository-scanner/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-scanner/pom.xml @@ -23,7 +23,7 @@ <parent> <artifactId>archiva-base</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-repository-scanner</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-base/archiva-security-common/pom.xml b/archiva-modules/archiva-base/archiva-security-common/pom.xml index ce06d77d4..00823b572 100644 --- a/archiva-modules/archiva-base/archiva-security-common/pom.xml +++ b/archiva-modules/archiva-base/archiva-security-common/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>archiva-base</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-security-common</artifactId> diff --git a/archiva-modules/archiva-base/archiva-test-utils/pom.xml b/archiva-modules/archiva-base/archiva-test-utils/pom.xml index a8e43432d..bb9700158 100644 --- a/archiva-modules/archiva-base/archiva-test-utils/pom.xml +++ b/archiva-modules/archiva-base/archiva-test-utils/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>archiva-base</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-test-utils</artifactId> diff --git a/archiva-modules/archiva-base/archiva-transaction/pom.xml b/archiva-modules/archiva-base/archiva-transaction/pom.xml index 5aa07fa99..f15b31f09 100644 --- a/archiva-modules/archiva-base/archiva-transaction/pom.xml +++ b/archiva-modules/archiva-base/archiva-transaction/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-transaction</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-base/archiva-xml-tools/pom.xml b/archiva-modules/archiva-base/archiva-xml-tools/pom.xml index ec4ba217f..b91c663bb 100644 --- a/archiva-modules/archiva-base/archiva-xml-tools/pom.xml +++ b/archiva-modules/archiva-base/archiva-xml-tools/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-base</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-xml-tools</artifactId> diff --git a/archiva-modules/archiva-base/pom.xml b/archiva-modules/archiva-base/pom.xml index dd9fa56e5..e78f79b76 100644 --- a/archiva-modules/archiva-base/pom.xml +++ b/archiva-modules/archiva-base/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-modules</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-base</artifactId> diff --git a/archiva-modules/archiva-karaf/archiva-features/pom.xml b/archiva-modules/archiva-karaf/archiva-features/pom.xml index 718b030b0..aadfb3677 100644 --- a/archiva-modules/archiva-karaf/archiva-features/pom.xml +++ b/archiva-modules/archiva-karaf/archiva-features/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-karaf</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.apache.archiva.karaf</groupId> diff --git a/archiva-modules/archiva-karaf/pom.xml b/archiva-modules/archiva-karaf/pom.xml index e813c1442..ff50a8dd0 100644 --- a/archiva-modules/archiva-karaf/pom.xml +++ b/archiva-modules/archiva-karaf/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-modules</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-karaf</artifactId> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml index 3272ce41c..38b1af312 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>archiva-scheduler</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-scheduler-api</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml index bad98fcce..33f967fc7 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>archiva-scheduler</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-scheduler-indexing</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskTest.java index 6a1210d1a..7e95b4f26 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskTest.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskTest.java @@ -18,11 +18,11 @@ package org.apache.archiva.scheduler.indexing; * under the License. */ -import junit.framework.TestCase; import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.utils.FileUtil; +import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.maven.index.FlatSearchRequest; @@ -30,12 +30,12 @@ import org.apache.maven.index.FlatSearchResponse; import org.apache.maven.index.MAVEN; import org.apache.maven.index.NexusIndexer; import org.apache.maven.index.expr.StringSearchExpression; -import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.servlet.DefaultServlet; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; -import static org.assertj.core.api.Assertions.assertThat; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -50,7 +50,8 @@ import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.concurrent.TimeUnit; -import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; + +import static org.assertj.core.api.Assertions.assertThat; /** * @author Olivier Lamy @@ -61,6 +62,7 @@ public class DownloadRemoteIndexTaskTest { private Server server; + private ServerConnector serverConnector; private int port; @@ -81,12 +83,12 @@ public class DownloadRemoteIndexTaskTest public void initialize() throws Exception { - server = new Server( 0 ); + server = new Server( ); + serverConnector = new ServerConnector( server, new HttpConnectionFactory()); + server.addConnector( serverConnector ); createContext( server, new File( "src/test/" ) ); - this.server.start(); - Connector connector = this.server.getConnectors()[0]; - this.port = connector.getLocalPort(); + this.port = serverConnector.getLocalPort(); log.info( "start server on port {}", this.port ); nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class ); } diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/resources/log4j2-test.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/resources/log4j2-test.xml index 6e3ef0ff3..c7f86dd6b 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/resources/log4j2-test.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/resources/log4j2-test.xml @@ -19,7 +19,7 @@ --> -<configuration status="debug"> +<configuration> <appenders> <Console name="console" target="SYSTEM_OUT"> <PatternLayout pattern="%d [%t] %-5p %c %x - %m%n"/> @@ -29,7 +29,7 @@ <logger name="org.springframework" level="error"/> - <logger name="org.apache.archiva.scheduler.indexing" level="debug"/> + <logger name="org.apache.archiva.scheduler.indexing" level="info"/> <!-- <logger name="org.apache.http" level="debug"/> --> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/pom.xml index 369ac9a59..122542a6b 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>archiva-scheduler</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-scheduler-repository-api</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml index 2102d954e..881d68981 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>archiva-scheduler</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-scheduler-repository</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/archiva-scheduler/pom.xml b/archiva-modules/archiva-scheduler/pom.xml index 88b411657..91eaa582a 100644 --- a/archiva-modules/archiva-scheduler/pom.xml +++ b/archiva-modules/archiva-scheduler/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-modules</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-scheduler</artifactId> diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml index 00e6fe9fe..cdbae6562 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>archiva-rest</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-rest-api</artifactId> <!-- DO NOT USE bundle packaging generated documentation is not included in the jar !!! --> diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml index 3436e6af6..456e3a1cc 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-rest</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-rest-services</artifactId> <packaging>bundle</packaging> @@ -396,24 +396,14 @@ </dependency> <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.tomcat</groupId> - <artifactId>tomcat-juli</artifactId> - <scope>test</scope> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + <version>${jettyVersion}</version> </dependency> <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-logging-juli</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.tomcat</groupId> - <artifactId>tomcat-jsp-api</artifactId> - <scope>test</scope> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlet</artifactId> + <version>${jettyVersion}</version> </dependency> <dependency> <groupId>xerces</groupId> @@ -467,6 +457,10 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> + <includes> + <include>**/*Tests.java</include> + <include>**/*Test.java</include> + </includes> <argLine>-Xmx512m -Xms512m -server -XX:MaxPermSize=256m ${jacocoagent}</argLine> <systemPropertyVariables> <appserver.base>${project.build.directory}/appserver-base</appserver.base> diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java index 682c367bb..e2efea419 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java @@ -1093,15 +1093,16 @@ public class DefaultBrowseService } } - protected List<ArtifactContentEntry> readFileEntries( File file, String filterPath, String repoId ) + protected List<ArtifactContentEntry> readFileEntries(final File file, final String filterPath, final String repoId ) throws IOException { + String cleanedfilterPath = filterPath==null ? "" : (StringUtils.startsWith(filterPath, "/") ? + StringUtils.substringAfter(filterPath, "/") : filterPath); Map<String, ArtifactContentEntry> artifactContentEntryMap = new HashMap<>(); - int filterDepth = StringUtils.countMatches( filterPath, "/" ); - /*if ( filterDepth == 0 ) - { - filterDepth = 1; - }*/ + int filterDepth = StringUtils.countMatches( cleanedfilterPath, "/" ); + if (!StringUtils.endsWith(cleanedfilterPath,"/") && !StringUtils.isEmpty(cleanedfilterPath)) { + filterDepth++; + } JarFile jarFile = new JarFile( file ); try { @@ -1113,7 +1114,7 @@ public class DefaultBrowseService StringUtils.substringBeforeLast( currentEntry.getName(), "/" ) : currentEntry.getName(); String entryRootPath = getRootPath( cleanedEntryName ); int depth = StringUtils.countMatches( cleanedEntryName, "/" ); - if ( StringUtils.isEmpty( filterPath ) // + if ( StringUtils.isEmpty( cleanedfilterPath ) // && !artifactContentEntryMap.containsKey( entryRootPath ) // && depth == filterDepth ) { @@ -1124,7 +1125,7 @@ public class DefaultBrowseService } else { - if ( StringUtils.startsWith( cleanedEntryName, filterPath ) // + if ( StringUtils.startsWith( cleanedEntryName, cleanedfilterPath ) // && ( depth == filterDepth || ( !currentEntry.isDirectory() && depth == filterDepth ) ) ) { artifactContentEntryMap.put( cleanedEntryName, new ArtifactContentEntry( cleanedEntryName, @@ -1134,7 +1135,7 @@ public class DefaultBrowseService } } - if ( StringUtils.isNotEmpty( filterPath ) ) + if ( StringUtils.isNotEmpty( cleanedfilterPath ) ) { Map<String, ArtifactContentEntry> filteredArtifactContentEntryMap = new HashMap<>(); diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultPluginsServices.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultPluginsServices.java index 4cab81d47..208400c83 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultPluginsServices.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultPluginsServices.java @@ -18,26 +18,25 @@ package org.apache.archiva.rest.services; * under the License. */ -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - import org.apache.archiva.rest.api.services.ArchivaRestServiceException; -import org.springframework.stereotype.Service; - -import javax.inject.Inject; - import org.apache.archiva.rest.api.services.PluginsService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.core.io.Resource; +import org.springframework.stereotype.Service; + +import javax.inject.Inject; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** * @author Eric Barboni * @since 1.4.0 */ -@Service("pluginsService#rest") +@Service( "pluginsService#rest" ) public class DefaultPluginsServices implements PluginsService { @@ -46,7 +45,7 @@ public class DefaultPluginsServices private List<String> adminFeatures = new ArrayList<>(); - private ApplicationContext appCont; + private ApplicationContext applicationContext; private Logger log = LoggerFactory.getLogger( getClass() ); @@ -56,11 +55,14 @@ public class DefaultPluginsServices public DefaultPluginsServices( ApplicationContext applicationContext ) throws IOException { - this.appCont = applicationContext; + log.debug( "init DefaultPluginsServices" ); + this.applicationContext = applicationContext; // rebuild - feed( repositoryType, "repository" ); - feed( adminFeatures, "features" ); + repositoryType = feed( "repository" ); + log.debug( "feed {}:{}", "repository" , repositoryType); + adminFeatures = feed( "features" ); + log.debug( "feed {}:{}", "features", adminFeatures ); StringBuilder sb = new StringBuilder(); for ( String repoType : repositoryType ) { @@ -81,27 +83,29 @@ public class DefaultPluginsServices } } - private void feed( List<String> repository, String key ) + private List<String> feed( String key ) throws IOException { log.info( "Feeding: {}", key ); - repository.clear(); - Resource[] xmlResources; - - xmlResources = appCont.getResources( "/**/" + key + "/**/main.js" ); + Resource[] xmlResources = applicationContext.getResources( "/**/" + key + "/**/main.js" ); + if (xmlResources == null) + { + return Collections.emptyList(); + } + List<String> repository = new ArrayList<>( xmlResources.length ); for ( Resource rc : xmlResources ) { String tmp = rc.getURL().toString(); tmp = tmp.substring( tmp.lastIndexOf( key ) + key.length() + 1, tmp.length() - 8 ); repository.add( "archiva/admin/" + key + "/" + tmp + "/main" ); } - + return repository; } @Override public String getAdminPlugins() throws ArchivaRestServiceException { - return adminPlugins; + return adminPlugins; } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRemoteRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRemoteRepositoriesService.java index 5a7948719..59358dddf 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRemoteRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRemoteRepositoriesService.java @@ -38,11 +38,14 @@ import org.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.repository.Repository; import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.ws.rs.core.Response; import java.net.URL; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @author Olivier Lamy @@ -51,8 +54,7 @@ import java.util.List; @Service( "remoteRepositoriesService#rest" ) public class DefaultRemoteRepositoriesService extends AbstractRestService - implements RemoteRepositoriesService -{ + implements RemoteRepositoriesService { @Inject private RemoteRepositoryAdmin remoteRepositoryAdmin; @@ -67,32 +69,26 @@ public class DefaultRemoteRepositoriesService int checkReadTimeout = 10000; int checkTimeout = 9000; + @Override public List<RemoteRepository> getRemoteRepositories() - throws ArchivaRestServiceException - { - try - { + throws ArchivaRestServiceException { + try { List<RemoteRepository> remoteRepositories = remoteRepositoryAdmin.getRemoteRepositories(); return remoteRepositories == null ? Collections.<RemoteRepository>emptyList() : remoteRepositories; - } - catch ( RepositoryAdminException e ) - { - log.error( e.getMessage(), e ); - throw new ArchivaRestServiceException( e.getMessage(), e.getFieldName(), e ); + } catch (RepositoryAdminException e) { + log.error(e.getMessage(), e); + throw new ArchivaRestServiceException(e.getMessage(), e.getFieldName(), e); } } @Override - public RemoteRepository getRemoteRepository( String repositoryId ) - throws ArchivaRestServiceException - { + public RemoteRepository getRemoteRepository(String repositoryId) + throws ArchivaRestServiceException { List<RemoteRepository> remoteRepositories = getRemoteRepositories(); - for ( RemoteRepository repository : remoteRepositories ) - { - if ( StringUtils.equals( repositoryId, repository.getId() ) ) - { + for (RemoteRepository repository : remoteRepositories) { + if (StringUtils.equals(repositoryId, repository.getId())) { return repository; } } @@ -100,121 +96,106 @@ public class DefaultRemoteRepositoriesService } @Override - public Boolean deleteRemoteRepository( String repositoryId ) - throws ArchivaRestServiceException - { - try - { - return remoteRepositoryAdmin.deleteRemoteRepository( repositoryId, getAuditInformation() ); - } - catch ( RepositoryAdminException e ) - { - log.error( e.getMessage(), e ); - throw new ArchivaRestServiceException( e.getMessage(), e.getFieldName(), e ); + public Boolean deleteRemoteRepository(String repositoryId) + throws ArchivaRestServiceException { + try { + return remoteRepositoryAdmin.deleteRemoteRepository(repositoryId, getAuditInformation()); + } catch (RepositoryAdminException e) { + log.error(e.getMessage(), e); + throw new ArchivaRestServiceException(e.getMessage(), e.getFieldName(), e); } } @Override - public Boolean addRemoteRepository( RemoteRepository remoteRepository ) - throws ArchivaRestServiceException - { - try - { - return remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getAuditInformation() ); - } - catch ( RepositoryAdminException e ) - { - log.error( e.getMessage(), e ); - throw new ArchivaRestServiceException( e.getMessage(), e.getFieldName(), e ); + public Boolean addRemoteRepository(RemoteRepository remoteRepository) + throws ArchivaRestServiceException { + try { + return remoteRepositoryAdmin.addRemoteRepository(remoteRepository, getAuditInformation()); + } catch (RepositoryAdminException e) { + log.error(e.getMessage(), e); + throw new ArchivaRestServiceException(e.getMessage(), e.getFieldName(), e); } } @Override - public Boolean updateRemoteRepository( RemoteRepository remoteRepository ) - throws ArchivaRestServiceException - { - try - { - return remoteRepositoryAdmin.updateRemoteRepository( remoteRepository, getAuditInformation() ); - } - catch ( RepositoryAdminException e ) - { - log.error( e.getMessage(), e ); - throw new ArchivaRestServiceException( e.getMessage(), e.getFieldName(), e ); + public Boolean updateRemoteRepository(RemoteRepository remoteRepository) + throws ArchivaRestServiceException { + try { + return remoteRepositoryAdmin.updateRemoteRepository(remoteRepository, getAuditInformation()); + } catch (RepositoryAdminException e) { + log.error(e.getMessage(), e); + throw new ArchivaRestServiceException(e.getMessage(), e.getFieldName(), e); } } @Override - public Boolean checkRemoteConnectivity( String repositoryId ) - throws ArchivaRestServiceException - { - try - { - RemoteRepository remoteRepository = remoteRepositoryAdmin.getRemoteRepository( repositoryId ); - if ( remoteRepository == null ) - { - log.warn( "ignore scheduleDownloadRemote for repo with id {} as not exists", repositoryId ); + public Boolean checkRemoteConnectivity(String repositoryId) + throws ArchivaRestServiceException { + try { + RemoteRepository remoteRepository = remoteRepositoryAdmin.getRemoteRepository(repositoryId); + if (remoteRepository == null) { + log.warn("ignore scheduleDownloadRemote for repo with id {} as not exists", repositoryId); return Boolean.FALSE; } NetworkProxy networkProxy = null; - if ( StringUtils.isNotBlank( remoteRepository.getRemoteDownloadNetworkProxyId() ) ) - { - networkProxy = networkProxyAdmin.getNetworkProxy( remoteRepository.getRemoteDownloadNetworkProxyId() ); - if ( networkProxy == null ) - { + if (StringUtils.isNotBlank(remoteRepository.getRemoteDownloadNetworkProxyId())) { + networkProxy = networkProxyAdmin.getNetworkProxy(remoteRepository.getRemoteDownloadNetworkProxyId()); + if (networkProxy == null) { log.warn( - "your remote repository is configured to download remote index trought a proxy we cannot find id:{}", - remoteRepository.getRemoteDownloadNetworkProxyId() ); + "your remote repository is configured to download remote index trought a proxy we cannot find id:{}", + remoteRepository.getRemoteDownloadNetworkProxyId()); } } - String wagonProtocol = new URL( remoteRepository.getUrl() ).getProtocol(); + String wagonProtocol = new URL(remoteRepository.getUrl()).getProtocol(); final Wagon wagon = - wagonFactory.getWagon( new WagonFactoryRequest( wagonProtocol, remoteRepository.getExtraHeaders() ) // - .networkProxy( networkProxy ) ); + wagonFactory.getWagon(new WagonFactoryRequest(wagonProtocol, remoteRepository.getExtraHeaders()) // + .networkProxy(networkProxy)); // hardcoded value as it's a check of the remote repo connectivity - wagon.setReadTimeout( checkReadTimeout ); - wagon.setTimeout( checkTimeout ); + wagon.setReadTimeout(checkReadTimeout); + wagon.setTimeout(checkTimeout); - if ( wagon instanceof AbstractHttpClientWagon ) - { + if (wagon instanceof AbstractHttpClientWagon) { HttpMethodConfiguration httpMethodConfiguration = new HttpMethodConfiguration() // - .setUsePreemptive( true ) // - .setReadTimeout( checkReadTimeout ); - HttpConfiguration httpConfiguration = new HttpConfiguration().setGet( httpMethodConfiguration ); - AbstractHttpClientWagon.class.cast( wagon ).setHttpConfiguration( httpConfiguration ); + .setUsePreemptive(true) // + .setReadTimeout(checkReadTimeout); + HttpConfiguration httpConfiguration = new HttpConfiguration().setGet(httpMethodConfiguration); + AbstractHttpClientWagon.class.cast(wagon).setHttpConfiguration(httpConfiguration); } - + ProxyInfo proxyInfo = null; - if ( networkProxy != null ) - { + if (networkProxy != null) { proxyInfo = new ProxyInfo(); - proxyInfo.setType( networkProxy.getProtocol() ); - proxyInfo.setHost( networkProxy.getHost() ); - proxyInfo.setPort( networkProxy.getPort() ); - proxyInfo.setUserName( networkProxy.getUsername() ); - proxyInfo.setPassword( networkProxy.getPassword() ); - } - - wagon.connect( new Repository( remoteRepository.getId(), remoteRepository.getUrl() ), proxyInfo ); - - // we only check connectivity as remote repo can be empty - // MRM-1909: Wagon implementation appends a slash already - wagon.getFileList( "" ); + proxyInfo.setType(networkProxy.getProtocol()); + proxyInfo.setHost(networkProxy.getHost()); + proxyInfo.setPort(networkProxy.getPort()); + proxyInfo.setUserName(networkProxy.getUsername()); + proxyInfo.setPassword(networkProxy.getPassword()); + } + String url = StringUtils.stripEnd(remoteRepository.getUrl(), "/"); + wagon.connect(new Repository(remoteRepository.getId(), url), proxyInfo); + + // MRM-1933, there are certain servers that do not allow browsing + if (!(StringUtils.isEmpty(remoteRepository.getCheckPath()) || + "/".equals(remoteRepository.getCheckPath()))) { + return wagon.resourceExists(remoteRepository.getCheckPath()); + } else { + // we only check connectivity as remote repo can be empty + // MRM-1909: Wagon implementation appends a slash already + wagon.getFileList(""); + } return Boolean.TRUE; - } - catch ( TransferFailedException e ) - { - log.info( "TransferFailedException :{}", e.getMessage() ); + } catch (TransferFailedException e) { + log.info("TransferFailedException :{}", e.getMessage()); + return Boolean.FALSE; + } catch (Exception e) { + // This service returns either true or false, Exception cannot be handled by the clients + log.debug("Exception occured on connectivity test.", e); + log.info("Connection exception: {}", e.getMessage()); return Boolean.FALSE; - } - catch ( Exception e ) - { - throw new ArchivaRestServiceException( e.getMessage(), - Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e ); } } @@ -234,4 +215,5 @@ public class DefaultRemoteRepositoriesService public void setCheckTimeout(int checkTimeout) { this.checkTimeout = checkTimeout; } + } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml index 77d365cbc..c9e677db6 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml @@ -52,6 +52,7 @@ <ref bean="jsonProvider"/> <ref bean="authenticationInterceptor#rest"/> <ref bean="permissionInterceptor#rest"/> + <ref bean="requestValidationInterceptor#rest" /> <ref bean="archivaRestServiceExceptionMapper"/> </jaxrs:providers> diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java index 2453e6af8..0d924f723 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java @@ -138,6 +138,7 @@ public abstract class AbstractArchivaRestTest { WebClient.client( service ).header( "Authorization", authzHeader ); } + WebClient.client(service).header("Referer","http://localhost:"+port); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); @@ -200,6 +201,7 @@ public abstract class AbstractArchivaRestTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); @@ -214,6 +216,7 @@ public abstract class AbstractArchivaRestTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); @@ -231,6 +234,8 @@ public abstract class AbstractArchivaRestTest WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); return service; } @@ -246,6 +251,7 @@ public abstract class AbstractArchivaRestTest WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); return service; } @@ -262,6 +268,8 @@ public abstract class AbstractArchivaRestTest { WebClient.client( service ).header( "Authorization", authzHeader ); } + // Set the Referer header to your archiva server url + WebClient.client(service).header("Referer","http://localhost:"+port); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); if ( useXml ) @@ -291,6 +299,8 @@ public abstract class AbstractArchivaRestTest { WebClient.client( service ).header( "Authorization", authzHeader ); } + // Set the Referer header to your archiva server url + WebClient.client(service).header("Referer","http://localhost:"+port); // to configure read timeout WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); // if you want to use json as exchange format xml is supported too @@ -312,6 +322,7 @@ public abstract class AbstractArchivaRestTest { WebClient.client( service ).header( "Authorization", authzHeader ); } + WebClient.client(service).header("Referer","http://localhost:"+port); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArtifactContentEntriesTests.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArtifactContentEntriesTests.java index 721cfb277..461cb8018 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArtifactContentEntriesTests.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArtifactContentEntriesTests.java @@ -20,6 +20,7 @@ package org.apache.archiva.rest.services; import junit.framework.TestCase; import org.apache.archiva.rest.api.model.ArtifactContentEntry; +import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -34,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Olivier Lamy */ -@RunWith( JUnit4.class ) +@RunWith( ArchivaBlockJUnit4ClassRunner.class ) public class ArtifactContentEntriesTests extends TestCase { diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java index 3d284e452..d3d667283 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java @@ -161,10 +161,62 @@ public class RemoteRepositoriesServiceTest } + /* + * Check maven repository + */ + @Test + public void checkRemoteConnectivity2() + throws Exception { + RemoteRepositoriesService service = getRemoteRepositoriesService(); + + WebClient.client(service).header("Authorization", authorizationHeader); + + int initialSize = service.getRemoteRepositories().size(); + + service.addRemoteRepository(getRemoteMavenRepository()); + + assertTrue(service.checkRemoteConnectivity("id-maven1")); + + } + + + /* + * Check oracle repository that allows not browsing (MRM-1933) + */ + @Test + public void checkRemoteConnectivity3() + throws Exception { + RemoteRepositoriesService service = getRemoteRepositoriesService(); + + WebClient.client(service).header("Authorization", authorizationHeader); + WebClient.client(service).accept("application/json"); + + int initialSize = service.getRemoteRepositories().size(); + + service.addRemoteRepository(getRemoteOracleRepository()); + + assertTrue(service.checkRemoteConnectivity("id-oracle")); + + } + RemoteRepository getRemoteRepository() { return new RemoteRepository( "id-new", "new one", "http://foo.com", "default", "foo", "foopassword", 120, "cool repo" ); } + + RemoteRepository getRemoteMavenRepository() + { + return new RemoteRepository( "id-maven1", "Maven1", "http://repo.maven.apache.org/maven2", "default", "foo", "foopassword", 120, + "cool repo3" ); + } + + + RemoteRepository getRemoteOracleRepository() + { + return new RemoteRepository( "id-oracle", "Oracle", "http://download.oracle.com/maven", "default", "foo", "foopassword", 120, + "cool repo4" ); + } + } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java index 017505859..1fee4a342 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoryGroupServiceTest.java @@ -39,6 +39,8 @@ public class RepositoryGroupServiceTest { RepositoryGroupService service = getRepositoryGroupService(); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); assertTrue( service.getRepositoriesGroups().isEmpty() ); diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml index 27d764d58..ceea546a8 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml @@ -84,6 +84,21 @@ <constructor-arg value="${appserver.base}/jcr"/> </bean> + <bean name="commons-configuration" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry" + init-method="initialize"> + <property name="properties"> + <value> + <![CDATA[ + <configuration> + <system/> + <properties fileName="${basedir}/src/test/resources/security.properties" config-optional="true" + config-at="org.apache.archiva.redback"/> + </configuration> + ]]> + </value> + </property> + </bean> + <alias name="userConfiguration#redback" alias="userConfiguration#default"/> <alias name="authorizer#rbac" alias="authorizer#default"/> diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j2-test.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j2-test.xml index a7e013916..1c258ef1e 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j2-test.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j2-test.xml @@ -19,7 +19,7 @@ --> -<configuration status="debug"> +<configuration> <!-- status="debug" --> <appenders> <Console name="console" target="SYSTEM_OUT"> <PatternLayout pattern="%highlight{%d{HH:mm:ss.SSS} [%L] [%t] %-5level %logger{3} - %msg%n}" /> @@ -27,13 +27,10 @@ </appenders> <loggers> - <logger name="org.codehaus.redback.rest.services" level="error"/> - + <logger name="org.apache.archiva.redback.rest.services" level="error"/> <logger name="JPOX" level="error"/> - - + <logger name="org.apache.archiva.rest.services" level="info"/> <logger name="org.springframework" level="error"/> - <logger name="org.apache.commons.configuration" level="error"/> <root level="info"> diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/security.properties b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/security.properties new file mode 100644 index 000000000..3607f9f6f --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/security.properties @@ -0,0 +1,19 @@ +# +# 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. +# +rest.csrffilter.disableTokenValidation=true diff --git a/archiva-modules/archiva-web/archiva-rest/pom.xml b/archiva-modules/archiva-web/archiva-rest/pom.xml index 39248b3e9..f1f4a594f 100644 --- a/archiva-modules/archiva-web/archiva-rest/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-web</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-rest</artifactId> <name>Archiva Web :: REST support</name> diff --git a/archiva-modules/archiva-web/archiva-rss/pom.xml b/archiva-modules/archiva-web/archiva-rss/pom.xml index 908e584af..a7bcf7602 100644 --- a/archiva-modules/archiva-web/archiva-rss/pom.xml +++ b/archiva-modules/archiva-web/archiva-rss/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>archiva-web</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-rss</artifactId> diff --git a/archiva-modules/archiva-web/archiva-security/pom.xml b/archiva-modules/archiva-web/archiva-security/pom.xml index 3f20162c8..064af5676 100644 --- a/archiva-modules/archiva-web/archiva-security/pom.xml +++ b/archiva-modules/archiva-web/archiva-security/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-web</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-security</artifactId> @@ -47,7 +47,7 @@ </dependency> <dependency> <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> + <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> </dependency> <dependency> diff --git a/archiva-modules/archiva-web/archiva-test-mocks/pom.xml b/archiva-modules/archiva-web/archiva-test-mocks/pom.xml index aafcdf65b..b25a684a1 100644 --- a/archiva-modules/archiva-web/archiva-test-mocks/pom.xml +++ b/archiva-modules/archiva-web/archiva-test-mocks/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-web</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-test-mocks</artifactId> diff --git a/archiva-modules/archiva-web/archiva-web-common/pom.xml b/archiva-modules/archiva-web/archiva-web-common/pom.xml index 971da5c73..4b79066c4 100644 --- a/archiva-modules/archiva-web/archiva-web-common/pom.xml +++ b/archiva-modules/archiva-web/archiva-web-common/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-web</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-web-common</artifactId> @@ -186,11 +186,6 @@ <artifactId>audit</artifactId> </dependency> <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> </dependency> @@ -234,13 +229,18 @@ </dependency> <dependency> <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> + <artifactId>javax.servlet-api</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency> <dependency> + <groupId>javax.mail</groupId> + <artifactId>mail</artifactId> + <scope>provided</scope> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index 5b8e0c7b7..eb4dc0351 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -172,8 +172,9 @@ remoterepository.download.remote.full=Full download ? remoterepository.download.remote.scheduled=Download Remote Index of repository {0} scheduled. remoterepository.delete.confirm=Are you sure to delete Remote Repository {0} ? remoterepository.deleted=Remote repository {0}\u00c2\u00a0deleted. -remoteRepository.extraParametersEntries=Additionnal url parameters -remoteRepository.extraHeadersEntries=Additionnal Http Headers +remoteRepository.extraParametersEntries=Additional url parameters +remoteRepository.extraHeadersEntries=Additional Http Headers +remoteRepository.checkPath=Connection Check Path remoteRepository.timeout.help.title=Download Timeout remoteRepository.timeout.help.content=Timeout in secondes for downloading files from remote repository. remoteRepository.userName.help.title=Username @@ -197,6 +198,11 @@ remoteRepository.extraParametersEntries.help.content=Key/Value pair you want to remoteRepository.extraHeadersEntries.help.title=Extra HTTP Headers remoteRepository.extraHeadersEntries.help.content=Key/Value pair HTTP headers you want to add when asking the remote repository. remoterepository.remotecheck=Remote Check +remoteRepository.checkPath.help.title=Connection Check Path +remoteRepository.checkPath.help.content=Path relative to the repository URL that is used to check the connection to the \ + remote repository. Some repositories may not allow to browse the root directory. So if this path is set, the repository is \ + considered online if the resources exists. + @@ -614,40 +620,40 @@ archiva.redback.usermanager.ldap=LDAP User Manager archiva.redback.usermanager.jdo=Database User Manager archiva.redback.usermanager.jpa=Database JPA User Manager redback.runtime.properties.help.title=Property Description -security.policy.password.rule.alphacount.enabled.help.content=Minimum of letter characters in the password. -security.policy.password.rule.reuse.enabled.help.content=Prevent reuse of previous passwords. +security.policy.password.rule.alphacount.enabled.help.content=If true, minimum number of letter characters in new passwords will be checked. +security.policy.password.rule.reuse.enabled.help.content=If true, reuse of passwords will be checked. email.validation.subject.help.content=Subject of the validation email. -security.policy.password.previous.count.help.content=Number of previous password verified when verifying not reused. +security.policy.password.previous.count.help.content=This is the number of previous passwords a new password is matched against. The password is rejected if one of the previous passwords matches. security.policy.password.expiration.days.help.content=Number of days before password expiration. email.validation.timeout.help.content=Timeout (in minutes) for the key generated for an email validation to remain valid. -security.policy.password.rule.alphanumeric.enabled.help.content=Minimum number of characters in the password rule enabled. -security.policy.password.rule.alphacount.minimum.help.content=Minimum number of characters in the password. -ldap.config.max.result.count.help.content=Maximum of result when searching users in LDAP. -security.policy.password.rule.numericalcount.enabled.help.content=Minimum of number characters in the password. -security.policy.allowed.login.attempt.help.content=Maximum number of login attempt before loking account. +security.policy.password.rule.alphanumeric.enabled.help.content=If true, only alphanumeric values in new passwords are allowed. +security.policy.password.rule.alphacount.minimum.help.content=Minimum number of letter characters in the password. +ldap.config.max.result.count.help.content=Maximum number of results when searching users in LDAP (0 means no limit). +security.policy.password.rule.numericalcount.enabled.help.content=If true, new passwords must contain a minimum number of numerical characters. +security.policy.allowed.login.attempt.help.content=Maximum number of unsuccessful login attempts before locking account. security.rememberme.enabled.help.content=Enable rememberme on login. security.rememberme.timeout.help.content=Timeout in days for rememberme cookie. security.rememberme.path.help.content=Path for rememberme cookie. -security.rememberme.secure.help.content=rememberme cookie secured. -security.rememberme.domain.help.content=rememberme cookie domain. -security.policy.unlockable.accounts.help.content=Non lockable accounts. +security.rememberme.secure.help.content=If true, the rememberme cookie is set as secure. +security.rememberme.domain.help.content=Name of the rememberme cookie domain. +security.policy.unlockable.accounts.help.content=Comma separated list of User-IDs, that cannot be locked. ldap.config.groups.class.help.content=The name of the objectClass in the ldap server used to identify groups. The default is groupOfUniqueNames. ldap.config.groups.member.help.content=The name of the attribute on a group that contains the user DN of group members. The default is uniqueMember. -ldap.config.mapper.attribute.fullname.help.content=The name of the attribute on a user that contains the users fullName. -security.policy.password.rule.characterlength.enabled.help.content=Character length password rule enabled. -security.policy.password.rule.musthave.enabled.help.content=Password mandatory rule enabled. +ldap.config.mapper.attribute.fullname.help.content=The name of the attribute on a user that contains the users full name. +security.policy.password.rule.characterlength.enabled.help.content=If true, minimum and maximum number of characters in new passwords are checked. +security.policy.password.rule.musthave.enabled.help.content=If true, each user must have a password. security.policy.password.rule.numericalcount.minimum.help.content=Minimum number of numerical characters in the password. -redback.default.admin.help.content=Id of the administrator user. +redback.default.admin.help.content=User-Id of the primary administrator. security.policy.password.rule.characterlength.minimum.help.content=Minimum size of the password. -ldap.config.mapper.attribute.user.object.class.help.content=the objectClass used in the ldap server for indentifying users, most commonly inetOrgPerson. +ldap.config.mapper.attribute.user.object.class.help.content=The objectClass used in the ldap server for identifying users, most commonly inetOrgPerson. ldap.config.mapper.attribute.password.help.content=The name of the attribute containing the users password, used for the authentiction using the user manager and not the ldap bind authenticator. -security.policy.password.rule.nowhitespace.enabled.help.content=Enabled no whitespace in password rule. -security.policy.password.expiration.enabled.help.content=Enable password expiration. -ldap.config.mapper.attribute.user.id.help.content=The name of the attribute containing the users userId, most commonly cn or sn. +security.policy.password.rule.nowhitespace.enabled.help.content=If true, no whitespace is allowed in passwords. +security.policy.password.expiration.enabled.help.content=If true, password expiration is enabled. +ldap.config.mapper.attribute.user.id.help.content=The name of the attribute containing the users User-ID, most commonly cn or sn. security.policy.password.rule.characterlength.maximum.help.content=Maximum size of the password. -security.signon.timeout.help.content=not used. +security.signon.timeout.help.content=Not used. ldap.config.mapper.attribute.email.help.content=The name of the attribute on a user that contains the email address. -email.validation.required.help.content=If all email addresses (from new user registration) require an account validation email. +email.validation.required.help.content=If true, all email addresses (from new user registration) require an account validation email. redback.runtime.properties.title=Properties redback.runtime.ldap.port.label=port redback.runtime.ldap.host.label=host @@ -671,6 +677,14 @@ redback.runtime.ldap.checkServer=Verify LDAP configuration on server side. redback.runtime.useUsersCache.label=Use a cache for users. redback.runtime.users.cache.title=Users Cache +ldap.config.dn.help.content=The name of the attribute containing the DN +ldap.config.user.attribute.help.content=The name of the RDN attribute in the DN of the user object containing the User-ID (e.g. for cn=usr1,ou=users,ou=tst,ou=org, the value would be cn) +redback.default.role.guest.id.help.content=The User-ID of the guest user +rest.baseUrl.help.content=URL that is used as base url for validating REST requests. If empty, the URL ist determined automatically. +rest.csrffilter.absentorigin.deny.help.content=If true and no Origin/Referer header can be found on REST requests, the requests will be denied. Default: true. +rest.csrffilter.disableTokenValidation.help.content=If true, token based origin validation of REST requests will be omitted. Default: false. +rest.csrffilter.enabled.help.content=If true, validation of REST requests will be validated based on header values, otherwise no validation is done at all. Default: true. + archiva.redback.rbacmanager.ldap=LDAP RBac Manager archiva.redback.rbacmanager.jdo=Database RBac Manager archiva.redback.rbacmanager.jpa=Database JPA RBac Manager diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/RuntimeInfoServiceTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/RuntimeInfoServiceTest.java index fce64f4e2..d4dd7b2fb 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/RuntimeInfoServiceTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/RuntimeInfoServiceTest.java @@ -25,6 +25,7 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.apache.cxf.jaxrs.client.JAXRSClientFactory; import org.apache.archiva.redback.rest.services.AbstractRestServicesTest; +import org.apache.cxf.jaxrs.client.WebClient; import org.junit.Before; import org.junit.Test; @@ -84,6 +85,7 @@ public class RuntimeInfoServiceTest RuntimeInfoService.class, Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + WebClient.client(service).header("Referer","http://localhost"); ApplicationRuntimeInfo applicationRuntimeInfo = service.getApplicationRuntimeInfo( "en" ); assertEquals( System.getProperty( "expectedVersion" ), applicationRuntimeInfo.getVersion() ); diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java index 227da18bc..f04148cbd 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/AbstractDownloadTest.java @@ -173,6 +173,8 @@ public abstract class AbstractDownloadTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); return service; } @@ -185,6 +187,8 @@ public abstract class AbstractDownloadTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); return service; } @@ -197,6 +201,8 @@ public abstract class AbstractDownloadTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); return service; } @@ -210,6 +216,8 @@ public abstract class AbstractDownloadTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); return service; } @@ -222,6 +230,8 @@ public abstract class AbstractDownloadTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); return service; } @@ -234,6 +244,8 @@ public abstract class AbstractDownloadTest Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.client(service).header("Referer","http://localhost:"+port); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); return service; } @@ -252,6 +264,8 @@ public abstract class AbstractDownloadTest RoleManagementService.class, Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + WebClient.client(service).header("Referer","http://localhost:"+port); + // for debuging purpose WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 3000000L ); @@ -268,6 +282,8 @@ public abstract class AbstractDownloadTest JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/redbackServices/", UserService.class, Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + WebClient.client(service).header("Referer","http://localhost:"+port); + // for debuging purpose WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 3000000L ); diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java index b009e8c71..eae41013f 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java @@ -25,7 +25,9 @@ import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; import org.apache.commons.io.FileUtils; import org.apache.maven.wagon.providers.http.HttpWagon; import org.apache.maven.wagon.repository.Repository; +import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.junit.After; @@ -96,7 +98,9 @@ public class DownloadArtifactsTest // repo handler - this.repoServer = new Server( 0 ); + this.repoServer = new Server( ); + ServerConnector repoServerConnector = new ServerConnector( this.repoServer, new HttpConnectionFactory()); + this.repoServer.addConnector( repoServerConnector ); ServletHolder shRepo = new ServletHolder( RepoServlet.class ); ServletContextHandler contextRepo = new ServletContextHandler(); @@ -105,12 +109,16 @@ public class DownloadArtifactsTest contextRepo.addServlet( shRepo, "/*" ); repoServer.setHandler( contextRepo ); + repoServer.start(); - this.repoServerPort = repoServer.getConnectors()[0].getLocalPort(); + this.repoServerPort = repoServerConnector.getLocalPort(); //redirect handler - this.redirectServer = new Server( 0 ); + this.redirectServer = new Server( ); + ServerConnector redirectServerConnector = new ServerConnector( this.redirectServer, new HttpConnectionFactory()); + this.redirectServer.addConnector( redirectServerConnector ); + ServletHolder shRedirect = new ServletHolder( RedirectServlet.class ); ServletContextHandler contextRedirect = new ServletContextHandler(); contextRedirect.setAttribute( "redirectToPort", Integer.toString( this.repoServerPort ) ); @@ -120,7 +128,7 @@ public class DownloadArtifactsTest redirectServer.setHandler( contextRedirect ); redirectServer.start(); - this.redirectPort = redirectServer.getConnectors()[0].getLocalPort(); + this.redirectPort = redirectServerConnector.getLocalPort(); log.info( "redirect server port {}", redirectPort ); } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/RemoteRepositoryConnectivityCheckTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/RemoteRepositoryConnectivityCheckTest.java index fabe56808..369bb10f8 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/RemoteRepositoryConnectivityCheckTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/RemoteRepositoryConnectivityCheckTest.java @@ -24,7 +24,9 @@ import org.apache.archiva.rest.api.services.RemoteRepositoriesService; import org.apache.commons.io.FileUtils; import org.apache.cxf.jaxrs.client.WebClient; import org.eclipse.jetty.server.Handler; +import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; @@ -71,6 +73,9 @@ public class RemoteRepositoryConnectivityCheckTest Server repoServer = buildStaticServer( new File( System.getProperty( "basedir" ) + "/src/test/repositories/test-repo" ) ); + + ServerConnector serverConnector = new ServerConnector( repoServer, new HttpConnectionFactory()); + repoServer.addConnector( serverConnector ); repoServer.start(); RemoteRepositoriesService service = getRemoteRepositoriesService(); @@ -80,7 +85,7 @@ public class RemoteRepositoryConnectivityCheckTest try { - int repoServerPort = repoServer.getConnectors()[0].getLocalPort(); + int repoServerPort = serverConnector.getLocalPort(); RemoteRepository repo = getRemoteRepository(); @@ -104,6 +109,8 @@ public class RemoteRepositoryConnectivityCheckTest File tmpDir = Files.createTempDirectory( "test" ).toFile(); Server repoServer = buildStaticServer( tmpDir ); + ServerConnector serverConnector = new ServerConnector( repoServer, new HttpConnectionFactory()); + repoServer.addConnector( serverConnector ); repoServer.start(); RemoteRepositoriesService service = getRemoteRepositoriesService(); @@ -113,7 +120,7 @@ public class RemoteRepositoryConnectivityCheckTest try { - int repoServerPort = repoServer.getConnectors()[0].getLocalPort(); + int repoServerPort = serverConnector.getLocalPort(); RemoteRepository repo = getRemoteRepository(); @@ -160,7 +167,7 @@ public class RemoteRepositoryConnectivityCheckTest protected Server buildStaticServer( File path ) { - Server repoServer = new Server( 0 ); + Server repoServer = new Server( ); ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setDirectoriesListed( true ); diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java index eda8af6a8..410d6c1a3 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java @@ -22,6 +22,7 @@ package org.apache.archiva.web.rss; import org.apache.archiva.redback.authentication.AuthenticationDataSource; import org.apache.archiva.redback.authentication.AuthenticationException; import org.apache.archiva.redback.authentication.AuthenticationResult; +import org.apache.archiva.redback.authentication.TokenManager; import org.apache.archiva.redback.authorization.AuthorizationException; import org.apache.archiva.redback.authorization.AuthorizationResult; import org.apache.archiva.redback.keys.KeyManager; @@ -703,4 +704,9 @@ public class SecuritySystemStub { return true; } + + @Override + public TokenManager getTokenManager() { + return null; + } } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/log4j2-test.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/log4j2-test.xml index b80c0b0fa..11ff56844 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/log4j2-test.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/log4j2-test.xml @@ -28,15 +28,15 @@ <loggers> <logger name="org.springframework" level="error"/> - + <logger name="org.apache.archiva" level="error"/> <logger name="org.apache.archiva.web" level="info"/> - <logger name="org.apache.commons.configuration" level="error"/> - - <logger name="org.apache.archiva.scheduler.indexing" level="debug"/> - - <logger name="org.apache.archiva.remotedownload" level="debug"/> - + <logger name="org.apache.archiva.scheduler.indexing" level="info"/> + <logger name="org.apache.archiva.remotedownload" level="info"/> + <logger name="org.apache.jackrabbit" level="error"/> + <logger name="org.quartz" level="error"/> + <logger name="JPOX.RDBMS" level="error"/> + <logger name="JPOX" level="error"/> <root level="info"> <appender-ref ref="console"/> </root> diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/org/apache/archiva/security.properties b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/org/apache/archiva/security.properties new file mode 100644 index 000000000..3607f9f6f --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/org/apache/archiva/security.properties @@ -0,0 +1,19 @@ +# +# 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. +# +rest.csrffilter.disableTokenValidation=true diff --git a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml index c473eeacd..61eb47a94 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-web</artifactId> - <version>2.2.1-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-webapp-test</artifactId> <packaging>pom</packaging> @@ -36,7 +36,7 @@ <maxWaitTimeInMs>10000</maxWaitTimeInMs> <seleniumPluginVersion>2.3</seleniumPluginVersion> - <selenium-server.version>2.43.1</selenium-server.version> + <selenium-server.version>2.53.1</selenium-server.version> <fluentlenium.version>0.10.2</fluentlenium.version> <browserPath></browserPath> @@ -83,6 +83,22 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.seleniumhq.selenium</groupId> + <artifactId>selenium-remote-driver</artifactId> + <version>${selenium-server.version}</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-exec</artifactId> + <version>1.3</version> + </dependency> + <dependency> + <groupId>org.seleniumhq.selenium</groupId> + <artifactId>htmlunit-driver</artifactId> + <version>2.24</version> + </dependency> + <dependency> <groupId>org.fluentlenium</groupId> @@ -175,18 +191,26 @@ <artifactId>selenium-server</artifactId> <version>${selenium-server.version}</version> </dependency> - <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-remote-driver</artifactId> <version>${selenium-server.version}</version> </dependency> - <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-api</artifactId> <version>${selenium-server.version}</version> </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-exec</artifactId> + <version>1.3</version> + </dependency> + <dependency> + <groupId>org.seleniumhq.selenium</groupId> + <artifactId>htmlunit-driver</artifactId> + <version>2.24</version> + </dependency> </dependencies> </plugin> <plugin> diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java index 481301229..4ed311db2 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java @@ -30,11 +30,15 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.ie.InternetExplorerDriver; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.safari.SafariDriver; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; import java.util.Properties; import java.util.concurrent.TimeUnit; import org.apache.commons.io.FileUtils; @@ -136,26 +140,36 @@ public class WebDriverBrowseTest } @Override - public WebDriver getDefaultDriver() - { - String seleniumBrowser = System.getProperty( "selenium.browser" ); - - if ( StringUtils.contains( seleniumBrowser, "chrome" ) ) - { - return new ChromeDriver(); - } - - if ( StringUtils.contains( seleniumBrowser, "safari" ) ) - { - return new SafariDriver(); - } - - if ( StringUtils.contains( seleniumBrowser, "iexplore" ) ) - { - return new InternetExplorerDriver(); + public WebDriver getDefaultDriver() { + String seleniumBrowser = System.getProperty("selenium.browser"); + String seleniumHost = System.getProperty("seleniumHost", "localhost"); + int seleniumPort = Integer.getInteger("seleniumPort", 4444); + try { + + if (StringUtils.contains(seleniumBrowser, "chrome")) { + return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), + DesiredCapabilities.chrome() + ); + } + + if (StringUtils.contains(seleniumBrowser, "safari")) { + return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), + DesiredCapabilities.safari() + ); + } + + if (StringUtils.contains(seleniumBrowser, "iexplore")) { + return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), + DesiredCapabilities.internetExplorer() + ); + } + + return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), + DesiredCapabilities.firefox() + ); + } catch (MalformedURLException e) { + throw new RuntimeException("Initializion of remote driver failed"); } - - return new FirefoxDriver(); } } diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java index 0a4c1adb3..deec6c0e2 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java @@ -29,13 +29,18 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.ie.InternetExplorerDriver; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.safari.SafariDriver; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; import java.util.Properties; import java.util.concurrent.TimeUnit; + import org.apache.commons.io.FileUtils; import org.fluentlenium.core.Fluent; import org.junit.Before; @@ -44,86 +49,86 @@ import org.junit.Before; * @author Olivier Lamy */ public class WebDriverTest - extends FluentTest -{ + extends FluentTest { @Override - public Fluent takeScreenShot( String fileName ) - { - try - { + public Fluent takeScreenShot(String fileName) { + try { // save html to have a minimum feedback if jenkins firefox not up - File fileNameHTML = new File( fileName + ".html" ); - FileUtils.writeStringToFile( fileNameHTML, getDriver().getPageSource() ); - } - catch ( IOException e ) - { - System.out.print( e.getMessage() ); + File fileNameHTML = new File(fileName + ".html"); + FileUtils.writeStringToFile(fileNameHTML, getDriver().getPageSource()); + } catch (IOException e) { + System.out.print(e.getMessage()); e.printStackTrace(); } - return super.takeScreenShot( fileName ); + return super.takeScreenShot(fileName); } - + @Before - public void init() - { - setSnapshotMode( Mode.TAKE_SNAPSHOT_ON_FAIL ); - setSnapshotPath( new File( "target", "errorshtmlsnap" ).getAbsolutePath() ); + public void init() { + setSnapshotMode(Mode.TAKE_SNAPSHOT_ON_FAIL); + setSnapshotPath(new File("target", "errorshtmlsnap").getAbsolutePath()); } - + @Test public void simpletest() - throws Exception - { - + throws Exception { + Properties tomcatPortProperties = new Properties(); tomcatPortProperties.load( - new FileInputStream( new File( System.getProperty( "tomcat.propertiesPortFilePath" ) ) ) ); + new FileInputStream(new File(System.getProperty("tomcat.propertiesPortFilePath")))); + + int tomcatPort = Integer.parseInt(tomcatPortProperties.getProperty("tomcat.maven.http.port")); - int tomcatPort = Integer.parseInt( tomcatPortProperties.getProperty( "tomcat.maven.http.port" ) ); + goTo("http://localhost:" + tomcatPort + "/archiva/index.html?request_lang=en"); - goTo( "http://localhost:" + tomcatPort + "/archiva/index.html?request_lang=en" ); - // wait until topbar-menu-container is feeded await().atMost(5, TimeUnit.SECONDS).until("#topbar-menu").isPresent(); - - FluentList<FluentWebElement> elements = find( "#create-admin-link-a" ); - if ( !elements.isEmpty() && elements.get( 0 ).isDisplayed() ) - { - WebElement webElement = elements.get( 0 ).getElement(); - Assert.assertEquals( "Create Admin User", webElement.getText() ); - } - else - { - elements = find( "#login-link-a" ); - WebElement webElement = elements.get( 0 ).getElement(); - Assert.assertEquals( "LOGIN", webElement.getText() ); + FluentList<FluentWebElement> elements = find("#create-admin-link-a"); + + if (!elements.isEmpty() && elements.get(0).isDisplayed()) { + WebElement webElement = elements.get(0).getElement(); + Assert.assertEquals("Create Admin User", webElement.getText()); + } else { + elements = find("#login-link-a"); + WebElement webElement = elements.get(0).getElement(); + Assert.assertEquals("LOGIN", webElement.getText()); } } @Override - public WebDriver getDefaultDriver() - { - String seleniumBrowser = System.getProperty( "selenium.browser" ); + public WebDriver getDefaultDriver() { + String seleniumBrowser = System.getProperty("selenium.browser"); + String seleniumHost = System.getProperty("seleniumHost", "localhost"); + int seleniumPort = Integer.getInteger("seleniumPort", 4444); + try { - if ( StringUtils.contains( seleniumBrowser, "chrome" ) ) - { - return new ChromeDriver(); - } + if (StringUtils.contains(seleniumBrowser, "chrome")) { + return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), + DesiredCapabilities.chrome() + ); + } - if ( StringUtils.contains( seleniumBrowser, "safari" ) ) - { - return new SafariDriver(); - } + if (StringUtils.contains(seleniumBrowser, "safari")) { + return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), + DesiredCapabilities.safari() + ); + } - if ( StringUtils.contains( seleniumBrowser, "iexplore" ) ) - { - return new InternetExplorerDriver(); - } + if (StringUtils.contains(seleniumBrowser, "iexplore")) { + return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), + DesiredCapabilities.internetExplorer() + ); + } - return new FirefoxDriver(); + return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), + DesiredCapabilities.firefox() + ); + } catch (MalformedURLException e) { + throw new RuntimeException("Initializion of remote driver failed"); + } } } diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml index 734a59768..9dc3eb80c 100644 --- a/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-web</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-webapp</artifactId> <packaging>war</packaging> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml index e1ac74b03..72d2debd4 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml @@ -51,7 +51,7 @@ </init-param> <init-param> <param-name>forceEncoding</param-name> - <param-value>true</param-value> + <param-value>false</param-value> </init-param> </filter> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/admin/repository/maven2/repositories.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/admin/repository/maven2/repositories.js index 3a6cb5ff3..abfb373b3 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/admin/repository/maven2/repositories.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/admin/repository/maven2/repositories.js @@ -692,7 +692,7 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) { RemoteRepository=function(id,name,layout,indexDirectory,url,userName,password,timeout,downloadRemoteIndex,remoteIndexUrl, remoteDownloadNetworkProxyId,cronExpression,remoteDownloadTimeout,downloadRemoteIndexOnStartup, - description,extraParametersEntries,extraHeadersEntries){ + description,extraParametersEntries,extraHeadersEntries,checkPath){ var self=this; @@ -774,6 +774,9 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) { self.modified(true); }); + this.checkPath=ko.observable(checkPath); + this.checkPath.subscribe(function(newValue){self.modified(true)}); + this.modified=ko.observable(false); } @@ -799,7 +802,7 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) { return new RemoteRepository(data.id,data.name,data.layout,data.indexDirectory,data.url,data.userName,data.password, data.timeout,data.downloadRemoteIndex,data.remoteIndexUrl,data.remoteDownloadNetworkProxyId, data.cronExpression,data.remoteDownloadTimeout,data.downloadRemoteIndexOnStartup,data.description, - extraParametersEntries,extraHeadersEntries); + extraParametersEntries,extraHeadersEntries,data.checkPath); } mapRemoteRepositories=function(data){ diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/main.js index 1d7dc714d..4a72ce817 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/main.js @@ -37,7 +37,7 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa var kUser = new User(user.username, user.password, user.confirmPassword,user.fullName,user.email,user.permanent,user.validated, user.timestampAccountCreation,user.timestampLastLogin,user.timestampLastPasswordChange,user.locked, - user.passwordChangeRequired,null,user.readOnly,user.userManagerId); + user.passwordChangeRequired,null,user.readOnly,user.userManagerId, user.validationToken); kUser.rememberme(user.rememberme()); var userJson=ko.toJSON(kUser); @@ -73,7 +73,7 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa } var kUser = new User(user.username, user.password, user.confirmPassword,user.fullName,user.email,user.permanent,user.validated, user.timestampAccountCreation,user.timestampLastLogin,user.timestampLastPasswordChange,user.locked, - user.passwordChangeRequired,null,user.readOnly,user.userManagerId); + user.passwordChangeRequired,null,user.readOnly,user.userManagerId, user.validationToken); $.log("user.rememberme:"+user.rememberme); @@ -861,6 +861,21 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa return $.inArray(karmaName,window.redbackModel.operatioNames)>=0; }; + addValidationTokenHeader=function(user) { + if(user) { + if (user.validationToken) { + $.log("Adding validation token "+user.validationToken); + $.ajaxSetup({ + beforeSend: function (xhr) { + xhr.setRequestHeader('X-XSRF-TOKEN', user.validationToken); + } + }); + } else { + $.log("No validation token in user object "+user.username+", "+user.validationToken); + } + } + }; + startArchivaApplication=function(){ $.log("startArchivaApplication"); @@ -897,6 +912,9 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa window.redbackModel.password=user.password(); loginCall(user.username(),user.password(),user.rememberme() ,successLoginCallbackFn,errorLoginCallbackFn,completeLoginCallbackFn); + } else { + // Token for origin validation + addValidationTokenHeader(user); } }; @@ -919,6 +937,7 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa } if (logged == true) { var user = mapUser(result); + addValidationTokenHeader(user); if (user.passwordChangeRequired()==true){ changePasswordBox(true,false,user); @@ -949,6 +968,8 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa } clearForm("#user-login-form"); decorateMenuWithKarma(user); + + // Token for origin validation $("#login-welcome" ).show(); $("#welcome-label" ).html( $.i18n.prop("user.login.welcome",user.username())); return; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/user.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/user.js index 758a56a94..4a8f0ccdc 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/user.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/user.js @@ -36,9 +36,11 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) { * @param ownerViewModel * @param readOnly * @param uuserManagerId + * @param validationToken */ User=function(username, password, confirmPassword,fullName,email,permanent,validated,timestampAccountCreation, - timestampLastLogin,timestampLastPasswordChange,locked,passwordChangeRequired,ownerViewModel,readOnly,userManagerId) { + timestampLastLogin,timestampLastPasswordChange,locked,passwordChangeRequired,ownerViewModel,readOnly, + userManagerId,validationToken) { var self=this; // Potentially Editable Field. this.username = ko.observable(username); @@ -84,6 +86,8 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) { this.rememberme=ko.observable(false); + this.validationToken=validationToken; + this.logged=false; this.remove = function() { @@ -145,17 +149,20 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) { var created = result; if (created == true) { displaySuccessMessage( $.i18n.prop("user.admin.created")); - var onSuccessCall=function(){ + var onSuccessCall=function(result){ + var logUser = mapUser(result); + currentAdminUser.validationToken=logUser.validationToken; reccordLoginCookie(currentAdminUser); + addValidationTokenHeader(currentAdminUser); window.archivaModel.adminExists=true; screenChange(); checkCreateAdminLink(); checkSecurityLinks(); + if(succesCallbackFn){ + succesCallbackFn(); + } } loginCall(currentAdminUser.username(), currentAdminUser.password(),false,onSuccessCall); - if(succesCallbackFn){ - succesCallbackFn(); - } return this; } else { displayErrorMessage("admin user not created"); @@ -318,6 +325,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) { } }); + $("#username").prop('disabled',true); // desactivate roles pill when adding user $("#edit_user_details_pills_headers").hide(); @@ -757,7 +765,8 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) { mapUser=function(data) { return new User(data.username, data.password, null,data.fullName,data.email,data.permanent,data.validated, data.timestampAccountCreation,data.timestampLastLogin,data.timestampLastPasswordChange, - data.locked,data.passwordChangeRequired,self,data.readOnly,data.userManagerId); + data.locked,data.passwordChangeRequired,self,data.readOnly,data.userManagerId, + data.validationToken); } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/repositories.html b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/repositories.html index 3d16cf84f..c23158e95 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/repositories.html +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/repositories.html @@ -733,6 +733,20 @@ </div> </div> + <div class="control-group"> + <label class="control-label" for="checkPath">${$.i18n.prop('remoteRepository.checkPath')}</label> + + <div class="controls"> + <input type="text" class="input-xxlarge" id="checkPath" name="checkPath" + data-bind="value: remoteRepository.checkPath"/> + <a class="btn btn-warning btn-mini popover-doc" id="remoteRepository-checkPath-info-button" + data-original-title="${$.i18n.prop('remoteRepository.checkPath.help.title')}" + data-content="${$.i18n.prop('remoteRepository.checkPath.help.content')}"> + <i class="icon-question-sign icon-white"></i> + </a> + </div> + </div> + <div class="row-fluid"> <div class="control-group span6"> <strong>${$.i18n.prop('remoteRepository.extraParametersEntries')}</strong> diff --git a/archiva-modules/archiva-web/archiva-webdav/pom.xml b/archiva-modules/archiva-web/archiva-webdav/pom.xml index ec877a212..fdf11ddf0 100644 --- a/archiva-modules/archiva-web/archiva-webdav/pom.xml +++ b/archiva-modules/archiva-web/archiva-webdav/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-web</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-webdav</artifactId> @@ -165,6 +165,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>javax.mail</groupId> + <artifactId>mail</artifactId> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> <scope>test</scope> diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java index 0c0a7183c..42146c031 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java @@ -28,7 +28,9 @@ import org.apache.archiva.policies.ChecksumPolicy; import org.apache.archiva.policies.ReleasesPolicy; import org.apache.archiva.policies.SnapshotsPolicy; import org.apache.commons.io.FileUtils; +import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.servlet.DefaultServlet; import org.eclipse.jetty.servlet.ServletContextHandler; @@ -137,7 +139,9 @@ public abstract class AbstractRepositoryServletProxiedTestCase repo.root.mkdirs(); } - repo.server = new Server( 0 ); + repo.server = new Server( ); + ServerConnector serverConnector = new ServerConnector( repo.server, new HttpConnectionFactory()); + repo.server.addConnector( serverConnector ); ContextHandlerCollection contexts = new ContextHandlerCollection(); repo.server.setHandler( contexts ); @@ -154,7 +158,7 @@ public abstract class AbstractRepositoryServletProxiedTestCase repo.server.start(); - int port = repo.server.getConnectors()[0].getLocalPort(); + int port = serverConnector.getLocalPort(); repo.url = "http://localhost:" + port + repo.context; log.info( "Remote HTTP Server started on {}", repo.url ); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavSessionProviderTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavSessionProviderTest.java index b657c082b..30a1049d6 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavSessionProviderTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavSessionProviderTest.java @@ -20,46 +20,30 @@ package org.apache.archiva.webdav; */ import junit.framework.TestCase; +import org.apache.archiva.redback.authentication.AuthenticationDataSource; import org.apache.archiva.redback.authentication.AuthenticationException; +import org.apache.archiva.redback.authentication.AuthenticationResult; +import org.apache.archiva.redback.authorization.AuthorizationException; +import org.apache.archiva.redback.authorization.UnauthorizedException; +import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator; import org.apache.archiva.redback.policy.AccountLockedException; import org.apache.archiva.redback.policy.MustChangePasswordException; +import org.apache.archiva.redback.system.SecuritySession; import org.apache.archiva.redback.users.User; +import org.apache.archiva.security.ServletAuthenticator; +import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; import org.apache.jackrabbit.webdav.DavSessionProvider; import org.apache.jackrabbit.webdav.WebdavRequest; import org.apache.jackrabbit.webdav.WebdavRequestImpl; -import org.apache.archiva.security.ServletAuthenticator; -import org.apache.archiva.redback.authentication.AuthenticationDataSource; -import org.apache.archiva.redback.authentication.AuthenticationResult; -import org.apache.archiva.redback.authorization.AuthorizationException; -import org.apache.archiva.redback.authorization.UnauthorizedException; -import org.apache.archiva.redback.system.SecuritySession; -import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.mock.web.MockHttpServletRequest; -import javax.servlet.AsyncContext; -import javax.servlet.DispatcherType; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import javax.servlet.http.Part; -import java.io.BufferedReader; import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.security.Principal; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Locale; -import java.util.Map; -import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; @RunWith( ArchivaBlockJUnit4ClassRunner.class ) public class ArchivaDavSessionProviderTest @@ -76,7 +60,7 @@ public class ArchivaDavSessionProviderTest { super.setUp(); sessionProvider = new ArchivaDavSessionProvider( new ServletAuthenticatorMock(), new HttpAuthenticatorMock() ); - request = new WebdavRequestImpl( new HttpServletRequestMock(), null ); + request = new WebdavRequestImpl( new MockHttpServletRequest(), null ); } @Test @@ -101,11 +85,31 @@ public class ArchivaDavSessionProviderTest } @SuppressWarnings( "unchecked" ) + /* private class HttpServletRequestMock implements HttpServletRequest { @Override + public long getContentLengthLong() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + @Override + public String changeSessionId() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + @Override + public <T extends HttpUpgradeHandler> T upgrade( Class<T> handlerClass ) + throws IOException, ServletException + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + @Override public boolean authenticate( HttpServletResponse httpServletResponse ) throws IOException, ServletException { @@ -513,6 +517,7 @@ public class ArchivaDavSessionProviderTest } } + */ private class ServletAuthenticatorMock implements ServletAuthenticator { diff --git a/archiva-modules/archiva-web/pom.xml b/archiva-modules/archiva-web/pom.xml index de43f61d3..0df3ad6f2 100644 --- a/archiva-modules/archiva-web/pom.xml +++ b/archiva-modules/archiva-web/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-modules</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>archiva-web</artifactId> diff --git a/archiva-modules/metadata/metadata-model-maven2/pom.xml b/archiva-modules/metadata/metadata-model-maven2/pom.xml index 3d58d66c4..ad10ffbcb 100644 --- a/archiva-modules/metadata/metadata-model-maven2/pom.xml +++ b/archiva-modules/metadata/metadata-model-maven2/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>metadata</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>metadata-model-maven2</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/metadata/metadata-model/pom.xml b/archiva-modules/metadata/metadata-model/pom.xml index 3d528341e..3ddf05645 100644 --- a/archiva-modules/metadata/metadata-model/pom.xml +++ b/archiva-modules/metadata/metadata-model/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>metadata</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>metadata-model</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/metadata/metadata-repository-api/pom.xml b/archiva-modules/metadata/metadata-repository-api/pom.xml index 2191f0ee0..5cc507898 100644 --- a/archiva-modules/metadata/metadata-repository-api/pom.xml +++ b/archiva-modules/metadata/metadata-repository-api/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>metadata</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>metadata-repository-api</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/metadata/pom.xml b/archiva-modules/metadata/pom.xml index 9ad7b4ac4..5ce399dea 100644 --- a/archiva-modules/metadata/pom.xml +++ b/archiva-modules/metadata/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>archiva-modules</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>metadata</artifactId> <name>Archiva :: Metadata</name> diff --git a/archiva-modules/metadata/test-repository/pom.xml b/archiva-modules/metadata/test-repository/pom.xml index f002fd225..7313a1c8a 100644 --- a/archiva-modules/metadata/test-repository/pom.xml +++ b/archiva-modules/metadata/test-repository/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>metadata</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>test-repository</artifactId> <name>Archiva Metadata :: Repository for Testing</name> diff --git a/archiva-modules/plugins/audit/pom.xml b/archiva-modules/plugins/audit/pom.xml index eb048db75..cf37c0d6f 100644 --- a/archiva-modules/plugins/audit/pom.xml +++ b/archiva-modules/plugins/audit/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>plugins</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>audit</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/plugins/generic-metadata-support/pom.xml b/archiva-modules/plugins/generic-metadata-support/pom.xml index bb1abadc4..64120b412 100644 --- a/archiva-modules/plugins/generic-metadata-support/pom.xml +++ b/archiva-modules/plugins/generic-metadata-support/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>plugins</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>generic-metadata-support</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/plugins/maven2-repository/pom.xml b/archiva-modules/plugins/maven2-repository/pom.xml index c77e2ff65..4c978436b 100644 --- a/archiva-modules/plugins/maven2-repository/pom.xml +++ b/archiva-modules/plugins/maven2-repository/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>plugins</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>maven2-repository</artifactId> <packaging>bundle</packaging> @@ -304,6 +304,8 @@ <exclude>src/test/resources/m1-repo-filelist.txt</exclude> <exclude>src/test/repositories/**</exclude> <exclude>src/test/expected-poms/**</exclude> + <exclude>src/test/resources/resolver-status.properties</exclude> + <exclude>src/test/resources/test01.properties</exclude> </excludes> </configuration> </plugin> diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java index 58a4dee56..efdb46087 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java @@ -148,6 +148,9 @@ public class Maven2RepositoryStorage private static final String METADATA_FILENAME = METADATA_FILENAME_START + ".xml"; + // This array must be lexically sorted + private static final String[] IGNORED_FILES = { METADATA_FILENAME, "resolver-status.properties" }; + private static final MavenXpp3Reader MAVEN_XPP_3_READER = new MavenXpp3Reader(); @@ -615,13 +618,25 @@ public class Maven2RepositoryStorage List<ArtifactMetadata> artifacts = new ArrayList<>(); if ( files != null ) { + int errorCount=0; for ( File file : files ) { - ArtifactMetadata metadata = - getArtifactFromFile( readMetadataRequest.getRepositoryId(), readMetadataRequest.getNamespace(), - readMetadataRequest.getProjectId(), readMetadataRequest.getProjectVersion(), - file ); - artifacts.add( metadata ); + try { + ArtifactMetadata metadata = + getArtifactFromFile(readMetadataRequest.getRepositoryId(), readMetadataRequest.getNamespace(), + readMetadataRequest.getProjectId(), readMetadataRequest.getProjectVersion(), + file); + artifacts.add(metadata); + } catch (Exception ex) { + LOGGER.error("Error while retrieving metadata of file {} (Project: {}, Repository: {}): {}", + file.getName(), readMetadataRequest.getProjectId(), readMetadataRequest.getRepositoryId(), + ex.getMessage()); + errorCount++; + } + } + // We throw only an error, if the number of errors equals the number of files + if (errorCount>0 && errorCount==files.length) { + throw new RepositoryStorageRuntimeException(readMetadataRequest.getRepositoryId(), "Could not retrieve metadata of the files"); } } return artifacts; @@ -1016,7 +1031,7 @@ public class Maven2RepositoryStorage { return false; } - else if ( name.equals( METADATA_FILENAME ) ) + else if ( Arrays.binarySearch(IGNORED_FILES, name)>=0 ) { return false; } diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java index 0cb92646a..b84a859b9 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java @@ -413,15 +413,30 @@ public class RepositoryModelResolver return connected; } - private File transferChecksum( Wagon wagon, RemoteRepository remoteRepository, String remotePath, File resource, - File tmpDirectory, String ext ) + /** + * + * @param wagon The wagon instance that should be connected. + * @param remoteRepository The repository from where the checksum file should be retrieved + * @param remotePath The remote path of the artifact (without extension) + * @param resource The local artifact (without extension) + * @param workingDir The working directory where the downloaded file should be placed to + * @param ext The extension of th checksum file + * @return The file where the data has been downloaded to. + * @throws AuthorizationException + * @throws TransferFailedException + * @throws ResourceDoesNotExistException + */ + private File transferChecksum( final Wagon wagon, final RemoteRepository remoteRepository, + final String remotePath, final File resource, + final File workingDir, final String ext ) throws AuthorizationException, TransferFailedException, ResourceDoesNotExistException { - File destFile = new File( tmpDirectory, resource.getName() + ext ); + File destFile = new File( workingDir, resource.getName() + ext ); + String remoteChecksumPath = remotePath + ext; - log.info( "Retrieving {} from {}", remotePath, remoteRepository.getName() ); + log.info( "Retrieving {} from {}", remoteChecksumPath, remoteRepository.getName() ); - wagon.get( addParameters( remotePath, remoteRepository ), destFile ); + wagon.get( addParameters( remoteChecksumPath, remoteRepository ), destFile ); log.debug( "Downloaded successfully." ); diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java index c277434d8..93f6bc7fb 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java @@ -101,11 +101,14 @@ public class DependencyTreeBuilderTestMaven3 builder.buildDependencyTree( Collections.singletonList( TEST_REPO_ID ), TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION ); - assertThat( treeEntries ).isNotNull().isNotEmpty().contains( - new TreeEntry( new Artifact( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION, "", "" ) ) ); + Artifact artifact = new Artifact( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION, "", "" ); + artifact.setFileExtension("jar"); + assertThat( treeEntries ).isNotNull().isNotEmpty().contains(new TreeEntry(artifact) ); + artifact = new Artifact( "commons-lang", "commons-lang", "2.2", "compile", "" ); + artifact.setFileExtension("jar"); assertThat( treeEntries.get( 0 ).getChilds() ).isNotNull().isNotEmpty().contains( - new TreeEntry( new Artifact( "commons-lang", "commons-lang", "2.2", "compile", "" ) ) ); + new TreeEntry(artifact) ); } diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java index 3f3b8e2dc..24e9b2609 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java @@ -52,6 +52,12 @@ import javax.inject.Inject; import javax.inject.Named; import java.io.File; import java.io.IOException; +import java.net.URL; +import java.nio.file.CopyOption; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -324,6 +330,90 @@ public class Maven2RepositoryMetadataResolverTest assertEquals( "pom", facet.getType() ); } + @Test + public void testGetArtifactMetadataSnapshotsMRM1859() + throws Exception + { + Path repoDir = Paths.get("target/test-repository/com/example/test/test-artifact/1.0-SNAPSHOT"); + URL url = Thread.currentThread().getContextClassLoader().getResource("resolver-status.properties"); + Path resFile = Paths.get(url.toURI()); + Path destFile = repoDir.resolve(resFile.getFileName()); + Files.copy(resFile, destFile, StandardCopyOption.REPLACE_EXISTING); + URL url2 = Thread.currentThread().getContextClassLoader().getResource("test01.properties"); + Path resFile2 = Paths.get(url2.toURI()); + Path destFile2 = repoDir.resolve(resFile2.getFileName()); + Files.copy(resFile2, destFile2, StandardCopyOption.REPLACE_EXISTING); + + try { + + + Collection<ArtifactMetadata> testArtifacts = storage.readArtifactsMetadata( + new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "test-artifact", "1.0-SNAPSHOT", ALL)); + List<ArtifactMetadata> artifacts = new ArrayList<>(testArtifacts); + Collections.sort(artifacts, new Comparator<ArtifactMetadata>() { + @Override + public int compare(ArtifactMetadata o1, ArtifactMetadata o2) { + return o1.getId().compareTo(o2.getId()); + } + }); + + assertEquals(6, artifacts.size()); + + ArtifactMetadata artifactMetadata = artifacts.get(0); + assertEquals("test-artifact-1.0-20100308.230825-1.jar", artifactMetadata.getId()); + MavenArtifactFacet facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID); + assertEquals(1, facet.getBuildNumber()); + assertEquals("20100308.230825", facet.getTimestamp()); + assertNull(facet.getClassifier()); + assertEquals("jar", facet.getType()); + + artifactMetadata = artifacts.get(1); + assertEquals("test-artifact-1.0-20100308.230825-1.pom", artifactMetadata.getId()); + facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID); + assertEquals(1, facet.getBuildNumber()); + assertEquals("20100308.230825", facet.getTimestamp()); + assertNull(facet.getClassifier()); + assertEquals("pom", facet.getType()); + + artifactMetadata = artifacts.get(2); + assertEquals("test-artifact-1.0-20100310.014828-2-javadoc.jar", artifactMetadata.getId()); + facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID); + assertEquals(2, facet.getBuildNumber()); + assertEquals("20100310.014828", facet.getTimestamp()); + assertEquals("javadoc", facet.getClassifier()); + assertEquals("javadoc", facet.getType()); + + artifactMetadata = artifacts.get(3); + assertEquals("test-artifact-1.0-20100310.014828-2-sources.jar", artifactMetadata.getId()); + facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID); + assertEquals(2, facet.getBuildNumber()); + assertEquals("20100310.014828", facet.getTimestamp()); + assertEquals("sources", facet.getClassifier()); + assertEquals("java-source", facet.getType()); + + artifactMetadata = artifacts.get(4); + assertEquals("test-artifact-1.0-20100310.014828-2.jar", artifactMetadata.getId()); + facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID); + assertEquals(2, facet.getBuildNumber()); + assertEquals("20100310.014828", facet.getTimestamp()); + assertNull(facet.getClassifier()); + assertEquals("jar", facet.getType()); + + artifactMetadata = artifacts.get(5); + assertEquals("test-artifact-1.0-20100310.014828-2.pom", artifactMetadata.getId()); + facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID); + assertEquals(2, facet.getBuildNumber()); + assertEquals("20100310.014828", facet.getTimestamp()); + assertNull(facet.getClassifier()); + assertEquals("pom", facet.getType()); + + } finally { + Files.delete(destFile); + Files.delete(destFile2); + } + + } + private void assertDependency( Dependency dependency, String groupId, String artifactId, String version ) { assertDependency( dependency, groupId, artifactId, version, "compile" ); diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-module-a/1.0/test-artifact-module-a-1.0.pom.md5 b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-module-a/1.0/test-artifact-module-a-1.0.pom.md5 new file mode 100644 index 000000000..40dc44a73 --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-module-a/1.0/test-artifact-module-a-1.0.pom.md5 @@ -0,0 +1 @@ +61a4d030260fc6bee0681cf99ba54674 test-artifact-module-a-1.0.pom diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-module-a/1.0/test-artifact-module-a-1.0.pom.sha1 b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-module-a/1.0/test-artifact-module-a-1.0.pom.sha1 new file mode 100644 index 000000000..59d811196 --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-module-a/1.0/test-artifact-module-a-1.0.pom.sha1 @@ -0,0 +1 @@ +6f54bc4223bc39d7880420f66baa3a24d7f9c181 test-artifact-module-a-1.0.pom diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-module-b/1.0/test-artifact-module-b-1.0.pom.md5 b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-module-b/1.0/test-artifact-module-b-1.0.pom.md5 new file mode 100644 index 000000000..c087db3b9 --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-module-b/1.0/test-artifact-module-b-1.0.pom.md5 @@ -0,0 +1 @@ +daa5fa59239b1a81d7c04aea1c235aad test-artifact-module-b-1.0.pom diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-module-b/1.0/test-artifact-module-b-1.0.pom.sha1 b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-module-b/1.0/test-artifact-module-b-1.0.pom.sha1 new file mode 100644 index 000000000..3315ef896 --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-module-b/1.0/test-artifact-module-b-1.0.pom.sha1 @@ -0,0 +1 @@ +3d0a66ad4f202b823feb367c46c7574cbb0301c8 test-artifact-module-b-1.0.pom diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-parent/1/test-artifact-parent-1.pom.md5 b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-parent/1/test-artifact-parent-1.pom.md5 new file mode 100644 index 000000000..98587da1d --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-parent/1/test-artifact-parent-1.pom.md5 @@ -0,0 +1 @@ +92c60efe85e23fe5afd8a854cea87209 test-artifact-parent-1.pom diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-parent/1/test-artifact-parent-1.pom.sha1 b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-parent/1/test-artifact-parent-1.pom.sha1 new file mode 100644 index 000000000..a0bcb35bd --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-parent/1/test-artifact-parent-1.pom.sha1 @@ -0,0 +1 @@ +6eca3509acf66023c29e2bc17f73e79d1d1a341a test-artifact-parent-1.pom diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-root/1.0/test-artifact-root-1.0.pom.md5 b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-root/1.0/test-artifact-root-1.0.pom.md5 new file mode 100644 index 000000000..8870d46d1 --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-root/1.0/test-artifact-root-1.0.pom.md5 @@ -0,0 +1 @@ +034449f8696981edce2485b841a02a47 test-artifact-root-1.0.pom diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-root/1.0/test-artifact-root-1.0.pom.sha1 b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-root/1.0/test-artifact-root-1.0.pom.sha1 new file mode 100644 index 000000000..eba419703 --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-artifact-root/1.0/test-artifact-root-1.0.pom.sha1 @@ -0,0 +1 @@ +bef26aec1a0714cec7fa56cdbb7ebcdb452295eb test-artifact-root-1.0.pom diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-snapshot-artifact-module-a/1.1-SNAPSHOT/test-snapshot-artifact-module-a-1.1-SNAPSHOT.pom.md5 b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-snapshot-artifact-module-a/1.1-SNAPSHOT/test-snapshot-artifact-module-a-1.1-SNAPSHOT.pom.md5 new file mode 100644 index 000000000..a36564b4f --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-snapshot-artifact-module-a/1.1-SNAPSHOT/test-snapshot-artifact-module-a-1.1-SNAPSHOT.pom.md5 @@ -0,0 +1 @@ +3b689a3c3cacecdf4371c342606211f1 test-snapshot-artifact-module-a-1.1-SNAPSHOT.pom diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-snapshot-artifact-module-a/1.1-SNAPSHOT/test-snapshot-artifact-module-a-1.1-SNAPSHOT.pom.sha1 b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-snapshot-artifact-module-a/1.1-SNAPSHOT/test-snapshot-artifact-module-a-1.1-SNAPSHOT.pom.sha1 new file mode 100644 index 000000000..e9d1ab6f9 --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-snapshot-artifact-module-a/1.1-SNAPSHOT/test-snapshot-artifact-module-a-1.1-SNAPSHOT.pom.sha1 @@ -0,0 +1 @@ +b401e87baeeb0174efd85eaf327d9c98efe79cf1 test-snapshot-artifact-module-a-1.1-SNAPSHOT.pom diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-snapshot-artifact-root/1.1-SNAPSHOT/test-snapshot-artifact-root-1.1-20100310.014828-2.pom.md5 b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-snapshot-artifact-root/1.1-SNAPSHOT/test-snapshot-artifact-root-1.1-20100310.014828-2.pom.md5 new file mode 100644 index 000000000..278e71bca --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-snapshot-artifact-root/1.1-SNAPSHOT/test-snapshot-artifact-root-1.1-20100310.014828-2.pom.md5 @@ -0,0 +1 @@ +0c304367d7a99291eb8292b1fe7114a2 test-snapshot-artifact-root-1.1-20100310.014828-2.pom diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-snapshot-artifact-root/1.1-SNAPSHOT/test-snapshot-artifact-root-1.1-20100310.014828-2.pom.sha1 b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-snapshot-artifact-root/1.1-SNAPSHOT/test-snapshot-artifact-root-1.1-20100310.014828-2.pom.sha1 new file mode 100644 index 000000000..3fe44e181 --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/com/example/test/test-snapshot-artifact-root/1.1-SNAPSHOT/test-snapshot-artifact-root-1.1-20100310.014828-2.pom.sha1 @@ -0,0 +1 @@ +e5e6ca9ae3628ae474c155619467848dc900b8cf test-snapshot-artifact-root-1.1-20100310.014828-2.pom diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/resolver-status.properties b/archiva-modules/plugins/maven2-repository/src/test/resources/resolver-status.properties new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/resolver-status.properties diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/test01.properties b/archiva-modules/plugins/maven2-repository/src/test/resources/test01.properties new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/test01.properties diff --git a/archiva-modules/plugins/metadata-store-cassandra/pom.xml b/archiva-modules/plugins/metadata-store-cassandra/pom.xml index 451686d29..3e32549d1 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/pom.xml +++ b/archiva-modules/plugins/metadata-store-cassandra/pom.xml @@ -23,7 +23,7 @@ <parent> <artifactId>plugins</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>metadata-store-cassandra</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/plugins/metadata-store-file/pom.xml b/archiva-modules/plugins/metadata-store-file/pom.xml index c68a0ed6a..2fcf7eb41 100644 --- a/archiva-modules/plugins/metadata-store-file/pom.xml +++ b/archiva-modules/plugins/metadata-store-file/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>plugins</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>metadata-store-file</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/plugins/metadata-store-jcr/pom.xml b/archiva-modules/plugins/metadata-store-jcr/pom.xml index 4b5aa528d..8fa30860c 100644 --- a/archiva-modules/plugins/metadata-store-jcr/pom.xml +++ b/archiva-modules/plugins/metadata-store-jcr/pom.xml @@ -23,7 +23,7 @@ <parent> <artifactId>plugins</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>metadata-store-jcr</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/plugins/pom.xml b/archiva-modules/plugins/pom.xml index 84da29235..039d7e14c 100644 --- a/archiva-modules/plugins/pom.xml +++ b/archiva-modules/plugins/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>archiva-modules</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>plugins</artifactId> <name>Archiva :: Core Plugins</name> diff --git a/archiva-modules/plugins/problem-reports/pom.xml b/archiva-modules/plugins/problem-reports/pom.xml index f93da1991..20db52b92 100644 --- a/archiva-modules/plugins/problem-reports/pom.xml +++ b/archiva-modules/plugins/problem-reports/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>plugins</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>problem-reports</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/plugins/repository-statistics/pom.xml b/archiva-modules/plugins/repository-statistics/pom.xml index 2513d4b28..2d20acacb 100644 --- a/archiva-modules/plugins/repository-statistics/pom.xml +++ b/archiva-modules/plugins/repository-statistics/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>plugins</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>repository-statistics</artifactId> <packaging>bundle</packaging> diff --git a/archiva-modules/plugins/stage-repository-merge/pom.xml b/archiva-modules/plugins/stage-repository-merge/pom.xml index a050b363c..d425434e0 100644 --- a/archiva-modules/plugins/stage-repository-merge/pom.xml +++ b/archiva-modules/plugins/stage-repository-merge/pom.xml @@ -22,7 +22,7 @@ <parent> <artifactId>plugins</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <groupId>org.apache.archiva</groupId> <artifactId>stage-repository-merge</artifactId> diff --git a/archiva-modules/plugins/stage-repository-merge/src/test/resources/log4j2-test.xml b/archiva-modules/plugins/stage-repository-merge/src/test/resources/log4j2-test.xml index 1ce090b03..84243affe 100644 --- a/archiva-modules/plugins/stage-repository-merge/src/test/resources/log4j2-test.xml +++ b/archiva-modules/plugins/stage-repository-merge/src/test/resources/log4j2-test.xml @@ -19,7 +19,7 @@ --> -<configuration status="debug"> +<configuration> <appenders> <Console name="console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> @@ -31,7 +31,6 @@ <logger name="org.springframework" level="error"/> - <root level="info"> <appender-ref ref="console"/> </root> diff --git a/archiva-modules/pom.xml b/archiva-modules/pom.xml index 656d1856e..ad65c36f9 100644 --- a/archiva-modules/pom.xml +++ b/archiva-modules/pom.xml @@ -21,7 +21,7 @@ <parent> <artifactId>archiva</artifactId> <groupId>org.apache.archiva</groupId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>archiva-modules</artifactId> @@ -98,7 +98,7 @@ <inherited>false</inherited> <configuration> <notimestamp>true</notimestamp> - <source>1.5</source> + <source>1.7</source> <links> <link>http://java.sun.com/j2se/1.5.0/docs/api</link> <link>http://commons.apache.org/collections/apidocs-COLLECTIONS_3_0/</link> @@ -19,18 +19,15 @@ --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> - <prerequisites> - <maven>3.0.5</maven> - </prerequisites> <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-parent</artifactId> - <version>17-SNAPSHOT</version> + <version>19-SNAPSHOT</version> </parent> <artifactId>archiva</artifactId> - <version>2.2.2-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> <packaging>pom</packaging> <name>Apache Archiva</name> @@ -64,14 +61,14 @@ <maven-model-converter.version>2.1</maven-model-converter.version> <maven.indexer.version>5.1.1</maven.indexer.version> <wagon.version>2.9</wagon.version> - <redback.version>2.5-SNAPSHOT</redback.version> + <redback.version>2.7-SNAPSHOT</redback.version> <redback.cache.version>2.2</redback.cache.version> <redback.quartz.version>2.1</redback.quartz.version> <redback.registry.version>2.4</redback.registry.version> <redback.spring-utils.version>2.1</redback.spring-utils.version> <redback.taskqueue.version>2.1</redback.taskqueue.version> - <slf4j.version>1.7.12</slf4j.version> - <log4j.version>2.5</log4j.version> + <slf4j.version>1.7.25</slf4j.version> + <log4j.version>2.8.2</log4j.version> <spring.version>4.2.1.RELEASE</spring.version> @@ -89,7 +86,7 @@ <httpclient.version>4.5.2</httpclient.version> <httpclient.core.version>4.4.4</httpclient.core.version> <javaxMailVersion>1.4</javaxMailVersion> - <jettyVersion>8.1.14.v20131031</jettyVersion> + <jettyVersion>9.4.5.v20170502</jettyVersion> <guava.version>16.0.1</guava.version> <openjpaVersion>2.4.1</openjpaVersion> @@ -1217,13 +1214,8 @@ </dependency> <dependency> <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>2.5</version> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> - <version>3.0.1</version> + <version>3.1.0</version> </dependency> <dependency> <groupId>org.slf4j</groupId> @@ -1812,7 +1804,7 @@ <autoVersionSubmodules>true</autoVersionSubmodules> <goals>deploy</goals> <preparationGoals>${release.preparationGoals}</preparationGoals> - <arguments>-Prelease</arguments> + <arguments>-Prelease -DretryFailedDeploymentCount=5</arguments> </configuration> </plugin> <plugin> @@ -1856,6 +1848,7 @@ <exclude>nb-configuration.xml</exclude> <exclude>.travis.yml</exclude> <exclude>out/**</exclude> + <exclude>Jenkinsfile</exclude> </excludes> </configuration> </plugin> @@ -1950,7 +1943,7 @@ <artifactId>modernizer-maven-plugin</artifactId> <version>1.1.0</version> <configuration> - <javaVersion>1.7</javaVersion> + <javaVersion>1.8</javaVersion> </configuration> <executions> <execution> diff --git a/src/ci/docker/webtest/Dockerfile b/src/ci/docker/webtest/Dockerfile new file mode 100644 index 000000000..b4c416f40 --- /dev/null +++ b/src/ci/docker/webtest/Dockerfile @@ -0,0 +1,77 @@ +# +# 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. +# +# Author: Martin Stockhammer <martin_s@apache.org> +# Date: 2017-04-16 +# +# Dockerfile for ci testing of the web modules. +# Currently only chrome browser is installed into the image. +# Uses selenium version 2.53.1 + +FROM ubuntu:yakkety +MAINTAINER Apache Archiva <dev@archiva.apache.org> + +ENV DEBIAN_FRONTEND noninteractive +ENV DEBCONF_NONINTERACTIVE_SEEN true + +ARG CHROME_VERSION=google-chrome-stable +RUN apt-get -qqy update +RUN apt-get -qqy install apt-utils >/dev/null 2>&1 +RUN apt-get -qqy install wget unzip >/dev/null +RUN apt-get -qqy upgrade +RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ + && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \ + && apt-get -qqy update \ + && apt-get -qqy install \ + $CHROME_VERSION \ + >/dev/null + + +ARG CHROME_DRIVER_VERSION=2.29 +RUN wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \ + && rm -rf /opt/selenium/chromedriver \ + && unzip /tmp/chromedriver_linux64.zip -d /opt/selenium \ + && rm /tmp/chromedriver_linux64.zip \ + && mv /opt/selenium/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \ + && chmod 755 /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \ + && ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver \ + >/dev/null + +RUN apt-get -qqy install openjdk-8-jdk xvfb dbus locales >/dev/null \ + && rm -rf /var/lib/apt/lists/* /var/cache/apt/* \ + >/dev/null + +ARG SELENIUM_VERSION=2.53.1 +RUN mkdir -p /opt/bin && wget --no-verbose -O /opt/bin/selenium-server-standalone.jar https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-$SELENIUM_VERSION.jar \ + && chmod 644 /opt/bin/selenium-server-standalone.jar + +COPY entry_point.sh /opt/bin/entry_point.sh +COPY chrome_launcher.sh /usr/bin/google-chrome +RUN chmod +x /opt/bin/entry_point.sh +RUN chmod +x /usr/bin/google-chrome + +ENV SCREEN_WIDTH 1360 +ENV SCREEN_HEIGHT 1020 +ENV SCREEN_DEPTH 24 +ENV X_START_NUM=3 + +RUN echo "DBUS_SESSION_BUS_ADDRESS=/dev/null" >> /etc/environment + +CMD ["/opt/bin/entry_point.sh"] + + diff --git a/src/ci/docker/webtest/chrome_launcher.sh b/src/ci/docker/webtest/chrome_launcher.sh new file mode 100644 index 000000000..02e3fe753 --- /dev/null +++ b/src/ci/docker/webtest/chrome_launcher.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# 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. +# +# Author: Martin Stockhammer <martin_s@apache.org> +# Date: 2017-04-16 +# +# Starts the chrome browser from the chrome installation path. +# + +export GNOME_DISABLE_CRASH_DIALOG=SET_BY_GOOGLE_CHROME +export DBUS_SESSION_BUS_ADDRESS=/dev/null + +# Make sure that the profile directory specified in the environment, if any, +# overrides the default. +if [[ -n "$CHROME_USER_DATA_DIR" ]]; then + PROFILE_DIRECTORY_FLAG="--user-data-dir=$CHROME_USER_DATA_DIR" +fi + +# Sanitize std{in,out,err} because they'll be shared with untrusted child +# processes (http://crbug.com/376567). +exec < /dev/null +exec > >(exec cat) +exec 2> >(exec cat >&2) + +exec /opt/google/chrome/chrome --no-sandbox "$@" diff --git a/src/ci/docker/webtest/entry_point.sh b/src/ci/docker/webtest/entry_point.sh new file mode 100644 index 000000000..4c6c1974a --- /dev/null +++ b/src/ci/docker/webtest/entry_point.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# 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. +# +# Author: Martin Stockhammer <martin_s@apache.org> +# Date: 2017-04-16 +# +# This is the start script for the docker image that runs the +# selenium standalone server. +# Starts a Xvfb framebuffer server for the browser display. +# Uses the automatic display number determination from the xvfb-run script. + + +# Set the number for the xserver display to start +: ${X_START_NUM:-1} + +export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH" + +function shutdown { + kill -s SIGTERM $NODE_PID + wait $NODE_PID +} + +if [ ! -z "$SE_OPTS" ]; then + echo "appending selenium options: ${SE_OPTS}" +fi + +rm -f /tmp/.X*lock + +xvfb-run -a -n $X_START_NUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \ + java ${JAVA_OPTS} -jar /opt/bin/selenium-server-standalone.jar \ + ${SE_OPTS} & +NODE_PID=$! + +trap shutdown SIGTERM SIGINT +wait $NODE_PID diff --git a/src/ci/scripts/cleanup.bat b/src/ci/scripts/cleanup.bat new file mode 100644 index 000000000..bcfdd2a2a --- /dev/null +++ b/src/ci/scripts/cleanup.bat @@ -0,0 +1,21 @@ +@echo off +REM Licensed to the Apache Software Foundation (ASF) under one +REM or more contributor license agreements. See the NOTICE file +REM distributed with this work for additional information +REM regarding copyright ownership. The ASF licenses this file +REM to you under the Apache License, Version 2.0 (the +REM "License"); you may not use this file except in compliance +REM with the License. You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, +REM software distributed under the License is distributed on an +REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +REM KIND, either express or implied. See the License for the +REM specific language governing permissions and limitations +REM under the License. + +SET runpath=%~dp0 + +PowerShell.exe -NonInteractive -ExecutionPolicy bypass -File %runpath%cleanup.ps1 %* diff --git a/src/ci/scripts/cleanup.ps1 b/src/ci/scripts/cleanup.ps1 new file mode 100644 index 000000000..fd709ed63 --- /dev/null +++ b/src/ci/scripts/cleanup.ps1 @@ -0,0 +1,96 @@ +# +# 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. +# +# +# Powershell script for cleaning up remaining browser and selenium server processes on the CI servers +# +# Author: Martin Stockhammer <martin_s@apache.org> +# Date : 2017-04-30 +# +# Descriptions: +# Stopps processes related to the selenium checks, if they were not stopped by the selenium server, because +# the job was aborted. +# The script cannot determine, which of the processes are started by the current job, so if there are +# parallel jobs running on this server that start processes with the same name and user, these +# will be stopped too. +# +# Per default the script will stop "firefox.exe","iexplore.exe","chrome.exe" +# and the processes "java.exe","mshta.exe" if their commandline arguments contain "selenium-server" +# +# Parameters: +# -Verbose : If set, more output will be printed +# -Browsers proc1,proc2 : The list of executables that define the browser processes, that are started by selenium +# -SeleniumProcesses : The list of processes with the string "selenium-server" in the commandline arguments + +param ( + [switch]$Verbose = $False, + [String[]]$Browsers = @("firefox.exe","iexplore.exe","chrome.exe"), + [String[]]$SeleniumProcesses = @("mshta.exe","java.exe") +) + +# $currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name +$currentUser = $env:UserName +Write-Output "User: $currentUser" + +if ($Verbose) +{ + Get-Process | Get-Member + + $View = @( + @{l='Handles';e={$_.HandleCount}}, + @{l='NPM(K)';e={ (Get-Process -Id $_.ProcessId).NonpagedSystemMemorySize/1KB -as [int]}}, + @{l='PM(K)';e={ $_.PrivatePageCount/1KB -as [int]}}, + @{l='WS(K)';e={ $_.WorkingSetSize/1KB -as [int]}}, + @{l='VM(M)';e={ $_.VirtualSize/1mB -as [int]}}, + @{l='CPU(s)';e={ (Get-Process -Id $_.ProcessId).CPU -as [int]}}, + @{l='Id';e={ $_.ProcessId}}, + 'UserName' + @{l='ProcessName';e={ $_.ProcessName}} + ) + Get-WmiObject Win32_Process | % { $_ | + Add-Member -MemberType ScriptProperty -Name UserName -Value { + '{0}\{1}' -f $this.GetOwner().Domain,$this.GetOwner().User + } -Force -PassThru + } +} + +foreach ($procName in $SeleniumProcesses) +{ + $processes = Get-WmiObject Win32_Process -Filter "name = '$procName'" | Where-Object {$_.GetOwner().User -eq $currentUser } | Where-Object {$_.CommandLine -match "selenium-server"} + if ($Verbose) { + Write-Output "Filter: name = '$procName'" + } + foreach($proc in $processes) + { + Write-Output "stopping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..." + Stop-Process -F $proc.ProcessId + } +} + +foreach ($procName in $Browsers) +{ + $processes = Get-WmiObject Win32_Process -Filter "name = '$procName'" | Where-Object {$_.GetOwner().User -eq $currentUser } + if ($Verbose) { + Write-Output "Filter: name = '$procName'" + } + foreach($proc in $processes) + { + Write-Output "stopping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..." + Stop-Process -F $proc.ProcessId + } +} diff --git a/src/ci/scripts/container_webtest.sh b/src/ci/scripts/container_webtest.sh new file mode 100644 index 000000000..0b73d8430 --- /dev/null +++ b/src/ci/scripts/container_webtest.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +# +# 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. +# +# Author: Martin Stockhammer <martin_s@apache.org> +# Date: 2017-04-16 +# +# Builds and runs a container +# +# Tries to find the docker configuration in ../docker/${DOCKER_CFG} +# + +# Always change the version, if your Dockerfile or scripts of the container change +CONTAINER_VERSION="1.0" +CONTAINER_NAME="archiva/selenium" +DOCKER_CFG="webtest" +INSTANCE_NAME="archiva-webtest" +PORT_MAPPING="4444:4444" +NETWORK_TYPE="host" + +HERE=`dirname $0` + +TAG="${CONTAINER_NAME}:${CONTAINER_VERSION}" + +START_ARG="$1" + +function stop_instance() { + CONT=`docker ps -q --filter=name=${INSTANCE_NAME}` + if [ "${CONT}" != "" ]; then + echo "Stopping container ${INSTANCE_NAME}" + docker stop "${INSTANCE_NAME}" + fi + # We remove the instance always + CONT=`docker ps -a -q --filter=name=${INSTANCE_NAME}` + if [ "${CONT}" != "" ]; then + echo "Removing container ${INSTANCE_NAME}" + docker rm "${INSTANCE_NAME}" + fi +} + +function start_instance() { + echo "Starting container ${INSTANCE_NAME}" + docker run -d --network="${NETWORK_TYPE}" -p "${PORT_MAPPING}" --name "${INSTANCE_NAME}" "${TAG}" +} + +function print_usage() { + echo "container_webtest start|stop" + echo "Starts or stops the container. Builds the images if necessary" +} + +if [ "${START_ARG}" == "start" ]; then + IMG=`docker images -q ${TAG}` + # Build the image, if it does not exist + if [ "${IMG}" == "" ]; then + echo "Building image ${TAG}" + DOCKER_DIR="${HERE}/../docker/${DOCKER_CFG}" + MY_PWD=`pwd` + cd ${DOCKER_DIR} || { echo "Could not change to docker directory ${DOCKER_CFG}"; exit 1; } + docker build --force-rm -t "${TAG}" . + if [ $? -ne 0 ]; then + cd ${MY_PWD} + echo "Could not build docker image" + exit 1 + fi + cd ${MY_PWD} + IMG=`docker images -q ${TAG}` + fi + # Removing old instances + stop_instance + # Starting + start_instance +elif [ "${START_ARG}" == "stop" ]; then + stop_instance +else + print_usage +fi + |