Author: tomekopo
Date: Sat Jul 31 16:34:47 2010
New Revision: 981073
URL: http://svn.apache.org/viewvc?rev=981073&view=rev
Log:
- Added word wrap to entry content;
- Added fancy exception handler;
- Hided security fields in "add/edit endpoint" dialog box;
- Added Customer service and client (for easy interact) to sample - service
produces log entries which simulate using LogBrowser in production environment;
- Updated default AtomPullServer's pageSize from 40 to 25;
- Added restoring entry selection when change page;
- Added validation for "Copies" fiels in sample;
- Added support for arrows in entries list;
- Replace cutting message with "title" property;
- Added milliseconds to datetime format;
- Fixed clearing entries list - added removing all cells rather than clearing
content;
- Added validation for "name" and "url" in "add/edit endpoint" dialog box;
Added:
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/CustomerService.java
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/jquery-1.4.2.min.js
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/ErrorDialog.java
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/LogBrowserCss.java
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/LogBrowserResources.java
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/logbrowser.css
cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/Generate.java
cxf/sandbox/logbrowser/rt/management-web/src/test/resources/generate.html
cxf/sandbox/logbrowser/rt/management-web/src/test/resources/logging.properties
Modified:
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/App.java
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/generate.html
cxf/sandbox/logbrowser/rt/management-web/pom.xml
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/atom/AtomPullServer.java
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/LogBrowser.gwt.xml
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/LogBrowser.java
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/browser/Entry.java
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/view/BrowseView.ui.xml
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/view/BrowseViewImpl.java
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/view/EditSubcriptionView.ui.xml
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/view/EditSubcriptionWidget.java
cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/view/SettingsViewImpl.java
cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/MockApp.java
cxf/sandbox/logbrowser/rt/management-web/src/test/resources/WEB-INF/web.xml
Modified:
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/App.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/App.java?rev=981073&r1=981072&r2=981073&view=diff
==============================================================================
---
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/App.java
(original)
+++
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/App.java
Sat Jul 31 16:34:47 2010
@@ -38,8 +38,7 @@ public class App extends Application {
static {
LOGS = new AtomPullServer();
- LOGS.setPageSize(30);
- LOGS.setLogger("demo");
+ LOGS.setLoggers("demo, org.apache.cxf");
LOGS.init();
}
Added:
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/CustomerService.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/CustomerService.java?rev=981073&view=auto
==============================================================================
---
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/CustomerService.java
(added)
+++
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/CustomerService.java
Sat Jul 31 16:34:47 2010
@@ -0,0 +1,130 @@
+/**
+ * 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 demo.logbrowser.servlet;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+import static java.util.logging.Level.INFO;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.commons.lang.Validate;
+import org.apache.cxf.common.logging.LogUtils;
+
+...@path("/customerservice/")
+public class CustomerService {
+ private static final Logger LOGGER =
LogUtils.getL7dLogger(CustomerService.class);
+
+ Map<Long, Customer> customers = new HashMap<Long, Customer>();
+
+ @GET
+ @Path("/{id}/")
+ @Produces("application/json")
+ public Customer getCustomer(@PathParam("id") final String id) {
+ Validate.notNull(id);
+ Validate.notEmpty(id);
+
+ LOGGER.log(INFO, "Invoking 'getCustomer', id='{0}'", id);
+
+ return customers.get(Long.parseLong(id));
+ }
+
+ @POST
+ @Consumes("application/json")
+ public Response updateCustomer(final Customer customer) {
+ Validate.notNull(customer);
+
+ LOGGER.log(INFO, "Invoking 'updateCustomer', customer='{0}'",
customer);
+
+ if (isCustomerExisted(customer)) {
+ LOGGER.log(INFO, "Specified customer exists, update data,
customer='{0}'", customer);
+ } else {
+ LOGGER.log(INFO, "Specified customer doesn't exist, add data,
customer='{0}'", customer);
+ }
+
+ customers.put(customer.getId(), customer);
+ return Response.ok().build();
+ }
+
+ @DELETE
+ @Path("/{id}/")
+ public Response deleteCustomer(@PathParam("id") String id) {
+ Validate.notNull(id);
+ Validate.notEmpty(id);
+
+ LOGGER.log(INFO, "Invoking 'deleteCustomer', id='{0}'", id);
+
+ long identifier = Long.parseLong(id);
+
+ Response response;
+
+ if (isCustomerExisted(identifier)) {
+ response = Response.ok().build();
+ customers.remove(identifier);
+ } else {
+ response = Response.notModified().build();
+ }
+
+ return response;
+ }
+
+ private boolean isCustomerExisted(final Customer customer) {
+ return customers.get(customer.getId()) != null;
+ }
+
+ private boolean isCustomerExisted(final long id) {
+ return customers.get(id) != null;
+ }
+
+ @XmlRootElement(name = "Customer")
+ public static class Customer {
+ private long id;
+ private String name;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return "Customer{id=" + id + ", name='" + name + "'}";
+ }
+ }
+}
Modified:
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java?rev=981073&r1=981072&r2=981073&view=diff
==============================================================================
---
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java
(original)
+++
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java
Sat Jul 31 16:34:47 2010
@@ -56,11 +56,8 @@ public class Generate extends HttpServle
int copies;
try {
copies = Integer.valueOf(request.getParameter(COPIES));
- if (copies < 0) {
- copies = 1;
- }
} catch (NumberFormatException e) {
- copies = 1;
+ throw new IllegalArgumentException("'copies' has invalid format",
e);
}
assert copies >= 1;
Modified:
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml?rev=981073&r1=981072&r2=981073&view=diff
==============================================================================
---
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml
(original)
+++
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml
Sat Jul 31 16:34:47 2010
@@ -46,7 +46,22 @@
demo.logbrowser.App
</param-value>
</init-param>
-
+
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>CustomerService</servlet-name>
+ <display-name>CustomerService</display-name>
+ <servlet-class>
+ org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
+ </servlet-class>
+ <init-param>
+ <param-name>jaxrs.serviceClasses</param-name>
+ <param-value>
+ demo.logbrowser.servlet.CustomerService
+ </param-value>
+ </init-param>
<init-param>
<param-name>jaxrs.inInterceptors</param-name>
<param-value>
@@ -60,8 +75,8 @@
org.apache.cxf.interceptor.LoggingOutInterceptor
</param-value>
</init-param>
-
- <load-on-startup>2</load-on-startup>
+
+ <load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
@@ -73,5 +88,10 @@
<servlet-name>App</servlet-name>
<url-pattern>/log/*</url-pattern>
</servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>CustomerService</servlet-name>
+ <url-pattern>/generate/*</url-pattern>
+ </servlet-mapping>
</web-app>
<!-- END SNIPPET: webxml -->
\ No newline at end of file
Modified:
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/generate.html
URL:
http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/generate.html?rev=981073&r1=981072&r2=981073&view=diff
==============================================================================
---
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/generate.html
(original)
+++
cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/generate.html
Sat Jul 31 16:34:47 2010
@@ -20,48 +20,191 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
- <title>Generate log entry</title>
+ <title>Generate log entries</title>
+
<style type="text/css">
label {
- width: 5em;
- float: left;
- text-align: right;
- margin-right: 0.5em;
- display: block
+ width: 5em;
+ float: left;
+ text-align: right;
+ margin-right: 0.5em;
+ display: block;
+ }
+ .submit a {
+ margin-left: 5.5em;
}
.submit input {
- margin-left: 8em;
+ margin-left: 8em;
}
</style>
+
+ <script type="text/javascript" src="./jquery-1.4.2.min.js"></script>
+
+ <script type="text/javascript">
+ function buildCustomerAsString(id, name) {
+ return "{ \"Customer\" : { \"id\" : \"" + id + "\", \"name\" : \""
+ name +"\" } }";
+ }
+
+ $(document).ready(function() {
+ $("#addOrUpdateCustomerButton").click(function() {
+ var isError = false;
+
+ var id = $("#addOrUpdateCustomerForm
INPUT[name='customer.id']").val();
+ if (id == null || id == "") {
+ alert("Field 'ID' can't be empty");
+ isError = true;
+ }
+
+ var name = $("#addOrUpdateCustomerForm
INPUT[name='customer.name']").val();
+ if (name == null || name == "") {
+ alert("Field 'Name' can't be empty");
+ isError = true;
+ }
+
+ if (isError) {
+ return;
+ }
+
+ $.ajax({
+ type: "POST",
+ url : "/generate/customerservice/",
+ contentType : "application/json",
+ data : buildCustomerAsString(id, name),
+ complete : function(xhr) {
+ if (xhr.status == 200) {
+ alert("Customer added/updated successfully");
+ } else {
+ alert("Error occurred");
+ }
+ }
+ });
+ });
+
+ $("#getCustomerButton").click(function() {
+ var id = $("#getCustomerForm INPUT[name='customer.id']").val();
+ if (id == null || id == "") {
+ alert("Field 'ID' can't be empty");
+ return;
+ }
+
+ $.ajax({
+ type: "GET",
+ url : "/generate/customerservice/" + id,
+ dataType : "text",
+ complete : function(xhr) {
+ if (xhr.status == 200) {
+ alert(xhr.responseText);
+ } else if (xhr.status == 204) {
+ alert("Customer, with specified ID, doesn't
exist");
+ } else {
+ alert("Error occurred");
+ }
+ }
+ });
+ });
+
+ $("#deleteCustomerButton").click(function() {
+ var id = $("#deleteCustomerForm
INPUT[name='customer.id']").val();
+ if (id == null || id == "") {
+ alert("Field 'ID' can't be empty");
+ return;
+ }
+
+ $.ajax({
+ type: "DELETE",
+ url : "/generate/customerservice/" + id,
+ complete : function(xhr) {
+ if (xhr.status == 200) {
+ alert("Customer deleted successfully");
+ } else if (xhr.status == 304) {
+ alert("Customer, with specified ID, doesn't
exist");
+ } else {
+ alert("Error occurred");
+ }
+ }
+ });
+ });
+
+ $("INPUT.digits").keyup(function () {
+ this.value = this.value.replace(/[^0-9\.]/g,'');
+ });
+ });
+ </script>
</head>
<body>
-<form action="generate.do" method="get">
- <p>
- <label for="level">Level:</label>
- <select id="level" name="level">
- <option value="debug">DEBUG</option>
- <option value="info">INFO</option>
- <option value="warning">WARNING</option>
- <option value="error">ERROR</option>
- </select>
- </p>
-
- <p>
- <label for="copies">Copies:</label>
- <input id="copies" name="copies" type="text" size="2" value="1"/>
- </p>
-
- <p>
- <label for="message">Message:</label>
- <textarea id="message" name="message" rows="10" cols="80"></textarea>
- </p>
-
- <p>
- <label for="exceptionMessage">Exception message:</label>
- <textarea id="exceptionMessage" name="exceptionMessage" rows="10"
cols="80"></textarea>
- </p>
- <p class="submit"><input type="submit" value="Generate"/></p>
-</form>
+<div>
+ <h1>Generate log entries by interact with Customer service</h1>
+
+ <h2>Add or update customer</h2>
+ <form id="addOrUpdateCustomerForm" action="#">
+ <p>
+ <label>ID:</label>
+ <input name="customer.id" class="digits" type="text" size="3"/>
+ </p>
+
+ <p>
+ <label>Name:</label>
+ <input name="customer.name" type="text" size="30"/>
+ </p>
+
+ <p class="submit"><a id="addOrUpdateCustomerButton" href="#">Add or
Update</a></p>
+ </form>
+
+ <h2>Get customer</h2>
+ <form id="getCustomerForm" action="#">
+ <p>
+ <label>ID:</label>
+ <input name="customer.id" class="digits" type="text" size="3"/>
+ </p>
+
+ <p class="submit"><a id="getCustomerButton" href="#">Get</a></p>
+ </form>
+
+ <h2>Delete customer</h2>
+ <form id="deleteCustomerForm" action="#">
+ <p>
+ <label>ID:</label>
+ <input name="customer.id" class="digits" type="text" size="3"/>
+ </p>
+
+ <p class="submit"><a id="deleteCustomerButton" href="#">Delete</a></p>
+ </form>
+</div>
+
+<hr/>
+
+<div>
+ <h1>Generate custom log entry</h1>
+ <form action="generate.do" method="get">
+ <p>
+ <label for="level">Level:</label>
+ <select id="level" name="level">
+ <option value="debug">DEBUG</option>
+ <option value="info">INFO</option>
+ <option value="warning">WARNING</option>
+ <option value="error">ERROR</option>
+ </select>
+ </p>
+
+ <p>
+ <label >Copies:</label>
+ <input name="copies" class="digits" type="text" size="2"
value="1"/>
+ </p>
+
+ <p>
+ <label for="message">Message:</label>
+ <textarea id="message" name="message" rows="10"
cols="50"></textarea>
+ </p>
+
+ <p>
+ <label for="exceptionMessage">Exception message:</label>
+ <textarea id="exceptionMessage" name="exceptionMessage" rows="5"
cols="50"></textarea>
+ </p>
+
+ <p class="submit"><input type="submit" value="Generate"/></p>
+ </form>
+</div>
+
</body>
</html>
\ No newline at end of file