Package org.apache.maven.archiva.configuration

Examples of org.apache.maven.archiva.configuration.RepositoryGroupConfiguration


                int count = 0;
                for ( Iterator iter = value.getRepositoryGroups().iterator(); iter.hasNext(); count++ )
                {
                    String name = "repositoryGroups.repositoryGroup(" + count + ")";
                    RepositoryGroupConfiguration o = ( RepositoryGroupConfiguration ) iter.next();
                    writeRepositoryGroupConfiguration( prefix + name + ".", o, registry );
                }
            }
            if ( value.getManagedRepositories() != null && value.getManagedRepositories().size() > 0
)
View Full Code Here


        value.setRepositories( repositories );
        java.util.List repositoryGroups = new java.util.ArrayList/*<RepositoryGroupConfiguration>*/();
        List repositoryGroupsSubsets = registry.getSubsetList( prefix + "repositoryGroups.repositoryGroup" );
        for ( Iterator i = repositoryGroupsSubsets.iterator(); i.hasNext(); )
        {
            RepositoryGroupConfiguration v = readRepositoryGroupConfiguration( "", (Registry) i.next() );
            repositoryGroups.add( v );
        }
        value.setRepositoryGroups( repositoryGroups );
        java.util.List managedRepositories = new java.util.ArrayList/*<ManagedRepositoryConfiguration>*/();
        List managedRepositoriesSubsets = registry.getSubsetList( prefix + "managedRepositories.managedRepository" );
View Full Code Here

        return value;
    }
   
    private RepositoryGroupConfiguration readRepositoryGroupConfiguration( String prefix, Registry registry )
    {
        RepositoryGroupConfiguration value = new RepositoryGroupConfiguration();

        String id = registry.getString( prefix + "id", value.getId() );
        value.setId( id );
        java.util.List repositories = new java.util.ArrayList/*<String>*/();
        repositories.addAll( registry.getList( prefix + "repositories.repository" ) );
        value.setRepositories( repositories );

        return value;
    }
View Full Code Here

                                       final DavServletResponse response )
        throws DavException
    {
        ArchivaDavResourceLocator archivaLocator = checkLocatorIsInstanceOfRepositoryLocator( locator );

        RepositoryGroupConfiguration repoGroupConfig =
            archivaConfiguration.getConfiguration().getRepositoryGroupsAsMap().get( archivaLocator.getRepositoryId() );

        String activePrincipal = getActivePrincipal( request );

        List<String> resourcesInAbsolutePath = new ArrayList<String>();

        boolean readMethod = WebdavMethodUtil.isReadMethod( request.getMethod() );
        DavResource resource;
        if ( repoGroupConfig != null )
        {
            if ( !readMethod )
            {
                throw new DavException( HttpServletResponse.SC_METHOD_NOT_ALLOWED,
                                        "Write method not allowed for repository groups." );
            }

            log.debug( "Repository group '" + repoGroupConfig.getId() + "' accessed by '" + activePrincipal + "'" );

            // handle browse requests for virtual repos
            if ( RepositoryPathUtil.getLogicalResource( archivaLocator.getOrigResourcePath() ).endsWith( "/" ) )
            {
                return getResource( request, repoGroupConfig.getRepositories(), archivaLocator );
            }
            else
            {               
                resource =
                    processRepositoryGroup( request, archivaLocator, repoGroupConfig.getRepositories(),
                                            activePrincipal, resourcesInAbsolutePath );               
            }
        }
        else
        {
            ManagedRepositoryContent managedRepository = null;

            try
            {
                managedRepository = repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
            }
            catch ( RepositoryNotFoundException e )
            {
                throw new DavException( HttpServletResponse.SC_NOT_FOUND, "Invalid repository: " +
                    archivaLocator.getRepositoryId() );
            }
            catch ( RepositoryException e )
            {
                throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
            }

            log.debug( "Managed repository '" + managedRepository.getId() + "' accessed by '" + activePrincipal + "'" );
          
            resource = processRepository( request, archivaLocator, activePrincipal, managedRepository );          

            String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
            resourcesInAbsolutePath.add( new File( managedRepository.getRepoRoot(), logicalResource ).getAbsolutePath() );
        }

        String requestedResource = request.getRequestURI();

        // MRM-872 : merge all available metadata
        // merge metadata only when requested via the repo group
        if ( ( repositoryRequest.isMetadata( requestedResource ) || repositoryRequest.isMetadataSupportFile( requestedResource ) ) &&
            repoGroupConfig != null )
        {
            // this should only be at the project level not version level!
            if ( isProjectReference( requestedResource ) )
            {
                String artifactId = StringUtils.substringBeforeLast( requestedResource.replace( '\\', '/' ), "/" );
                artifactId = StringUtils.substringAfterLast( artifactId, "/" );

                ArchivaDavResource res = (ArchivaDavResource) resource;
                String filePath =
                    StringUtils.substringBeforeLast( res.getLocalResource().getAbsolutePath().replace( '\\', '/' ), "/" );
                filePath = filePath + "/maven-metadata-" + repoGroupConfig.getId() + ".xml";

                // for MRM-872 handle checksums of the merged metadata files
                if ( repositoryRequest.isSupportFile( requestedResource ) )
                {
                    File metadataChecksum =
View Full Code Here

                                       final DavServletResponse response )
        throws DavException
    {
        ArchivaDavResourceLocator archivaLocator = checkLocatorIsInstanceOfRepositoryLocator( locator );

        RepositoryGroupConfiguration repoGroupConfig =
            archivaConfiguration.getConfiguration().getRepositoryGroupsAsMap().get( archivaLocator.getRepositoryId() );

        String activePrincipal = getActivePrincipal( request );

        List<String> resourcesInAbsolutePath = new ArrayList<String>();

        boolean readMethod = WebdavMethodUtil.isReadMethod( request.getMethod() );
        DavResource resource;
        if ( repoGroupConfig != null )
        {
            if ( !readMethod )
            {
                throw new DavException( HttpServletResponse.SC_METHOD_NOT_ALLOWED,
                                        "Write method not allowed for repository groups." );
            }

            // handle browse requests for virtual repos
            if ( RepositoryPathUtil.getLogicalResource( archivaLocator.getOrigResourcePath() ).endsWith( "/" ) )
            {
                return getResource( request, repoGroupConfig.getRepositories(), archivaLocator );
            }
            else
            {
                resource =
                    processRepositoryGroup( request, archivaLocator, repoGroupConfig.getRepositories(),
                                            activePrincipal, resourcesInAbsolutePath );
            }
        }
        else
        {
            ManagedRepositoryContent managedRepository = null;

            try
            {
                managedRepository = repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
            }
            catch ( RepositoryNotFoundException e )
            {
                throw new DavException( HttpServletResponse.SC_NOT_FOUND, "Invalid repository: "
                    + archivaLocator.getRepositoryId() );
            }
            catch ( RepositoryException e )
            {
                throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
            }

            resource = processRepository( request, archivaLocator, activePrincipal, managedRepository );

            String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
            resourcesInAbsolutePath.add( new File( managedRepository.getRepoRoot(), logicalResource ).getAbsolutePath() );
        }

        String requestedResource = request.getRequestURI();

        // MRM-872 : merge all available metadata
        // merge metadata only when requested via the repo group
        if ( ( repositoryRequest.isMetadata( requestedResource ) || ( requestedResource.endsWith( "metadata.xml.sha1" ) || requestedResource.endsWith( "metadata.xml.md5" ) ) )
            && repoGroupConfig != null )
        {
            // this should only be at the project level not version level!
            if ( isProjectReference( requestedResource ) )
            {
                String artifactId = StringUtils.substringBeforeLast( requestedResource.replace( '\\', '/' ), "/" );
                artifactId = StringUtils.substringAfterLast( artifactId, "/" );

                ArchivaDavResource res = (ArchivaDavResource) resource;
                String filePath =
                    StringUtils.substringBeforeLast( res.getLocalResource().getAbsolutePath().replace( '\\', '/' ), "/" );
                filePath = filePath + "/maven-metadata-" + repoGroupConfig.getId() + ".xml";

                // for MRM-872 handle checksums of the merged metadata files
                if ( repositoryRequest.isSupportFile( requestedResource ) )
                {
                    File metadataChecksum =
View Full Code Here

        value.setRepositories( repositories );
        java.util.List repositoryGroups = new java.util.ArrayList();
        List repositoryGroupsSubsets = registry.getSubsetList( prefix + "repositoryGroups.repositoryGroup" );
        for ( Iterator i = repositoryGroupsSubsets.iterator(); i.hasNext(); )
        {
            RepositoryGroupConfiguration v = readRepositoryGroupConfiguration( "", (Registry) i.next() );
            repositoryGroups.add( v );
        }
        value.setRepositoryGroups( repositoryGroups );
        java.util.List managedRepositories = new java.util.ArrayList();
        List managedRepositoriesSubsets = registry.getSubsetList( prefix + "managedRepositories.managedRepository" );
View Full Code Here

        return value;
    }
   
    private RepositoryGroupConfiguration readRepositoryGroupConfiguration( String prefix, Registry registry )
    {
        RepositoryGroupConfiguration value = new RepositoryGroupConfiguration();

        String id = registry.getString( prefix + "id", value.getId() );
        value.setId( id );
        java.util.List repositories = new java.util.ArrayList();
        repositories.addAll( registry.getList( prefix + "repositories.repository" ) );
        value.setRepositories( repositories );

        return value;
    }
View Full Code Here

        throws DavException
    {
        checkLocatorIsInstanceOfRepositoryLocator( locator );
        ArchivaDavResourceLocator archivaLocator = (ArchivaDavResourceLocator) locator;

        RepositoryGroupConfiguration repoGroupConfig =
            archivaConfiguration.getConfiguration().getRepositoryGroupsAsMap().get( archivaLocator.getRepositoryId() );
        List<String> repositories = new ArrayList<String>();

        boolean isGet = WebdavMethodUtil.isReadMethod( request.getMethod() );
        boolean isPut = WebdavMethodUtil.isWriteMethod( request.getMethod() );

        if ( repoGroupConfig != null )
        {
            if( WebdavMethodUtil.isWriteMethod( request.getMethod() ) )
            {
                throw new DavException( HttpServletResponse.SC_METHOD_NOT_ALLOWED,
                                        "Write method not allowed for repository groups." );
            }
            repositories.addAll( repoGroupConfig.getRepositories() );

            // handle browse requests for virtual repos
            if ( RepositoryPathUtil.getLogicalResource( locator.getResourcePath() ).endsWith( "/" ) )
            {
                return getResource( request, repositories, archivaLocator );
            }
        }
        else
        {
            repositories.add( archivaLocator.getRepositoryId() );
        }

        //MRM-419 - Windows Webdav support. Should not 404 if there is no content.
        if (StringUtils.isEmpty(archivaLocator.getRepositoryId()))
        {
            throw new DavException(HttpServletResponse.SC_NO_CONTENT);
        }

        List<DavResource> availableResources = new ArrayList<DavResource>();
        List<String> resourcesInAbsolutePath = new ArrayList<String>();
        DavException e = null;
       
        for ( String repositoryId : repositories )
        {
            ManagedRepositoryContent managedRepository = null;

            try
            {
                managedRepository = getManagedRepository( repositoryId );
            }
            catch ( DavException de )
            {
                throw new DavException( HttpServletResponse.SC_NOT_FOUND, "Invalid managed repository <" +
                    repositoryId + ">" );
            }
           
            DavResource resource = null;
           
            if ( !locator.getResourcePath().startsWith( ArchivaDavResource.HIDDEN_PATH_PREFIX ) )
            {
                if ( managedRepository != null )
                {
                    try
                    {
                        if( isAuthorized( request, repositoryId ) )
                        {
                            LogicalResource logicalResource =
                                new LogicalResource( RepositoryPathUtil.getLogicalResource( locator.getResourcePath() ) );

                            if ( isGet )
                            {
                                resource = doGet( managedRepository, request, archivaLocator, logicalResource );
                            }

                            if ( isPut )
                            {
                                resource = doPut( managedRepository, request, archivaLocator, logicalResource );
                            }
                        }
                    }
                    catch ( DavException de )
                    {
                        e = de;
                        continue;
                    }

                    if( resource == null )
                    {
                        e = new DavException( HttpServletResponse.SC_NOT_FOUND, "Resource does not exist" );
                    }
                    else
                    {  
                        availableResources.add( resource );

                        String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
                        resourcesInAbsolutePath.add( managedRepository.getRepoRoot() + logicalResource );
                    }
                }
                else
                {
                    e = new DavException( HttpServletResponse.SC_NOT_FOUND, "Repository does not exist" );
                }
            }
        }       
       
        if ( availableResources.isEmpty() )
        {
            throw e;
        }
       
        String requestedResource = request.getRequestURI();
       
        // MRM-872 : merge all available metadata
        // merge metadata only when requested via the repo group       
        if ( ( repositoryRequest.isMetadata( requestedResource ) || ( requestedResource.endsWith( "metadata.xml.sha1" ) || requestedResource.endsWith( "metadata.xml.md5" ) ) ) &&
            repoGroupConfig != null )
        {  
            // this should only be at the project level not version level!
            if( isProjectReference( requestedResource ) )
            {
                String artifactId = StringUtils.substringBeforeLast( requestedResource.replace( '\\', '/' ), "/" );
                artifactId = StringUtils.substringAfterLast( artifactId, "/" );
               
                ArchivaDavResource res = ( ArchivaDavResource ) availableResources.get( 0 );
                String filePath = StringUtils.substringBeforeLast( res.getLocalResource().getAbsolutePath().replace( '\\', '/' ), "/" );                               
                filePath = filePath + "/maven-metadata-" + repoGroupConfig.getId() + ".xml";
               
                // for MRM-872 handle checksums of the merged metadata files
                if( repositoryRequest.isSupportFile( requestedResource ) )
                {
                    File metadataChecksum = new File( filePath + "."
View Full Code Here

                                       final DavServletResponse response )
        throws DavException
    {
        ArchivaDavResourceLocator archivaLocator = checkLocatorIsInstanceOfRepositoryLocator( locator );

        RepositoryGroupConfiguration repoGroupConfig =
            archivaConfiguration.getConfiguration().getRepositoryGroupsAsMap().get( archivaLocator.getRepositoryId() );

        String activePrincipal = getActivePrincipal( request );

        List<String> resourcesInAbsolutePath = new ArrayList<String>();

        boolean readMethod = WebdavMethodUtil.isReadMethod( request.getMethod() );
        DavResource resource;
        if ( repoGroupConfig != null )
        {
            if ( !readMethod )
            {
                throw new DavException( HttpServletResponse.SC_METHOD_NOT_ALLOWED,
                                        "Write method not allowed for repository groups." );
            }

            log.debug( "Repository group '" + repoGroupConfig.getId() + "' accessed by '" + activePrincipal + "'" );

            // handle browse requests for virtual repos
            if ( RepositoryPathUtil.getLogicalResource( archivaLocator.getOrigResourcePath() ).endsWith( "/" ) )
            {
                return getResource( request, repoGroupConfig.getRepositories(), archivaLocator );
            }
            else
            {
                // make a copy to avoid potential concurrent modifications (eg. by configuration)
                // TODO: ultimately, locking might be more efficient than copying in this fashion since updates are
                //  infrequent
                ArrayList<String> repositories = new ArrayList<String>( repoGroupConfig.getRepositories() );
                resource = processRepositoryGroup( request, archivaLocator, repositories, activePrincipal,
                                                   resourcesInAbsolutePath );
            }
        }
        else
        {
            ManagedRepositoryContent managedRepository = null;

            try
            {
                managedRepository = repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
            }
            catch ( RepositoryNotFoundException e )
            {
                throw new DavException( HttpServletResponse.SC_NOT_FOUND,
                                        "Invalid repository: " + archivaLocator.getRepositoryId() );
            }
            catch ( RepositoryException e )
            {
                throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
            }

            log.debug( "Managed repository '" + managedRepository.getId() + "' accessed by '" + activePrincipal + "'" );

            resource = processRepository( request, archivaLocator, activePrincipal, managedRepository );

            String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
            resourcesInAbsolutePath.add( new File( managedRepository.getRepoRoot(),
                                                   logicalResource ).getAbsolutePath() );
        }

        String requestedResource = request.getRequestURI();

        // MRM-872 : merge all available metadata
        // merge metadata only when requested via the repo group
        if ( ( repositoryRequest.isMetadata( requestedResource ) || repositoryRequest.isMetadataSupportFile(
            requestedResource ) ) && repoGroupConfig != null )
        {
            // this should only be at the project level not version level!
            if ( isProjectReference( requestedResource ) )
            {
                String artifactId = StringUtils.substringBeforeLast( requestedResource.replace( '\\', '/' ), "/" );
                artifactId = StringUtils.substringAfterLast( artifactId, "/" );

                ArchivaDavResource res = (ArchivaDavResource) resource;
                String filePath = StringUtils.substringBeforeLast( res.getLocalResource().getAbsolutePath().replace(
                    '\\', '/' ), "/" );
                filePath = filePath + "/maven-metadata-" + repoGroupConfig.getId() + ".xml";

                // for MRM-872 handle checksums of the merged metadata files
                if ( repositoryRequest.isSupportFile( requestedResource ) )
                {
                    File metadataChecksum = new File( filePath + "." + StringUtils.substringAfterLast(
View Full Code Here

    }
 
    private List<String> getRepositoriesFromGroup()
    {
        Configuration config = archivaConfiguration.getConfiguration();
        RepositoryGroupConfiguration repoGroup = config.findRepositoryGroupById( repoGroupId );
        return repoGroup.getRepositories();
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.archiva.configuration.RepositoryGroupConfiguration

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.