Package org.apache.archiva.metadata.model

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


    @Test
    public void testUpdateArtifactMetadataWithExistingFacets()
        throws Exception
    {
        ArtifactMetadata metadata = createArtifact();
        MetadataFacet facet = new TestMetadataFacet( "baz" );
        metadata.addFacet( facet );
        repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );

        metadata = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
                                            TEST_PROJECT_VERSION ).iterator().next();
View Full Code Here


    public void testGetMetadataFacetWhenDefaultValue()
        throws Exception
    {
        repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( null ) );

        MetadataFacet metadataFacet = repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME );

        assertEquals( new TestMetadataFacet( TEST_METADATA_VALUE ), metadataFacet );
    }
View Full Code Here

            node.setProperty( "version", artifactMeta.getVersion() );

            // iterate over available facets to update/add/remove from the artifactMetadata
            for ( String facetId : metadataFacetFactories.keySet() )
            {
                MetadataFacet metadataFacet = artifactMeta.getFacet( facetId );
                if ( metadataFacet == null )
                {
                    continue;
                }
                if ( node.hasNode( facetId ) )
                {
                    node.getNode( facetId ).remove();
                }
                if ( metadataFacet != null )
                {
                    // recreate, to ensure properties are removed
                    Node n = node.addNode( facetId );
                    n.addMixin( FACET_NODE_TYPE );

                    for ( Map.Entry<String, String> entry : metadataFacet.toProperties().entrySet() )
                    {
                        n.setProperty( entry.getKey(), entry.getValue() );
                    }
                }
            }
View Full Code Here

    }

    public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name )
        throws MetadataRepositoryException
    {
        MetadataFacet metadataFacet = null;
        try
        {
            Node root = getJcrSession().getRootNode();
            Node node = root.getNode( getFacetPath( repositoryId, facetId, name ) );

            if ( metadataFacetFactories == null )
            {
                return metadataFacet;
            }

            MetadataFacetFactory metadataFacetFactory = metadataFacetFactories.get( facetId );
            if ( metadataFacetFactory != null )
            {
                metadataFacet = metadataFacetFactory.createMetadataFacet( repositoryId, name );
                Map<String, String> map = new HashMap<String, String>();
                for ( Property property : JcrUtils.getProperties( node ) )
                {
                    String p = property.getName();
                    if ( !p.startsWith( "jcr:" ) )
                    {
                        map.put( p, property.getString() );
                    }
                }
                metadataFacet.fromProperties( map );
            }
        }
        catch ( PathNotFoundException e )
        {
            // ignored - the facet doesn't exist, so return null
View Full Code Here

                    {
                        log.error( "Attempted to load unknown project version metadata facet: {}", name );
                    }
                    else
                    {
                        MetadataFacet facet = factory.createMetadataFacet();
                        Map<String, String> map = new HashMap<String, String>();
                        for ( Property property : JcrUtils.getProperties( n ) )
                        {
                            String p = property.getName();
                            if ( !p.startsWith( "jcr:" ) )
                            {
                                map.put( p, property.getString() );
                            }
                        }
                        facet.fromProperties( map );
                        versionMetadata.addFacet( facet );
                    }
                }
            }
        }
View Full Code Here

                {
                    if ( n.isNodeType( ARTIFACT_NODE_TYPE ) )
                    {
                        ArtifactMetadata artifactMetadata = getArtifactFromNode( repositoryId, n );
                        log.debug( "artifactMetadata: {}", artifactMetadata );
                        MetadataFacet metadataFacetToRemove = artifactMetadata.getFacet( metadataFacet.getFacetId() );
                        if ( metadataFacetToRemove != null && metadataFacet.equals( metadataFacetToRemove ) )
                        {
                            n.remove();
                        }
                    }
View Full Code Here

                {
                    log.error( "Attempted to load unknown project version metadata facet: " + name );
                }
                else
                {
                    MetadataFacet facet = factory.createMetadataFacet();
                    Map<String, String> map = new HashMap<String, String>();
                    for ( Property p : JcrUtils.getProperties( n ) )
                    {
                        String property = p.getName();
                        if ( !property.startsWith( "jcr:" ) )
                        {
                            map.put( property, p.getString() );
                        }
                    }
                    facet.fromProperties( map );
                    artifact.addFacet( facet );
                }
            }
        }
        return artifact;
View Full Code Here

            getProjectMetadata( groupId, artifactId, version, repositoryId );
        if ( projectVersionMetadata == null )
        {
            return Collections.emptyList();
        }
        MetadataFacet metadataFacet = projectVersionMetadata.getFacet( GenericMetadataFacet.FACET_ID );

        if ( metadataFacet == null )
        {
            return Collections.emptyList();
        }
        Map<String, String> map = metadataFacet.toProperties();
        List<Entry> entries = new ArrayList<Entry>( map.size() );

        for ( Map.Entry<String, String> entry : map.entrySet() )
        {
            entries.add( new Entry( entry.getKey(), entry.getValue() ) );
View Full Code Here

            return Boolean.FALSE;
        }

        Map<String, String> properties = new HashMap<String, String>();

        MetadataFacet metadataFacet = projectVersionMetadata.getFacet( GenericMetadataFacet.FACET_ID );

        if ( metadataFacet != null && metadataFacet.toProperties() != null )
        {
            properties.putAll( metadataFacet.toProperties() );
        }
        else
        {
            metadataFacet = new GenericMetadataFacet();
        }

        properties.put( key, value );

        metadataFacet.fromProperties( properties );

        projectVersionMetadata.addFacet( metadataFacet );

        RepositorySession repositorySession = repositorySessionFactory.createSession();
View Full Code Here

            node.setProperty( "version", artifactMeta.getVersion() );

            // iterate over available facets to update/add/remove from the artifactMetadata
            for ( String facetId : metadataFacetFactories.keySet() )
            {
                MetadataFacet metadataFacet = artifactMeta.getFacet( facetId );
                if ( metadataFacet == null )
                {
                    continue;
                }
                if ( node.hasNode( facetId ) )
                {
                    node.getNode( facetId ).remove();
                }
                if ( metadataFacet != null )
                {
                    // recreate, to ensure properties are removed
                    Node n = node.addNode( facetId );
                    n.addMixin( FACET_NODE_TYPE );

                    for ( Map.Entry<String, String> entry : metadataFacet.toProperties().entrySet() )
                    {
                        n.setProperty( entry.getKey(), entry.getValue() );
                    }
                }
            }
View Full Code Here

TOP

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

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.