diff options
author | Olivier Lamy <olamy@apache.org> | 2012-09-13 22:11:00 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-09-13 22:11:00 +0000 |
commit | bdb81fef28a65fcd8f339d7f252e77fa8a5bed4e (patch) | |
tree | b1a4c4738125b39637ffd486368a9fa9a675b84e /archiva-modules/archiva-web | |
parent | 0638fbf4b1a7bf85289ca1ad1c330ae0c7e4afe1 (diff) | |
download | archiva-bdb81fef28a65fcd8f339d7f252e77fa8a5bed4e.tar.gz archiva-bdb81fef28a65fcd8f339d7f252e77fa8a5bed4e.zip |
[MRM-1668] download artifacts when coming from search results.
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1384563 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web')
6 files changed, 204 insertions, 100 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java index d5584ff15..e381fa91b 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java @@ -19,14 +19,14 @@ package org.apache.archiva.rest.api.services; */ import org.apache.archiva.admin.model.beans.ManagedRepository; +import org.apache.archiva.maven2.model.Artifact; +import org.apache.archiva.maven2.model.TreeEntry; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.redback.authorization.RedbackAuthorization; -import org.apache.archiva.maven2.model.Artifact; import org.apache.archiva.rest.api.model.ArtifactContent; import org.apache.archiva.rest.api.model.ArtifactContentEntry; import org.apache.archiva.rest.api.model.BrowseResult; import org.apache.archiva.rest.api.model.Entry; -import org.apache.archiva.maven2.model.TreeEntry; import org.apache.archiva.rest.api.model.VersionsList; import javax.ws.rs.DELETE; @@ -43,143 +43,154 @@ import java.util.List; * @author Olivier Lamy * @since 1.4-M3 */ -@Path( "/browseService/" ) +@Path ( "/browseService/" ) public interface BrowseService { - @Path( "rootGroups" ) + @Path ( "rootGroups" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = true, noRestriction = true ) - BrowseResult getRootGroups( @QueryParam( "repositoryId" ) String repositoryId ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) + BrowseResult getRootGroups( @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; - @Path( "browseGroupId/{groupId}" ) + @Path ( "browseGroupId/{groupId}" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = true, noRestriction = true ) - BrowseResult browseGroupId( @PathParam( "groupId" ) String groupId, - @QueryParam( "repositoryId" ) String repositoryId ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) + BrowseResult browseGroupId( @PathParam ( "groupId" ) String groupId, + @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; - @Path( "versionsList/{g}/{a}" ) + @Path ( "versionsList/{g}/{a}" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = true, noRestriction = true ) - VersionsList getVersionsList( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId, - @QueryParam( "repositoryId" ) String repositoryId ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) + VersionsList getVersionsList( @PathParam ( "g" ) String groupId, @PathParam ( "a" ) String artifactId, + @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; - @Path( "projectVersionMetadata/{g}/{a}" ) + @Path ( "projectVersionMetadata/{g}/{a}" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = true, noRestriction = true ) - ProjectVersionMetadata getProjectVersionMetadata( @PathParam( "g" ) String groupId, - @PathParam( "a" ) String artifactId, - @QueryParam( "repositoryId" ) String repositoryId ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) + ProjectVersionMetadata getProjectVersionMetadata( @PathParam ( "g" ) String groupId, + @PathParam ( "a" ) String artifactId, + @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; - @Path( "projectVersionMetadata/{g}/{a}/{v}" ) + @Path ( "projectVersionMetadata/{g}/{a}/{v}" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = true, noRestriction = true ) - ProjectVersionMetadata getProjectMetadata( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId, - @PathParam( "v" ) String version, - @QueryParam( "repositoryId" ) String repositoryId ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) + ProjectVersionMetadata getProjectMetadata( @PathParam ( "g" ) String groupId, @PathParam ( "a" ) String artifactId, + @PathParam ( "v" ) String version, + @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; - @Path( "userRepositories" ) + @Path ( "userRepositories" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = true, noRestriction = true ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) /** * @return List of managed repositories current user can read */ List<ManagedRepository> getUserRepositories() throws ArchivaRestServiceException; - @Path( "treeEntries/{g}/{a}/{v}" ) + @Path ( "treeEntries/{g}/{a}/{v}" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = true, noRestriction = true ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) /** * return the dependency Tree for an artifacts * <b>the List result has only one entry</b> */ - List<TreeEntry> getTreeEntries( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId, - @PathParam( "v" ) String version, - @QueryParam( "repositoryId" ) String repositoryId ) + List<TreeEntry> getTreeEntries( @PathParam ( "g" ) String groupId, @PathParam ( "a" ) String artifactId, + @PathParam ( "v" ) String version, + @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; - @Path( "dependees/{g}/{a}/{v}" ) + @Path ( "dependees/{g}/{a}/{v}" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = true, noRestriction = true ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) /** * List of artifacts using the artifact passed in parameter. */ - List<Artifact> getDependees( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId, - @PathParam( "v" ) String version, @QueryParam( "repositoryId" ) String repositoryId ) + List<Artifact> getDependees( @PathParam ( "g" ) String groupId, @PathParam ( "a" ) String artifactId, + @PathParam ( "v" ) String version, @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; - @Path( "metadatas/{g}/{a}/{v}" ) + @Path ( "metadatas/{g}/{a}/{v}" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = true, noRestriction = true ) - List<Entry> getMetadatas( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId, - @PathParam( "v" ) String version, @QueryParam( "repositoryId" ) String repositoryId ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) + List<Entry> getMetadatas( @PathParam ( "g" ) String groupId, @PathParam ( "a" ) String artifactId, + @PathParam ( "v" ) String version, @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; - @Path( "metadata/{g}/{a}/{v}/{key}/{value}" ) + @Path ( "metadata/{g}/{a}/{v}/{key}/{value}" ) @PUT - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = false, noRestriction = false, permissions = "archiva-add-metadata" ) - Boolean addMetadata( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId, - @PathParam( "v" ) String version, @PathParam( "key" ) String key, - @PathParam( "value" ) String value, @QueryParam( "repositoryId" ) String repositoryId ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = false, noRestriction = false, permissions = "archiva-add-metadata" ) + Boolean addMetadata( @PathParam ( "g" ) String groupId, @PathParam ( "a" ) String artifactId, + @PathParam ( "v" ) String version, @PathParam ( "key" ) String key, + @PathParam ( "value" ) String value, @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; - @Path( "metadata/{g}/{a}/{v}/{key}" ) + @Path ( "metadata/{g}/{a}/{v}/{key}" ) @DELETE - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = false, noRestriction = false, permissions = "archiva-add-metadata" ) - Boolean deleteMetadata( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId, - @PathParam( "v" ) String version, @PathParam( "key" ) String key, - @QueryParam( "repositoryId" ) String repositoryId ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = false, noRestriction = false, permissions = "archiva-add-metadata" ) + Boolean deleteMetadata( @PathParam ( "g" ) String groupId, @PathParam ( "a" ) String artifactId, + @PathParam ( "v" ) String version, @PathParam ( "key" ) String key, + @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; - @Path( "artifactContentEntries/{g}/{a}/{v}" ) + @Path ( "artifactContentEntries/{g}/{a}/{v}" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = true, noRestriction = true ) - List<ArtifactContentEntry> getArtifactContentEntries( @PathParam( "g" ) String groupId, - @PathParam( "a" ) String artifactId, - @PathParam( "v" ) String version, - @QueryParam( "c" ) String classifier, - @QueryParam( "t" ) String type, - @QueryParam( "p" ) String path, - @QueryParam( "repositoryId" ) String repositoryId ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) + List<ArtifactContentEntry> getArtifactContentEntries( @PathParam ( "g" ) String groupId, + @PathParam ( "a" ) String artifactId, + @PathParam ( "v" ) String version, + @QueryParam ( "c" ) String classifier, + @QueryParam ( "t" ) String type, + @QueryParam ( "p" ) String path, + @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; - @Path( "artifactDownloadInfos/{g}/{a}/{v}" ) + @Path ( "artifactDownloadInfos/{g}/{a}/{v}" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = true, noRestriction = true ) - List<Artifact> getArtifactDownloadInfos( @PathParam( "g" ) String groupId, - @PathParam( "a" ) String artifactId, - @PathParam( "v" ) String version, - @QueryParam( "repositoryId" ) String repositoryId ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) + List<Artifact> getArtifactDownloadInfos( @PathParam ( "g" ) String groupId, @PathParam ( "a" ) String artifactId, + @PathParam ( "v" ) String version, + @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; - @Path( "artifactContentText/{g}/{a}/{v}" ) + @Path ( "artifactContentText/{g}/{a}/{v}" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) - @RedbackAuthorization( noPermission = true, noRestriction = true ) + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) /** * if path is empty content of the file is returned (for pom view) */ - ArtifactContent getArtifactContentText( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId, - @PathParam( "v" ) String version, @QueryParam( "c" ) String classifier, - @QueryParam( "t" ) String type, @QueryParam( "p" ) String path, - @QueryParam( "repositoryId" ) String repositoryId ) + ArtifactContent getArtifactContentText( @PathParam ( "g" ) String groupId, @PathParam ( "a" ) String artifactId, + @PathParam ( "v" ) String version, @QueryParam ( "c" ) String classifier, + @QueryParam ( "t" ) String type, @QueryParam ( "p" ) String path, + @QueryParam ( "repositoryId" ) String repositoryId ) + throws ArchivaRestServiceException; + + @Path ( "artifactAvailable/{g}/{a}/{v}" ) + @GET + @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization ( noPermission = true, noRestriction = true ) + /** + * verify if an artifact is available locally if not download from proxies will be try + * @since 1.4-M3 + */ + Boolean artifactAvailable( @PathParam ( "g" ) String groupId, @PathParam ( "a" ) String artifactId, + @PathParam ( "v" ) String version, @QueryParam ( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; } 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 a1a812d39..6d6df708a 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 @@ -136,6 +136,10 @@ <artifactId>archiva-rest-api</artifactId> </dependency> <dependency> + <groupId>org.apache.archiva</groupId> + <artifactId>archiva-proxy</artifactId> + </dependency> + <dependency> <groupId>org.apache.archiva.redback</groupId> <artifactId>redback-rest-services</artifactId> </dependency> 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 754b73c63..6ea8f6bf0 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 @@ -22,6 +22,7 @@ package org.apache.archiva.rest.services; 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.managed.ManagedRepositoryAdmin; import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.audit.AuditListener; import org.apache.archiva.common.utils.VersionUtil; @@ -77,6 +78,9 @@ public abstract class AbstractRestService @Inject protected ArchivaAdministration archivaAdministration; + @Inject + protected ManagedRepositoryAdmin managedRepositoryAdmin; + @Context protected HttpServletRequest httpServletRequest; 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 8fd1f0239..4ba91f52a 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 @@ -18,8 +18,10 @@ package org.apache.archiva.rest.services; * under the License. */ +import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.common.utils.VersionComparator; +import org.apache.archiva.common.utils.VersionUtil; import org.apache.archiva.dependency.tree.maven2.DependencyTreeBuilder; import org.apache.archiva.maven2.model.Artifact; import org.apache.archiva.maven2.model.TreeEntry; @@ -36,6 +38,7 @@ import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMetadataVersionComparator; import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet; import org.apache.archiva.model.ArchivaArtifact; +import org.apache.archiva.proxy.RepositoryProxyConnectors; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RepositoryContentFactory; import org.apache.archiva.repository.RepositoryException; @@ -58,6 +61,7 @@ import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; import javax.inject.Inject; +import javax.inject.Named; import javax.ws.rs.core.Response; import java.io.File; import java.io.IOException; @@ -91,6 +95,10 @@ public class DefaultBrowseService @Inject private RepositoryContentFactory repositoryContentFactory; + @Inject + @Named ( value = "repositoryProxyConnectors#default" ) + private RepositoryProxyConnectors connectors; + public BrowseResult getRootGroups( String repositoryId ) throws ArchivaRestServiceException { @@ -268,7 +276,7 @@ public class DefaultBrowseService } catch ( MetadataResolutionException e ) { - log.error( + log.warn( "Skipping invalid metadata while compiling shared model for " + groupId + ":" + artifactId + " in repo " + repoId + ": " + e.getMessage() ); } @@ -778,6 +786,70 @@ public class DefaultBrowseService return new ArtifactContent(); } + public Boolean artifactAvailable( String groupId, String artifactId, String version, String repositoryId ) + throws ArchivaRestServiceException + { + List<String> selectedRepos = getSelectedRepos( repositoryId ); + + try + { + for ( String repoId : selectedRepos ) + { + + ManagedRepository managedRepository = managedRepositoryAdmin.getManagedRepository( repoId ); + + boolean snapshot = VersionUtil.isSnapshot( version ); + + if ( ( snapshot && !managedRepository.isSnapshots() ) || ( !snapshot + && managedRepository.isSnapshots() ) ) + { + continue; + } + ManagedRepositoryContent managedRepositoryContent = + repositoryContentFactory.getManagedRepositoryContent( repoId ); + // FIXME default to jar which can be wrong for war zip etc.... + ArchivaArtifact archivaArtifact = + new ArchivaArtifact( groupId, artifactId, version, "", "jar", repoId ); + File file = managedRepositoryContent.toFile( archivaArtifact ); + + if ( file != null && file.exists() ) + { + return true; + } + + String path = managedRepositoryContent.toPath( archivaArtifact ); + + file = connectors.fetchFromProxies( managedRepositoryContent, path ); + + if ( file != null && file.exists() ) + { + // download pom now + String pomPath = StringUtils.substringBeforeLast( path, ".jar" ) + ".pom"; + connectors.fetchFromProxies( managedRepositoryContent, pomPath ); + return true; + } + } + } + catch ( RepositoryAdminException e ) + { + log.error( e.getMessage(), e ); + throw new ArchivaRestServiceException( e.getMessage(), + Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e ); + } + catch ( RepositoryException e ) + { + log.error( e.getMessage(), e ); + throw new ArchivaRestServiceException( e.getMessage(), + Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e ); + } + + return false; + } + + //--------------------------- + // internals + //--------------------------- + private void closeQuietly( JarFile jarFile ) { if ( jarFile != null ) @@ -793,10 +865,6 @@ public class DefaultBrowseService } } - //--------------------------- - // internals - //--------------------------- - protected List<ArtifactContentEntry> readFileEntries( File file, String filterPath, String repoId ) throws IOException { 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 5072e440e..e3f9716eb 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 @@ -54,9 +54,6 @@ public class DefaultManagedRepositoriesService { @Inject - private ManagedRepositoryAdmin managedRepositoryAdmin; - - @Inject private RepositoryCommonValidator repositoryCommonValidator; @Inject diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index 974141242..da249ee3b 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -329,14 +329,34 @@ function(jquery,ui,sammy,tmpl) { return; } } - generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId, - function(artifactVersionDetailViewModel){ - $("#main-content #"+tabToActivate).tab('show'); - if(contentDisplayFn){ - contentDisplayFn(groupId,artifactId,version,artifactVersionDetailViewModel); - } - } - ); + + + var artifactAvailableUrl="restServices/archivaServices/browseService/artifactAvailable/"+encodeURIComponent(groupId)+"/"+encodeURIComponent(artifactId); + artifactAvailableUrl+="/"+encodeURIComponent(version); + var selectedRepo=getSelectedBrowsingRepository(); + if (selectedRepo){ + artifactAvailableUrl+="?repositoryId="+encodeURIComponent(selectedRepo); + } + $("#main-content").html( mediumSpinnerImg()); + $.ajax(artifactAvailableUrl, { + type: "GET", + dataType: 'json', + success: function(data) { + // TODO take of the result true or false + //$.log("artifactAvailable:"+data); + generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId, + function(artifactVersionDetailViewModel){ + $("#main-content #"+tabToActivate).tab('show'); + if(contentDisplayFn){ + contentDisplayFn(groupId,artifactId,version,artifactVersionDetailViewModel); + } + } + ); + + } + }); + + }; this.get('#artifact/:groupId/:artifactId/:version',function(context){ |