Package org.apache.archiva.repository

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


    @Test
    public void testToNativePathLegacyMetadataDefaultToLegacy()
        throws Exception
    {
        ManagedRepositoryContent repository = createManagedRepo( "legacy" );

        // Test (metadata) default to legacy

        // Special Case: This direction is not supported, should throw a LayoutException.
        try
View Full Code Here

    @Test
    public void testNativePathPomDefaultToLegacy()
        throws Exception
    {
        ManagedRepositoryContent repository = createManagedRepo( "legacy" );

        // Test (pom) default to legacy
        assertEquals( "org.apache.derby/poms/derby-10.2.2.0.pom",
                      repoRequest.toNativePath( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.pom", repository ) );
    }
View Full Code Here

    @Test
    public void testNativePathSupportFileDefaultToLegacy()
        throws Exception
    {
        ManagedRepositoryContent repository = createManagedRepo( "legacy" );

        // Test (supportfile) default to legacy
        assertEquals( "org.apache.derby/jars/derby-10.2.2.0.jar.sha1",
                      repoRequest.toNativePath( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.jar.sha1",
                                                repository ) );
View Full Code Here

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

            ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );

            String artifactPath = repository.toPath( artifactReference );

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

            String path = artifactPath.substring( 0, lastIndex );
            File targetPath = new File( repoConfig.getLocation(), path );
View Full Code Here

            artifactReference.setVersion( version );
            artifactReference.setClassifier( fileMetadata.getClassifier() );
            artifactReference.setType(
                StringUtils.isEmpty( fileMetadata.getPackaging() ) ? packaging : fileMetadata.getPackaging() );

            ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );

            String artifactPath = repository.toPath( artifactReference );

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

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

            log.debug( "artifactPath: {} found targetPath: {}", artifactPath, targetPath );

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

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

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

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

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

            boolean fixChecksums =
                !( archivaAdministration.getKnownContentConsumers().contains( "create-missing-checksums" ) );

            try
            {
                File targetFile = new File( targetPath, filename );
                if ( targetFile.exists() && !VersionUtil.isSnapshot( version ) && repoConfig.isBlockRedeployments() )
                {
                    throw new ArchivaRestServiceException(
                        "Overwriting released artifacts in repository '" + repoConfig.getId() + "' is not allowed.",
                        Response.Status.BAD_REQUEST.getStatusCode(), null );
                }
                else
                {
                    copyFile( new File( fileMetadata.getServerFileName() ), targetPath, filename, fixChecksums );
                    triggerAuditEvent( repository.getId(), path + "/" + filename, AuditEvent.UPLOAD_FILE );
                    queueRepositoryTask( repository.getId(), targetFile );
                }
            }
            catch ( IOException ie )
            {
                log.error( "IOException copying file: {}", ie.getMessage(), ie );
View Full Code Here

    @Test
    public void testUpdateProjectNonExistingVersion()
        throws Exception
    {
        ManagedRepositoryContent testRepo = createTestRepoContent();
        ProjectReference reference = new ProjectReference();
        reference.setGroupId( "org.apache.archiva.metadata.tests" );
        reference.setArtifactId( "missing_artifact" );

        prepTestRepo( testRepo, reference );
View Full Code Here

        reference.setArtifactId( artifactId );
        reference.setVersion( version );

        ManagedRepository repo =
            createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRootDir );
        ManagedRepositoryContent repoContent =
            applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class );
        repoContent.setRepository( repo );

        Set<String> testedVersionSet = tools.gatherSnapshotVersions( repoContent, reference );

        // Sort the list (for asserts)
        List<String> testedVersions = new ArrayList<>();
View Full Code Here

    private void assertUpdatedProjectMetadata( String artifactId, String[] expectedVersions, String latestVersion,
                                               String releaseVersion )
        throws Exception
    {
        ManagedRepositoryContent testRepo = createTestRepoContent();
        ProjectReference reference = new ProjectReference();
        reference.setGroupId( "org.apache.archiva.metadata.tests" );
        reference.setArtifactId( artifactId );

        prepTestRepo( testRepo, reference );
View Full Code Here

    }

    private void assertUpdatedReleaseVersionMetadata( String artifactId, String version )
        throws Exception
    {
        ManagedRepositoryContent testRepo = createTestRepoContent();
        VersionedReference reference = new VersionedReference();
        reference.setGroupId( "org.apache.archiva.metadata.tests" );
        reference.setArtifactId( artifactId );
        reference.setVersion( version );
View Full Code Here

TOP

Related Classes of org.apache.archiva.repository.ManagedRepositoryContent

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.