@Override public VersionsList getVersionsList( String groupId, String artifactId, String repositoryId ) throws ArchivaRestServiceException { List<String> selectedRepos = getSelectedRepos( repositoryId ); try { Collection<String> versions = getVersions( selectedRepos, groupId, artifactId ); return new VersionsList( new ArrayList<>( versions ) ); } catch ( MetadataResolutionException e ) { throw new ArchivaRestServiceException( e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e ); } }
@Override public VersionsList getVersionsList( String groupId, String artifactId, String repositoryId ) throws ArchivaRestServiceException { List<String> selectedRepos = getSelectedRepos( repositoryId ); try { Collection<String> versions = getVersions( selectedRepos, groupId, artifactId ); return new VersionsList( new ArrayList<>( versions ) ); } catch ( MetadataResolutionException e ) { throw new ArchivaRestServiceException( e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e ); } }
@Override public List<ArtifactMetadata> getArtifacts( String repoId ) throws MetadataRepositoryException { try { List<ArtifactMetadata> artifacts = new ArrayList<>(); for ( String ns : getRootNamespaces( repoId ) ) { getArtifacts( artifacts, repoId, ns ); } return artifacts; } catch ( MetadataResolutionException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
@Override public List<Artifact> getArtifactDownloadInfos( String groupId, String artifactId, String version, String repositoryId ) throws ArchivaRestServiceException { List<String> selectedRepos = getSelectedRepos( repositoryId ); List<Artifact> artifactDownloadInfos = new ArrayList<>(); try (RepositorySession session = repositorySessionFactory.createSession()) { MetadataResolver metadataResolver = session.getResolver(); for ( String repoId : selectedRepos ) { List<ArtifactMetadata> artifacts = new ArrayList<>( metadataResolver.resolveArtifacts( session, repoId, groupId, artifactId, version ) ); Collections.sort( artifacts, ArtifactMetadataVersionComparator.INSTANCE ); if ( artifacts != null && !artifacts.isEmpty() ) { return buildArtifacts( artifacts, repoId ); } } } catch ( MetadataResolutionException e ) { log.error( e.getMessage(), e ); throw new ArchivaRestServiceException( e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e ); } return artifactDownloadInfos; }
@Override public List<ArtifactMetadata> getArtifacts( String repoId ) throws MetadataRepositoryException { try { List<ArtifactMetadata> artifacts = new ArrayList<>(); for ( String ns : getRootNamespaces( repoId ) ) { getArtifacts( artifacts, repoId, ns ); } return artifacts; } catch ( MetadataResolutionException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
@Override public List<Artifact> getArtifactDownloadInfos( String groupId, String artifactId, String version, String repositoryId ) throws ArchivaRestServiceException { List<String> selectedRepos = getSelectedRepos( repositoryId ); List<Artifact> artifactDownloadInfos = new ArrayList<>(); try (RepositorySession session = repositorySessionFactory.createSession()) { MetadataResolver metadataResolver = session.getResolver(); for ( String repoId : selectedRepos ) { List<ArtifactMetadata> artifacts = new ArrayList<>( metadataResolver.resolveArtifacts( session, repoId, groupId, artifactId, version ) ); Collections.sort( artifacts, ArtifactMetadataVersionComparator.INSTANCE ); if ( artifacts != null && !artifacts.isEmpty() ) { return buildArtifacts( artifacts, repoId ); } } } catch ( MetadataResolutionException e ) { log.error( e.getMessage(), e ); throw new ArchivaRestServiceException( e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e ); } return artifactDownloadInfos; }
@Override public List<ArtifactMetadata> getArtifactsByDateRange( String repoId, Date startTime, Date endTime ) throws MetadataRepositoryException { try { // TODO: this is quite slow - if we are to persist with this repository implementation we should build an index // of this information (eg. in Lucene, as before) List<ArtifactMetadata> artifacts = new ArrayList<>(); for ( String ns : getRootNamespaces( repoId ) ) { getArtifactsByDateRange( artifacts, repoId, ns, startTime, endTime ); } artifacts.sort(new ArtifactComparator() ); return artifacts; } catch ( MetadataResolutionException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
@Override public List<ArtifactMetadata> getArtifactsByDateRange( String repoId, Date startTime, Date endTime ) throws MetadataRepositoryException { try { // TODO: this is quite slow - if we are to persist with this repository implementation we should build an index // of this information (eg. in Lucene, as before) List<ArtifactMetadata> artifacts = new ArrayList<>(); for ( String ns : getRootNamespaces( repoId ) ) { getArtifactsByDateRange( artifacts, repoId, ns, startTime, endTime ); } Collections.sort( artifacts, new ArtifactComparator() ); return artifacts; } catch ( MetadataResolutionException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
/** * Walks each namespace of the given repository id and counts the artifacts. * * @param metadataRepository The repository implementation * @param repositoryId The repository Id * @param repositoryStatistics The statistics object that must be populated * @throws MetadataRepositoryException Throws the repository exception, if an error occurs while accessing the repository. */ @Override public void populateStatistics( MetadataRepository metadataRepository, String repositoryId, RepositoryStatistics repositoryStatistics ) throws MetadataRepositoryException { try { for ( String ns : metadataRepository.getRootNamespaces( repositoryId ) ) { walkRepository( metadataRepository, repositoryStatistics, repositoryId, ns ); } } catch ( MetadataResolutionException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
throw new ArchivaRestServiceException( e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
throw new ArchivaRestServiceException( e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
throw new ArchivaRestServiceException( e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
throw new ArchivaRestServiceException( e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
throw new ArchivaRestServiceException( e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
private void getArtifactsByChecksum( List<ArtifactMetadata> artifacts, String repositoryId, String ns, String checksum ) throws MetadataRepositoryException { try { for ( String namespace : getNamespaces( repositoryId, ns ) ) { getArtifactsByChecksum( artifacts, repositoryId, ns + "." + namespace, checksum ); } for ( String project : getProjects( repositoryId, ns ) ) { for ( String version : getProjectVersions( repositoryId, ns, project ) ) { for ( ArtifactMetadata artifact : getArtifacts( repositoryId, ns, project, version ) ) { if ( checksum.equals( artifact.getMd5() ) || checksum.equals( artifact.getSha1() ) ) { artifacts.add( artifact ); } } } } } catch ( MetadataResolutionException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
private void getArtifactsByChecksum( List<ArtifactMetadata> artifacts, String repositoryId, String ns, String checksum ) throws MetadataRepositoryException { try { for ( String namespace : getNamespaces( repositoryId, ns ) ) { getArtifactsByChecksum( artifacts, repositoryId, ns + "." + namespace, checksum ); } for ( String project : getProjects( repositoryId, ns ) ) { for ( String version : getProjectVersions( repositoryId, ns, project ) ) { for ( ArtifactMetadata artifact : getArtifacts( repositoryId, ns, project, version ) ) { if ( checksum.equals( artifact.getMd5() ) || checksum.equals( artifact.getSha1() ) ) { artifacts.add( artifact ); } } } } } catch ( MetadataResolutionException e ) { throw new MetadataRepositoryException( e.getMessage(), e ); } }
throw new MetadataRepositoryException( e.getMessage(), e );
throw new MetadataRepositoryException( e.getMessage(), e );
groupId, artifactId, repoId, e.getMessage() );
groupId, artifactId, repoId, e.getMessage() );