You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by bo...@apache.org on 2007/08/31 06:31:23 UTC
svn commit: r571369 - in
/gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources:
GumpArtifact.java LogEntry.java LogFile.java
Author: bodewig
Date: Thu Aug 30 21:31:22 2007
New Revision: 571369
URL: http://svn.apache.org/viewvc?rev=571369&view=rev
Log:
add logging
Added:
gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogEntry.java
gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogFile.java
Modified:
gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/GumpArtifact.java
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=571369&r1=571368&r2=571369&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 Thu Aug 30 21:31:22 2007
@@ -18,6 +18,8 @@
package org.apache.gump.mvnrepo.resources;
+import java.util.ArrayList;
+
import org.apache.gump.mvnrepo.Constants;
import org.apache.gump.mvnrepo.Registry;
import org.apache.gump.mvnrepo.restlets.Proxy;
@@ -36,6 +38,7 @@
public abstract class GumpArtifact extends Resource {
private final String fileName;
+ private static final ArrayList<LogEntry> served = new ArrayList<LogEntry>();
public GumpArtifact(Context ctx, Request request, Response response,
Variant type) {
@@ -65,6 +68,13 @@
Constants.MVN_REPO_HOST + getURITemplate())
.serve(getRequest(), getResponse());
}
+ }
+
+ /**
+ * The artifacts served so far.
+ */
+ static final LogEntry[] getServedArtifacts() {
+ return served.toArray(new LogEntry[0]);
}
private void log(String start) {
Added: 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=571369&view=auto
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogEntry.java (added)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogEntry.java Thu Aug 30 21:31:22 2007
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+import java.util.Date;
+
+/**
+ * Encapsulates information about artifacts served.
+ */
+class LogEntry {
+ private final boolean proxied;
+ private final Date servedAt;
+ private final String artifactName;
+
+ LogEntry(boolean proxied, String artifactName) {
+ this.proxied = proxied;
+ this.servedAt = new Date();
+ this.artifactName = artifactName;
+ }
+
+ public String getArtifactName() {return artifactName;}
+ public Date getServedAt() {return servedAt;}
+ public boolean hasBeenProxied() {return proxied;}
+}
Added: 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=571369&view=auto
==============================================================================
--- gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogFile.java (added)
+++ gump/mvnrepo/trunk/src/java/org/apache/gump/mvnrepo/resources/LogFile.java Thu Aug 30 21:31:22 2007
@@ -0,0 +1,110 @@
+/*
+ * 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;
+
+import org.restlet.Context;
+import org.restlet.data.MediaType;
+import org.restlet.data.Request;
+import org.restlet.data.Response;
+import org.restlet.resource.Resource;
+import org.restlet.resource.Representation;
+import org.restlet.resource.StringRepresentation;
+import org.restlet.resource.Variant;
+
+public class LogFile extends Resource {
+
+ private static final String HEAD =
+ "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
+ + "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
+ + "<!-- Automatically Generated by Gump Maven2 Repository: http://gump.apache.org/ -->\n"
+ + "<html>\n"
+ + " <head>\n"
+ + " <title>Gump Maven2 Repository Log</title>\n"
+ + " <meta name=\"author\" content=\"general@gump.apache.org\"/>\n"
+ + " <meta name=\"copyright\" content=\"Apache Software Foundation\"/>\n"
+ + " <link rel=\"stylesheet\" type=\"text/css\" href=\"./css/style.css\" title=\"Style\"/>\n"
+ + " </head>\n"
+ + "<body>\n"
+ + "<table class=\"TRANSPARENT\">\n"
+ + " <tr>\n"
+ + " <td><a href=\"./index.html\">Run</a></td><td>|</td>\n"
+ + " <td><a href=\"./workspace.html\">Workspace</a></td><td>|</td>\n"
+ + " <td><a href=\"./buildLog.html\">Log</a></td><td>|</td>\n"
+ + " <td><a href=\"./project_todos.html\">Issues</a></td><td>|</td>\n"
+ + " <td><a href=\"./project_fixes.html\">Fixes</a></td><td>|</td>\n"
+ + " <td><a href=\"./project_prereqs.html\">Pre-reqs</a></td><td>|</td>\n"
+ + " <td><a href=\"./gump_stats/index.html\">Stats</a></td><td>|</td>\n"
+ + " <td><a href=\"./gump_xref/index.html\">XRef</a></td>\n"
+ + " <td colspan=\"3\"><img align=\"right\" src=\"./images/gump-logo.png\" alt=\"Gump Logo\"/></td>\n"
+ + " </tr>\n"
+ + "</table>\n"
+ + "<h3>Artifacts served (in request order)</h3>\n"
+ + "<table>\n"
+ + "<tr>\n"
+ + "<th>Index</th>\n"
+ + "<th>Time</th>\n"
+ + "<th>Name</th>\n"
+ + "<th>State</th>\n"
+ + "<th>Notes</th>\n"
+ + "</tr>\n";
+
+ private static final String LINE_PATTERN =
+ "<tr class=\"%1$\">\n"
+ + "<td>%2$</td>\n"
+ + "<td>%3$tc</td>\n"
+ + "<td>%4$</td>\n"
+ + "<td>%5$</td>\n"
+ + "<td></td>\n"
+ + "</tr>\n";
+
+ private static final String FOOT_PATTERN =
+ "</table>\n"
+ + "</body>\n"
+ + "<p align=\"right\">Last Updated: %1$tc</p>\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/success.png' alt='Failed' />";
+
+ public LogFile(Context ctx, Request request, Response response) {
+ super(ctx, request, response);
+ getVariants().add(new Variant(MediaType.TEXT_HTML));
+ }
+
+ @Override
+ public Representation getRepresentation(Variant v) {
+ StringBuilder result = new StringBuilder(HEAD);
+ int i = 1;
+ for (LogEntry entry : GumpArtifact.getServedArtifacts()) {
+ result.append(String.format(LINE_PATTERN,
+ !entry.hasBeenProxied()
+ ? "SUCCESS" : "FAILURE",
+ i++, entry.getServedAt(),
+ entry.getArtifactName(),
+ entry.hasBeenProxied()
+ ? SUCCESS_ICON : PROXIED_ICON));
+ }
+ result.append(String.format(FOOT_PATTERN, new java.util.Date()));
+ return new StringRepresentation(result, MediaType.TEXT_HTML);
+ }
+
+}
\ No newline at end of file