import org.apache.archiva.admin.model.AuditInformation;
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
import org.apache.archiva.audit.AuditEvent;
// we must replace it with a valid managed one available for the user.
if ( StringUtils.isEmpty( repositoryId ) )
{
- sb.append( '/' ).append( artifact.getContext() );
+ List<String> userRepos = userRepositories.getObservableRepositoryIds( getPrincipal() );
+ // is it a good one? if yes nothing to
+ // if not search the repo who is proxy for this remote
+ if ( !userRepos.contains( artifact.getContext() ) )
+ {
+ for ( Map.Entry<String, List<ProxyConnector>> entry : proxyConnectorAdmin.getProxyConnectorAsMap().entrySet() )
+ {
+ for ( ProxyConnector proxyConnector : entry.getValue() )
+ {
+ if ( StringUtils.equals( "remote-" + proxyConnector.getTargetRepoId(),
+ artifact.getContext() ) //
+ && userRepos.contains( entry.getKey() ) )
+ {
+ sb.append( '/' ).append( entry.getKey() );
+ }
+ }
+ }
+
+ }
+
+
}
else
{
return sb.toString();
}
- catch ( RepositoryAdminException e )
+ catch ( Exception e )
{
throw new ArchivaRestServiceException( e.getMessage(),
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
new ArtifactBuilder().forArtifactMetadata( artifact ).withManagedRepositoryContent(
repositoryContentFactory.getManagedRepositoryContent( repositoryId ) );
Artifact art = builder.build();
- art.setUrl( getArtifactUrl( art ) );
+ art.setUrl( getArtifactUrl( art, repositoryId ) );
artifacts.add( art );
}
return artifacts;
* under the License.
*/
-import org.apache.archiva.admin.model.beans.ProxyConnector;
import org.apache.archiva.indexer.search.RepositorySearch;
import org.apache.archiva.indexer.search.RepositorySearchException;
import org.apache.archiva.indexer.search.SearchFields;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.Map;
/**
* @author Olivier Lamy
} ).build();
}
- String artifactUrl = null;
-
Artifact artifact = artifacts.get( 0 );
- // we need to configure correctly the repositoryId
- if ( StringUtils.isEmpty( repositoryId ) )
- {
- // is it a good one? if yes nothing to
- // if not search the repo who is proxy for this remote
- if ( !userRepos.contains( artifact.getContext() ) )
- {
- for ( Map.Entry<String, List<ProxyConnector>> entry : proxyConnectorAdmin.getProxyConnectorAsMap().entrySet() )
- {
- for ( ProxyConnector proxyConnector : entry.getValue() )
- {
- if ( StringUtils.equals( "remote-" + proxyConnector.getTargetRepoId(),
- artifact.getContext() ) //
- && userRepos.contains( entry.getKey() ) )
- {
- return Response.temporaryRedirect(
- new URI( getArtifactUrl( artifact, entry.getKey() ) ) ).build();
- }
- }
- }
-
- }
-
- }
- else
- {
- artifactUrl = getArtifactUrl( artifact, repositoryId );
- }
-
- return Response.temporaryRedirect( new URI( artifactUrl ) ).build();
+ return Response.temporaryRedirect( new URI( artifact.getUrl() ) ).build();
}
catch ( Exception e )
{