gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r790786 - in /gump/mvnrepo/trunk: ./ src/java/org/apache/gump/mvnrepoproxy/ src/java/org/apache/gump/mvnrepoproxy/resources/ src/java/org/apache/gump/mvnrepoproxy/restlets/
Date Fri, 03 Jul 2009 04:47:57 GMT
Author: bodewig
Date: Fri Jul  3 04:47:56 2009
New Revision: 790786

URL: http://svn.apache.org/viewvc?rev=790786&view=rev
Log:
first steps at serving POMs as well

Modified:
    gump/mvnrepo/trunk/build.xml
    gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Constants.java
    gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Main.java
    gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Registry.java
    gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/Checksum.java
    gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/GumpArtifact.java
    gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/Jar.java
    gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/restlets/ArtifactAdder.java

Modified: gump/mvnrepo/trunk/build.xml
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/build.xml?rev=790786&r1=790785&r2=790786&view=diff
==============================================================================
--- gump/mvnrepo/trunk/build.xml (original)
+++ gump/mvnrepo/trunk/build.xml Fri Jul  3 04:47:56 2009
@@ -14,7 +14,7 @@
 
   <target name="compile" depends="init">
     <javac srcdir="src/java" destdir="${classes.dir}" source="5"
-           deprecation="true"
+           deprecation="true" includeantruntime="false"
            target="5" debug="true">
       <classpath>
         <fileset dir="lib"/>

Modified: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Constants.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Constants.java?rev=790786&r1=790785&r2=790786&view=diff
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Constants.java (original)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Constants.java Fri Jul  3 04:47:56
2009
@@ -36,10 +36,21 @@
     String ARTIFACT_ID = "artifactId";
 
     /**
+     * Artifact Type for jars.
+     */
+    String JAR_TYPE = ".jar";
+
+    /**
+     * Artifact Type for POMs.
+     */
+    String POM_TYPE = ".pom";
+
+    /**
      * URL template that matches requests for jars by mvn
      */
     String JAR_ARTIFACT_TEMPLATE
-        = "/{" + GROUP_ID + "}/{" + ARTIFACT_ID + "}/{version}/{jarname}.jar";
+        = "/{" + GROUP_ID + "}/{" + ARTIFACT_ID + "}/{version}/{jarname}"
+        + JAR_TYPE;
 
     /**
      * parameter representing the checksum algorithm
@@ -47,12 +58,25 @@
     String CS_ALGORITHM = "algorithm";
 
     /**
-     * URL template that matches requests for checksums by mvn
+     * URL template that matches requests for checksums of jars by mvn
      */
-    String CHECKSUM_ARTIFACT_TEMPLATE
+    String JAR_CHECKSUM_ARTIFACT_TEMPLATE
         = JAR_ARTIFACT_TEMPLATE + ".{" + CS_ALGORITHM + "}";
 
     /**
+     * URL template that matches requests for POMs by mvn
+     */
+    String POM_ARTIFACT_TEMPLATE
+        = "/{" + GROUP_ID + "}/{" + ARTIFACT_ID + "}/{version}/{pomname}"
+        + POM_TYPE;
+
+    /**
+     * URL template that matches requests for checksums of POMs by mvn
+     */
+    String POM_CHECKSUM_ARTIFACT_TEMPLATE
+        = POM_ARTIFACT_TEMPLATE + ".{" + CS_ALGORITHM + "}";
+
+    /**
      * parameter representing the filename
      */
     String FILE_NAME = "file";
@@ -63,8 +87,13 @@
     Variant JAR_VARIANT = new Variant(MediaType.APPLICATION_JAVA_ARCHIVE);
 
     /**
-     * Variant used for JAR files
+     * Variant used for checksum files
      */
     Variant CHECKSUM_VARIANT = new Variant(MediaType.TEXT_PLAIN);
 
+    /**
+     * Variant used for POM files
+     */
+    Variant POM_VARIANT = new Variant(MediaType.TEXT_XML);
+
 }
\ No newline at end of file

Modified: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Main.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Main.java?rev=790786&r1=790785&r2=790786&view=diff
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Main.java (original)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Main.java Fri Jul  3 04:47:56
2009
@@ -139,7 +139,7 @@
     private static void attachResources(Router router, String prefix) {
         attachResource(router, prefix, Constants.JAR_ARTIFACT_TEMPLATE,
                        Jar.class);
-        attachResource(router, prefix, Constants.CHECKSUM_ARTIFACT_TEMPLATE,
+        attachResource(router, prefix, Constants.JAR_CHECKSUM_ARTIFACT_TEMPLATE,
                        Checksum.class);
     }
 

Modified: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Registry.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Registry.java?rev=790786&r1=790785&r2=790786&view=diff
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Registry.java (original)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/Registry.java Fri Jul  3 04:47:56
2009
@@ -26,29 +26,33 @@
  */
 public class Registry {
 
-    // {groupId, artifactId} -> local file name
+    // {groupId, artifactId, type} -> local file name
     private static final Map<Key, String> knownArtifacts
         = new HashMap<Key, String>();
 
     /**
-     * Adds an artifact mapping {group, artifact} -> local file name
+     * Adds an artifact mapping {group, artifact, type} -&gt; local file name
      */
     public static void addArtifact(String group, String artifactId,
+                                   String artifactType,
                                    String fileName) {
-	knownArtifacts.put(new Key(group, artifactId), fileName);
+	knownArtifacts.put(new Key(group, artifactId, artifactType), fileName);
     }
 
-    public static String getArtifactPath(String groupId, String artifactId) {
-	return knownArtifacts.get(new Key(groupId, artifactId));
+    public static String getArtifactPath(String groupId, String artifactId,
+                                         String artifactType) {
+	return knownArtifacts.get(new Key(groupId, artifactId, artifactType));
     }
 
     private static class Key {
 	private final String groupId;
 	private final String artifactId;
+        private final String type;
 
-	Key(String groupId, String artifactId) {
+	Key(String groupId, String artifactId, String type) {
 	    this.groupId = groupId;
 	    this.artifactId = artifactId;
+            this.type = type;
 	}
 
 	@Override
@@ -58,12 +62,14 @@
 	    }
 	    Key other = (Key) o;
 	    return groupId.equals(other.groupId)
-		&& artifactId.equals(other.artifactId);
+		&& artifactId.equals(other.artifactId)
+                && type.equals(other.type);
 	}
 
 	@Override
 	public int hashCode() {
-	    return groupId.hashCode() + 7 * artifactId.hashCode();
+	    return type.hashCode() + 
+                13 * (groupId.hashCode() + 7 * artifactId.hashCode());
 	}
     }
 }
\ No newline at end of file

Modified: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/Checksum.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/Checksum.java?rev=790786&r1=790785&r2=790786&view=diff
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/Checksum.java (original)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/Checksum.java Fri Jul
 3 04:47:56 2009
@@ -39,7 +39,8 @@
     private final String algorithm;
 
     public Checksum(Context ctx, Request request, Response response) {
-        super(ctx, request, response, Constants.CHECKSUM_VARIANT);
+        super(ctx, request, response, Constants.CHECKSUM_VARIANT,
+              Constants.JAR_TYPE);
         this.algorithm =
             (String) request.getAttributes().get(Constants.CS_ALGORITHM);
     }
@@ -89,7 +90,7 @@
     }
 
     @Override
-    protected String getArtifactType() {
-        return algorithm + " checksum";
+    protected String getArtifactQualifier() {
+        return " " + algorithm + " checksum";
     }
 }
\ No newline at end of file

Modified: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/GumpArtifact.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/GumpArtifact.java?rev=790786&r1=790785&r2=790786&view=diff
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/GumpArtifact.java (original)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/GumpArtifact.java Fri
Jul  3 04:47:56 2009
@@ -39,19 +39,21 @@
 public abstract class GumpArtifact extends Resource {
 
     private final String fileName;
+    private final String artifactType;
     private static final ArrayList<LogEntry> served = new ArrayList<LogEntry>();
 
     public GumpArtifact(Context ctx, Request request, Response response,
-                        Variant type) {
+                        Variant type, String artifactType) {
         super(ctx, request, response);
+        this.artifactType = artifactType;
         fileName = Registry.getArtifactPath(getGroupId(request),
                                             (String) request.getAttributes()
-                                            .get(Constants.ARTIFACT_ID));
+                                            .get(Constants.ARTIFACT_ID),
+                                            artifactType);
         getVariants().add(type);
     }
 
     protected abstract Representation getRepresentation(String fileName);
-    protected abstract String getArtifactType();
 
     /**
      * The local file or a proxied request
@@ -81,7 +83,7 @@
     }
 
     private void log(String start) {
-        getLogger().info(start + " " + getArtifactType()
+        getLogger().info(start + " " + artifactType + getArtifactQualifier()
                          + " artifact for groupId '"
                          + getGroupId()
                          + "' and artifactId '"
@@ -95,6 +97,10 @@
         return getGroupId(getRequest());
     }
 
+    protected String getArtifactQualifier() {
+        return "";
+    }
+
     protected static String getGroupId(Request request) {
         String s = (String) request.getAttributes().get(Constants.GROUP_ID);
         return s != null ? s.replace("/", ".") : s;

Modified: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/Jar.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/Jar.java?rev=790786&r1=790785&r2=790786&view=diff
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/Jar.java (original)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/resources/Jar.java Fri Jul  3
04:47:56 2009
@@ -33,7 +33,7 @@
 public class Jar extends GumpArtifact {
 
     public Jar(Context ctx, Request request, Response response) {
-        super(ctx, request, response, Constants.JAR_VARIANT);
+        super(ctx, request, response, Constants.JAR_VARIANT, Constants.JAR_TYPE);
     }
 
     @Override
@@ -43,8 +43,4 @@
                                       300);
     }
 
-    @Override
-    protected String getArtifactType() {
-        return "jar";
-    }
 }
\ No newline at end of file

Modified: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/restlets/ArtifactAdder.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/restlets/ArtifactAdder.java?rev=790786&r1=790785&r2=790786&view=diff
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/restlets/ArtifactAdder.java (original)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepoproxy/restlets/ArtifactAdder.java Fri
Jul  3 04:47:56 2009
@@ -44,11 +44,14 @@
                          + "' and file name '"
                          + request.getAttributes().get(Constants.FILE_NAME)
                          + "'");
+        String fileName =
+            (String) request.getAttributes().get(Constants.FILE_NAME);
         Registry.addArtifact((String) request.getAttributes()
 			     .get(Constants.GROUP_ID),
 			     (String) request.getAttributes()
 			     .get(Constants.ARTIFACT_ID),
-			     (String) request.getAttributes()
-			     .get(Constants.FILE_NAME));
+                             fileName.endsWith(Constants.POM_TYPE)
+                             ? Constants.POM_TYPE : Constants.JAR_TYPE,
+			     fileName);
     }
 }
\ No newline at end of file



Mime
View raw message