summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaria Odea B. Ching <oching@apache.org>2013-05-01 10:07:11 +0000
committerMaria Odea B. Ching <oching@apache.org>2013-05-01 10:07:11 +0000
commit1799c0c11ddd196c5c8ff9ab124cd094f1364f7f (patch)
tree2bf945e8e166dc0dfe677b107875788450c097be
parentbc9e7a49e641b9158f163843b6cd07884d8cfba0 (diff)
downloadarchiva-1799c0c11ddd196c5c8ff9ab124cd094f1364f7f.tar.gz
archiva-1799c0c11ddd196c5c8ff9ab124cd094f1364f7f.zip
[MRM-1757] remove trailing '/' in application url if present + unit test
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1477941 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java4
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java29
2 files changed, 33 insertions, 0 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java
index bf0bad9e9..854da3e59 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java
@@ -366,6 +366,10 @@ public class DefaultArchivaAdministrationService
{
try
{
+ // fix for MRM-1757
+ // strip any trailing '/' at the end of the url so it won't affect url/link calculations in UI
+ uiConfiguration.setApplicationUrl(StringUtils.stripEnd(uiConfiguration.getApplicationUrl(), "/"));
+
archivaAdministration.updateUiConfiguration( uiConfiguration );
}
catch ( RepositoryAdminException e )
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java
index 9c9e18653..63c5d74cb 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java
@@ -141,6 +141,35 @@ public class ArchivaAdministrationServiceTest
}
@Test
+ public void uiConfigurationUpdate_ApplicationUrlHasTrailingSlash()
+ throws Exception {
+
+ UiConfiguration ui = getArchivaAdministrationService().getUiConfiguration();
+ assertNotNull( ui );
+ assertNull( ui.getApplicationUrl() );
+
+ String url = "http://foo.fr/bar/";
+ ui.setApplicationUrl( url );
+
+ getArchivaAdministrationService().setUiConfiguration( ui );
+
+ ui = getArchivaAdministrationService().getUiConfiguration();
+
+ assertEquals( "http://foo.fr/bar", ui.getApplicationUrl() );
+
+ // test if multiple '/' is trailing
+ url = "http://foo.fr/bar//";
+
+ ui.setApplicationUrl(url);
+
+ getArchivaAdministrationService().setUiConfiguration(ui);
+
+ ui = getArchivaAdministrationService().getUiConfiguration();
+
+ assertEquals( "http://foo.fr/bar", ui.getApplicationUrl() );
+ }
+
+ @Test
public void getKnownContentAdminRepositoryConsumer()
throws Exception
{