Author: chetanm Date: Wed Oct 12 17:02:00 2016 New Revision: 1764489 URL: http://svn.apache.org/viewvc?rev=1764489&view=rev Log: SLING-5932 - Move Web Console Plugin to separate bundle
Added: sling/trunk/bundles/commons/log-webconsole/ sling/trunk/bundles/commons/log-webconsole/pom.xml - copied, changed from r1764477, sling/trunk/bundles/commons/log/pom.xml sling/trunk/bundles/commons/log-webconsole/src/ sling/trunk/bundles/commons/log-webconsole/src/main/ sling/trunk/bundles/commons/log-webconsole/src/main/appended-resources/ sling/trunk/bundles/commons/log-webconsole/src/main/appended-resources/META-INF/ sling/trunk/bundles/commons/log-webconsole/src/main/appended-resources/META-INF/LICENSE (with props) sling/trunk/bundles/commons/log-webconsole/src/main/appended-resources/META-INF/NOTICE - copied, changed from r1764477, sling/trunk/bundles/commons/log/src/main/appended-resources/META-INF/NOTICE sling/trunk/bundles/commons/log-webconsole/src/main/java/ sling/trunk/bundles/commons/log-webconsole/src/main/java/org/ sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/ sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/ sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/ sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/ sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/ sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/ sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/Activator.java (with props) sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/LogWebConsolePlugin.java (with props) sling/trunk/bundles/commons/log-webconsole/src/main/resources/ sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/ sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/jquery.autocomplete.css (contents, props changed) - copied, changed from r1764477, sling/trunk/bundles/commons/log/src/main/resources/res/ui/jquery.autocomplete.css sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/jquery.autocomplete.min.js (contents, props changed) - copied, changed from r1764477, sling/trunk/bundles/commons/log/src/main/resources/res/ui/jquery.autocomplete.min.js sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/log.css (contents, props changed) - copied, changed from r1764477, sling/trunk/bundles/commons/log/src/main/resources/res/ui/log.css sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/prettify.css (contents, props changed) - copied, changed from r1764477, sling/trunk/bundles/commons/log/src/main/resources/res/ui/prettify.css sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/prettify.js (contents, props changed) - copied, changed from r1764477, sling/trunk/bundles/commons/log/src/main/resources/res/ui/prettify.js sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/resourceresolver.css (contents, props changed) - copied, changed from r1764477, sling/trunk/bundles/resourceresolver/src/main/resources/res/ui/resourceresolver.css sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/slinglog.js (contents, props changed) - copied, changed from r1764477, sling/trunk/bundles/commons/log/src/main/resources/res/ui/slinglog.js sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/styles.css (contents, props changed) - copied, changed from r1764477, sling/trunk/bundles/servlets/resolver/src/main/resources/res/ui/styles.css sling/trunk/bundles/commons/log-webconsole/src/test/ sling/trunk/bundles/commons/log-webconsole/src/test/java/ sling/trunk/bundles/commons/log-webconsole/src/test/java/org/ sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/ sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/ sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/ sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/ sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ITLogWebConsolePlugin.java (contents, props changed) - copied, changed from r1764477, sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITLogWebConsolePlugin.java sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ITWebConsoleRemote.java (contents, props changed) - copied, changed from r1764477, sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITWebConsoleRemote.java sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/LogTestBase.java - copied, changed from r1764477, sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/LogTestBase.java sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/remote/ sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/remote/WebConsoleTestActivator.java (contents, props changed) - copied, changed from r1764477, sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/remote/WebConsoleTestActivator.java sling/trunk/bundles/commons/log-webconsole/src/test/resources/ sling/trunk/bundles/commons/log-webconsole/src/test/resources/exam.properties (with props) sling/trunk/bundles/commons/log-webconsole/src/test/resources/test-webconsole-remote.xml (contents, props changed) - copied, changed from r1764477, sling/trunk/bundles/commons/log/src/test/resources/test-webconsole-remote.xml sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/ sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/LogPanel.java (with props) sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/LoggerConfig.java (with props) sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/TailerOptions.java (with props) sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/package-info.java (with props) Removed: sling/trunk/bundles/commons/log/src/main/resources/res/ sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITLogWebConsolePlugin.java sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITWebConsoleRemote.java sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/remote/ sling/trunk/bundles/commons/log/src/test/resources/test-webconsole-remote.xml sling/trunk/bundles/resourceresolver/src/main/resources/ sling/trunk/bundles/servlets/resolver/src/main/resources/res/ Modified: sling/trunk/bundles/commons/log/pom.xml sling/trunk/bundles/commons/log/src/main/appended-resources/META-INF/NOTICE sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/LogbackManager.java sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/SlingLogPanel.java sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/LogTestBase.java Copied: sling/trunk/bundles/commons/log-webconsole/pom.xml (from r1764477, sling/trunk/bundles/commons/log/pom.xml) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/pom.xml?p2=sling/trunk/bundles/commons/log-webconsole/pom.xml&p1=sling/trunk/bundles/commons/log/pom.xml&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== --- sling/trunk/bundles/commons/log/pom.xml (original) +++ sling/trunk/bundles/commons/log-webconsole/pom.xml Wed Oct 12 17:02:00 2016 @@ -27,21 +27,19 @@ <relativePath /> </parent> - <artifactId>org.apache.sling.commons.log</artifactId> - <version>4.0.7-SNAPSHOT</version> + <artifactId>org.apache.sling.commons.log.webconsole</artifactId> + <version>0.0.1-SNAPSHOT</version> <packaging>bundle</packaging> - <name>Apache Sling SLF4J Implementation (Logback)</name> + <name>Apache Sling Log WebConsole</name> <description> - This bundle embeds Logback which provides the SLF4J logging API. - The embedding supports dynamic OSGi-configuration without - requiring to edit some global filesystem based XML file. + This bundle provides webconsole plugin for Sling Commons Log </description> <scm> - <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/log</connection> - <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/log</developerConnection> - <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log</url> + <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/log-webconsole</connection> + <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/log-webconsole</developerConnection> + <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole</url> </scm> <properties> @@ -58,36 +56,6 @@ </properties> <build> - <pluginManagement> - <plugins> - <!-- - Unfortunately the <ignores> sections do not seem to - properly work, so the sniffer is disabled by default. - - Note: 1.9 contains a call to a Java 7 specific method - (java.nio.CharBuffer.subSequence(II)Ljava/nio/CharBuffer;) - that is triggered when an undefined reference is found. This breaks error - reporting on Java 5/6. - --> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>animal-sniffer-maven-plugin</artifactId> - <version>1.8</version> - <configuration> - <skip>true</skip> - <ignores> - <ignore>ch.qos.logback.classic.spi*</ignore> - </ignores> - <signature> - <groupId>org.codehaus.mojo.signature</groupId> - <artifactId>java1${sling.java.version}</artifactId> - <version>1.0</version> - </signature> - </configuration> - </plugin> - </plugins> - </pluginManagement> - <plugins> <plugin> <groupId>org.apache.felix</groupId> @@ -96,59 +64,20 @@ <configuration> <instructions> <Bundle-Activator> - org.apache.sling.commons.log.logback.internal.Activator + org.apache.sling.commons.log.webconsole.internal.Activator </Bundle-Activator> <Bundle-DocURL> http://sling.apache.org/site/logging.html </Bundle-DocURL> - <_exportcontents> - org.slf4j.impl;version=${slf4j.version}, - ch.qos.logback.classic*; - ch.qos.logback.core*; - </_exportcontents> + <Embed-Dependency> + org.apache.sling.commons.osgi;inline= + org/apache/sling/commons/osgi/PropertiesUtil*.class + </Embed-Dependency> <Import-Package> - !org.slf4j.impl, - !org.osgi.service.cm, - !javax.servlet, - !javax.servlet.http, - !org.osgi.service.event, - !javax.xml.transform, - !javax.xml.transform.sax, - !javax.xml.transform.stream, - org.osgi.framework;version=1.3, - org.slf4j;version="[1.6,1.8)", - org.slf4j.spi;version="[1.6,1.8)", - !groovy.lang, - !org.codehaus.*, - !javax.jms, - !javax.mail, - !javax.mail.internet, - javax.management; - javax.naming; - javax.sql; - javax.xml.parsers; - org.xml.sax.*; - sun.reflect;resolution:=optional, + javax.servlet; + javax.servlet.http;version=2.3, * </Import-Package> - <Export-Package> - org.apache.sling.commons.log.logback - </Export-Package> - <DynamicImport-Package> - org.osgi.service.cm;version=1.2, - javax.servlet, - javax.servlet.http;version=2.3, - org.osgi.service.event;version=1.2, - <!-- Required by WebConsole support--> - javax.xml.transform, - javax.xml.transform.sax, - javax.xml.transform.stream - </DynamicImport-Package> - <Embed-Dependency> - jul-to-slf4j;inline="org/slf4j/bridge/SLF4JBridgeHandler.class", - logback-core, - logback-classic - </Embed-Dependency> </instructions> </configuration> </plugin> @@ -292,19 +221,34 @@ <version>${logback.version}</version> <scope>compile</scope> </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.commons.log</artifactId> + <version>4.0.7-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.commons.osgi</artifactId> + <version>2.2.0</version> + </dependency> <!-- OSGi Libraries not included here --> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> - <version>4.2.0</version> + <version>5.0.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.compendium</artifactId> + <version>5.0.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.webconsole</artifactId> <version>4.2.0</version> - <scope>provided</scope> </dependency> <!-- servlet API for the web console plugin --> @@ -399,12 +343,6 @@ <!-- Required for testing WebConsole Support --> <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.webconsole</artifactId> - <version>3.1.8</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20070829</version> @@ -452,6 +390,11 @@ <version>1.3</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.inventory</artifactId> + <version>1.0.4</version> + </dependency> </dependencies> <profiles> @@ -474,7 +417,7 @@ </goals> <configuration> <target> - <copy file="${project.build.directory}/${project.build.finalName}.jar" tofile="${project.build.directory}/slinglogback.jar" /> + <copy file="${project.build.directory}/${project.build.finalName}.jar" tofile="${project.build.directory}/slinglogback-webconsole.jar" /> </target> </configuration> </execution> Added: sling/trunk/bundles/commons/log-webconsole/src/main/appended-resources/META-INF/LICENSE URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/main/appended-resources/META-INF/LICENSE?rev=1764489&view=auto ============================================================================== --- sling/trunk/bundles/commons/log-webconsole/src/main/appended-resources/META-INF/LICENSE (added) +++ sling/trunk/bundles/commons/log-webconsole/src/main/appended-resources/META-INF/LICENSE Wed Oct 12 17:02:00 2016 @@ -0,0 +1,244 @@ + + +APACHE SLING COMMONS LOG SUBCOMPONENTS: + +The Apache Sling Script Commons Log Plugin includes a number of subcomponents +with separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and conditions +of the following licenses. + +For the Logback Core and Logback Classic + +Eclipse Public License -v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF +THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + a) in the case of the initial Contributor, the initial code and + documentation distributed under this Agreement, and + b) in the case of each subsequent Contributor: + i) changes to the Program, and + ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' +from a Contributor if it was added to the Program by such Contributor +itself or anyone acting on such Contributor's behalf. Contributions do +not include additions to the Program which: (i) are separate modules of +software distributed in conjunction with the Program under their own +license agreement, and (ii) are not derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents" mean patent claims licensable by a Contributor which +are necessarily infringed by the use or sale of its Contribution alone or +when combined with the Program. + +"Program" means the Contributions distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free copyright + license to reproduce, prepare derivative works of, publicly display, + publicly perform, distribute and sublicense the Contribution of such + Contributor, if any, and such derivative works, in source code and + object code form. + b) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free patent + license under Licensed Patents to make, use, sell, offer to sell, + import and otherwise transfer the Contribution of such Contributor, + if any, in source code and object code form. This patent license + shall apply to the combination of the Contribution and the Program + if, at the time the Contribution is added by the Contributor, such + addition of the Contribution causes such combination to be covered + by the Licensed Patents. The patent license shall not apply to any + other combinations which include the Contribution. No hardware per + se is licensed hereunder. + c) Recipient understands that although each Contributor grants the + licenses to its Contributions set forth herein, no assurances are + provided by any Contributor that the Program does not infringe the + patent or other intellectual property rights of any other entity. + Each Contributor disclaims any liability to Recipient for claims + brought by any other entity based on infringement of intellectual + property rights or otherwise. As a condition to exercising the + rights and licenses granted hereunder, each Recipient hereby + assumes sole responsibility to secure any other intellectual + property rights needed, if any. For example, if a third party + patent license is required to allow Recipient to distribute the + Program, it is Recipient's responsibility to acquire that license + before distributing the Program. + d) Each Contributor represents that to its knowledge it has sufficient + copyright rights in its Contribution, if any, to grant the copyright + license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form +under its own license agreement, provided that: + + a) it complies with the terms and conditions of this Agreement; and + b) its license agreement: + i) effectively disclaims on behalf of all Contributors all warranties + and conditions, express and implied, including warranties or + conditions of title and non-infringement, and implied warranties or + conditions of merchantability and fitness for a particular purpose; + ii) effectively excludes on behalf of all Contributors all liability + for damages, including direct, indirect, special, incidental and + consequential damages, such as lost profits; + iii) states that any provisions which differ from this Agreement are + offered by that Contributor alone and not by any other party; and + iv) states that source code for the Program is available from such + Contributor, and informs licensees how to obtain it in a reasonable + manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + + a) it must be made available under this Agreement; and + b) a copy of this Agreement must be included with each copy of the + Program. + +Contributors may not remove or alter any copyright notices contained +within the Program. + +Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities +with respect to end users, business partners and the like. While this +license is intended to facilitate the commercial use of the Program, the +Contributor who includes the Program in a commercial product offering +should do so in a manner which does not create potential liability for +other Contributors. Therefore, if a Contributor includes the Program in a +commercial product offering, such Contributor ("Commercial Contributor") +hereby agrees to defend and indemnify every other Contributor ("Indemnified +Contributor") against any losses, damages and costs (collectively "Losses") +arising from claims, lawsuits and other legal actions brought by a third +party against the Indemnified Contributor to the extent caused by the acts +or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses relating +to any actual or alleged intellectual property infringement. In order to +qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial +Contributor to control, and cooperate with the Commercial Contributor in, +the defense and any related settlement negotiations. The Indemnified +Contributor may participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance claims, +or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under +this section, the Commercial Contributor would have to defend claims +against the other Contributors related to those performance claims and +warranties, and if a court requires any other Contributor to pay any +damages as a result, the Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED +ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER +EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR +CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A +PARTICULAR PURPOSE. Each Recipient is solely responsible for determining +the appropriateness of using and distributing the Program and assumes all +risks associated with its exercise of rights under this Agreement, +including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR +ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION +OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of the +remainder of the terms of this Agreement, and without further action by +the parties hereto, such provision shall be reformed to the minimum extent +necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Program itself +(excluding combinations of the Program with other software or hardware) +infringes such Recipient's patent(s), then such Recipient's rights granted +under Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and +does not cure such failure in a reasonable period of time after becoming +aware of such noncompliance. If all Recipient's rights under this Agreement +terminate, Recipient agrees to cease use and distribution of the Program as +soon as reasonably practicable. However, Recipient's obligations under this +Agreement and any licenses granted by Recipient relating to the Program +shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but +in order to avoid inconsistency the Agreement is copyrighted and may only +be modified in the following manner. The Agreement Steward reserves the +right to publish new versions (including revisions) of this Agreement from +time to time. No one other than the Agreement Steward has the right to +modify this Agreement. The Eclipse Foundation is the initial Agreement +Steward. The Eclipse Foundation may assign the responsibility to serve as +the Agreement Steward to a suitable separate entity. Each new version of +the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version +of the Agreement under which it was received. In addition, after a new +version of the Agreement is published, Contributor may elect to distribute +the Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives no +rights or licenses to the intellectual property of any Contributor under +this Agreement, whether expressly, by implication, estoppel or otherwise. +All rights in the Program not expressly granted under this Agreement are +reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to +this Agreement will bring a legal action under this Agreement more than +one year after the cause of action arose. Each party waives its rights to +a jury trial in any resulting litigation. + + +For JUL-to-SLF4J Bridge + +Copyright (c) 2004-2013 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file Propchange: sling/trunk/bundles/commons/log-webconsole/src/main/appended-resources/META-INF/LICENSE ------------------------------------------------------------------------------ svn:eol-style = native Copied: sling/trunk/bundles/commons/log-webconsole/src/main/appended-resources/META-INF/NOTICE (from r1764477, sling/trunk/bundles/commons/log/src/main/appended-resources/META-INF/NOTICE) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/main/appended-resources/META-INF/NOTICE?p2=sling/trunk/bundles/commons/log-webconsole/src/main/appended-resources/META-INF/NOTICE&p1=sling/trunk/bundles/commons/log/src/main/appended-resources/META-INF/NOTICE&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== (empty) Added: sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/Activator.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/Activator.java?rev=1764489&view=auto ============================================================================== --- sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/Activator.java (added) +++ sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/Activator.java Wed Oct 12 17:02:00 2016 @@ -0,0 +1,57 @@ +/* + * 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.sling.commons.log.webconsole.internal; + +import org.apache.sling.commons.log.logback.webconsole.LogPanel; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.util.tracker.ServiceTracker; + +public class Activator implements BundleActivator { + private ServiceTracker<LogPanel, LogWebConsolePlugin> panelTracker; + + @Override + public void start(BundleContext context) throws Exception { + panelTracker = new ServiceTracker<LogPanel, LogWebConsolePlugin>(context, LogPanel.class, null) { + @Override + public LogWebConsolePlugin addingService(ServiceReference<LogPanel> reference) { + LogPanel panel = context.getService(reference); + LogWebConsolePlugin plugin = new LogWebConsolePlugin(panel); + plugin.register(context); + return plugin; + } + + @Override + public void removedService(ServiceReference<LogPanel> reference, LogWebConsolePlugin plugin) { + plugin.unregister(); + context.ungetService(reference); + } + }; + panelTracker.open(); + } + + @Override + public void stop(BundleContext context) throws Exception { + if (panelTracker != null) { + panelTracker.close(); + } + } +} Propchange: sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/Activator.java ------------------------------------------------------------------------------ svn:eol-style = native Added: sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/LogWebConsolePlugin.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/LogWebConsolePlugin.java?rev=1764489&view=auto ============================================================================== --- sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/LogWebConsolePlugin.java (added) +++ sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/LogWebConsolePlugin.java Wed Oct 12 17:02:00 2016 @@ -0,0 +1,121 @@ +/* + * 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.sling.commons.log.webconsole.internal; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.felix.webconsole.SimpleWebConsolePlugin; +import org.apache.sling.commons.log.logback.webconsole.LogPanel; +import org.apache.sling.commons.log.logback.webconsole.LoggerConfig; +import org.apache.sling.commons.log.logback.webconsole.TailerOptions; +import org.apache.sling.commons.osgi.PropertiesUtil; + +import static org.apache.sling.commons.log.logback.webconsole.LogPanel.APP_ROOT; +import static org.apache.sling.commons.log.logback.webconsole.LogPanel.PARAM_APPENDER_NAME; +import static org.apache.sling.commons.log.logback.webconsole.LogPanel.PARAM_NUM_OF_LINES; +import static org.apache.sling.commons.log.logback.webconsole.LogPanel.PATH_TAILER; + +public class LogWebConsolePlugin extends SimpleWebConsolePlugin { + private static final String RES_LOC = LogPanel.APP_ROOT + "/res/ui"; + + private static final String[] CSS_REFS = { + RES_LOC + "/jquery.autocomplete.css", + RES_LOC + "/prettify.css", + RES_LOC + "/log.css", + }; + + private final LogPanel panel; + + public LogWebConsolePlugin(LogPanel panel) { + super(LogPanel.APP_ROOT, "Log Support", "Sling", CSS_REFS); + this.panel = panel; + } + + @Override + protected void renderContent(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + final PrintWriter pw = resp.getWriter(); + final String consoleAppRoot = getAppRoot(req); + + if (req.getPathInfo() != null) { + if (req.getPathInfo().endsWith(PATH_TAILER)) { + String appenderName = req.getParameter(PARAM_APPENDER_NAME); + addNoSniffHeader(resp); + if (appenderName == null) { + pw.printf("Provide appender name via [%s] request parameter%n", PARAM_APPENDER_NAME); + return; + } + int numOfLines = PropertiesUtil.toInteger(req.getParameter(PARAM_NUM_OF_LINES), 0); + TailerOptions opts = new TailerOptions(numOfLines); + panel.tail(pw, appenderName, opts); + return; + } + } + + panel.render(pw, consoleAppRoot); + } + + @Override + protected boolean isHtmlRequest(HttpServletRequest request) { + return !request.getRequestURI().endsWith(PATH_TAILER); + } + + @Override + protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) + throws ServletException, IOException { + // check if a configuration should be deleted + boolean isDelete = req.getParameter("delete") != null; + // get the configuration pid + String pid = req.getParameter("pid"); + if (isDelete) { + // in delete mode remove the logger with the given pid + panel.deleteLoggerConfig(pid); + } else { + // get the logger parameters and configure the logger + // if the given pid is empty a new logger with be created + String logger = req.getParameter("logger"); + String logLevel = req.getParameter("loglevel"); + String logFile = req.getParameter("logfile"); + boolean additive = PropertiesUtil.toBoolean(req.getParameter("logAdditive"), false); + String[] loggers = req.getParameterValues("logger"); + if (null != logger) { + LoggerConfig config = new LoggerConfig(pid, logLevel, loggers, logFile, additive); + panel.createLoggerConfig(config); + } + } + + // send the redirect back to the logpanel + final String consoleAppRoot = getAppRoot(req); + resp.sendRedirect(consoleAppRoot + "/" + APP_ROOT); + } + + private static String getAppRoot(HttpServletRequest req) { + return (String) req.getAttribute("felix.webconsole.appRoot"); + } + + private static void addNoSniffHeader(HttpServletResponse resp) { + resp.setHeader("X-Content-Type-Options", "nosniff"); + } +} Propchange: sling/trunk/bundles/commons/log-webconsole/src/main/java/org/apache/sling/commons/log/webconsole/internal/LogWebConsolePlugin.java ------------------------------------------------------------------------------ svn:eol-style = native Copied: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/jquery.autocomplete.css (from r1764477, sling/trunk/bundles/commons/log/src/main/resources/res/ui/jquery.autocomplete.css) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/jquery.autocomplete.css?p2=sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/jquery.autocomplete.css&p1=sling/trunk/bundles/commons/log/src/main/resources/res/ui/jquery.autocomplete.css&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== (empty) Propchange: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/jquery.autocomplete.css ------------------------------------------------------------------------------ svn:eol-style = native Copied: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/jquery.autocomplete.min.js (from r1764477, sling/trunk/bundles/commons/log/src/main/resources/res/ui/jquery.autocomplete.min.js) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/jquery.autocomplete.min.js?p2=sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/jquery.autocomplete.min.js&p1=sling/trunk/bundles/commons/log/src/main/resources/res/ui/jquery.autocomplete.min.js&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== (empty) Propchange: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/jquery.autocomplete.min.js ------------------------------------------------------------------------------ svn:eol-style = native Copied: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/log.css (from r1764477, sling/trunk/bundles/commons/log/src/main/resources/res/ui/log.css) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/log.css?p2=sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/log.css&p1=sling/trunk/bundles/commons/log/src/main/resources/res/ui/log.css&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== (empty) Propchange: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/log.css ------------------------------------------------------------------------------ svn:eol-style = native Copied: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/prettify.css (from r1764477, sling/trunk/bundles/commons/log/src/main/resources/res/ui/prettify.css) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/prettify.css?p2=sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/prettify.css&p1=sling/trunk/bundles/commons/log/src/main/resources/res/ui/prettify.css&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== (empty) Propchange: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/prettify.css ------------------------------------------------------------------------------ svn:eol-style = native Copied: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/prettify.js (from r1764477, sling/trunk/bundles/commons/log/src/main/resources/res/ui/prettify.js) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/prettify.js?p2=sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/prettify.js&p1=sling/trunk/bundles/commons/log/src/main/resources/res/ui/prettify.js&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== (empty) Propchange: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/prettify.js ------------------------------------------------------------------------------ svn:eol-style = native Copied: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/resourceresolver.css (from r1764477, sling/trunk/bundles/resourceresolver/src/main/resources/res/ui/resourceresolver.css) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/resourceresolver.css?p2=sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/resourceresolver.css&p1=sling/trunk/bundles/resourceresolver/src/main/resources/res/ui/resourceresolver.css&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== (empty) Propchange: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/resourceresolver.css ------------------------------------------------------------------------------ svn:eol-style = native Copied: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/slinglog.js (from r1764477, sling/trunk/bundles/commons/log/src/main/resources/res/ui/slinglog.js) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/slinglog.js?p2=sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/slinglog.js&p1=sling/trunk/bundles/commons/log/src/main/resources/res/ui/slinglog.js&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== (empty) Propchange: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/slinglog.js ------------------------------------------------------------------------------ svn:eol-style = native Copied: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/styles.css (from r1764477, sling/trunk/bundles/servlets/resolver/src/main/resources/res/ui/styles.css) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/styles.css?p2=sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/styles.css&p1=sling/trunk/bundles/servlets/resolver/src/main/resources/res/ui/styles.css&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== (empty) Propchange: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/styles.css ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/trunk/bundles/commons/log-webconsole/src/main/resources/res/ui/styles.css ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Rev URL Copied: sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ITLogWebConsolePlugin.java (from r1764477, sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITLogWebConsolePlugin.java) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ITLogWebConsolePlugin.java?p2=sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ITLogWebConsolePlugin.java&p1=sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITLogWebConsolePlugin.java&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== --- sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITLogWebConsolePlugin.java (original) +++ sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ITLogWebConsolePlugin.java Wed Oct 12 17:02:00 2016 @@ -17,15 +17,13 @@ * under the License. */ -package org.apache.sling.commons.log.logback.integration; +package org.apache.sling.commons.log.webconsole; import javax.inject.Inject; import javax.servlet.Servlet; -import org.apache.sling.commons.log.logback.integration.LogTestBase; import org.junit.Test; import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.junit.PaxExam; import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; import org.ops4j.pax.exam.spi.reactors.PerClass; @@ -47,11 +45,6 @@ public class ITLogWebConsolePlugin exten } - @Override - protected Option addExtraOptions() { - return webSupport(); - } - /** * Checks the presence of plugin servlet if Servlet API is present */ Propchange: sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ITLogWebConsolePlugin.java ------------------------------------------------------------------------------ svn:eol-style = native Copied: sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ITWebConsoleRemote.java (from r1764477, sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITWebConsoleRemote.java) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ITWebConsoleRemote.java?p2=sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ITWebConsoleRemote.java&p1=sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITWebConsoleRemote.java&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== --- sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITWebConsoleRemote.java (original) +++ sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ITWebConsoleRemote.java Wed Oct 12 17:02:00 2016 @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.sling.commons.log.logback.integration; +package org.apache.sling.commons.log.webconsole; import java.io.File; import java.io.IOException; @@ -27,7 +27,7 @@ import com.gargoylesoftware.htmlunit.Pag import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlPage; import org.apache.commons.io.FilenameUtils; -import org.apache.sling.commons.log.logback.integration.remote.WebConsoleTestActivator; +import org.apache.sling.commons.log.webconsole.remote.WebConsoleTestActivator; import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; @@ -43,9 +43,7 @@ import static org.junit.Assert.assertEqu import static org.junit.Assert.assertTrue; import static org.ops4j.pax.exam.CoreOptions.composite; import static org.ops4j.pax.exam.CoreOptions.frameworkProperty; -import static org.ops4j.pax.exam.CoreOptions.mavenBundle; import static org.ops4j.pax.exam.CoreOptions.provision; -import static org.ops4j.pax.exam.CoreOptions.wrappedBundle; import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle; import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd; @@ -53,7 +51,7 @@ public class ITWebConsoleRemote extends private static final String PLUGIN_SUFFIX = "slinglog"; - private static final String PRINTER_SUFFIX = "config/slinglogs.nfo"; + private static final String PRINTER_SUFFIX = "status-slinglogs"; private static TestContainer testContainer; @@ -66,16 +64,7 @@ public class ITWebConsoleRemote extends @Override protected Option addExtraOptions() { - return composite(webSupport(), - mavenBundle("org.apache.sling", "org.apache.sling.commons.logservice").versionAsInProject(), - mavenBundle("org.apache.felix", "org.apache.felix.http.jetty").versionAsInProject(), - mavenBundle("org.apache.felix", "org.apache.felix.webconsole").versionAsInProject(), - mavenBundle("org.apache.felix", "org.apache.felix.metatype").versionAsInProject(), - mavenBundle("org.apache.felix", "org.apache.felix.scr").versionAsInProject(), - mavenBundle("commons-io", "commons-io").versionAsInProject(), - wrappedBundle(mavenBundle("commons-fileupload", "commons-fileupload").versionAsInProject()), - wrappedBundle(mavenBundle("org.json", "json").versionAsInProject()), - configAdmin(), + return composite( frameworkProperty("org.apache.sling.commons.log.configurationFile").value( FilenameUtils.concat(new File(".").getAbsolutePath(), "src/test/resources/test-webconsole-remote.xml")), createWebConsoleTestBundle() @@ -152,6 +141,6 @@ public class ITWebConsoleRemote extends } private static String prepareUrl(String suffix) { - return String.format("http://localhost:%s/system/console/%s", getServerPort(), suffix); + return String.format("http://localhost:%s/system/console/%s", LogTestBase.getServerPort(), suffix); } } Propchange: sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/ITWebConsoleRemote.java ------------------------------------------------------------------------------ svn:eol-style = native Copied: sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/LogTestBase.java (from r1764477, sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/LogTestBase.java) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/LogTestBase.java?p2=sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/LogTestBase.java&p1=sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/LogTestBase.java&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== --- sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/LogTestBase.java (original) +++ sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/LogTestBase.java Wed Oct 12 17:02:00 2016 @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.sling.commons.log.logback.integration; +package org.apache.sling.commons.log.webconsole; import java.io.File; import java.io.IOException; @@ -34,6 +34,7 @@ import org.ops4j.pax.exam.options.Defaul import org.osgi.framework.BundleContext; import static org.ops4j.pax.exam.CoreOptions.composite; +import static org.ops4j.pax.exam.CoreOptions.frameworkProperty; import static org.ops4j.pax.exam.CoreOptions.junitBundles; import static org.ops4j.pax.exam.CoreOptions.keepCaches; import static org.ops4j.pax.exam.CoreOptions.mavenBundle; @@ -41,6 +42,7 @@ import static org.ops4j.pax.exam.CoreOpt import static org.ops4j.pax.exam.CoreOptions.systemProperty; import static org.ops4j.pax.exam.CoreOptions.systemTimeout; import static org.ops4j.pax.exam.CoreOptions.workingDirectory; +import static org.ops4j.pax.exam.CoreOptions.wrappedBundle; import static org.ops4j.pax.exam.util.PathUtils.getBaseDir; public abstract class LogTestBase { @@ -57,7 +59,7 @@ public abstract class LogTestBase { protected static final String COVERAGE_COMMAND = "coverage.command"; // the default bundle jar file name - protected static final String BUNDLE_JAR_DEFAULT = "target/slinglogback.jar"; + protected static final String BUNDLE_JAR_DEFAULT = "target/slinglogback-webconsole.jar"; // the JVM option to set to enable remote debugging @SuppressWarnings("UnusedDeclaration") @@ -85,7 +87,20 @@ public abstract class LogTestBase { return options( // the current project (the bundle under test) CoreOptions.bundle(bundleFile.toURI().toString()), - mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(), addPaxExamSpecificOptions(), + mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(), + mavenBundle("org.apache.sling", "org.apache.sling.commons.logservice").versionAsInProject(), + LogTestBase.webSupport(), + mavenBundle("org.apache.sling", "org.apache.sling.commons.log").versionAsInProject(), + mavenBundle("org.apache.felix", "org.apache.felix.http.jetty").versionAsInProject(), + mavenBundle("org.apache.felix", "org.apache.felix.webconsole").versionAsInProject(), + mavenBundle("org.apache.felix", "org.apache.felix.inventory").versionAsInProject(), + mavenBundle("org.apache.felix", "org.apache.felix.metatype").versionAsInProject(), + mavenBundle("org.apache.felix", "org.apache.felix.scr").versionAsInProject(), + mavenBundle("commons-io", "commons-io").versionAsInProject(), + wrappedBundle(mavenBundle("commons-fileupload", "commons-fileupload").versionAsInProject()), + wrappedBundle(mavenBundle("org.json", "json").versionAsInProject()), + LogTestBase.configAdmin(), + addPaxExamSpecificOptions(), addCodeCoverageOption(), addDebugOptions(), addExtraOptions(), addDefaultOptions()); } @@ -136,10 +151,6 @@ public abstract class LogTestBase { return new DefaultCompositeOption(); } - protected static String absolutePath(String configFileName){ - return FilenameUtils.concat(new File(".").getAbsolutePath(), "src/test/resources/"+configFileName); - } - protected static void delay() { try { TimeUnit.MILLISECONDS.sleep(300); Copied: sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/remote/WebConsoleTestActivator.java (from r1764477, sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/remote/WebConsoleTestActivator.java) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/remote/WebConsoleTestActivator.java?p2=sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/remote/WebConsoleTestActivator.java&p1=sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/remote/WebConsoleTestActivator.java&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== --- sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/remote/WebConsoleTestActivator.java (original) +++ sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/remote/WebConsoleTestActivator.java Wed Oct 12 17:02:00 2016 @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.commons.log.logback.integration.remote; +package org.apache.sling.commons.log.webconsole.remote; import java.io.StringReader; import java.util.ArrayList; Propchange: sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/remote/WebConsoleTestActivator.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/trunk/bundles/commons/log-webconsole/src/test/java/org/apache/sling/commons/log/webconsole/remote/WebConsoleTestActivator.java ------------------------------------------------------------------------------ svn:keywords = author date id revision rev url Added: sling/trunk/bundles/commons/log-webconsole/src/test/resources/exam.properties URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/test/resources/exam.properties?rev=1764489&view=auto ============================================================================== --- sling/trunk/bundles/commons/log-webconsole/src/test/resources/exam.properties (added) +++ sling/trunk/bundles/commons/log-webconsole/src/test/resources/exam.properties Wed Oct 12 17:02:00 2016 @@ -0,0 +1,21 @@ +# +# 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. +# + +#Disable the pax logging +pax.exam.logging=none \ No newline at end of file Propchange: sling/trunk/bundles/commons/log-webconsole/src/test/resources/exam.properties ------------------------------------------------------------------------------ svn:eol-style = native Copied: sling/trunk/bundles/commons/log-webconsole/src/test/resources/test-webconsole-remote.xml (from r1764477, sling/trunk/bundles/commons/log/src/test/resources/test-webconsole-remote.xml) URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log-webconsole/src/test/resources/test-webconsole-remote.xml?p2=sling/trunk/bundles/commons/log-webconsole/src/test/resources/test-webconsole-remote.xml&p1=sling/trunk/bundles/commons/log/src/test/resources/test-webconsole-remote.xml&r1=1764477&r2=1764489&rev=1764489&view=diff ============================================================================== (empty) Propchange: sling/trunk/bundles/commons/log-webconsole/src/test/resources/test-webconsole-remote.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/trunk/bundles/commons/log-webconsole/src/test/resources/test-webconsole-remote.xml ------------------------------------------------------------------------------ svn:keywords = Id Modified: sling/trunk/bundles/commons/log/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log/pom.xml?rev=1764489&r1=1764488&r2=1764489&view=diff ============================================================================== --- sling/trunk/bundles/commons/log/pom.xml (original) +++ sling/trunk/bundles/commons/log/pom.xml Wed Oct 12 17:02:00 2016 @@ -132,12 +132,11 @@ * </Import-Package> <Export-Package> - org.apache.sling.commons.log.logback + org.apache.sling.commons.log.logback, + org.apache.sling.commons.log.logback.webconsole </Export-Package> <DynamicImport-Package> org.osgi.service.cm;version=1.2, - javax.servlet, - javax.servlet.http;version=2.3, org.osgi.service.event;version=1.2, <!-- Required by WebConsole support--> javax.xml.transform, @@ -155,24 +154,6 @@ <!-- Required for pax exam--> <plugin> <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>reserve-network-port</id> - <goals> - <goal>reserve-network-port</goal> - </goals> - <phase>pre-integration-test</phase> - <configuration> - <portNames> - <portName>http.port</portName> - </portNames> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0-alpha-2</version> <executions> @@ -187,10 +168,6 @@ <name>project.bundle.file</name> <value>${bundle.file.name}</value> </property> - <property> - <name>http.port</name> - <value>${http.port}</value> - </property> </properties> </configuration> </execution> @@ -229,19 +206,15 @@ </systemPropertyVariables> </configuration> </plugin> - <plugin> - <groupId>org.apache.rat</groupId> - <artifactId>apache-rat-plugin</artifactId> - <configuration> - <excludes> - <exclude>src/main/resources/res/ui/jquery.autocomplete.css</exclude> - <exclude>src/main/resources/res/ui/jquery.autocomplete.min.js</exclude> - <exclude>src/main/resources/res/ui/prettify.css</exclude> - <exclude>src/main/resources/res/ui/prettify.js</exclude> - <exclude>README.md</exclude> - </excludes> - </configuration> - </plugin> + <plugin> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-plugin</artifactId> + <configuration> + <excludes> + <exclude>README.md</exclude> + </excludes> + </configuration> + </plugin> </plugins> </build> @@ -307,13 +280,6 @@ <scope>provided</scope> </dependency> - <!-- servlet API for the web console plugin --> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>2.3</version> - </dependency> - <!-- OSGi Command Line Shell support --> <dependency> <groupId>org.apache.felix</groupId> @@ -373,55 +339,18 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.http.bundle</artifactId> - <version>2.2.0</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.4</version> <scope>test</scope> </dependency> <dependency> - <groupId>net.sourceforge.htmlunit</groupId> - <artifactId>htmlunit</artifactId> - <version>2.12</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.commons.logservice</artifactId> <version>1.0.2</version> <scope>test</scope> </dependency> - <!-- Required for testing WebConsole Support --> - <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.webconsole</artifactId> - <version>3.1.8</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.json</groupId> - <artifactId>json</artifactId> - <version>20070829</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>commons-fileupload</groupId> - <artifactId>commons-fileupload</artifactId> - <version>1.2.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.http.jetty</artifactId> - <version>2.2.0</version> - <scope>test</scope> - </dependency> <dependency> <groupId>org.ops4j.pax.url</groupId> <artifactId>pax-url-wrap</artifactId> Modified: sling/trunk/bundles/commons/log/src/main/appended-resources/META-INF/NOTICE URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log/src/main/appended-resources/META-INF/NOTICE?rev=1764489&r1=1764488&r2=1764489&view=diff ============================================================================== --- sling/trunk/bundles/commons/log/src/main/appended-resources/META-INF/NOTICE (original) +++ sling/trunk/bundles/commons/log/src/main/appended-resources/META-INF/NOTICE Wed Oct 12 17:02:00 2016 @@ -2,11 +2,5 @@ This product includes software from http Copyright (C) 1999-2012, QOS.ch Licensed under the EPL License http://logback.qos.ch/license.html -This product includes software from http://code.google.com/p/google-code-prettify/ -Licensed under the Apache License 2.0. - This product includes software from http://www.slf4j.org/ Licensed under the MIT License - -This product includes software from https://github.com/dyve/jquery-autocomplete -Licensed under the Apache License 2.0. Modified: sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/LogbackManager.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/LogbackManager.java?rev=1764489&r1=1764488&r2=1764489&view=diff ============================================================================== --- sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/LogbackManager.java (original) +++ sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/LogbackManager.java Wed Oct 12 17:02:00 2016 @@ -35,6 +35,7 @@ import java.util.concurrent.TimeUnit; import org.apache.sling.commons.log.logback.internal.AppenderTracker.AppenderInfo; import org.apache.sling.commons.log.logback.internal.util.SlingRollingFileAppender; import org.apache.sling.commons.log.logback.internal.util.SlingStatusPrinter; +import org.apache.sling.commons.log.logback.webconsole.LogPanel; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; @@ -70,21 +71,6 @@ import ch.qos.logback.core.status.Status public class LogbackManager extends LoggerContextAwareBase { private static final String JUL_SUPPORT = "org.apache.sling.commons.log.julenabled"; - //These properties should have been defined in SlingLogPanel - //But we need them while registering ServiceFactory and hence - //would not want to load SlingLogPanel class for registration - //purpose as we need to run in cases where Servlet classes - //are not available - static final String APP_ROOT = "slinglog"; - - static final String RES_LOC = APP_ROOT + "/res/ui"; - - public static final String[] CSS_REFS = { - RES_LOC + "/jquery.autocomplete.css", - RES_LOC + "/prettify.css", - RES_LOC + "/log.css", - }; - private static final String PREFIX = "org.apache.sling.commons.log"; private static final String DEBUG = PREFIX + "." + "debug"; @@ -753,17 +739,11 @@ public class LogbackManager extends Logg } private void registerWebConsoleSupport() { - final ServiceFactory serviceFactory = new PluginServiceFactory(); - - Properties pluginProps = new Properties(); - pluginProps.put(Constants.SERVICE_VENDOR, "Apache Software Foundation"); - pluginProps.put(Constants.SERVICE_DESCRIPTION, "Sling Log Support"); - pluginProps.put("felix.webconsole.label", APP_ROOT); - pluginProps.put("felix.webconsole.title", "Log Support"); - pluginProps.put("felix.webconsole.category", "Sling"); - pluginProps.put("felix.webconsole.css", CSS_REFS); - - registrations.add(bundleContext.registerService("javax.servlet.Servlet", serviceFactory, pluginProps)); + Properties panelProps = new Properties(); + panelProps.put(Constants.SERVICE_VENDOR, "Apache Software Foundation"); + panelProps.put(Constants.SERVICE_DESCRIPTION, "Sling Log Panel Support"); + registrations.add(bundleContext.registerService(LogPanel.class.getName(), + new SlingLogPanel(this, bundleContext), panelProps)); Properties printerProps = new Properties(); printerProps.put(Constants.SERVICE_VENDOR, "Apache Software Foundation"); @@ -777,24 +757,6 @@ public class LogbackManager extends Logg new SlingConfigurationPrinter(this), printerProps)); } - private class PluginServiceFactory implements ServiceFactory { - private Object instance; - - @Override - public Object getService(Bundle bundle, ServiceRegistration registration) { - synchronized (this) { - if (this.instance == null) { - this.instance = new SlingLogPanel(LogbackManager.this,bundleContext); - } - return instance; - } - } - - @Override - public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) { - } - } - private void registerEventHandler() { Properties props = new Properties(); props.put(Constants.SERVICE_VENDOR, "Apache Software Foundation"); Modified: sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/SlingLogPanel.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/SlingLogPanel.java?rev=1764489&r1=1764488&r2=1764489&view=diff ============================================================================== --- sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/SlingLogPanel.java (original) +++ sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/SlingLogPanel.java Wed Oct 12 17:02:00 2016 @@ -18,9 +18,6 @@ */ package org.apache.sling.commons.log.logback.internal; -import static org.apache.sling.commons.log.logback.internal.LogbackManager.APP_ROOT; -import static org.apache.sling.commons.log.logback.internal.LogbackManager.RES_LOC; - import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; @@ -30,7 +27,6 @@ import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLConnection; -import java.net.URLDecoder; import java.net.URLEncoder; import java.util.Collection; import java.util.Dictionary; @@ -40,11 +36,6 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.apache.sling.commons.log.logback.internal.AppenderTracker.AppenderInfo; import org.apache.sling.commons.log.logback.internal.ConfigSourceTracker.ConfigSourceInfo; import org.apache.sling.commons.log.logback.internal.LogbackManager.LoggerStateContext; @@ -52,6 +43,9 @@ import org.apache.sling.commons.log.logb import org.apache.sling.commons.log.logback.internal.util.SlingRollingFileAppender; import org.apache.sling.commons.log.logback.internal.util.Util; import org.apache.sling.commons.log.logback.internal.util.XmlUtil; +import org.apache.sling.commons.log.logback.webconsole.LogPanel; +import org.apache.sling.commons.log.logback.webconsole.LoggerConfig; +import org.apache.sling.commons.log.logback.webconsole.TailerOptions; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.ServiceReference; @@ -77,21 +71,7 @@ import ch.qos.logback.core.util.CachingD * In future revisions of this plugin, the configuration may probably even be * modified through this panel. */ -public class SlingLogPanel extends HttpServlet { - - private static final long serialVersionUID = 1L; - - /** - * Request param name to control number of lines to include in the log - */ - private static final String PARAM_NUM_OF_LINES = "tail"; - private static final String PARAM_APPENDER_NAME = "name"; - - /** - * Let the path end with extension. In that case WebConsole logic would by pass this request's - * response completely - */ - private static final String PATH_TAILER = "tailer.txt"; +public class SlingLogPanel implements LogPanel { private final CachingDateFormatter SDF = new CachingDateFormatter("yyyy-MM-dd HH:mm:ss"); @@ -124,26 +104,14 @@ public class SlingLogPanel extends HttpS } @Override - protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { - - final PrintWriter pw = resp.getWriter(); - - final String consoleAppRoot = (String) req.getAttribute("felix.webconsole.appRoot"); - + public void tail(PrintWriter pw, String appenderName, TailerOptions options) throws IOException { final LoggerStateContext ctx = logbackManager.determineLoggerState(); - if (req.getPathInfo() != null) { - if (req.getPathInfo().endsWith(PATH_TAILER)){ - String appenderName = req.getParameter(PARAM_APPENDER_NAME); - addNoSniffHeader(resp); - if (appenderName == null){ - pw.printf("Provide appender name via [%s] request parameter%n", PARAM_APPENDER_NAME); - return; - } - renderAppenderContent(ctx, pw, appenderName, getNumOfLines(req)); - return; - } - } + renderAppenderContent(ctx, pw, appenderName, options); + } + @Override + public void render(PrintWriter pw, String consoleAppRoot) throws IOException { + final LoggerStateContext ctx = logbackManager.determineLoggerState(); appendLoggerStatus(pw, ctx); appendOsgiConfiguredLoggerData(pw, consoleAppRoot); appendOtherLoggerData(pw, ctx); @@ -156,34 +124,22 @@ public class SlingLogPanel extends HttpS } @Override - protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) - throws ServletException, IOException { - // check if a configuration should be deleted - boolean isDelete = req.getParameter("delete") != null; - // get the configuration pid - String pid = req.getParameter("pid"); + public void deleteLoggerConfig(String pid) { try { - if (isDelete) { - // in delete mode remove the logger with the given pid - removeLogger(pid); - } else { - // get the logger parameters and configure the logger - // if the given pid is empty a new logger with be created - String logger = req.getParameter("logger"); - String logLevel = req.getParameter("loglevel"); - String logFile = req.getParameter("logfile"); - String additive = req.getParameter("logAdditive"); - String[] loggers = req.getParameterValues("logger"); - if (null != logger) { - configureLogger(pid, logLevel, loggers, logFile, additive); - } - } + removeLogger(pid); + } catch (ConfigurationException e) { + internalFailure("", e); + } + } + + @Override + public void createLoggerConfig(LoggerConfig config) throws IOException { + try { + configureLogger(config.getPid(), config.getLogLevel(), config.getLoggers(), + config.getLogFile(), config.isAdditive()); } catch (ConfigurationException e) { internalFailure("", e); } - // send the redirect back to the logpanel - final String consoleAppRoot = (String) req.getAttribute("felix.webconsole.appRoot"); - resp.sendRedirect(consoleAppRoot + "/" + APP_ROOT); } private void addScriptBlock(final PrintWriter pw, final LoggerStateContext ctx) { @@ -580,24 +536,6 @@ public class SlingLogPanel extends HttpS } /** - * Called internally by AbstractWebConsolePlugin to load resources. - * This particular implementation depends on the label. As example, if the - * plugin is accessed as <code>/system/console/abc</code>, and the plugin - * resources are accessed like <code>/system/console/abc/res/logo.gif</code> - * , the code here will try load resource <code>/res/logo.gif</code> from - * the bundle, providing the plugin. - * - * @param path the path to read. - * @return the URL of the resource or <code>null</code> if not found. - */ - @SuppressWarnings("UnusedDeclaration") - protected URL getResource(String path) { - return (path != null && path.startsWith(labelRes)) ? // - getClass().getResource(path.substring(labelResLen)) - : null; - } - - /** * Checks if all log files are in the same folder, then the path can displayed shortened in the panel. * * @param logWriters list of log writers @@ -621,15 +559,19 @@ public class SlingLogPanel extends HttpS return true; } - private void renderAppenderContent(LoggerStateContext ctx, PrintWriter pw, String appenderName, int numOfLines) + private void renderAppenderContent(LoggerStateContext ctx, PrintWriter pw, String appenderName, TailerOptions opts) throws IOException { for (final Appender<ILoggingEvent> appender : ctx.appenders.values()) { if (appender instanceof FileAppender && appenderName.equals(appender.getName())) { final File file = new File(((FileAppender) appender).getFile()); if (file.exists()) { - if (numOfLines < 0) { + if (opts.tailAll()) { SlingConfigurationPrinter.includeWholeFile(pw, file); } else { + int numOfLines = opts.getNumOfLines(); + if (numOfLines == 0){ + numOfLines = logbackManager.getLogConfigManager().getNumOfLines(); + } new Tailer(pw, numOfLines).tail(file); } } @@ -639,10 +581,6 @@ public class SlingLogPanel extends HttpS pw.printf("No appender with name [%s] found", appenderName); } - private int getNumOfLines(HttpServletRequest req) { - return Util.toInteger(req.getParameter(PARAM_NUM_OF_LINES), logbackManager.getLogConfigManager().getNumOfLines()); - } - private String getLinkedName(FileAppender<ILoggingEvent> appender) throws UnsupportedEncodingException { String fileName = appender.getFile(); String name = appender.getName(); @@ -669,7 +607,8 @@ public class SlingLogPanel extends HttpS * @throws IOException when an existing configuration couldn't be updated or a configuration couldn't be created. * @throws ConfigurationException when mandatory parameters where not specified */ - private void configureLogger(final String pid, final String logLevel, final String[] loggers, final String logFile, String additive) + private void configureLogger(final String pid, final String logLevel, final String[] loggers, final String + logFile, boolean additive) throws IOException, ConfigurationException { // try to get the configadmin service reference ServiceReference sr = this.bundleContext @@ -704,10 +643,10 @@ public class SlingLogPanel extends HttpS dict.put(LogConfigManager.LOG_LOGGERS, loggers); dict.put(LogConfigManager.LOG_FILE, logFile); - if (additive == null){ - dict.put(LogConfigManager.LOG_ADDITIV, "false"); - } else { + if (additive){ dict.put(LogConfigManager.LOG_ADDITIV, "true"); + } else { + dict.put(LogConfigManager.LOG_ADDITIV, "false"); } config.update(dict); } @@ -858,10 +797,6 @@ public class SlingLogPanel extends HttpS return (path != null) ? path : "[stdout]"; } - private static void addNoSniffHeader(HttpServletResponse resp) { - resp.setHeader("X-Content-Type-Options", "nosniff"); - } - // ~------------------------------------------------Status Manager // Based on ch.qos.logback.core.status.ViewStatusMessagesServletBase Added: sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/LogPanel.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/LogPanel.java?rev=1764489&view=auto ============================================================================== --- sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/LogPanel.java (added) +++ sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/LogPanel.java Wed Oct 12 17:02:00 2016 @@ -0,0 +1,54 @@ +/* + * 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.sling.commons.log.logback.webconsole; + +import java.io.IOException; +import java.io.PrintWriter; + +import aQute.bnd.annotation.ProviderType; + +@ProviderType +public interface LogPanel { + /** + * Request param name to control number of lines to include in the log + */ + String PARAM_NUM_OF_LINES = "tail"; + /** + * Request param name for appender name + */ + String PARAM_APPENDER_NAME = "name"; + /** + * Let the path end with extension. In that case WebConsole logic would by pass this request's + * response completely + */ + String PATH_TAILER = "tailer.txt"; + + String APP_ROOT = "slinglog"; + + String RES_LOC = APP_ROOT + "/res/ui"; + + void tail(PrintWriter pw, String appenderName, TailerOptions options) throws IOException; + + void render(PrintWriter pw, String consoleAppRoot) throws IOException; + + void deleteLoggerConfig(String pid); + + void createLoggerConfig(LoggerConfig config) throws IOException; +} Propchange: sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/LogPanel.java ------------------------------------------------------------------------------ svn:eol-style = native Added: sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/LoggerConfig.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/LoggerConfig.java?rev=1764489&view=auto ============================================================================== --- sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/LoggerConfig.java (added) +++ sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/LoggerConfig.java Wed Oct 12 17:02:00 2016 @@ -0,0 +1,58 @@ +/* + * 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.sling.commons.log.logback.webconsole; + +import java.util.Arrays; + +public final class LoggerConfig { + private final String pid; + private final String logLevel; + private final String[] loggers; + private final String logFile; + private boolean additive; + + public LoggerConfig(String pid, String logLevel, String[] loggers, String logFile, boolean additive) { + this.pid = pid; + this.logLevel = logLevel; + this.loggers = Arrays.copyOf(loggers, loggers.length); + this.logFile = logFile; + this.additive = additive; + } + + public String getPid() { + return pid; + } + + public String getLogLevel() { + return logLevel; + } + + public String[] getLoggers() { + return loggers; + } + + public String getLogFile() { + return logFile; + } + + public boolean isAdditive() { + return additive; + } +} Propchange: sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/webconsole/LoggerConfig.java ------------------------------------------------------------------------------ svn:eol-style = native