Package org.apache.archiva.metadata.repository

Examples of org.apache.archiva.metadata.repository.MetadataRepository


        catch ( IOException e )
        {
            throw new ConsumerException( e.getMessage(), e );
        }

        MetadataRepository metadataRepository = repositorySession.getRepository();

        List<ArtifactMetadata> results;
        try
        {
            results = metadataRepository.getArtifactsByChecksum( repoId, checksumSha1 );
        }
        catch ( MetadataRepositoryException e )
        {
            throw new ConsumerException( e.getMessage(), e );
        }

        if ( CollectionUtils.isNotEmpty( results ) )
        {
            ArtifactMetadata originalArtifact;
            try
            {
                originalArtifact = pathTranslator.getArtifactForPath( repoId, path );
            }
            catch ( Exception e )
            {
                log.warn( "Not reporting problem for invalid artifact in checksum check: " + e.getMessage() );
                return;
            }

            for ( ArtifactMetadata dupArtifact : results )
            {
                String id = path.substring( path.lastIndexOf( "/" ) + 1 );
                if ( dupArtifact.getId().equals( id )
                    && dupArtifact.getNamespace().equals( originalArtifact.getNamespace() )
                    && dupArtifact.getProject().equals( originalArtifact.getProject() )
                    && dupArtifact.getVersion().equals( originalArtifact.getVersion() ) )
                {
                    // Skip reference to itself.
                    if ( log.isDebugEnabled() )
                    {
                        log.debug( "Not counting duplicate for artifact " + dupArtifact + " for path " + path );
                    }
                    continue;
                }

                RepositoryProblemFacet problem = new RepositoryProblemFacet();
                problem.setRepositoryId( repoId );
                problem.setNamespace( originalArtifact.getNamespace() );
                problem.setProject( originalArtifact.getProject() );
                problem.setVersion( originalArtifact.getVersion() );
                problem.setId( id );
                // FIXME: need to get the right storage resolver for the repository the dupe artifact is in, it might be
                //       a different type
                // FIXME: we need the project version here, not the artifact version
                problem.setMessage( "Duplicate Artifact Detected: " + path + " <--> " + pathTranslator.toPath(
                    dupArtifact.getNamespace(), dupArtifact.getProject(), dupArtifact.getVersion(),
                    dupArtifact.getId() ) );
                problem.setProblem( "duplicate-artifact" );

                try
                {
                    metadataRepository.addMetadataFacet( repoId, problem );
                }
                catch ( MetadataRepositoryException e )
                {
                    throw new ConsumerException( e.getMessage(), e );
                }
View Full Code Here


            File metadataFile = getMetadata( targetPath.getAbsolutePath() );
            ArchivaRepositoryMetadata metadata = getMetadata( metadataFile );

            updateMetadata( metadata, metadataFile, lastUpdatedTimestamp, artifact );

            MetadataRepository metadataRepository = repositorySession.getRepository();

            Collection<ArtifactMetadata> artifacts =
                metadataRepository.getArtifacts( repositoryId, artifact.getGroupId(), artifact.getArtifactId(),
                                                 artifact.getVersion() );

            for ( ArtifactMetadata artifactMetadata : artifacts )
            {
                // TODO: mismatch between artifact (snapshot) version and project (base) version here
                if ( artifact.getVersion().equals( artifact.getVersion() ) )
                {
                    metadataRepository.removeArtifact( artifactMetadata.getRepositoryId(),
                                                       artifactMetadata.getNamespace(), artifactMetadata.getProject(),
                                                       artifact.getVersion(), artifactMetadata.getId() );

                    // TODO: move into the metadata repository proper - need to differentiate attachment of
                    //       repository metadata to an artifact
View Full Code Here

        Date endDateInDF;

        RepositorySession repositorySession = repositorySessionFactory.createSession();
        try
        {
            MetadataRepository metadataRepository = repositorySession.getRepository();
            if ( selectedRepositories.size() > 1 )
            {
                numPages = 1;

                try
View Full Code Here

        StringBuilder input;
        RepositorySession repositorySession = repositorySessionFactory.createSession();
        try
        {
            MetadataRepository metadataRepository = repositorySession.getRepository();
            if ( selectedRepositories.size() > 1 )
            {
                try
                {
                    startDateInDF = getStartDateInDateFormat();
View Full Code Here

        List<RepositoryProblemFacet> problemArtifacts = new ArrayList<RepositoryProblemFacet>();
        RepositorySession repositorySession = repositorySessionFactory.createSession();
        try
        {
            MetadataRepository metadataRepository = repositorySession.getRepository();
            for ( String repoId : repoIds )
            {
                // TODO: improve performance by navigating into a group subtree. Currently group is property, not part of name of item
                for ( String name : metadataRepository.getMetadataFacets( repoId, RepositoryProblemFacet.FACET_ID ) )
                {
                    RepositoryProblemFacet metadataFacet =
                        (RepositoryProblemFacet) metadataRepository.getMetadataFacet( repoId,
                                                                                      RepositoryProblemFacet.FACET_ID,
                                                                                      name );

                    if ( StringUtils.isEmpty( groupId ) || groupId.equals( metadataFacet.getNamespace() ) )
                    {
View Full Code Here

        databaseResults = new ArrayList<ArtifactMetadata>();
        RepositorySession repositorySession = repositorySessionFactory.createSession();
        try
        {
            MetadataRepository metadataRepository = repositorySession.getRepository();
            for ( String repoId : getObservableRepos() )
            {
                databaseResults.addAll(metadataRepository.getArtifactsByChecksum(repoId, q));
            }
        }
        finally
        {
            repositorySession.close();
View Full Code Here

            VersionedReference versionRef = new VersionedReference();
            versionRef.setGroupId( artifactRef.getGroupId() );
            versionRef.setArtifactId( artifactRef.getArtifactId() );

            MetadataRepository metadataRepository = repositorySession.getRepository();

            if ( releasedVersions.contains( VersionUtil.getReleaseVersion( artifactRef.getVersion() ) ) )
            {
                versionRef.setVersion( artifactRef.getVersion() );
                repository.deleteVersion( versionRef );
View Full Code Here

            // FIXME: is this the right separation? or should a JCR session object contain the JCR session information?
            //  such a change might allow us to avoid creating two objects for each request. It would also clear up
            //  the ambiguities in the API where session & repository are the inverse of JCR; and the resolver is
            //  retrieved from the session but must have it passed in. These should be reviewed before finalising the
            //  API.
            MetadataRepository metadataRepository = new JcrMetadataRepository( metadataFacetFactories, repository );

            return new RepositorySession( metadataRepository, metadataResolver );
        }
        catch ( RepositoryException e )
        {
View Full Code Here

            }

            @Override
            public MetadataRepository getRepository( )
            {
                return new MetadataRepository( )
                {
                    public void updateProject( String repositoryId, ProjectMetadata project )
                        throws MetadataRepositoryException
                    {
                        //To change body of implemented methods use File | Settings | File Templates.
View Full Code Here

        throws Exception
    {
        try
        {
            MockControl control = MockControl.createControl( MetadataRepository.class );
            MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
            control.expectAndReturn( metadataRepository.getMetadataFacets( "internal", RepositoryStatistics.FACET_ID ),
                                     Arrays.asList( "20091125.123456.678" ) );
            control.expectAndReturn(
                metadataRepository.getMetadataFacet( "internal", RepositoryStatistics.FACET_ID, "20091125.123456.678" ),
                new RepositoryStatistics() );
            control.expectAndReturn( metadataRepository.getMetadataFacets( "snapshots", RepositoryStatistics.FACET_ID ),
                                     Arrays.asList( "20091112.012345.012" ) );
            control.expectAndReturn( metadataRepository.getMetadataFacet( "snapshots", RepositoryStatistics.FACET_ID,
                                                                          "20091112.012345.012" ),
                                     new RepositoryStatistics() );
            control.replay();

            RepositorySession session = mock( RepositorySession.class );
View Full Code Here

TOP

Related Classes of org.apache.archiva.metadata.repository.MetadataRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.