Examples of BidirectionalRepositoryLayout


Examples of org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout

    private String toPath( ArchivaArtifact artifact )
    {
        try
        {
            BidirectionalRepositoryLayout layout = layoutFactory.getLayout( artifact );
            return layout.toPath( artifact );
        }
        catch ( LayoutException e )
        {
            getLogger().warn( "Unable to calculate path for artifact: " + artifact );
            return "";
View Full Code Here

Examples of org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout

    }

    protected ArtifactReference createArtifactReference( String layoutType, String path )
        throws Exception
    {
        BidirectionalRepositoryLayout layout = layoutFactory.getLayout( layoutType );
        ArchivaArtifact artifact = layout.toArtifact( path );
        ArtifactReference ref = new ArtifactReference();
        ref.setGroupId( artifact.getGroupId() );
        ref.setArtifactId( artifact.getArtifactId() );
        ref.setVersion( artifact.getVersion() );
        ref.setClassifier( artifact.getClassifier() );
View Full Code Here

Examples of org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout

    private String toPath( ArchivaArtifact artifact )
    {
        try
        {
            BidirectionalRepositoryLayout layout = layoutFactory.getLayout( artifact );
            return layout.toPath( artifact );
        }
        catch ( LayoutException e )
        {
            getLogger().warn( "Unable to calculate path for artifact: " + artifact );
            return null;
View Full Code Here

Examples of org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout

    private File toFile( ArchivaArtifact artifact )
    {
        ManagedRepositoryConfiguration repoConfig = getRepository( artifact );

        BidirectionalRepositoryLayout layout = null;

        try
        {
            layout = layoutFactory.getLayout( artifact );
        }
        catch ( LayoutException e )
        {
            getLogger().warn( "Unable to determine layout of " + artifact + ": " + e.getMessage(), e );
            return null;
        }

        return new File( repoConfig.getLocation(), layout.toPath( artifact ) );
    }
View Full Code Here

Examples of org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout

    private String toPath( ArchivaArtifact artifact )
    {
        try
        {
            BidirectionalRepositoryLayout layout = layoutFactory.getLayout( artifact );
            return layout.toPath( artifact );
        }
        catch ( LayoutException e )
        {
            getLogger().warn( "Unable to calculate path for artifact: " + artifact );
            return null;
View Full Code Here

Examples of org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout

     * @throws LayoutException
     */
    public ArtifactReference getFirstArtifact( ArchivaRepository managedRepository, VersionedReference reference )
        throws LayoutException, IOException
    {
        BidirectionalRepositoryLayout layout = layoutFactory.getLayout( managedRepository.getLayoutType() );
        String path = toPath( reference );

        int idx = path.lastIndexOf( '/' );
        if ( idx > 0 )
        {
            path = path.substring( 0, idx );
        }

        File repoDir = new File( managedRepository.getUrl().getPath(), path );

        if ( !repoDir.exists() )
        {
            throw new IOException( "Unable to gather the list of snapshot versions on a non-existant directory: " +
                repoDir.getAbsolutePath() );
        }

        if ( !repoDir.isDirectory() )
        {
            throw new IOException(
                "Unable to gather the list of snapshot versions on a non-directory: " + repoDir.getAbsolutePath() );
        }

        File repoFiles[] = repoDir.listFiles();
        for ( int i = 0; i < repoFiles.length; i++ )
        {
            if ( repoFiles[i].isDirectory() )
            {
                // Skip it. it's a directory.
                continue;
            }

            String relativePath = PathUtil.getRelative( managedRepository.getUrl().getPath(), repoFiles[i] );

            if ( matchesArtifactPattern( relativePath ) )
            {
                ArtifactReference artifact = layout.toArtifactReference( relativePath );

                return artifact;
            }
        }

View Full Code Here

Examples of org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout

     * @throws LayoutException
     */
    public Set<String> gatherSnapshotVersions( ArchivaRepository managedRepository, VersionedReference reference )
        throws LayoutException, IOException
    {
        BidirectionalRepositoryLayout layout = layoutFactory.getLayout( managedRepository.getLayoutType() );
        String path = toPath( reference );

        int idx = path.lastIndexOf( '/' );
        if ( idx > 0 )
        {
            path = path.substring( 0, idx );
        }

        File repoDir = new File( managedRepository.getUrl().getPath(), path );

        if ( !repoDir.exists() )
        {
            throw new IOException( "Unable to gather the list of snapshot versions on a non-existant directory: " +
                repoDir.getAbsolutePath() );
        }

        if ( !repoDir.isDirectory() )
        {
            throw new IOException(
                "Unable to gather the list of snapshot versions on a non-directory: " + repoDir.getAbsolutePath() );
        }

        Set<String> foundVersions = new HashSet<String>();

        // First gather up the versions found as artifacts in the managed repository.
        File repoFiles[] = repoDir.listFiles();
        for ( int i = 0; i < repoFiles.length; i++ )
        {
            if ( repoFiles[i].isDirectory() )
            {
                // Skip it. it's a directory.
                continue;
            }

            String relativePath = PathUtil.getRelative( managedRepository.getUrl().getPath(), repoFiles[i] );

            if ( matchesArtifactPattern( relativePath ) )
            {
                ArtifactReference artifact = layout.toArtifactReference( relativePath );

                if ( VersionUtil.isSnapshot( artifact.getVersion() ) )
                {
                    foundVersions.add( artifact.getVersion() );
                }
View Full Code Here

Examples of org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout

     * @throws IOException
     */
    public void updateMetadata( ArchivaRepository managedRepository, VersionedReference reference )
        throws LayoutException, RepositoryMetadataException, IOException
    {
        BidirectionalRepositoryLayout layout = layoutFactory.getLayout( managedRepository.getLayoutType() );
        File metadataFile = new File( managedRepository.getUrl().getPath(), toPath( reference ) );

        ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
        metadata.setGroupId( reference.getGroupId() );
        metadata.setArtifactId( reference.getArtifactId() );

        if ( VersionUtil.isSnapshot( reference.getVersion() ) )
        {
            // Do SNAPSHOT handling.
            metadata.setVersion( VersionUtil.getBaseVersion( reference.getVersion() ) );

            // Gather up all of the versions found in the reference dir, and any
            // proxied maven-metadata.xml files.
            Set snapshotVersions = gatherSnapshotVersions( managedRepository, reference );

            if ( snapshotVersions.isEmpty() )
            {
                throw new IOException( "Not snapshot versions found to reference." );
            }

            // sort the list to determine to aide in determining the Latest version.
            List<String> sortedVersions = new ArrayList<String>();
            sortedVersions.addAll( snapshotVersions );
            Collections.sort( sortedVersions, new VersionComparator() );

            String latestVersion = sortedVersions.get( sortedVersions.size() - 1 );

            if ( VersionUtil.isUniqueSnapshot( latestVersion ) )
            {
                // The latestVersion will contain the full version string "1.0-alpha-5-20070821.213044-8"
                // This needs to be broken down into ${base}-${timestamp}-${build_number}

                Matcher m = VersionUtil.UNIQUE_SNAPSHOT_PATTERN.matcher( latestVersion );
                if ( m.matches() )
                {
                    metadata.setSnapshotVersion( new SnapshotVersion() );
                    int buildNumber = NumberUtils.toInt( m.group( 3 ), -1 );
                    metadata.getSnapshotVersion().setBuildNumber( buildNumber );

                    Matcher mtimestamp = VersionUtil.TIMESTAMP_PATTERN.matcher( m.group( 2 ) );
                    if ( mtimestamp.matches() )
                    {
                        String tsDate = mtimestamp.group( 1 );
                        String tsTime = mtimestamp.group( 2 );
                        metadata.setLastUpdated( tsDate + tsTime );
                        metadata.getSnapshotVersion().setTimestamp( m.group( 2 ) );
                    }
                }
            }
            else if ( VersionUtil.isGenericSnapshot( latestVersion ) )
            {
                // The latestVersion ends with the generic version string.
                // Example: 1.0-alpha-5-SNAPSHOT

                metadata.setSnapshotVersion( new SnapshotVersion() );

                /* TODO: Should this be the last updated timestamp of the file, or in the case of an
                 * archive, the most recent timestamp in the archive?
                 */
                ArtifactReference artifact = getFirstArtifact( managedRepository, reference );

                if ( artifact == null )
                {
                    throw new IOException( "Not snapshot artifact found to reference in " + reference );
                }

                File artifactFile = new File( managedRepository.getUrl().getPath(), layout.toPath( artifact ) );

                if ( artifactFile.exists() )
                {
                    Date lastModified = new Date( artifactFile.lastModified() );
                    metadata.setLastUpdatedTimestamp( lastModified );
View Full Code Here

Examples of org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout

            if ( relatedArtifacts != null )
            {
                String repoId = ( (ArchivaArtifact) relatedArtifacts.get( 0 ) ).getModel().getRepositoryId();
                ArchivaRepository repo = dao.getRepositoryDAO().getRepository( repoId );
                BidirectionalRepositoryLayout layout = layoutFactory.getLayout( repo.getLayoutType() );

                String prefix = req.getContextPath() + "/repository/" + repoId;

                if ( mini )
                {
View Full Code Here

Examples of org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout

            }
        }

        // Not any of the above? Then it's gotta be an artifact reference.
        ArtifactReference artifact;
        BidirectionalRepositoryLayout resourceLayout;

        try
        {
            resourceLayout = layoutFactory.getLayoutForPath( resource );
        }
        catch ( LayoutException e )
        {
            /* invalid request - eat it */
            return;
        }

        try
        {
            artifact = resourceLayout.toArtifactReference( resource );
            if ( artifact != null )
            {
                applyServerSideRelocation( artifact );

                connectors.fetchFromProxies( managedRepository, artifact );
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.