Package org.apache.archiva.metadata.model

Examples of org.apache.archiva.metadata.model.ArtifactMetadata


        repoFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( "internal" ), repoContent );

        recordInManagedLegacyRepoContent( fileTypesControl, fileTypes, pathParserControl, parser );

        List<ArtifactMetadata> artifacts = getArtifacts();
        ArtifactMetadata artifact = artifacts.get( 0 );

        metadataRepositoryControl.expectAndReturn(
            metadataRepository.getArtifacts( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
                                             artifact.getVersion() ), artifacts );
        metadataRepository.removeArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
                                           artifact.getVersion(), artifact.getId() );

        listener.deleteArtifact( metadataRepository, repoContent.getId(), artifact.getNamespace(),
                                 artifact.getProject(), artifact.getVersion(), artifact.getId() );
        listenerControl.setVoidCallable( 1 );

        archivaConfigControl.replay();
        configControl.replay();
        repoFactoryControl.replay();
View Full Code Here


    public void testMergeRepositoriesAndScan()
        throws Exception
    {
        List<ArtifactMetadata> sources = new ArrayList<ArtifactMetadata>();

        ArtifactMetadata artifact = new ArtifactMetadata();
        artifact.setId( "artifact" );
        artifact.setFileLastModified( System.currentTimeMillis() );

        sources.add( artifact );

        ManagedRepositoryConfiguration merge = createManagedRepo( "merge", "default", "merge", true, true );
        merge.setLocation( "target/test-repository/merge" );
View Full Code Here

    @Test
    public void testMergeRepositoriesWithConflictsAndScan()
        throws Exception
    {
        List<ArtifactMetadata> sources = new ArrayList<ArtifactMetadata>();
        ArtifactMetadata one = new ArtifactMetadata();
        one.setId( "one" );
        one.setVersion( "1.0" );

        ArtifactMetadata two = new ArtifactMetadata();
        two.setId( "two" );
        two.setVersion( "1.0-SNAPSHOT" );

        sources.add( one );
        sources.add( two );

        List<ArtifactMetadata> conflicts = new ArrayList<ArtifactMetadata>();
View Full Code Here

    private List<ArtifactMetadata> getArtifacts()
    {
        List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>();

        ArtifactMetadata artifact = new ArtifactMetadata();
        artifact.setId( "archiva-test-1.0.jar" );
        artifact.setProject( "archiva-test" );
        artifact.setVersion( "1.0" );
        artifact.setProjectVersion( "1.0" );
        artifact.setNamespace( "org.apache.archiva" );
        artifact.setRepositoryId( "internal" );
        artifacts.add( artifact );
        return artifacts;
    }
View Full Code Here

        userReposControl.expectAndReturn( userRepos.getObservableRepositories(),
                                          Collections.singletonList( TEST_REPO ) );

        Date whenGathered = new Date();

        ArtifactMetadata artifact = createArtifact( whenGathered );
        metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, CHECKSUM ),
                                                   Collections.singletonList( artifact ) );

        metadataRepositoryControl.replay();
        userReposControl.replay();
View Full Code Here

    }

    private ArtifactMetadata createArtifact( Date whenGathered )
    {
        String version = "1.0";
        ArtifactMetadata artifactMetadata = new ArtifactMetadata();
        artifactMetadata.setVersion( version );
        artifactMetadata.setProjectVersion( version );
        artifactMetadata.setId( ARCHIVA_TEST_ARTIFACT_ID + "-" + version + ".jar" );
        artifactMetadata.setProject( ARCHIVA_TEST_ARTIFACT_ID );
        artifactMetadata.setNamespace( ARCHIVA_TEST_GROUP_ID );
        artifactMetadata.setMd5( CHECKSUM );
        artifactMetadata.setWhenGathered( whenGathered );
        artifactMetadata.setRepositoryId( TEST_REPO );

        MavenArtifactFacet facet = new MavenArtifactFacet();
        facet.setType( "jar" );
        artifactMetadata.addFacet( facet );

        return artifactMetadata;
    }
View Full Code Here

            artifactId ) );
    }

    private String getTypeFromArtifactId( String artifactId )
    {
        ArtifactMetadata artifact = pathTranslator.getArtifactFromId( null, "groupId", artifactId, "1.0",
                                                                      artifactId + "-1.0.jar" );
        MavenArtifactFacet facet = (MavenArtifactFacet) artifact.getFacet( MavenArtifactFacet.FACET_ID );
        return facet.getType();
    }
View Full Code Here

        assertEquals( "duplicate-artifact", problem.getProblem() );
    }

    private static ArtifactMetadata createMetadata( String version )
    {
        ArtifactMetadata artifact = new ArtifactMetadata();
        artifact.setId( TEST_PROJECT + "-" + version + ".jar" );
        artifact.setNamespace( TEST_NAMESPACE );
        artifact.setProject( TEST_PROJECT );
        artifact.setProjectVersion( version );
        artifact.setVersion( version );
        artifact.setRepositoryId( TEST_REPO );
        return artifact;
    }
View Full Code Here

        addArtifact( "artifact-four", "1.1-beta-2", whenGathered );
    }

    private void addArtifact( String projectId, String projectVersion, Date whenGathered )
    {
        ArtifactMetadata artifact = new ArtifactMetadata();
        artifact.setFileLastModified( System.currentTimeMillis() );
        artifact.setNamespace( TEST_NAMESPACE );
        artifact.setProjectVersion( projectVersion );
        artifact.setVersion( projectVersion );
        artifact.setId( projectId + "-" + projectVersion + ".jar" );
        artifact.setProject( projectId );
        artifact.setRepositoryId( TEST_REPO );
        artifact.setWhenGathered( whenGathered );
        artifacts.add( artifact );

        versions.add( projectVersion );
    }
View Full Code Here

            if ( tok.hasMoreTokens() && "artifact".equals( tok.nextToken() ) )
            {
                String field = tok.nextToken();
                String id = tok.nextToken();

                ArtifactMetadata artifact = artifacts.get( id );
                if ( artifact == null )
                {
                    artifact = new ArtifactMetadata();
                    artifact.setRepositoryId( repoId );
                    artifact.setNamespace( namespace );
                    artifact.setProject( projectId );
                    artifact.setProjectVersion( projectVersion );
                    artifact.setVersion( projectVersion );
                    artifact.setId( id );
                    artifacts.put( id, artifact );
                }

                String value = (String) entry.getValue();
                if ( "updated".equals( field ) )
                {
                    artifact.setFileLastModified( Long.parseLong( value ) );
                }
                else if ( "size".equals( field ) )
                {
                    artifact.setSize( Long.valueOf( value ) );
                }
                else if ( "whenGathered".equals( field ) )
                {
                    artifact.setWhenGathered( new Date( Long.parseLong( value ) ) );
                }
                else if ( "version".equals( field ) )
                {
                    artifact.setVersion( value );
                }
                else if ( "md5".equals( field ) )
                {
                    artifact.setMd5( value );
                }
                else if ( "sha1".equals( field ) )
                {
                    artifact.setSha1( value );
                }
                else if ( "facetIds".equals( field ) )
                {
                    if ( value.length() > 0 )
                    {
                        String propertyPrefix = "artifact:facet:" + id + ":";
                        for ( String facetId : value.split( "," ) )
                        {
                            MetadataFacetFactory factory = metadataFacetFactories.get( facetId );
                            if ( factory == null )
                            {
                                log.error( "Attempted to load unknown artifact metadata facet: " + facetId );
                            }
                            else
                            {
                                MetadataFacet facet = factory.createMetadataFacet();
                                String prefix = propertyPrefix + facet.getFacetId();
                                Map<String, String> map = new HashMap<>();
                                for ( Object key : new ArrayList( properties.keySet() ) )
                                {
                                    String property = (String) key;
                                    if ( property.startsWith( prefix ) )
                                    {
                                        map.put( property.substring( prefix.length() + 1 ),
                                                 properties.getProperty( property ) );
                                    }
                                }
                                facet.fromProperties( map );
                                artifact.addFacet( facet );
                            }
                        }
                    }

                    updateArtifactFacets( artifact, properties );
View Full Code Here

TOP

Related Classes of org.apache.archiva.metadata.model.ArtifactMetadata

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.