Package org.apache.archiva.metadata.model

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


        assertEquals( "Artifact metadata is incomplete.", action.getActionErrors().toArray()[0].toString() );
    }

    public void testGetMailingLists()
    {
        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
        MailingList ml1 = createMailingList( "Users List", "users" );
        MailingList ml2 = createMailingList( "Developers List", "dev" );
        versionMetadata.setMailingLists( Arrays.asList( ml1, ml2 ) );
        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );

        setActionParameters();

        String result = action.mailingLists();

        assertActionSuccess( action, result );

        assertActionParameters( action );
        ProjectVersionMetadata model = action.getModel();
        assertDefaultModel( model );

        assertNotNull( action.getMailingLists() );
        assertMailingList( action.getMailingLists().get( 0 ), "Users List", "users" );
        assertMailingList( action.getMailingLists().get( 1 ), "Developers List", "dev" );
View Full Code Here


        assertTrue( action.getArtifacts().isEmpty() );
    }

    public void testGetDependencies()
    {
        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
        Dependency dependency1 = createDependencyBasic( "artifactId1" );
        Dependency dependency2 = createDependencyExtended( "artifactId2" );
        versionMetadata.setDependencies( Arrays.asList( dependency1, dependency2 ) );
        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );

        setActionParameters();

        String result = action.dependencies();

        assertActionSuccess( action, result );

        assertActionParameters( action );
        ProjectVersionMetadata model = action.getModel();
        assertDefaultModel( model );

        assertNotNull( action.getDependencies() );
        assertDependencyBasic( action.getDependencies().get( 0 ), "artifactId1" );
        assertDependencyExtended( action.getDependencies().get( 1 ), "artifactId2" );
View Full Code Here

    }

    public void testGetDependees()
        throws Exception
    {
        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
        ProjectVersionReference dependee1 = createReference( "artifactId1" );
        ProjectVersionReference dependee2 = createReference( "artifactId2" );
        metadataResolver.setProjectReferences( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION,
                                               Arrays.asList( dependee1, dependee2 ) );

        setActionParameters();

        String result = action.dependees();

        assertActionSuccess( action, result );

        assertActionParameters( action );
        ProjectVersionMetadata model = action.getModel();
        assertDefaultModel( model );

        assertNotNull( action.getDependees() );
        assertCoordinate( action.getDependees().get( 0 ), "artifactId1" );
        assertCoordinate( action.getDependees().get( 1 ), "artifactId2" );
View Full Code Here

        assertTrue( action.getArtifacts().isEmpty() );
    }

    public void testGetProjectMetadata()
    {
        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );

        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );

        setActionParameters();
View Full Code Here

        assertTrue( action.getArtifacts().isEmpty() );
    }

    public void testAddAndDeleteMetadataProperty()
    {
        ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );

        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );

        setActionParameters();
        action.setPropertyName( "foo" );
View Full Code Here

        {
            MetadataResolver metadataResolver = repositorySession.getResolver();

            for ( String repoId : observableRepos )
            {
                ProjectVersionMetadata model = metadataResolver.resolveProjectVersion( repositorySession, repoId,
                                                                                       groupId, artifactId, version );
                if ( model != null )
                {
                    List<Dependency> dependencies = new ArrayList<Dependency>();
                    List<org.apache.archiva.metadata.model.Dependency> modelDeps = model.getDependencies();
                    for ( org.apache.archiva.metadata.model.Dependency dep : modelDeps )
                    {
                        Dependency dependency = new Dependency( dep.getGroupId(), dep.getArtifactId(), dep.getVersion(),
                                                                dep.getClassifier(), dep.getType(), dep.getScope() );
                        dependencies.add( dependency );
View Full Code Here

    private String handleArtifact( RepositorySession session )
    {
        // In the future, this should be replaced by the repository grouping mechanism, so that we are only making
        // simple resource requests here and letting the resolver take care of it
        ProjectVersionMetadata versionMetadata = getProjectVersionMetadata( session );

        if ( versionMetadata == null )
        {
            addActionError( "Artifact not found" );
            return ERROR;
        }

        if ( versionMetadata.isIncomplete() )
        {
            addIncompleteModelWarning( "Artifact metadata is incomplete." );
        }

        model = versionMetadata;
View Full Code Here

        return SUCCESS;
    }

    private ProjectVersionMetadata getProjectVersionMetadata( RepositorySession session )
    {
        ProjectVersionMetadata versionMetadata = null;
        artifacts = new LinkedHashMap<String, List<ArtifactDownloadInfo>>();

        List<String> repos = getObservableRepos();

        MetadataResolver metadataResolver = session.getResolver();
        for ( String repoId : repos )
        {
            if ( versionMetadata == null )
            {
                // we don't want the implementation being that intelligent - so another resolver to do the
                // "just-in-time" nature of picking up the metadata (if appropriate for the repository type) is used
                try
                {
                    versionMetadata =
                        metadataResolver.resolveProjectVersion( session, repoId, groupId, artifactId, version );
                    if ( versionMetadata != null )
                    {
                        MetadataFacet repoProbFacet;
                        if ( ( repoProbFacet = versionMetadata.getFacet( RepositoryProblemFacet.FACET_ID ) ) != null )
                        {
                            addIncompleteModelWarning( "Artifact metadata is incomplete: "
                                                           + ( (RepositoryProblemFacet) repoProbFacet ).getProblem() );
                            //set metadata to complete so that no additional 'Artifact metadata is incomplete' warning is logged
                            versionMetadata.setIncomplete( false );
                        }
                    }

                }
                catch ( MetadataResolutionException e )
                {
                    addIncompleteModelWarning( "Error resolving artifact metadata: " + e.getMessage() );

                    // TODO: need a consistent way to construct this - same in ArchivaMetadataCreationConsumer
                    versionMetadata = new ProjectVersionMetadata();
                    versionMetadata.setId( version );
                }
                if ( versionMetadata != null )
                {
                    repositoryId = repoId;
View Full Code Here

    }

    public String addMetadataProperty()
    {
        RepositorySession repositorySession = repositorySessionFactory.createSession();
        ProjectVersionMetadata projectMetadata;
        try
        {
            MetadataRepository metadataRepository = repositorySession.getRepository();
            projectMetadata = getProjectVersionMetadata( repositorySession );
            if ( projectMetadata == null )
            {
                addActionError( "Artifact not found" );
                return ERROR;
            }

            if ( projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ) == null )
            {
                genericMetadata = new HashMap<String, String>();
            }
            else
            {
                genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
            }

            if ( propertyName == null || "".equals( propertyName.trim() ) || propertyValue == null || "".equals(
                propertyValue.trim() ) )
            {
                model = projectMetadata;
                addActionError( "Property Name and Property Value are required." );
                return INPUT;
            }

            genericMetadata.put( propertyName, propertyValue );

            try
            {
                updateProjectMetadata( projectMetadata, metadataRepository );
                repositorySession.save();
            }
            catch ( MetadataRepositoryException e )
            {
                log.warn( "Unable to persist modified project metadata after adding entry: " + e.getMessage(), e );
                addActionError(
                    "Unable to add metadata item to underlying content storage - consult application logs." );
                return ERROR;
            }

            // TODO: why re-retrieve?
            projectMetadata = getProjectVersionMetadata( repositorySession );
        }
        finally
        {
            repositorySession.close();
        }

        genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();

        model = projectMetadata;

        propertyName = "";
        propertyValue = "";
View Full Code Here

    {
        RepositorySession repositorySession = repositorySessionFactory.createSession();
        try
        {
            MetadataRepository metadataRepository = repositorySession.getRepository();
            ProjectVersionMetadata projectMetadata = getProjectVersionMetadata( repositorySession );

            if ( projectMetadata == null )
            {
                addActionError( "Artifact not found" );
                return ERROR;
            }

            if ( projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ) != null )
            {
                genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();

                if ( !StringUtils.isEmpty( deleteItem ) )
                {
                    genericMetadata.remove( deleteItem );

                    try
                    {
                        updateProjectMetadata( projectMetadata, metadataRepository );
                        repositorySession.save();
                    }
                    catch ( MetadataRepositoryException e )
                    {
                        log.warn( "Unable to persist modified project metadata after removing entry: " + e.getMessage(),
                                  e );
                        addActionError(
                            "Unable to remove metadata item to underlying content storage - consult application logs." );
                        return ERROR;
                    }

                    // TODO: why re-retrieve?
                    projectMetadata = getProjectVersionMetadata( repositorySession );

                    genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();

                    model = projectMetadata;

                    addActionMessage( "Property successfully deleted." );
                }
View Full Code Here

TOP

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

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.