Examples of ManagedRepositoryContent


Examples of org.apache.archiva.repository.ManagedRepositoryContent

    @Test
    public void testNativePathBadRequestUnknownType()
        throws Exception
    {
        ManagedRepositoryContent repository = createManagedRepo( "default" );

        // Test bad request path (too short)
        try
        {
            repoRequest.toNativePath( "org/apache/derby/derby/10.2.2.0/license.txt", repository );
View Full Code Here

Examples of org.apache.maven.archiva.repository.ManagedRepositoryContent

            artifactReference.setGroupId( groupId );
            artifactReference.setVersion( version );
            artifactReference.setClassifier( classifier );
            artifactReference.setType( packaging );

            ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );

            String artifactPath = repository.toPath( artifactReference );

            int lastIndex = artifactPath.lastIndexOf( '/' );

            File targetPath = new File( repoConfig.getLocation(), artifactPath.substring( 0, lastIndex ) );

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

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

            if ( VersionUtil.isSnapshot( version ) )
            {
                TimeZone timezone = TimeZone.getTimeZone( "UTC" );
                DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
                fmt.setTimeZone( timezone );
                timestamp = fmt.format( lastUpdatedTimestamp );
                if ( metadata.getSnapshotVersion() != null )
                {
                    newBuildNumber = metadata.getSnapshotVersion().getBuildNumber() + 1;
                }
                else
                {
                    metadata.setSnapshotVersion( new SnapshotVersion() );
                    newBuildNumber = 1;
                }
            }

            if ( !targetPath.exists() )
            {
                targetPath.mkdirs();
            }

            String filename = artifactPath.substring( lastIndex + 1 );
            if ( VersionUtil.isSnapshot( version ) )
            {
                filename = filename.replaceAll( "SNAPSHOT", timestamp + "-" + newBuildNumber );
            }

            boolean fixChecksums = !( config.getRepositoryScanning().getKnownContentConsumers().contains( "create-missing-checksums" ) );
           
            try
            {  
                File targetFile = new File( targetPath, filename );
                if( targetFile.exists() && !VersionUtil.isSnapshot( version ) && repoConfig.isBlockRedeployments() )
                {
                    addActionError( "Overwriting released artifacts in repository '" + repoConfig.getId() + "' is not allowed." );
                    return ERROR;
                }
                else
                {
                    copyFile( artifactFile, targetPath, filename, fixChecksums );
                    queueRepositoryTask( repository.getId(), repository.toFile( artifactReference ) );                   
                }
            }
            catch ( IOException ie )
            {
                addActionError( "Error encountered while uploading file: " + ie.getMessage() );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.