gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r571428 - in /gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources: ArtifactState.java GumpArtifact.java LogEntry.java LogFile.java
Date Fri, 31 Aug 2007 10:52:29 GMT
Author: bodewig
Date: Fri Aug 31 03:52:28 2007
New Revision: 571428

URL: http://svn.apache.org/viewvc?rev=571428&view=rev
Log:
simplify a bit by using an enum

Added:
    gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/ArtifactState.java   (with
props)
Modified:
    gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/GumpArtifact.java
    gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogEntry.java
    gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogFile.java

Added: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/ArtifactState.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/ArtifactState.java?rev=571428&view=auto
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/ArtifactState.java (added)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/ArtifactState.java Fri Aug
31 03:52:28 2007
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.gump.mvnrepo.resources;
+
+enum ArtifactState {
+    PROXIED("complete"), FROM_FILE("success");
+
+    private final String cssClass;
+
+    private ArtifactState(String cssClass) {
+        this.cssClass = cssClass;
+    }
+
+    String getCssClass() {
+        return cssClass;
+    }
+}
\ No newline at end of file

Propchange: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/ArtifactState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/GumpArtifact.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/GumpArtifact.java?rev=571428&r1=571427&r2=571428&view=diff
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/GumpArtifact.java (original)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/GumpArtifact.java Fri Aug
31 03:52:28 2007
@@ -59,7 +59,9 @@
      */
     @Override
     public Representation getRepresentation(Variant v) {
-        served.add(new LogEntry(fileName == null,
+        served.add(new LogEntry(fileName != null
+                                ? ArtifactState.FROM_FILE
+                                : ArtifactState.PROXIED,
                                 getRequest().getResourceRef().getPath()));
         if (fileName != null) {
             log("serving " + fileName + " as");

Modified: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogEntry.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogEntry.java?rev=571428&r1=571427&r2=571428&view=diff
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogEntry.java (original)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogEntry.java Fri Aug 31
03:52:28 2007
@@ -24,17 +24,17 @@
  * Encapsulates information about artifacts served.
  */
 class LogEntry {
-    private final boolean proxied;
+    private final ArtifactState state;
     private final Date servedAt;
     private final String artifactName;
 
-    LogEntry(boolean proxied, String artifactName) {
-	this.proxied = proxied;
+    LogEntry(ArtifactState state, String artifactName) {
+	this.state = state;
 	this.servedAt = new Date();
 	this.artifactName = artifactName;
     }
 
     public String getArtifactName() {return artifactName;}
     public Date getServedAt() {return servedAt;}
-    public boolean hasBeenProxied() {return proxied;}
+    public ArtifactState getState() {return state;}
 }

Modified: gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogFile.java
URL: http://svn.apache.org/viewvc/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogFile.java?rev=571428&r1=571427&r2=571428&view=diff
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogFile.java (original)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogFile.java Fri Aug 31
03:52:28 2007
@@ -65,11 +65,11 @@
 	+ "</tr>\n";
 
     private static final String LINE_PATTERN =
-	"<tr class=\"%1$s\">\n"
+	"<tr class=\"%1$S\">\n"
 	+ "<td>%2$d</td>\n"
 	+ "<td>%3$tc</td>\n"
 	+ "<td>%4$s</td>\n"
-	+ "<td>%5$s</td>\n"
+	+ "<td><img src='gump_icons/%1$s.png' alt='%5$s'/></td>\n"
 	+ "<td></td>\n"
 	+ "</tr>\n";
 
@@ -79,12 +79,6 @@
 	+ "</body>\n"
 	+ "</html>\n";
 
-    private static final String SUCCESS_ICON =
-	"<img src='gump_icons/success.png' alt='Success' />";
-
-    private static final String PROXIED_ICON =
-	"<img src='gump_icons/complete.png' alt='Proxied' />";
-
     public LogFile(Context ctx, Request request, Response response) {
         super(ctx, request, response);
         getVariants().add(new Variant(MediaType.TEXT_HTML));
@@ -96,12 +90,10 @@
 	int i = 1;
 	for (LogEntry entry : GumpArtifact.getServedArtifacts()) {
 	    result.append(String.format(LINE_PATTERN,
-					!entry.hasBeenProxied()
-					? "SUCCESS" : "COMPLETE",
+					entry.getState().getCssClass(),
 					i++, entry.getServedAt(),
 					entry.getArtifactName(),
-					!entry.hasBeenProxied()
-					? SUCCESS_ICON : PROXIED_ICON));
+					entry.getState()));
 	}
 	result.append(String.format(FOOT_PATTERN, new java.util.Date()));
 	return new StringRepresentation(result, MediaType.TEXT_HTML);



Mime
View raw message