diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java index 9f76d191a..f7aaf895e 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java @@ -130,7 +130,7 @@ public abstract class AbstractRestService : redbackRequestInformation.getUser().getUsername() ); } - protected String getBaseUrl( HttpServletRequest req ) + protected String getBaseUrl() throws RepositoryAdminException { String applicationUrl = archivaAdministration.getUiConfiguration().getApplicationUrl(); @@ -138,9 +138,9 @@ public abstract class AbstractRestService { return applicationUrl; } - return req.getScheme() + "://" + req.getServerName() + ( req.getServerPort() == 80 - ? "" - : ":" + req.getServerPort() ) + req.getContextPath(); + return httpServletRequest.getScheme() + "://" + httpServletRequest.getServerName() + ( + httpServletRequest.getServerPort() == 80 ? "" : ":" + httpServletRequest.getServerPort() ) + + httpServletRequest.getContextPath(); } protected Map getBeansOfType( ApplicationContext applicationContext, Class clazz ) @@ -173,8 +173,6 @@ public abstract class AbstractRestService } /** - * TODO add a configuration mechanism to have configured the base archiva url - * * @param artifact * @return */ @@ -189,7 +187,7 @@ public abstract class AbstractRestService return null; } - StringBuilder sb = new StringBuilder( getBaseUrl( httpServletRequest ) ); + StringBuilder sb = new StringBuilder( getBaseUrl() ); sb.append( "/repository" ); diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java index 417c7b048..5072e440e 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java @@ -218,7 +218,7 @@ public class DefaultManagedRepositoriesService snippet.append( " <" ).append( distRepoName ).append( ">\n" ); snippet.append( " " ).append( repo.getId() ).append( "\n" ); snippet.append( " " ); - snippet.append( getBaseUrl( httpServletRequest ) + "/repository" ); + snippet.append( getBaseUrl( ) + "/repository" ); snippet.append( "/" ).append( repo.getId() ).append( "/" ).append( "\n" ); if ( !"default".equals( repo.getLayout() ) ) @@ -236,7 +236,7 @@ public class DefaultManagedRepositoriesService snippet.append( " " ).append( repo.getName() ).append( "\n" ); snippet.append( " " ); - snippet.append( getBaseUrl( httpServletRequest ) + "/repository" ); + snippet.append( getBaseUrl( ) + "/repository" ); snippet.append( "/" ).append( repo.getId() ).append( "/" ); snippet.append( "\n" ); @@ -262,7 +262,7 @@ public class DefaultManagedRepositoriesService snippet.append( " " ).append( repo.getName() ).append( "\n" ); snippet.append( " " ); - snippet.append( getBaseUrl( httpServletRequest ) + "/repository" ); + snippet.append( getBaseUrl( ) + "/repository" ); snippet.append( "/" ).append( repo.getId() ).append( "/" ); snippet.append( "\n" );