Examples of ManagedRepositoryContent


Examples of org.apache.archiva.repository.ManagedRepositoryContent

            }
            else
            {
                for ( String repository : repositories )
                {
                    ManagedRepositoryContent managedRepository = null;

                    try
                    {
                        managedRepository = repositoryFactory.getManagedRepositoryContent( repository );
                    }
                    catch ( RepositoryNotFoundException e )
                    {
                        throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                                                "Invalid managed repository <" + repository + ">: " + e.getMessage() );
                    }
                    catch ( RepositoryException e )
                    {
                        throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                                                "Invalid managed repository <" + repository + ">: " + e.getMessage() );
                    }

                    File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource.getPath() );
                    if ( resourceFile.exists() )
                    {
                        // in case of group displaying index directory doesn't have sense !!
                        String repoIndexDirectory = managedRepository.getRepository().getIndexDirectory();
                        if ( StringUtils.isNotEmpty( repoIndexDirectory ) )
                        {
                            if ( !new File( repoIndexDirectory ).isAbsolute() )
                            {
                                repoIndexDirectory = new File( managedRepository.getRepository().getLocation(),
                                                               StringUtils.isEmpty( repoIndexDirectory )
                                                                   ? ".indexer"
                                                                   : repoIndexDirectory ).getAbsolutePath();
                            }
                        }
                        if ( StringUtils.isEmpty( repoIndexDirectory ) )
                        {
                            repoIndexDirectory = new File( managedRepository.getRepository().getLocation(),
                                                           ".indexer" ).getAbsolutePath();
                        }

                        if ( !StringUtils.equals( FilenameUtils.normalize( repoIndexDirectory ),
                                                  FilenameUtils.normalize( resourceFile.getAbsolutePath() ) ) )
View Full Code Here

Examples of org.apache.archiva.repository.ManagedRepositoryContent

        artifactReference.setType( StringUtils.isEmpty( packaging ) ? "jar" : packaging );

        try
        {

            ManagedRepositoryContent sourceRepository =
                repositoryFactory.getManagedRepositoryContent( artifactTransferRequest.getRepositoryId() );

            String artifactSourcePath = sourceRepository.toPath( artifactReference );

            if ( StringUtils.isEmpty( artifactSourcePath ) )
            {
                log.error( "cannot find artifact " + artifactTransferRequest.toString() );
                throw new ArchivaRestServiceException( "cannot find artifact " + artifactTransferRequest.toString() );
            }

            File artifactFile = new File( source.getLocation(), artifactSourcePath );

            if ( !artifactFile.exists() )
            {
                log.error( "cannot find artifact " + artifactTransferRequest.toString() );
                throw new ArchivaRestServiceException( "cannot find artifact " + artifactTransferRequest.toString() );
            }

            ManagedRepositoryContent targetRepository =
                repositoryFactory.getManagedRepositoryContent( artifactTransferRequest.getTargetRepositoryId() );

            String artifactPath = targetRepository.toPath( artifactReference );

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

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

Examples of org.apache.archiva.repository.ManagedRepositoryContent

            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() ) )
            {
                if ( StringUtils.isBlank( artifact.getPackaging() ) )
                {
                    throw new ArchivaRestServiceException( "You must configure a type/packaging when using classifier",
                                                           400 );
                }
                ArtifactReference artifactReference = new ArtifactReference();
                artifactReference.setArtifactId( artifact.getArtifactId() );
                artifactReference.setGroupId( artifact.getGroupId() );
                artifactReference.setVersion( artifact.getVersion() );
                artifactReference.setClassifier( artifact.getClassifier() );
                artifactReference.setType( artifact.getPackaging() );
                repository.deleteArtifact( artifactReference );

                // TODO cleanup facet which contains classifier information
                return Boolean.TRUE;
            }

            String path = repository.toMetadataPath( ref );
            int index = path.lastIndexOf( '/' );
            path = path.substring( 0, index );
            File targetPath = new File( repoConfig.getLocation(), path );

            if ( !targetPath.exists() )
            {
                throw new ContentNotFoundException(
                    artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() );
            }

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

            Collection<ArtifactMetadata> artifacts =
                metadataRepository.getArtifacts( repositoryId, artifact.getGroupId(), artifact.getArtifactId(),
                                                 artifact.getVersion() );

            for ( ArtifactMetadata artifactMetadata : artifacts )
            {
                // TODO: mismatch between artifact (snapshot) version and project (base) version here
                if ( artifact.getVersion().equals( artifact.getVersion() ) )
                {
                    metadataRepository.removeArtifact( artifactMetadata.getRepositoryId(),
                                                       artifactMetadata.getNamespace(), artifactMetadata.getProject(),
                                                       artifact.getVersion(), artifactMetadata.getId() );

                    // TODO: move into the metadata repository proper - need to differentiate attachment of
                    //       repository metadata to an artifact
                    for ( RepositoryListener listener : listeners )
                    {
                        listener.deleteArtifact( metadataRepository, repository.getId(),
                                                 artifactMetadata.getNamespace(), artifactMetadata.getProject(),
                                                 artifactMetadata.getVersion(), artifactMetadata.getId() );
                    }

                    triggerAuditEvent( repositoryId, path, AuditEvent.REMOVE_FILE );
View Full Code Here

Examples of org.apache.archiva.repository.ManagedRepositoryContent

        repo.setId( id );
        repo.setName( name );
        repo.setLocation( location.getAbsolutePath() );
        repo.setLayout( layout );

        ManagedRepositoryContent repoContent =
            applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class );
        repoContent.setRepository( repo );

        return repoContent;
    }
View Full Code Here

Examples of org.apache.archiva.repository.ManagedRepositoryContent

        repo.setId( MANAGED_ID );
        repo.setName( "Default Managed Repository" );
        repo.setLocation( repoPath );
        repo.setLayout( "default" );

        ManagedRepositoryContent repoContent =
            applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class );

        repoContent.setRepository( repo );
        managedDefaultRepository = repoContent;

        ( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
            ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( config );
View Full Code Here

Examples of org.apache.archiva.repository.ManagedRepositoryContent

    }

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

        return repoContent;
    }
View Full Code Here

Examples of org.apache.archiva.repository.ManagedRepositoryContent

    {
        DavResourceLocator locator = new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP
            + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
                                                                    new ArchivaDavLocatorFactory() );

        ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
        ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );

        try
        {
            archivaConfigurationControl.reset();
            archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
View Full Code Here

Examples of org.apache.archiva.repository.ManagedRepositoryContent

        repoGroups.add( repoGroup );

        config.setRepositoryGroups( repoGroups );

        ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );

        ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );

        try
        {
            archivaConfigurationControl.reset();
            archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
View Full Code Here

Examples of org.apache.archiva.repository.ManagedRepositoryContent

        repoGroups.add( repoGroup );

        config.setRepositoryGroups( repoGroups );

        ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
        ManagedRepositoryContent localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO );

        try
        {
            archivaConfigurationControl.reset();
            archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
View Full Code Here

Examples of org.apache.archiva.repository.ManagedRepositoryContent

        // should fetch metadata
        DavResourceLocator locator =
            new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml",
                                           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 );
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.