You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2016/12/22 14:23:25 UTC
[3/8] cxf git commit: [CXF-7192] Removing cxf-rt-management-web
module, to be restored on demand
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/client/ui/settings/SubscriptionDialogImpl.java
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/client/ui/settings/SubscriptionDialogImpl.java b/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/client/ui/settings/SubscriptionDialogImpl.java
deleted file mode 100644
index b9649f6..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/client/ui/settings/SubscriptionDialogImpl.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * 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.cxf.management.web.browser.client.ui.settings;
-
-import java.util.Map;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.uibinder.client.UiBinder;
-import com.google.gwt.uibinder.client.UiField;
-import com.google.gwt.uibinder.client.UiTemplate;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.HasValue;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.Widget;
-
-import org.apache.cxf.management.web.browser.client.service.settings.Subscription;
-
-public class SubscriptionDialogImpl extends DialogBox implements SubscriptionDialog {
-
- @Nonnull
- private Form form;
-
- @Nullable
- private Presenter presenter;
-
- @Nullable
- private String subscriptionId;
-
- public SubscriptionDialogImpl() {
- form = new Form();
- form.nameErrorLabel.setVisible(false);
- form.urlErrorLabel.setVisible(false);
-
- form.cancelButton.addClickHandler(new ClickHandler() {
-
- public void onClick(@Nonnull final ClickEvent clickEvent) {
- assert presenter != null;
- presenter.onCancelButtonClicked();
- }
- });
- form.saveButton.addClickHandler(new ClickHandler() {
-
- public void onClick(@Nonnull final ClickEvent clickEvent) {
- assert presenter != null;
- presenter.onSaveButtonClicked(subscriptionId, form.nameTextBox, form.urlTextBox);
- }
- });
-
- setGlassEnabled(true);
- setAnimationEnabled(false);
- setAutoHideEnabled(true);
- setWidget(form);
- }
-
- public void setValidationErrors(@Nullable Map<HasValue<String>, String> errors) {
- form.nameErrorLabel.setVisible(false);
- form.urlErrorLabel.setVisible(false);
-
- if (errors == null) {
- return;
- }
-
- if (errors.containsKey(form.nameTextBox)) {
- form.nameErrorLabel.setText(errors.get(form.nameTextBox));
- form.nameErrorLabel.setVisible(true);
- }
- if (errors.containsKey(form.urlTextBox)) {
- form.urlErrorLabel.setText(errors.get(form.urlTextBox));
- form.urlErrorLabel.setVisible(true);
- }
- }
-
- public void setTitle(@Nonnull final String title) {
- setText(title);
- }
-
- public void setData(@Nullable final Subscription subscription) {
- if (subscription == null) {
- form.nameTextBox.setValue("");
- form.urlTextBox.setValue("");
- subscriptionId = null;
- } else {
- form.nameTextBox.setValue(subscription.getName());
- form.urlTextBox.setValue(subscription.getUrl());
- subscriptionId = subscription.getId();
- }
- }
-
- public void setPresenter(@Nonnull final Presenter presenter) {
- this.presenter = presenter;
- }
-
- protected static class Form extends Composite {
-
- @UiTemplate("SubscriptionForm.ui.xml")
- interface FormViewUiBinder extends UiBinder<Widget, Form> { }
-
- private static final FormViewUiBinder UI_BINDER = GWT.create(FormViewUiBinder.class);
-
- @UiField @Nonnull
- TextBox nameTextBox;
-
- @UiField @Nonnull
- Label nameErrorLabel;
-
- @UiField @Nonnull
- TextBox urlTextBox;
-
- @UiField @Nonnull
- Label urlErrorLabel;
-
- @UiField @Nonnull
- Button saveButton;
-
- @UiField @Nonnull
- Button cancelButton;
-
- public Form() {
- initWidget(UI_BINDER.createAndBindUi(this));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/client/ui/settings/SubscriptionEntry.ui.xml
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/client/ui/settings/SubscriptionEntry.ui.xml b/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/client/ui/settings/SubscriptionEntry.ui.xml
deleted file mode 100644
index c9a554d..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/client/ui/settings/SubscriptionEntry.ui.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
- -->
-<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
- <ui:with field="res" type="org.apache.cxf.management.web.browser.client.ui.resources.LogBrowserResources"/>
- <g:HTMLPanel>
- <table class="{res.css.feedEntry}">
- <tr>
- <td>
- <g:Label ui:field="nameLabel" addStyleNames="{res.css.feedEntryNameLabel}"/>
- <g:Label ui:field="urlLabel" addStyleNames="{res.css.feedEntryUrlLabel}"/>
- </td>
- <td class="{res.css.feedEntryButtons}">
- <g:Button ui:field="removeButton" addStyleNames="{res.css.feedEntryRemoveButton}">
- Remove
- </g:Button>
- <g:Button ui:field="editButton" addStyleNames="{res.css.feedEntryEditButton}">
- Edit
- </g:Button>
- </td>
- </tr>
- </table>
- </g:HTMLPanel>
-</ui:UiBinder>
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/client/ui/settings/SubscriptionForm.ui.xml
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/client/ui/settings/SubscriptionForm.ui.xml b/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/client/ui/settings/SubscriptionForm.ui.xml
deleted file mode 100644
index 8b06e97..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/client/ui/settings/SubscriptionForm.ui.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
- -->
-<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
- <ui:with field="res" type="org.apache.cxf.management.web.browser.client.ui.resources.LogBrowserResources"/>
- <g:HTMLPanel>
- <table cellspacing="6">
- <tr>
- <td>
- <g:Label>Name:</g:Label>
- </td>
- <td>
- <g:TextBox ui:field="nameTextBox"/>
- </td>
- </tr>
- <tr>
- <td/>
- <td>
- <g:Label ui:field="nameErrorLabel" addStyleNames="{res.css.editFeedDialogErrorMessage}"/>
- </td>
- </tr>
- <tr>
- <td>
- <g:Label>URL:</g:Label>
- </td>
- <td>
- <g:TextBox ui:field="urlTextBox"/>
- </td>
- </tr>
- <tr>
- <td/>
- <td>
- <g:Label ui:field="urlErrorLabel" addStyleNames="{res.css.editFeedDialogErrorMessage}"/>
- </td>
- </tr>
- </table>
- <g:FlowPanel addStyleNames="{res.css.editFeedDialogButtons}">
- <g:Button ui:field="cancelButton">
- Cancel
- </g:Button>
- <g:Button ui:field="saveButton" addStyleNames="{res.css.editFeedDialogAddButton}">
- Save
- </g:Button>
- </g:FlowPanel>
- </g:HTMLPanel>
-</ui:UiBinder>
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/LogBrowser.html
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/LogBrowser.html b/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/LogBrowser.html
deleted file mode 100644
index 89d7238..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/LogBrowser.html
+++ /dev/null
@@ -1,43 +0,0 @@
-<!doctype html>
-<!--
- ~ * 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.
- -->
-
-<html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
-
- <title>LogBrowser</title>
-
- <script type="text/javascript" language="javascript" src="logbrowser.nocache.js"></script>
- <script type="text/javascript" language="javascript" src="uuid.min.js"></script>
- <script type="text/javascript" language="javascript" src="json2.min.js"></script>
-
- </head>
-
- <body>
- <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
-
- <noscript>
- <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
- Your web browser must have JavaScript enabled
- in order for this application to display correctly.
- </div>
- </noscript>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/custom.css
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/custom.css b/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/custom.css
deleted file mode 100644
index 71d568b..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/custom.css
+++ /dev/null
@@ -1,16 +0,0 @@
-body table {
- width:100%;
-}
-
-.gwt-DecoratedTabPanel-settings .gwt-TabPanelBottom {
- border-color: #FFF7D7;
- background-color: #FFF7D7;
-}
-
-.gwt-DecoratedTabPanel-settings .tabMiddleLeft, .gwt-DecoratedTabPanel-settings .tabMiddleCenter, .gwt-DecoratedTabPanel-settings .tabMiddleRight, .gwt-DecoratedTabPanel-settings .tabTopLeft, .gwt-DecoratedTabPanel-settings .tabTopCenter, .gwt-DecoratedTabPanel-settings .tabTopRight {
- background: none repeat scroll 0 0 #FFF7D7 !important;
-}
-
-.gwt-TextBox-clear {
- padding: 1px 0px;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/json2.min.js
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/json2.min.js b/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/json2.min.js
deleted file mode 100644
index df33848..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/json2.min.js
+++ /dev/null
@@ -1,7 +0,0 @@
-if(!this.JSON)this.JSON={};
-(function(){function l(b){return b<10?"0"+b:b}function o(b){p.lastIndex=0;return p.test(b)?'"'+b.replace(p,function(f){var c=r[f];return typeof c==="string"?c:"\\u"+("0000"+f.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+b+'"'}function m(b,f){var c,d,g,j,i=h,e,a=f[b];if(a&&typeof a==="object"&&typeof a.toJSON==="function")a=a.toJSON(b);if(typeof k==="function")a=k.call(f,b,a);switch(typeof a){case "string":return o(a);case "number":return isFinite(a)?String(a):"null";case "boolean":case "null":return String(a);
-case "object":if(!a)return"null";h+=n;e=[];if(Object.prototype.toString.apply(a)==="[object Array]"){j=a.length;for(c=0;c<j;c+=1)e[c]=m(c,a)||"null";g=e.length===0?"[]":h?"[\n"+h+e.join(",\n"+h)+"\n"+i+"]":"["+e.join(",")+"]";h=i;return g}if(k&&typeof k==="object"){j=k.length;for(c=0;c<j;c+=1){d=k[c];if(typeof d==="string")if(g=m(d,a))e.push(o(d)+(h?": ":":")+g)}}else for(d in a)if(Object.hasOwnProperty.call(a,d))if(g=m(d,a))e.push(o(d)+(h?": ":":")+g);g=e.length===0?"{}":h?"{\n"+h+e.join(",\n"+h)+
-"\n"+i+"}":"{"+e.join(",")+"}";h=i;return g}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+l(this.getUTCMonth()+1)+"-"+l(this.getUTCDate())+"T"+l(this.getUTCHours())+":"+l(this.getUTCMinutes())+":"+l(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var q=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
-p=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,h,n,r={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},k;if(typeof JSON.stringify!=="function")JSON.stringify=function(b,f,c){var d;n=h="";if(typeof c==="number")for(d=0;d<c;d+=1)n+=" ";else if(typeof c==="string")n=c;if((k=f)&&typeof f!=="function"&&(typeof f!=="object"||typeof f.length!=="number"))throw new Error("JSON.stringify");return m("",
-{"":b})};if(typeof JSON.parse!=="function")JSON.parse=function(b,f){function c(g,j){var i,e,a=g[j];if(a&&typeof a==="object")for(i in a)if(Object.hasOwnProperty.call(a,i)){e=c(a,i);if(e!==undefined)a[i]=e;else delete a[i]}return f.call(g,j,a)}var d;b=String(b);q.lastIndex=0;if(q.test(b))b=b.replace(q,function(g){return"\\u"+("0000"+g.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(b.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
-"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){d=eval("("+b+")");return typeof f==="function"?c({"":d},""):d}throw new SyntaxError("JSON.parse");}})();
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/uuid.min.js
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/uuid.min.js b/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/uuid.min.js
deleted file mode 100644
index 846fb48..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/browser/resources/uuid.min.js
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
-Math.uuid.js (v1.4)
-http://www.broofa.com
-mailto:robert@broofa.com
-
-Copyright (c) 2010 Robert Kieffer
-Dual licensed under the MIT and GPL licenses.
-*/
-(function(){var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");Math.uuid=function(f,d){var a=[];d=d||c.length;if(f)for(var b=0;b<f;b++)a[b]=c[0|Math.random()*d];else{var e;a[8]=a[13]=a[18]=a[23]="-";a[14]="4";for(b=0;b<36;b++)if(!a[b]){e=0|Math.random()*16;a[b]=c[b==19?e&3|8:e]}}return a.join("")}})();
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/LogLevel.java
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/LogLevel.java b/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/LogLevel.java
deleted file mode 100644
index 535f68e..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/LogLevel.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * 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.cxf.management.web.logging;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-
-import javax.xml.bind.annotation.XmlEnum;
-import javax.xml.bind.annotation.XmlTransient;
-
-/**
- * Log level of {@link LogRecord}. Based on SLF4J being popular facade for loggers like JUL, Log4J, JCL and so
- * on. Severities order is: FATAL > ERROR > WARN > INFO > DEBUG > TRACE.
- * <p>
- * Mapping of levels:
- * <ol>
- * <li>JUL - same as <a href="http://www.slf4j.org/apidocs/org/slf4j/bridge/SLF4JBridgeHandler.html">SLF4J
- * approach</a>.</li>
- * <li>Log4J - levels are identical</li>
- * </ol>
- */
-@XmlEnum
-public enum LogLevel {
- ALL,
- FATAL,
- ERROR,
- WARN,
- INFO,
- DEBUG,
- TRACE,
- OFF;
-
- @XmlTransient
- private static Map<Level, LogLevel> fromJul = new HashMap<Level, LogLevel>();
-
- @XmlTransient
- private static Map<LogLevel, Level> toJul = new HashMap<LogLevel, Level>();
-
- static {
- fromJul.put(Level.ALL, LogLevel.ALL);
- fromJul.put(Level.SEVERE, LogLevel.ERROR);
- fromJul.put(Level.WARNING, LogLevel.WARN);
- fromJul.put(Level.INFO, LogLevel.INFO);
- fromJul.put(Level.FINE, LogLevel.DEBUG);
- fromJul.put(Level.FINER, LogLevel.DEBUG);
- fromJul.put(Level.FINEST, LogLevel.TRACE);
- fromJul.put(Level.OFF, LogLevel.OFF);
-
- toJul.put(LogLevel.ALL, Level.ALL);
- toJul.put(LogLevel.FATAL, Level.SEVERE);
- toJul.put(LogLevel.ERROR, Level.SEVERE);
- toJul.put(LogLevel.WARN, Level.WARNING);
- toJul.put(LogLevel.INFO, Level.INFO);
- toJul.put(LogLevel.DEBUG, Level.FINE);
- toJul.put(LogLevel.TRACE, Level.FINEST);
- toJul.put(LogLevel.OFF, Level.OFF);
- }
-
- /**
- * Creates this enum from JUL {@link Level}.
- */
- public static LogLevel fromJUL(Level level) {
- return fromJul.get(level);
- }
-
- /**
- * Creates this JUL {@link Level} from this enum.
- */
- public static Level toJUL(LogLevel level) {
- return toJul.get(level);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/LogRecord.java
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/LogRecord.java b/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/LogRecord.java
deleted file mode 100644
index 3b95118..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/LogRecord.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * 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.cxf.management.web.logging;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.MessageFormat;
-import java.util.Date;
-import java.util.UUID;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
-
-import org.apache.commons.lang3.Validate;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-
-/**
- * Log entry serializable to XML. Based on common set of {@link java.util.logging.LogRecord} and
- * {@link org.apache.log4j.spi.LoggingEvent} attributes.
- * <p>
- * LogRecord are never null; if some attributes are not set (e.g. logger name, or rendered cause taken from
- * Throwable) empty strings are returned.
- */
-@XmlRootElement(namespace = "http://cxf.apache.org/log")
-public class LogRecord {
-
- @XmlTransient
- private String id = "uuid:" + UUID.randomUUID().toString();
-
- private Date eventTimestamp = new Date();
- private LogLevel level = LogLevel.INFO;
- private String message = "";
- private String loggerName = "";
- private String threadName = "";
- private String throwable = "";
-
- public LogRecord() {
-
- }
-
- public LogRecord(String id) {
- this.id = id;
- }
-
- public LogRecord(LogRecord copy) {
- this.eventTimestamp = copy.getDate();
- this.level = copy.getLevel();
- this.message = copy.getMessage();
- this.loggerName = copy.getLoggerName();
- this.threadName = copy.getThreadName();
- this.throwable = copy.getThrowable();
- }
-
- /**
- * Creates this object from JUL LogRecord. Most attributes are copied, others are converted as follows:
- * raw {@link java.util.logging.LogRecord#getMessage() message} is formatted with
- * {@link java.util.logging.LogRecord#getParameters() parameters} using {@link MessageFormat}, attached
- * {@link java.util.logging.LogRecord#getThrown() throwable} has full stack trace dumped, and log levels
- * are mapped as specified in {@link LogRecord}.
- *
- * @param julRecord log record to convert.
- * @return conversion result.
- */
- public static LogRecord fromJUL(java.util.logging.LogRecord julRecord) {
- Validate.notNull(julRecord, "julRecord is null");
- LogRecord record = new LogRecord();
- record.setDate(new Date(julRecord.getMillis()));
- record.setLevel(LogLevel.fromJUL(julRecord.getLevel()));
- record.setLoggerName(julRecord.getLoggerName());
- if (julRecord.getThrown() != null) {
- StringWriter sw = new StringWriter();
- julRecord.getThrown().printStackTrace(new PrintWriter(sw));
- record.setThrowable(sw.getBuffer().toString());
- }
- if (julRecord.getParameters() != null) {
- record.setMessage(MessageFormat.format(julRecord.getMessage(), julRecord.getParameters()));
- } else {
- record.setMessage(julRecord.getMessage());
- }
- record.setThreadName(Integer.toString(julRecord.getThreadID()));
- return record;
- }
-
- public String getId() {
- return id;
- }
-
- @XmlElement(namespace = "http://cxf.apache.org/log")
- public Date getDate() {
- return eventTimestamp;
- }
-
- public void setDate(Date date) {
- Validate.notNull(date, "eventTimestamp is null");
- this.eventTimestamp = date;
- }
-
- @XmlElement(namespace = "http://cxf.apache.org/log")
- public LogLevel getLevel() {
- return level;
- }
-
- public void setLevel(LogLevel level) {
- Validate.notNull(level, "level is null");
- this.level = level;
- }
-
- /**
- * Formatted message with parameters filled in.
- */
- @XmlElement(namespace = "http://cxf.apache.org/log")
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String renderedMessage) {
- Validate.notNull(level, "message is null");
- this.message = renderedMessage;
- }
-
- @XmlElement(namespace = "http://cxf.apache.org/log")
- public String getLoggerName() {
- return loggerName;
- }
-
- public void setLoggerName(String loggerName) {
- Validate.notNull(level, "loggerName is null");
- this.loggerName = loggerName;
- }
-
- @XmlElement(namespace = "http://cxf.apache.org/log")
- public String getThreadName() {
- return threadName;
- }
-
- public void setThreadName(String threadName) {
- Validate.notNull(level, "threadName is null");
- this.threadName = threadName;
- }
-
- /**
- * Full stack trace of {@link Throwable} associated with log record.
- */
- @XmlElement(namespace = "http://cxf.apache.org/log")
- public String getThrowable() {
- return throwable;
- }
-
- public void setThrowable(String throwable) {
- Validate.notNull(throwable, "throwable is null");
- this.throwable = throwable;
- }
-
- @Override
- public boolean equals(Object obj) {
- return EqualsBuilder.reflectionEquals(obj, this);
- }
-
- @Override
- public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/LogRecords.java
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/LogRecords.java b/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/LogRecords.java
deleted file mode 100644
index 9a6d336..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/LogRecords.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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.cxf.management.web.logging;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.commons.lang3.Validate;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-
-/**
- * List of {@link LogRecord}s. Necessary wrapper for {@link List} used in JAXB context.
- */
-@XmlRootElement(namespace = "http://cxf.apache.org/log")
-public class LogRecords {
-
- private List<LogRecord> logRecords = new ArrayList<LogRecord>();
-
- @XmlElement(name = "logRecord", namespace = "http://cxf.apache.org/log")
- public List<LogRecord> getLogRecords() {
- return logRecords;
- }
-
- public void setLogRecords(List<LogRecord> logRecords) {
- Validate.notNull(logRecords, "logRecords is null");
- this.logRecords = logRecords;
- }
-
- @Override
- public boolean equals(Object obj) {
- return EqualsBuilder.reflectionEquals(obj, this);
- }
-
- @Override
- public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadOnlyFileStorage.java
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadOnlyFileStorage.java b/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadOnlyFileStorage.java
deleted file mode 100644
index 79849e7..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadOnlyFileStorage.java
+++ /dev/null
@@ -1,621 +0,0 @@
-/**
- * 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.cxf.management.web.logging;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.text.SimpleDateFormat;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.cxf.common.util.SystemPropertyAction;
-import org.apache.cxf.jaxrs.ext.search.SearchCondition;
-
-/**
- * Facilitates reading the log entries from the existing log files.
- */
-public class ReadOnlyFileStorage implements ReadableLogStorage {
-
- public static final String LEVEL_PROPERTY = "level";
- public static final String DATE_PROPERTY = "date";
- public static final String MESSAGE_PROPERTY = "message";
- public static final String CATEGORY_PROPERTY = "category";
- public static final String THREAD_PROPERTY = "thread";
-
- public static final String DATE_ONLY_FORMAT = "yyyy-MM-dd";
-
- private static final String LINE_SEP = SystemPropertyAction.getProperty("line.separator");
- private static final String DEFAULT_COLUMN_SEP = "|";
-
- private String columnSep = DEFAULT_COLUMN_SEP;
- private int numberOfColumns;
- private boolean startsFromSeparator;
- private boolean endsWithSeparator;
-
- private SimpleDateFormat recordDateFormat;
- private boolean useFileModifiedDate;
- private Pattern fileNameDatePattern;
- private String fileNameDateFormat;
-
- private File logDirectory;
- private Comparator<String> fileNameComparator;
-
- private Map<Integer, String> columnsMap;
- private List<FileInfo> logFiles = new LinkedList<FileInfo>();
- private Map<String, String> levelsMap;
- private Map<Integer, PageInfo> pagesMap = new HashMap<Integer, PageInfo>();
-
- /**
- * {@inheritDoc}
- */
- public int getSize() {
- return -1;
- }
-
- /**
- * {@inheritDoc}
- */
- // Synchronization can not be avoided at the moment as
- // the file position is continuously changed.
- // Realistically, the log files will probably be viewed
- // by the admin so it's not a problem. However the memory mapping can
- // help in making it more flexible
- public synchronized int load(List<LogRecord> list,
- SearchCondition<LogRecord> condition,
- int pageNumber,
- int pageSize) {
- FileInfo logFileInfo = getLogFileInfo(pageNumber);
- if (logFileInfo == null) {
- return pageNumber;
- }
-
- int recordCount = 0;
- int currentIndex = 0;
- while (true) {
- LogRecord record = readRecord(logFileInfo);
- if (record == null) {
- logFileInfo = getNextLogFileInfo(logFileInfo, true);
- if (logFileInfo != null) {
- continue;
- } else {
- return pageNumber;
- }
- }
- if (condition == null || condition.isMet(record)) {
- list.add(record);
- if (++recordCount == pageSize) {
- saveNextPagePosition(pageNumber + 1, logFileInfo);
- break;
- }
- }
- if (++currentIndex == pageSize) {
- pageNumber++;
- recordCount = 0;
- currentIndex = 0;
- }
- }
- return pageNumber;
- }
-
- /**
- * If no more records is available in the current file then try to get
- * the next one with an optional scanning
- **/
- private FileInfo getNextLogFileInfo(FileInfo logFileInfo, boolean firstTry) {
- for (int i = 0; i < logFiles.size(); i++) {
- FileInfo fileInfo = logFiles.get(i);
- if (fileInfo == logFileInfo) {
- if (i + 1 < logFiles.size()) {
- return setFilePosition(logFiles.get(i + 1), logFiles.get(i + 1).getStartPosition());
- } else {
- break;
- }
- }
- }
- if (firstTry && logDirectory != null && scanLogDirectory()) {
- return getNextLogFileInfo(logFileInfo, false);
- }
- return null;
- }
-
- private FileInfo setFilePosition(FileInfo fileInfo, long pos) {
- try {
- fileInfo.getFile().seek(pos);
- return fileInfo;
- } catch (IOException ex) {
- System.err.println("Problem setting a page position in " + fileInfo.getFileName());
- return null;
- }
- }
-
- /**
- * Gets the file corresponding to the current page.
- */
- private FileInfo getLogFileInfo(int pageNumber) {
- PageInfo pageInfo = pagesMap.get(pageNumber);
- if (pageInfo != null) {
- return setFilePosition(pageInfo.getFileInfo(), pageInfo.getPosition());
- }
- int oldSize = logFiles.size();
- if (logDirectory != null
- && scanLogDirectory()) {
- FileInfo fileInfo = logFiles.get(oldSize);
- saveNextPagePosition(pageNumber, fileInfo);
- return fileInfo;
- }
- return null;
- }
-
- /**
- * Save the position of the next page
- */
- private void saveNextPagePosition(int pageNumber, FileInfo fileInfo) {
- try {
- long pos = fileInfo.getFile().getFilePointer();
- if (pos < fileInfo.getFile().length()) {
- pagesMap.put(pageNumber, new PageInfo(fileInfo, pos));
- } else {
- FileInfo nextFileInfo = getNextLogFileInfo(fileInfo, false);
- if (nextFileInfo != null) {
- pagesMap.put(pageNumber,
- new PageInfo(nextFileInfo, nextFileInfo.getFile().getFilePointer()));
- }
- }
- } catch (IOException ex) {
- // ignore
- }
-
- }
-
- protected LogRecord readRecord(FileInfo logFileInfo) {
- try {
- Map<Integer, String> map = new HashMap<Integer, String>(numberOfColumns);
- readTheLine(logFileInfo.getFile(), map, 1);
- return createRecord(map, logFileInfo);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
-
- }
-
- protected LogRecord createRecord(Map<Integer, String> map, FileInfo logFileInfo) {
- if (map.isEmpty()) {
- return null;
- }
- LogRecord record = new LogRecord();
- for (Map.Entry<Integer, String> entry : map.entrySet()) {
- String propertyName = columnsMap.get(entry.getKey());
- if (LEVEL_PROPERTY.equals(propertyName)) {
- setLogRecordLevel(record, entry.getValue());
- } else if (DATE_PROPERTY.equals(propertyName)) {
- setLogRecordDate(record, entry.getValue(), logFileInfo);
- } else if (MESSAGE_PROPERTY.equals(propertyName)) {
- record.setMessage(entry.getValue());
- } else if (CATEGORY_PROPERTY.equals(propertyName)) {
- record.setLoggerName(entry.getValue());
- } else if (THREAD_PROPERTY.equals(propertyName)) {
- record.setThreadName(entry.getValue());
- }
- }
- return record;
- }
-
- protected void setLogRecordLevel(LogRecord record, String logLevel) {
- if (levelsMap != null) {
- logLevel = levelsMap.get(logLevel);
- }
- if (logLevel != null) {
- record.setLevel(LogLevel.valueOf(logLevel));
- }
- }
-
- protected void setLogRecordDate(LogRecord record, String logDate, FileInfo logFileInfo) {
- if (recordDateFormat != null) {
- try {
- String fileModifiedDate = logFileInfo.getFileModified();
- logDate = fileModifiedDate != null ? fileModifiedDate + " " + logDate : logDate;
- Date date = recordDateFormat.parse(logDate);
- record.setDate(date);
- } catch (Exception ex) {
- // ignore
- }
- }
- }
-
- protected void readTheLine(RandomAccessFile logFile, Map<Integer, String> map, int columnIndex)
- throws IOException {
-
- long nextPos = logFile.getFilePointer();
- if (nextPos >= logFile.length()) {
- return;
- }
-
- String line = logFile.readLine();
-
- int lastIndex = 0;
- if (columnIndex == 1 && startsFromSeparator) {
- lastIndex = 1;
- }
-
- Set<Integer> requestedColumns = columnsMap.keySet();
- int startingColumn = columnIndex;
- while (lastIndex < line.length()) {
-
- int sepIndex = line.indexOf(columnSep, lastIndex);
-
- if (sepIndex != -1 && startingColumn == numberOfColumns && !endsWithSeparator) {
- logFile.seek(nextPos);
- return;
- }
-
- int actualIndex = sepIndex == -1 ? line.length() : sepIndex;
-
- if (requestedColumns.contains(columnIndex)) {
- String value = line.substring(lastIndex, actualIndex).trim();
- String existingValue = map.get(columnIndex);
- map.put(columnIndex, existingValue == null
- ? value : existingValue + LINE_SEP + value);
- }
-
- lastIndex = actualIndex + 1;
- if (sepIndex != -1 && columnIndex != numberOfColumns) {
- columnIndex++;
- }
- }
-
- if (columnIndex == numberOfColumns) {
- readTheLine(logFile, map, columnIndex);
- }
- }
-
- /**
- * Log column separator such as '|'
- * @param columnSep the separator
- */
- public void setColumnSep(String columnSep) {
- this.columnSep = columnSep;
- }
-
- /**
- * Sets the number of columns per record
- * @param number the number of columns per record
- */
- public void setNumberOfColumns(String number) {
- this.numberOfColumns = Integer.parseInt(number);
- }
-
- /**
- * Identifies the columns which this reader should use
- * when creating a LogRecord. Example, given a 7-columns
- * record a user may only need the information from 1, 2,
- * and the last column. Regular expressions are not suitable.
- *
- * @param columnsMap the map, the key is the column number (starting from 1)
- * and the value is the name of the property such as 'message'.
- * The following properties are supported at the moment:
- * 'date', 'level' 'category', 'thread', 'message'.
- */
- public void setColumnsMap(Map<Integer, String> columnsMap) {
- this.columnsMap = columnsMap;
- }
-
- /**
- * A list of log files, the oldest files are expected to be in the top
- * of the list
- * @param locations the locations
- */
- public void setLogLocations(List<String> locations) {
- logFiles = new LinkedList<FileInfo>();
- for (int i = 0; i < locations.size(); i++) {
- String realPath = getRealLocation(locations.get(i));
-
- try {
- processNewLogFile(new File(realPath));
- } catch (IOException ex) {
- throw new RuntimeException("The log file " + realPath + " can not be opened: "
- + ex.getMessage());
- }
- }
- }
-
-
- /**
- * It may make sense to map logFile.getChannel() to memory for large files
- * >= 1MB
- */
- private void processNewLogFile(File file) throws IOException {
- RandomAccessFile logFile = new RandomAccessFile(file, "r");
-
- String fileModifiedDate = null;
- if (useFileModifiedDate) {
- if (fileNameDatePattern != null) {
- fileModifiedDate = getDateFromFileName(file.getName());
- }
- if (fileModifiedDate == null) {
- Date fileDate = new Date(file.lastModified());
- fileModifiedDate = getLogDateFormat().format(fileDate);
- }
- }
- skipIgnorableRecords(logFile);
- FileInfo fileInfo = new FileInfo(logFile,
- file.getName(),
- fileModifiedDate,
- logFile.getFilePointer());
- if (logFiles.size() == 0) {
- pagesMap.put(1, new PageInfo(fileInfo, fileInfo.getStartPosition()));
- }
- logFiles.add(fileInfo);
- }
-
- private String getDateFromFileName(String name) {
- Matcher m = fileNameDatePattern.matcher(name);
- if (m.matches() && m.groupCount() > 0) {
- return m.group(1);
- } else {
- return null;
- }
- }
-
- private SimpleDateFormat getLogDateFormat() {
- String format = fileNameDateFormat == null ? DATE_ONLY_FORMAT : fileNameDateFormat;
- return new SimpleDateFormat(format);
- }
-
- private String getRealLocation(String location) {
- int indexOpen = location.indexOf("{");
- int indexClose = location.indexOf("}");
- String realPath = null;
- if (indexOpen == 0 && indexClose != -1) {
- String property = location.substring(1, indexClose);
- String resolvedPath = SystemPropertyAction.getProperty(property);
- if (resolvedPath == null) {
- throw new IllegalArgumentException("System property " + property + " can not be resolved");
- }
- realPath = resolvedPath + location.substring(indexClose + 1);
-
- } else {
- realPath = location;
- }
- return realPath;
- }
-
- /**
- * Sets the log location.
- * @param location the location, if it is a directory then
- * the on-demand scanning will be enabled
- */
- public void setLogLocation(String location) {
- String realPath = getRealLocation(location);
- File file = new File(realPath);
- if (file.isDirectory()) {
- logDirectory = file;
- } else {
- setLogLocations(Collections.singletonList(realPath));
- }
- }
-
- /**
- * Skip the records at the top of the file which have no column separators
- */
- private void skipIgnorableRecords(RandomAccessFile file) throws IOException {
- long nextPos = file.getFilePointer();
- if (nextPos == file.length()) {
- return;
- }
- String line = file.readLine();
- if (line.contains(columnSep)) {
- file.seek(nextPos);
- } else {
- skipIgnorableRecords(file);
- }
-
- }
- //CHECKSTYLE:OFF
- /**
- * The format for parsing the log date
- * <p>
- * Please see <a href="http://download.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat</a>
- * </p>
- */
- //CHECKSTYLE:ON
- public void setRecordDateFormat(String format) {
- recordDateFormat = new SimpleDateFormat(format);
- }
-
- /**
- * Optional map for converting the levels.
- * This map is not required if the log records have levels
- * with one of the following values:
- * 'WARN', 'ERROR', 'DEBUG', 'TRACE', 'INFO', 'FATAL'.
- * @param map the map of levels
- */
- public void setLevelsMap(Map<String, String> map) {
- this.levelsMap = map;
- }
-
- /**
- * Optional comparator which can be used for sorting the
- * new log files found after the latest scan iteration.
- *
- * If scanning is enabled then by default the file names are compared
- * using either the embedded date (provided the fileNameDatePattern is set)
- * or the last segment in the file name which is expected to be a number.
- * The files with the oldest dates or bigger indexes will be positioned first.
- *
- * @param comp the comparator
- */
- public void setFileNameComparator(Comparator<String> comp) {
- this.fileNameComparator = comp;
- }
-
- public void close() {
- for (FileInfo fileInfo : logFiles) {
- try {
- fileInfo.getFile().close();
- } catch (IOException ex) {
- // ignore
- }
- }
- }
-
- /**
- * Indicates if the file modified date needs to be used for
- * creating a LogRecord date - in case the actual log record
- * contains no year/month/hour information.
- */
- public void setUseFileModifiedDate(boolean useFileModifiedDate) {
- this.useFileModifiedDate = useFileModifiedDate;
- }
-
- private boolean scanLogDirectory() {
- int oldSize = logFiles.size();
- for (File file : logDirectory.listFiles()) {
- if (file.isDirectory() || file.isHidden()
- || fileNameDatePattern != null
- && getDateFromFileName(file.getName()) == null) {
- continue;
- }
-
- boolean isNew = true;
- for (FileInfo fInfo : logFiles) {
- if (fInfo.getFileName().equalsIgnoreCase(file.getName())) {
- isNew = false;
- break;
- }
- }
- if (isNew) {
- try {
- processNewLogFile(file);
- } catch (IOException ex) {
- System.out.println("Log file " + file.getName() + " can not be opened");
- }
- }
- }
- if (logFiles.size() > oldSize) {
- Collections.sort(logFiles, new FileInfoComparator());
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Sets the regular expression for capturing the date from the file name
- * If set then it must contain a single capturing group only.
- * @param fileNameDatePattern
- */
- public void setFileNameDatePattern(String fileNameDatePattern) {
- this.fileNameDatePattern = Pattern.compile(fileNameDatePattern);
- }
-
- /**
- * Optional pattern for parsing the file date
- * @param fileNameDateFormat
- */
- public void setFileNameDateFormat(String fileNameDateFormat) {
- this.fileNameDateFormat = fileNameDateFormat;
- }
-
- protected static class PageInfo {
- private FileInfo fileInfo;
- private long pos;
- public PageInfo(FileInfo fileInfo, long pos) {
- this.fileInfo = fileInfo;
- this.pos = pos;
- }
-
- public FileInfo getFileInfo() {
- return fileInfo;
- }
- public long getPosition() {
- return pos;
- }
- }
-
- protected static class FileInfo {
- private RandomAccessFile file;
- private String fileModified;
- private String fileName;
- private long startPosition;
-
- public FileInfo(RandomAccessFile file, String fileName, String fileModified, long startPos) {
- this.file = file;
- this.fileModified = fileModified;
- this.fileName = fileName;
- this.startPosition = startPos;
- }
-
- public RandomAccessFile getFile() {
- return file;
- }
- public String getFileModified() {
- return fileModified;
- }
- public String getFileName() {
- return fileName;
- }
- public long getStartPosition() {
- return startPosition;
- }
- }
-
- protected class FileInfoComparator implements Comparator<FileInfo> {
-
- public int compare(FileInfo info1, FileInfo info2) {
-
- if (useFileModifiedDate && fileNameDatePattern != null) {
- SimpleDateFormat dateFormat = getLogDateFormat();
- try {
- Date date1 = dateFormat.parse(info1.getFileModified());
- Date date2 = dateFormat.parse(info2.getFileModified());
- return date1.compareTo(date2);
- } catch (Exception ex) {
- // continue
- }
- }
-
- String name1 = info1.getFileName();
- String name2 = info2.getFileName();
- if (fileNameComparator != null) {
- return fileNameComparator.compare(name1, name2);
- }
- Integer logIndex1 = getLogIndex(name1);
- Integer logIndex2 = getLogIndex(name2);
- return logIndex1.compareTo(logIndex2) * -1;
- }
-
- private int getLogIndex(String name) {
- int index = name.lastIndexOf('.');
- try {
- return Integer.parseInt(name.substring(index + 1));
- } catch (Exception ex) {
- return 0;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadWriteLogStorage.java
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadWriteLogStorage.java b/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadWriteLogStorage.java
deleted file mode 100644
index 81eb9ff..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadWriteLogStorage.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.cxf.management.web.logging;
-
-import java.util.List;
-
-/**
- * Can be used by pull-style loggers to offload/save the records to some external storage
- *
- */
-public interface ReadWriteLogStorage extends ReadableLogStorage {
-
- /**
- * Save the records
- * @param records log records to save
- */
- void save(List<LogRecord> records);
-
- /**
- * Clear the storage
- */
- void clear();
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadableLogStorage.java
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadableLogStorage.java b/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadableLogStorage.java
deleted file mode 100644
index 5a7e87b..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadableLogStorage.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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.cxf.management.web.logging;
-
-import java.util.List;
-
-import org.apache.cxf.jaxrs.ext.search.SearchCondition;
-
-/**
- * Can be used by pull-style loggers to read the records from some external storage
- *
- */
-public interface ReadableLogStorage {
-
-
- /**
- * Read the records and load them into a provided list
- * @param list the list saved records should be added to
- * @param condition the condition loaded records must meet, can be null
- * @param pageNumber the initial page to have records loaded from
- * @param int pageSize the max number of records to load from the storage
- *
- * @return the current page number; it may be different from the starting page if
- * certain records within the given page range did not match the search condition.
- */
- int load(List<LogRecord> list,
- SearchCondition<LogRecord> condition,
- int pageNumber,
- int pageSize);
-
-
- /**
- * Get the size of storage (in records)
- * @return the size, -1 if not known, for ex, when reading from an open file containing log entries
- */
- int getSize();
-
-
- /**
- * Close the storage
- */
- void close();
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/atom/AbstractAtomBean.java
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/atom/AbstractAtomBean.java b/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/atom/AbstractAtomBean.java
deleted file mode 100644
index 589a156..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/atom/AbstractAtomBean.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- * 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.cxf.management.web.logging.atom;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.logging.Handler;
-import java.util.logging.Logger;
-
-import org.apache.commons.lang3.Validate;
-import org.apache.cxf.Bus;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.management.web.logging.LogLevel;
-
-
-public abstract class AbstractAtomBean {
-
- private List<LoggerLevel> loggers = new ArrayList<LoggerLevel>();
- private boolean initialized;
- private Bus bus;
-
- /**
- * Creates unconfigured and uninitialized bean. To configure setters must be used, then {@link #init()}
- * must be called.
- */
- public AbstractAtomBean() {
- initSingleLogger();
- }
-
- private void initSingleLogger() {
- loggers = new ArrayList<LoggerLevel>();
- loggers.add(new LoggerLevel("", "INFO"));
- }
-
- public void setBus(Bus bus) {
- this.bus = bus;
- }
-
- public Bus getBus() {
- return bus;
- }
-
- /**
- * Set one or more loggers and levels descriptor. <br>
- * Parsed input syntax is:
- *
- * <pre>
- * loggers := <logger>(<separator><logger>)*
- * logger := <name>[":"<level>]
- * separator := "," | " " | "\n"
- * </pre>
- *
- * Examples:
- * <p>
- * Two loggers and two levels: <br>
- * <tt>org.apache.cxf:INFO, org.apache.cxf.jaxrs:DEBUG</tt>
- * <p>
- * Three loggers, first with default "INFO" level: <br>
- * <tt>org.apache.cxf, org.apache.cxf.jaxrs:DEBUG, namedLogger:ERROR</tt><br>
- * <p>
- * One logger with default "INFO" level: <br>
- * <tt>org.apache.cxf</tt><br>
- */
- public void setLoggers(String loggers) {
- checkInit();
- Validate.notNull(loggers, "loggers is null");
- parseLoggers(loggers);
- }
-
- /**
- * Name of logger to associate with ATOM push handler; empty string for root logger.
- */
- public void setLogger(String logger) {
- checkInit();
- Validate.notNull(logger, "logger is null");
- if (loggers.size() != 1) {
- initSingleLogger();
- }
- loggers.get(0).setLogger(logger);
- }
-
- /**
- * Name of level that logger will use publishing log events to ATOM push handler; empty string for default
- * "INFO" level.
- */
- public void setLevel(String level) {
- checkInit();
- Validate.notNull(level, "level is null");
- if (loggers.size() != 1) {
- initSingleLogger();
- }
- loggers.get(0).setLevel(level);
- }
-
-
- /**
- * Initializes bean; creates ATOM handler based on current properties state, and attaches handler to
- * logger(s).
- */
- public void init() {
- checkInit();
- initialized = true;
- Handler h = createHandler();
- for (int i = 0; i < loggers.size(); i++) {
- Logger l = LogUtils.getL7dLogger(AbstractAtomBean.class, null, loggers.get(i).getLogger());
- l.addHandler(h);
- l.setLevel(LogLevel.toJUL(LogLevel.valueOf(loggers.get(i).getLevel())));
- }
- }
-
- protected abstract Handler createHandler();
-
- protected void checkInit() {
- if (initialized) {
- throw new IllegalStateException("Bean is already initialized");
- }
- }
-
- private void parseLoggers(String param) {
- loggers = new ArrayList<LoggerLevel>();
- StringTokenizer st1 = new StringTokenizer(param, ", \t\n\r\f");
- while (st1.hasMoreTokens()) {
- String tok = st1.nextToken();
- int idx = tok.indexOf(":");
- if (idx != -1) {
- loggers.add(new LoggerLevel(tok.substring(0, idx), tok.substring(idx + 1, tok.length())));
- } else {
- loggers.add(new LoggerLevel(tok, "INFO"));
- }
- }
- }
-
- protected List<LoggerLevel> getLoggers() {
- return loggers;
- }
-
- protected static class LoggerLevel {
- private String logger;
- private String level;
-
- public LoggerLevel(String logger, String level) {
- this.logger = logger;
- this.level = level;
- }
-
- public String getLogger() {
- return logger;
- }
-
- public void setLogger(String logger) {
- this.logger = logger;
- }
-
- public String getLevel() {
- return level;
- }
-
- public void setLevel(String level) {
- this.level = level;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/7f4a24d0/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/atom/AtomPullHandler.java
----------------------------------------------------------------------
diff --git a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/atom/AtomPullHandler.java b/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/atom/AtomPullHandler.java
deleted file mode 100644
index ff2215d..0000000
--- a/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/atom/AtomPullHandler.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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.cxf.management.web.logging.atom;
-
-import java.util.logging.Handler;
-
-import org.apache.cxf.management.web.logging.LogRecord;
-
-
-public final class AtomPullHandler extends Handler {
-
- private AtomPullServer engine;
- /**
- * Creates handler using (package private).
- *
- * @param engine configured engine.
- */
- AtomPullHandler(AtomPullServer engine) {
- this.engine = engine;
- }
-
- @Override
- public void publish(java.util.logging.LogRecord record) {
- if (LoggingThread.isSilent()) {
- return;
- }
- LoggingThread.markSilent(true);
- try {
- LogRecord rec = LogRecord.fromJUL(record);
- engine.publish(rec);
- } finally {
- LoggingThread.markSilent(false);
- }
- }
-
- @Override
- public synchronized void close() throws SecurityException {
- engine.close();
- }
-
- @Override
- public synchronized void flush() {
- // no-op
- }
-}