jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Archiva
  • MRM-153

when used as a maven1 proxy, Archiva should handle relocation from maven2 poms

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.0-beta-2
  • Component/s: None
  • Labels:
    None
  • Environment:
    Archiva as a repository proxy for maven1
  • Patch Submitted:
    Yes

Description

When a maven1 client asks for /servletapi/jars/servletapi-2.4.jar, Archiva converts path to the maven2 location of this artifact. As maven1 has no relocation support, the jar is required in the repo.
Archiva can be more that a proxy : download the artifact POM, read relocation infos, and return the relocated jar.

attached Patch add a new "applyRelocation" to DefaultProxyManager.
I've tried this code with the servletapi example, but it may be bad designed as I just discovered maven / archiva APIs.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    DefaultProxyManager.java.patch
    28/Aug/06 5:30 AM
    6 kB
    nicolas de loof
  2. Text File
    DefaultProxyManager.java.patch
    28/Aug/06 3:49 AM
    5 kB
    nicolas de loof
  3. Text File
    MRM-153.patch
    31/Aug/06 4:18 AM
    20 kB
    nicolas de loof
  4. Text File
    MRM153-1.0-beta-2.patch
    14/Sep/07 10:59 AM
    6 kB
    nicolas de loof
  5. Text File
    MRM153-reopened.patch
    14/Feb/07 7:07 AM
    82 kB
    nicolas de loof
  6. Text File
    MRM153-reopened+MRM-268.patch
    14/Feb/07 7:57 AM
    87 kB
    nicolas de loof
  7. Text File
    MRM-153-test.patch
    29/Aug/06 5:42 AM
    101 kB
    nicolas de loof
  8. Text File
    MRM-155.patch
    31/Aug/06 2:20 AM
    8 kB
    nicolas de loof
  9. Text File
    patch.patch
    24/Aug/06 2:37 AM
    6 kB
    nicolas de loof

Issue Links

is duplicated by

Bug - A problem which impairs or prevents the functions of the product. MRM-309 relocated artifacts are not delivered

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
nicolas de loof added a comment - 28/Aug/06 3:49 AM

Patch updated for "archiva" renamed project.

Show
nicolas de loof added a comment - 28/Aug/06 3:49 AM Patch updated for "archiva" renamed project.
Hide
Permalink
nicolas de loof added a comment - 28/Aug/06 5:30 AM

Patch updated to allow request for checksum on a relocated artifact to return the checksum of the relocated artifact.

Show
nicolas de loof added a comment - 28/Aug/06 5:30 AM Patch updated to allow request for checksum on a relocated artifact to return the checksum of the relocated artifact.
Hide
Permalink
nicolas de loof added a comment - 29/Aug/06 5:42 AM

Testcase that uses servletapi POM to relocate a maven1 request.

Show
nicolas de loof added a comment - 29/Aug/06 5:42 AM Testcase that uses servletapi POM to relocate a maven1 request.
Hide
Permalink
Brett Porter added a comment - 30/Aug/06 1:48 AM

Hi Nicolas. The test looks pretty, good, but some comments:

  • this will require downloading from ibiblio, which is not very good. I think it would be better to have the 'managed' repository created in, say, target/test/managed-repository instead of src/test/maven-2.x-repository, and use maven-2.x repository as the proxy repo (using file:// ... as the URL)
  • in the patch, you should omit binary files. Besides, its not necessary to have a full size servlet jar for this test
  • the code and test should be in the proxy module instead of core. The code should be part of the proxy request handler instead of being done in the proxy manager. This can guarantee it gets done after the POM is downloaded, whereas this technique I think will fail if the POM was not already present.

Can you review the patch? Thanks!

If you could submit a single diff file for the proxy module that would be most helpful.

Show
Brett Porter added a comment - 30/Aug/06 1:48 AM Hi Nicolas. The test looks pretty, good, but some comments:
  • this will require downloading from ibiblio, which is not very good. I think it would be better to have the 'managed' repository created in, say, target/test/managed-repository instead of src/test/maven-2.x-repository, and use maven-2.x repository as the proxy repo (using file:// ... as the URL)
  • in the patch, you should omit binary files. Besides, its not necessary to have a full size servlet jar for this test
  • the code and test should be in the proxy module instead of core. The code should be part of the proxy request handler instead of being done in the proxy manager. This can guarantee it gets done after the POM is downloaded, whereas this technique I think will fail if the POM was not already present.
Can you review the patch? Thanks! If you could submit a single diff file for the proxy module that would be most helpful.
Hide
Permalink
nicolas de loof added a comment - 31/Aug/06 2:20 AM

Repackaged patch to include testcase.

adds "testLegacyRequestConvertedToMaven2PathInManagedRepo" to ProxyRequestHandlerTest.

Show
nicolas de loof added a comment - 31/Aug/06 2:20 AM Repackaged patch to include testcase. adds "testLegacyRequestConvertedToMaven2PathInManagedRepo" to ProxyRequestHandlerTest.
Hide
Permalink
nicolas de loof added a comment - 31/Aug/06 2:29 AM

Please don't mind my patch name is "MRM-155" as it is a typo. This patch file IS related to MRM-153

Show
nicolas de loof added a comment - 31/Aug/06 2:29 AM Please don't mind my patch name is "MRM-155" as it is a typo. This patch file IS related to MRM-153
Hide
Permalink
nicolas de loof added a comment - 31/Aug/06 2:35 AM

I realy have troubles with numbers. Please don't care this patch that IS for MRM-155 and has been also attached to MRM-155 issue. I'll provide a patch for MRM-153 (this one) latter.

Sory for noise...

Show
nicolas de loof added a comment - 31/Aug/06 2:35 AM I realy have troubles with numbers. Please don't care this patch that IS for MRM-155 and has been also attached to MRM-155 issue. I'll provide a patch for MRM-153 (this one) latter. Sory for noise...
Hide
Permalink
nicolas de loof added a comment - 31/Aug/06 4:18 AM

This patch moves the relocation handling in DefaultProxyRequestHandler (archiva-proxy). No more change on archiva-core is required.
Testcase is included for artecfact + checksum relocation on maven1 request.

This patch requires some logic change on the DefaultProxyRequestHandler.get() :
Artifact layout is discovered BEFORE proxies are used to get the file. This require to handle checksums, metadata and unknown file before requesting proxied repositories.

I moved metadata and unknown files handling in a dedicated method to clarify code.

Please note this patch includes correction for issue MRM-155 as managed repository path is build during artifact discovery, so my patch for MRM-155 gets obsolete if this patch is applied.

Show
nicolas de loof added a comment - 31/Aug/06 4:18 AM This patch moves the relocation handling in DefaultProxyRequestHandler (archiva-proxy). No more change on archiva-core is required. Testcase is included for artecfact + checksum relocation on maven1 request. This patch requires some logic change on the DefaultProxyRequestHandler.get() : Artifact layout is discovered BEFORE proxies are used to get the file. This require to handle checksums, metadata and unknown file before requesting proxied repositories. I moved metadata and unknown files handling in a dedicated method to clarify code. Please note this patch includes correction for issue MRM-155 as managed repository path is build during artifact discovery, so my patch for MRM-155 gets obsolete if this patch is applied.
Hide
Permalink
Brett Porter added a comment - 31/Aug/06 11:20 PM

there are a number of issues with this that I am reworking:

  • the same ones highlighted in MRM-155
  • incorrect assumptions about the location of the POM
  • didn't test m2 relocations at all
  • exception handling in the relocation was not ideal
  • applyRelocation didn't need to return artifact, it modifies the passed in instance
Show
Brett Porter added a comment - 31/Aug/06 11:20 PM there are a number of issues with this that I am reworking:
  • the same ones highlighted in MRM-155
  • incorrect assumptions about the location of the POM
  • didn't test m2 relocations at all
  • exception handling in the relocation was not ideal
  • applyRelocation didn't need to return artifact, it modifies the passed in instance
Hide
Permalink
nicolas de loof added a comment - 07/Feb/07 9:12 AM

This feature is broken by the use of DAV repository in place of the original "/proxy" path.

in ProxiedDavServer :
if ( WebdavMethodUtil.isReadMethod( request.getRequest().getMethod() ) )
{
if ( !hasResource( request.getLogicalResource() ) )

{ fetchContentFromProxies( request ); }

}
davServer.process( request, response );

> The relocation is handled in fetchContentFromProxies( request ); but the relocated path is not reported in the request

The request can be updated, but this requires to convert the File object into a path in the managed repository. I solved this by using :

File file = proxyRequestHandler.get( request.getLogicalResource(), this.proxiedRepositories, this.managedRepository,
this.wagonProxy );
File baseDir = new File( this.managedRepository.getBasedir() );
String path = file.getAbsolutePath().substring( baseDir.getAbsolutePath().length() );
request.getRequest().setPathInfo( path );

... but those absolutePath.substring don't look very clean. Is there any other way to compute this Path from the File object and the managedRepository ? An alternative would be to return a "RepositoryEntry" in place of a File, that would contain both File and path.

Show
nicolas de loof added a comment - 07/Feb/07 9:12 AM This feature is broken by the use of DAV repository in place of the original "/proxy" path. in ProxiedDavServer : if ( WebdavMethodUtil.isReadMethod( request.getRequest().getMethod() ) ) { if ( !hasResource( request.getLogicalResource() ) ) { fetchContentFromProxies( request ); } } davServer.process( request, response ); > The relocation is handled in fetchContentFromProxies( request ); but the relocated path is not reported in the request The request can be updated, but this requires to convert the File object into a path in the managed repository. I solved this by using : File file = proxyRequestHandler.get( request.getLogicalResource(), this.proxiedRepositories, this.managedRepository, this.wagonProxy ); File baseDir = new File( this.managedRepository.getBasedir() ); String path = file.getAbsolutePath().substring( baseDir.getAbsolutePath().length() ); request.getRequest().setPathInfo( path ); ... but those absolutePath.substring don't look very clean. Is there any other way to compute this Path from the File object and the managedRepository ? An alternative would be to return a "RepositoryEntry" in place of a File, that would contain both File and path.
Hide
Permalink
nicolas de loof added a comment - 14/Feb/07 7:07 AM

This patch changes ProxyRequestHandler to return a ProxiedArtifact with both File and (relocated) Path.

Show
nicolas de loof added a comment - 14/Feb/07 7:07 AM This patch changes ProxyRequestHandler to return a ProxiedArtifact with both File and (relocated) Path.
Hide
Permalink
nicolas de loof added a comment - 14/Feb/07 7:57 AM

This latest patch includes previous but also fixes MRM-268 :

as Maven2 request come from maven2 we can expect the client to handle relocation, and the client expecet archiva to return the expected artifact (a POM) with no internal relocation.

Previous patch also was missing the ProxiedArtifact class.

Show
nicolas de loof added a comment - 14/Feb/07 7:57 AM This latest patch includes previous but also fixes MRM-268 : as Maven2 request come from maven2 we can expect the client to handle relocation, and the client expecet archiva to return the expected artifact (a POM) with no internal relocation. Previous patch also was missing the ProxiedArtifact class.
Hide
Permalink
Arnaud Heritier added a comment - 10/May/07 5:31 PM

MRM153-reopened+MRM-268.patch applied in 0.9 branch

Show
Arnaud Heritier added a comment - 10/May/07 5:31 PM MRM153-reopened+MRM-268.patch applied in 0.9 branch
Hide
Permalink
Brett Porter added a comment - 31/Jul/07 3:06 AM

need to test this still works in 1.0-*, as it was applied for 0.9

Show
Brett Porter added a comment - 31/Jul/07 3:06 AM need to test this still works in 1.0-*, as it was applied for 0.9
Hide
Permalink
nicolas de loof added a comment - 14/Sep/07 10:59 AM

This patch has been tested on 1.0-beta-2-SNAPSHOT (rev 575722)

It allows to get a relocated artifact using either :

maven2 request :
http://localhost:8080/archiva/repository/internal/servletapi/servletapi/2.3/servletapi-2.3.pom
<"client-side" relocation>
http://localhost:8080/archiva/repository/internal/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar

maven1 request :
http://localhost:8080/archiva/repository/internal/javax.servlet/jars/servlet-api-2.3.jar
or <"server-side" relocation>
http://localhost:8080/archiva/repository/internal/servletapi/jars/servletapi-2.3.jar

I'd like to write some junit test but I'm not familiar with plexus and how to test servlet-based code. Maybe some integration-test would be helpfull ?

Show
nicolas de loof added a comment - 14/Sep/07 10:59 AM This patch has been tested on 1.0-beta-2-SNAPSHOT (rev 575722) It allows to get a relocated artifact using either : maven2 request : http://localhost:8080/archiva/repository/internal/servletapi/servletapi/2.3/servletapi-2.3.pom <"client-side" relocation> http://localhost:8080/archiva/repository/internal/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar maven1 request : http://localhost:8080/archiva/repository/internal/javax.servlet/jars/servlet-api-2.3.jar or <"server-side" relocation> http://localhost:8080/archiva/repository/internal/servletapi/jars/servletapi-2.3.jar I'd like to write some junit test but I'm not familiar with plexus and how to test servlet-based code. Maybe some integration-test would be helpfull ?
Hide
Permalink
Maria Odea Ching added a comment - 16/Sep/07 12:19 AM

Patch applied (-r576032)

Thanks!

Show
Maria Odea Ching added a comment - 16/Sep/07 12:19 AM Patch applied (-r576032) Thanks!

People

  • Assignee:
    Brett Porter
    Reporter:
    nicolas de loof
Vote (0)
Watch (0)

Dates

  • Created:
    24/Aug/06 2:37 AM
    Updated:
    02/Oct/07 1:59 PM
    Resolved:
    16/Sep/07 12:19 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.