Package org.apache.archiva.repository.content.maven2

Examples of org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent


        }

        // The Filename.
        String filename = pathParts[2];

        FilenameParser parser = new FilenameParser( filename );

        artifact.setArtifactId( parser.nextNonVersion() );

        // Sanity Check: does it have an artifact id?
        if ( StringUtils.isEmpty( artifact.getArtifactId() ) )
        {
            // Special Case: The filename might start with a version id (like "test-arch-1.0.jar").
            int idx = filename.indexOf( '-' );
            if ( idx > 0 )
            {
                parser.reset();
                // Take the first section regardless of content.
                String artifactId = parser.next();

                // Is there anything more that is considered not a version id?
                String moreArtifactId = parser.nextNonVersion();
                if ( StringUtils.isNotBlank( moreArtifactId ) )
                {
                    artifact.setArtifactId( artifactId + "-" + moreArtifactId );
                }
                else
                {
                    artifact.setArtifactId( artifactId );
                }
            }

            // Sanity Check: still no artifact id?
            if ( StringUtils.isEmpty( artifact.getArtifactId() ) )
            {
                throw new LayoutException( INVALID_ARTIFACT_PATH + "no artifact id present." );
            }
        }

        artifact.setVersion( parser.remaining() );

        // Sanity Check: does it have a version?
        if ( StringUtils.isEmpty( artifact.getVersion() ) )
        {
            // Special Case: use last section of artifactId as version.
            String artifactId = artifact.getArtifactId();
            int idx = artifactId.lastIndexOf( '-' );
            if ( idx > 0 )
            {
                artifact.setVersion( artifactId.substring( idx + 1 ) );
                artifact.setArtifactId( artifactId.substring( 0, idx ) );
            }
            else
            {
                throw new LayoutException( INVALID_ARTIFACT_PATH + "no version found." );
            }
        }

        String classifier = ArtifactClassifierMapping.getClassifier( expectedType );
        if ( classifier != null )
        {
            String version = artifact.getVersion();
            if ( !version.endsWith( "-" + classifier ) )
            {
                throw new LayoutException(
                    INVALID_ARTIFACT_PATH + expectedType + " artifacts must use the classifier " + classifier );
            }
            version = version.substring( 0, version.length() - classifier.length() - 1 );
            artifact.setVersion( version );
            artifact.setClassifier( classifier );
        }

        String extension = parser.getExtension();

        // Set Type
        String defaultExtension = expectedType.substring( 0, expectedType.length() - 1 );
        artifact.setType(
            ArtifactExtensionMapping.mapExtensionAndClassifierToType( classifier, extension, defaultExtension ) );
View Full Code Here


        }

        // The Filename.
        String filename = pathParts[2];

        FilenameParser parser = new FilenameParser( filename );

        artifact.setArtifactId( parser.nextNonVersion() );

        // Sanity Check: does it have an artifact id?
        if ( StringUtils.isEmpty( artifact.getArtifactId() ) )
        {
            // Special Case: The filename might start with a version id (like "test-arch-1.0.jar").
            int idx = filename.indexOf( '-' );
            if ( idx > 0 )
            {
                parser.reset();
                // Take the first section regardless of content.
                String artifactId = parser.next();

                // Is there anything more that is considered not a version id?
                String moreArtifactId = parser.nextNonVersion();
                if ( StringUtils.isNotBlank( moreArtifactId ) )
                {
                    artifact.setArtifactId( artifactId + "-" + moreArtifactId );
                }
                else
                {
                    artifact.setArtifactId( artifactId );
                }
            }

            // Sanity Check: still no artifact id?
            if ( StringUtils.isEmpty( artifact.getArtifactId() ) )
            {
                throw new LayoutException( INVALID_ARTIFACT_PATH + "no artifact id present." );
            }
        }

        artifact.setVersion( parser.remaining() );

        // Sanity Check: does it have a version?
        if ( StringUtils.isEmpty( artifact.getVersion() ) )
        {
            // Special Case: use last section of artifactId as version.
            String artifactId = artifact.getArtifactId();
            int idx = artifactId.lastIndexOf( '-' );
            if ( idx > 0 )
            {
                artifact.setVersion( artifactId.substring( idx + 1 ) );
                artifact.setArtifactId( artifactId.substring( 0, idx ) );
            }
            else
            {
                throw new LayoutException( INVALID_ARTIFACT_PATH + "no version found." );
            }
        }

        String classifier = ArtifactClassifierMapping.getClassifier( expectedType );
        if ( classifier != null )
        {
            String version = artifact.getVersion();
            if ( !version.endsWith( "-" + classifier ) )
            {
                throw new LayoutException(
                    INVALID_ARTIFACT_PATH + expectedType + " artifacts must use the classifier " + classifier );
            }
            version = version.substring( 0, version.length() - classifier.length() - 1 );
            artifact.setVersion( version );
            artifact.setClassifier( classifier );
        }

        String extension = parser.getExtension();

        // Set Type
        String defaultExtension = expectedType.substring( 0, expectedType.length() - 1 );
        artifact.setType(
            ArtifactExtensionMapping.mapExtensionAndClassifierToType( classifier, extension, defaultExtension ) );
View Full Code Here

    }

    private ManagedRepositoryContent createManagedRepositoryContent( String repoId )
        throws RepositoryAdminException
    {
        ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
        repoContent.setRepository( defaultManagedRepositoryAdmin.getManagedRepository( repoId ) );

        return repoContent;
    }
View Full Code Here

    @Override
    public void beginScan( ManagedRepository repository, Date whenGathered )
        throws ConsumerException
    {
        this.managedRepository = new ManagedDefaultRepositoryContent();
        this.managedRepository.setRepository( repository );
    }
View Full Code Here

    }

    public void beginScan( ManagedRepository repository, Date whenGathered )
        throws ConsumerException
    {
        this.managedRepository = new ManagedDefaultRepositoryContent();
        this.managedRepository.setRepository( repository );
    }
View Full Code Here

    @Override
    public void beginScan( ManagedRepository repository, Date whenGathered )
        throws ConsumerException
    {
        this.managedRepository = new ManagedDefaultRepositoryContent();
        this.managedRepository.setRepository( repository );
    }
View Full Code Here

    }

    private ManagedRepositoryContent createManagedRepositoryContent( String repoId )
        throws RepositoryAdminException
    {
        ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
        repoContent.setRepository( defaultManagedRepositoryAdmin.getManagedRepository( repoId ) );

        return repoContent;
    }
View Full Code Here

    }

    public void beginScan( ManagedRepository repository, Date whenGathered )
        throws ConsumerException
    {
        this.managedRepository = new ManagedDefaultRepositoryContent();
        this.managedRepository.setRepository( repository );
    }
View Full Code Here

                                           INTERNAL_REPO, new ArchivaDavLocatorFactory() );

        ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );

        // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
        RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
        resourceFactory.setRepositoryRequest( repoRequest );

        try
        {
            archivaConfigurationControl.reset();
View Full Code Here

                                           INTERNAL_REPO, new ArchivaDavLocatorFactory() );

        ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );

        // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
        RepositoryRequest repoRequest = new RepositoryRequest( new LegacyPathParser( this.archivaConfiguration ) );
        resourceFactory.setRepositoryRequest( repoRequest );

        try
        {
            archivaConfigurationControl.reset();
View Full Code Here

TOP

Related Classes of org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent

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.