import org.springframework.stereotype.Service;
import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
/**
* @author Olivier Lamy
private ArchivaRuntimeInfo archivaRuntimeInfo;
+ @Context
+ protected HttpServletRequest httpServletRequest;
+
@Inject
public DefaultRuntimeInfoService( ArchivaRuntimeInfo archivaRuntimeInfo )
{
applicationRuntimeInfo.setBuildNumber( this.archivaRuntimeInfo.getBuildNumber() );
applicationRuntimeInfo.setTimestamp( this.archivaRuntimeInfo.getTimestamp() );
applicationRuntimeInfo.setVersion( this.archivaRuntimeInfo.getVersion() );
+ applicationRuntimeInfo.setBaseUrl( getBaseUrl( httpServletRequest ) );
return applicationRuntimeInfo;
}
+ protected String getBaseUrl( HttpServletRequest req )
+ {
+ return req.getScheme() + "://" + req.getServerName() + ( req.getServerPort() == 80
+ ? ""
+ : ":" + req.getServerPort() ) + req.getContextPath();
+ }
+
public Boolean logMissingI18n( String key )
{
i18nLogger.info( "missing i18n key : '{}'", key );
private boolean logMissingI18n;
+ private String baseUrl;
+
public ApplicationRuntimeInfo()
{
this.logMissingI18n = logMissingI18n;
}
+ public String getBaseUrl()
+ {
+ return baseUrl;
+ }
+
+ public void setBaseUrl( String baseUrl )
+ {
+ this.baseUrl = baseUrl;
+ }
+
@Override
public String toString()
{
sb.append( ", timestamp=" ).append( timestamp );
sb.append( ", copyrightRange='" ).append( copyrightRange ).append( '\'' );
sb.append( ", logMissingI18n=" ).append( logMissingI18n );
+ sb.append( ", baseUrl='" ).append( baseUrl ).append( '\'' );
sb.append( '}' );
return sb.toString();
}