Package org.apache.archiva.model

Examples of org.apache.archiva.model.ArchivaRepositoryMetadata


            Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
            int newBuildNumber = 1;
            String timestamp = null;

            File versionMetadataFile = new File( targetPath, MetadataTools.MAVEN_METADATA );
            ArchivaRepositoryMetadata versionMetadata = getMetadata( versionMetadataFile );

            if ( !targetPath.exists() )
            {
                targetPath.mkdirs();
            }
View Full Code Here


    }

    private ArchivaRepositoryMetadata getMetadata( File metadataFile )
        throws RepositoryMetadataException
    {
        ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
        if ( metadataFile.exists() )
        {
            metadata = RepositoryMetadataReader.read( metadataFile );
        }
        return metadata;
View Full Code Here

        String latestVersion = artifactTransferRequest.getVersion();

        File projectDir = new File( targetPath ).getParentFile();
        File projectMetadataFile = new File( projectDir, MetadataTools.MAVEN_METADATA );

        ArchivaRepositoryMetadata projectMetadata = getMetadata( projectMetadataFile );

        if ( projectMetadataFile.exists() )
        {
            availableVersions = projectMetadata.getAvailableVersions();

            Collections.sort( availableVersions, VersionComparator.getInstance() );

            if ( !availableVersions.contains( artifactTransferRequest.getVersion() ) )
            {
                availableVersions.add( artifactTransferRequest.getVersion() );
            }

            latestVersion = availableVersions.get( availableVersions.size() - 1 );
        }
        else
        {
            availableVersions.add( artifactTransferRequest.getVersion() );

            projectMetadata.setGroupId( artifactTransferRequest.getGroupId() );
            projectMetadata.setArtifactId( artifactTransferRequest.getArtifactId() );
        }

        if ( projectMetadata.getGroupId() == null )
        {
            projectMetadata.setGroupId( artifactTransferRequest.getGroupId() );
        }

        if ( projectMetadata.getArtifactId() == null )
        {
            projectMetadata.setArtifactId( artifactTransferRequest.getArtifactId() );
        }

        projectMetadata.setLatestVersion( latestVersion );
        projectMetadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
        projectMetadata.setAvailableVersions( availableVersions );

        if ( !VersionUtil.isSnapshot( artifactTransferRequest.getVersion() ) )
        {
            projectMetadata.setReleasedVersion( latestVersion );
        }

        RepositoryMetadataWriter.write( projectMetadata, projectMetadataFile );

        if ( fixChecksums )
View Full Code Here

                else
                {
                    if ( resourcesInAbsolutePath != null && resourcesInAbsolutePath.size() > 1 )
                    {
                        // merge the metadata of all repos under group
                        ArchivaRepositoryMetadata mergedMetadata = new ArchivaRepositoryMetadata();
                        for ( String resourceAbsPath : resourcesInAbsolutePath )
                        {
                            try
                            {
                                File metadataFile = new File( resourceAbsPath );
                                ArchivaRepositoryMetadata repoMetadata = RepositoryMetadataReader.read( metadataFile );
                                mergedMetadata = RepositoryMetadataMerge.merge( mergedMetadata, repoMetadata );
                            }
                            catch ( RepositoryMetadataException r )
                            {
                                throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
View Full Code Here

            // TODO: this should be in the storage mechanism so that it is all tied together
            // delete from file system
            repository.deleteVersion( ref );

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

            updateMetadata( metadata, metadataFile, lastUpdatedTimestamp, artifact );

            MetadataRepository metadataRepository = repositorySession.getRepository();
View Full Code Here

        {
            XMLReader xml = new XMLReader( "metadata", metadataFile );
            // invoke this to remove namespaces, see MRM-1136
            xml.removeNamespaces();
           
            ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();

            metadata.setGroupId( xml.getElementText( "//metadata/groupId" ) );
            metadata.setArtifactId( xml.getElementText( "//metadata/artifactId" ) );
            metadata.setVersion( xml.getElementText( "//metadata/version" ) );
            metadata.setFileLastModified( new Date( metadataFile.lastModified() ) );
            metadata.setFileSize( metadataFile.length() );

            metadata.setLastUpdated( xml.getElementText( "//metadata/versioning/lastUpdated" ) );
            metadata.setLatestVersion( xml.getElementText( "//metadata/versioning/latest" ) );
            metadata.setReleasedVersion( xml.getElementText( "//metadata/versioning/release" ) );
            metadata.setAvailableVersions( xml.getElementListText( "//metadata/versioning/versions/version" ) );

            Element snapshotElem = xml.getElement( "//metadata/versioning/snapshot" );
            if ( snapshotElem != null )
            {
                SnapshotVersion snapshot = new SnapshotVersion();
                snapshot.setTimestamp( snapshotElem.elementTextTrim( "timestamp" ) );
                String tmp = snapshotElem.elementTextTrim( "buildNumber" );
                if( NumberUtils.isNumber( tmp ))
                {
                    snapshot.setBuildNumber( NumberUtils.toInt( tmp ) );
                }
                metadata.setSnapshotVersion( snapshot );
            }

            for ( Element plugin : xml.getElementList( "//metadata/plugins/plugin" ) )
            {
                Plugin p = new Plugin();
                p.setPrefix( plugin.elementTextTrim( "prefix" ) );
                p.setArtifactId( plugin.elementTextTrim( "artifactId" ) );
                p.setName( plugin.elementTextTrim( "name" ) );
                metadata.addPlugin( p );
            }

            return metadata;
        }
        catch ( XMLException e )
View Full Code Here

    {
        File defaultRepoDir = new File( "src/test/repositories/default-repository" );
        File expectedFile = new File( defaultRepoDir, "org/apache/maven/shared/maven-downloader/maven-metadata.xml" );
        String expectedContent = FileUtils.readFileToString( expectedFile, null );

        ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();

        metadata.setGroupId( "org.apache.maven.shared" );
        metadata.setArtifactId( "maven-downloader" );
        metadata.setVersion( "1.0" );
        metadata.setReleasedVersion( "1.1" );
        metadata.getAvailableVersions().add( "1.0" );
        metadata.getAvailableVersions().add( "1.1" );
        metadata.setLastUpdated( "20061212214311" );

        StringWriter actual = new StringWriter();
        RepositoryMetadataWriter.write( metadata, actual );

        XMLAssert.assertXMLEqual( "XML Contents", expectedContent, actual.toString() );
View Full Code Here

        throws RepositoryMetadataException
    {
        File defaultRepoDir = new File( "src/test/repositories/default-repository" );
        File metadataFile = new File( defaultRepoDir, "org/apache/maven/shared/maven-downloader/maven-metadata.xml" );

        ArchivaRepositoryMetadata metadata = RepositoryMetadataReader.read( metadataFile );

        assertNotNull( metadata );
        assertEquals( "Group Id", "org.apache.maven.shared", metadata.getGroupId() );
        assertEquals( "Artifact Id", "maven-downloader", metadata.getArtifactId() );
        assertEquals( "Released Version", "1.1", metadata.getReleasedVersion() );
        assertEquals( "List of Available Versions", 2, metadata.getAvailableVersions().size() );
        assertTrue( "Available version 1.0", metadata.getAvailableVersions().contains( "1.0" ) );
        assertTrue( "Available version 1.1", metadata.getAvailableVersions().contains( "1.1" ) );
    }
View Full Code Here

        if ( sourceMetadata == null )
        {
            throw new RepositoryMetadataException( "Cannot copy to a null parent project." );
        }

        ArchivaRepositoryMetadata merged = new ArchivaRepositoryMetadata();

        merged.setGroupId( merge( mainMetadata.getGroupId(), sourceMetadata.getGroupId() ) );
        merged.setArtifactIdmerge(mainMetadata.getArtifactId(), sourceMetadata.getArtifactId()));
        merged.setVersion( merge(mainMetadata.getVersion(), sourceMetadata.getVersion()) );
        merged.setReleasedVersion( merge( mainMetadata.getReleasedVersion(), sourceMetadata.getReleasedVersion() ) );
        merged.setSnapshotVersion( merge( mainMetadata.getSnapshotVersion(), sourceMetadata.getSnapshotVersion() ) );
        merged.setAvailableVersions( mergeAvailableVersions( mainMetadata.getAvailableVersions(), sourceMetadata.getAvailableVersions() ) );
        merged.setPlugins( mergePlugins( mainMetadata.getPlugins(), sourceMetadata.getPlugins() ) );
       
        //Don't set if merge was not possible
        long lastUpdated = mergeTimestamp( mainMetadata.getLastUpdated(), sourceMetadata.getLastUpdated());
        if (lastUpdated > -1)
        {
            merged.setLastUpdatedLong.toString(lastUpdated) );
        }
       
        return merged;
    }
View Full Code Here

        assertNotNull( "Actual File should not be null.", actualFile );

        assertTrue( "Actual file exists.", actualFile.exists() );

        StringWriter actualContents = new StringWriter();
        ArchivaRepositoryMetadata metadata = RepositoryMetadataReader.read( actualFile );
        RepositoryMetadataWriter.write( metadata, actualContents );

        DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadataXml, actualContents.toString() ) );
        if ( !detailedDiff.similar() )
        {
View Full Code Here

TOP

Related Classes of org.apache.archiva.model.ArchivaRepositoryMetadata

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.