Package org.apache.archiva.model

Examples of org.apache.archiva.model.VersionedReference


            TimeZone timezone = TimeZone.getTimeZone( "UTC" );
            DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
            fmt.setTimeZone( timezone );
            ManagedRepository repoConfig = managedRepositoryAdmin.getManagedRepository( repositoryId );

            VersionedReference ref = new VersionedReference();
            ref.setArtifactId( artifact.getArtifactId() );
            ref.setGroupId( artifact.getGroupId() );
            ref.setVersion( artifact.getVersion() );

            ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );

            if ( StringUtils.isNotBlank( artifact.getClassifier() ) )
            {
View Full Code Here


        if ( !path.endsWith( "/" + MAVEN_METADATA ) )
        {
            throw new RepositoryMetadataException( "Cannot convert to versioned reference, not a metadata file. " );
        }

        VersionedReference reference = new VersionedReference();

        String normalizedPath = StringUtils.replace( path, "\\", "/" );
        String pathParts[] = StringUtils.split( normalizedPath, '/' );

        int versionOffset = pathParts.length - 2;
        int artifactIdOffset = versionOffset - 1;
        int groupIdEnd = artifactIdOffset - 1;

        reference.setVersion( pathParts[versionOffset] );

        if ( !hasNumberAnywhere( reference.getVersion() ) )
        {
            // Scary check, but without it, all paths are version references;
            throw new RepositoryMetadataException(
                "Not a versioned reference, as version id on path has no number in it." );
        }

        reference.setArtifactId( pathParts[artifactIdOffset] );

        StringBuilder gid = new StringBuilder();
        for ( int i = 0; i <= groupIdEnd; i++ )
        {
            if ( i > 0 )
            {
                gid.append( "." );
            }
            gid.append( pathParts[i] );
        }

        reference.setGroupId( gid.toString() );

        return reference;
    }
View Full Code Here

    private void assertFetchVersioned( String requestedResource )
        throws Exception
    {
        File expectedFile = new File( managedDefaultDir, requestedResource );

        VersionedReference metadata = createVersionedReference( requestedResource );

        File downloadedFile = proxyHandler.fetchMetatadaFromProxies( managedDefaultRepository,
                                                                     managedDefaultRepository.toMetadataPath(
                                                                         metadata ) );
View Full Code Here

     */
    private void assertFetchVersionedFailed( String requestedResource )
        throws Exception
    {
        File expectedFile = new File( managedDefaultDir, requestedResource );
        VersionedReference metadata = createVersionedReference( requestedResource );

        File downloadedFile = proxyHandler.fetchMetatadaFromProxies( managedDefaultRepository,
                                                                     managedDefaultRepository.toMetadataPath(
                                                                         metadata ) );

View Full Code Here

        throws Exception
    {
        File actualFile = new File( managedDefaultDir, requestedResource );
        assertTrue( "Release Metadata should exist: " + requestedResource, actualFile.exists() );

        VersionedReference metadata = createVersionedReference( requestedResource );

        // Build expected metadata XML
        StringWriter expectedMetadataXml = new StringWriter();
        ArchivaRepositoryMetadata m = new ArchivaRepositoryMetadata();
        m.setGroupId( metadata.getGroupId() );
        m.setArtifactId( metadata.getArtifactId() );
        m.setVersion( metadata.getVersion() );
        RepositoryMetadataWriter.write( m, expectedMetadataXml );

        // Compare the file to the actual contents.
        assertMetadataEquals( expectedMetadataXml.toString(), actualFile );
    }
View Full Code Here

        throws Exception
    {
        File actualFile = new File( managedDefaultDir, requestedResource );
        assertTrue( "Snapshot Metadata should exist: " + requestedResource, actualFile.exists() );

        VersionedReference actualMetadata = createVersionedReference( requestedResource );

        assertSnapshotMetadata( actualFile, actualMetadata, expectedDate, expectedTime, expectedBuildnumber );
    }
View Full Code Here

        String proxiedFile = metadataTools.getRepositorySpecificName( proxiedRepoId, requestedResource );

        File actualFile = new File( managedDefaultDir, proxiedFile );
        assertTrue( "Repo Specific Snapshot Metadata should exist: " + requestedResource, actualFile.exists() );

        VersionedReference actualMetadata = createVersionedReference( requestedResource );

        assertSnapshotMetadata( actualFile, actualMetadata, expectedDate, expectedTime, expectedBuildnumber );
    }
View Full Code Here

        String proxiedFile = metadataTools.getRepositorySpecificName( proxiedRepoId, requestedResource );

        File actualFile = new File( managedDefaultDir, proxiedFile );
        assertTrue( "Release metadata for repo should exist: " + actualFile, actualFile.exists() );

        VersionedReference metadata = createVersionedReference( requestedResource );

        // Build expected metadata XML
        StringWriter expectedMetadataXml = new StringWriter();
        ArchivaRepositoryMetadata m = new ArchivaRepositoryMetadata();
        m.setGroupId( metadata.getGroupId() );
        m.setArtifactId( metadata.getArtifactId() );
        m.setVersion( metadata.getVersion() );
        RepositoryMetadataWriter.write( m, expectedMetadataXml );

        // Compare the file to the actual contents.
        assertMetadataEquals( expectedMetadataXml.toString(), actualFile );
    }
View Full Code Here

            throw new ContentNotFoundException(
                "Unable to get Versions on a non-directory: " + repoDir.getAbsolutePath() );
        }

        Set<String> foundVersions = new HashSet<String>();
        VersionedReference versionRef = new VersionedReference();
        versionRef.setGroupId( reference.getGroupId() );
        versionRef.setArtifactId( reference.getArtifactId() );

        File repoFiles[] = repoDir.listFiles();
        for ( int i = 0; i < repoFiles.length; i++ )
        {
            if ( !repoFiles[i].isDirectory() )
            {
                // Skip it. not a directory.
                continue;
            }

            // Test if dir has an artifact, which proves to us that it is a valid version directory.
            String version = repoFiles[i].getName();
            versionRef.setVersion( version );

            if ( hasArtifact( versionRef ) )
            {
                // Found an artifact, must be a valid version.
                foundVersions.add( version );
View Full Code Here

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

            // Now clean out any version that is earlier than the highest released version.
            boolean needsMetadataUpdate = false;

            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 );

                // FIXME: looks incomplete, might not delete related metadata?
                for ( RepositoryListener listener : listeners )
                {
View Full Code Here

TOP

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

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.