You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2013/01/22 13:08:11 UTC
svn commit: r1436858 - in /archiva/trunk/archiva-modules/archiva-web:
archiva-web-common/src/main/java/org/apache/archiva/web/api/
archiva-web-common/src/main/java/org/apache/archiva/web/model/
archiva-web-common/src/main/resources/META-INF/ archiva-we...
Author: olamy
Date: Tue Jan 22 12:08:10 2013
New Revision: 1436858
URL: http://svn.apache.org/viewvc?rev=1436858&view=rev
Log:
add a remote log to log from javascript to server log
Added:
archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultJavascriptLogger.java (with props)
archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/JavascriptLogger.java (with props)
archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/JavascriptLog.java (with props)
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js
Added: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultJavascriptLogger.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultJavascriptLogger.java?rev=1436858&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultJavascriptLogger.java (added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultJavascriptLogger.java Tue Jan 22 12:08:10 2013
@@ -0,0 +1,80 @@
+package org.apache.archiva.web.api;
+/*
+ * 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.
+ */
+
+import org.apache.archiva.web.model.JavascriptLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M4
+ */
+@Service( "javascriptLogger#default" )
+public class DefaultJavascriptLogger
+ implements JavascriptLogger
+{
+ private Logger logger = LoggerFactory.getLogger( getClass() );
+
+ public Boolean trace( JavascriptLog javascriptLog )
+ {
+ Logger toUse =
+ javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
+
+ toUse.trace( javascriptLog.getMessage() );
+ return Boolean.TRUE;
+ }
+
+ public Boolean debug( JavascriptLog javascriptLog )
+ {
+ Logger toUse =
+ javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
+
+ toUse.debug( javascriptLog.getMessage() );
+ return Boolean.TRUE;
+ }
+
+ public Boolean info( JavascriptLog javascriptLog )
+ {
+ Logger toUse =
+ javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
+
+ toUse.info( javascriptLog.getMessage() );
+ return Boolean.TRUE;
+ }
+
+ public Boolean warn( JavascriptLog javascriptLog )
+ {
+ Logger toUse =
+ javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
+
+ toUse.warn( javascriptLog.getMessage() );
+ return Boolean.TRUE;
+ }
+
+ public Boolean error( JavascriptLog javascriptLog )
+ {
+ Logger toUse =
+ javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
+
+ toUse.error( javascriptLog.getMessage() );
+ return Boolean.TRUE;
+ }
+}
Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultJavascriptLogger.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultJavascriptLogger.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/JavascriptLogger.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/JavascriptLogger.java?rev=1436858&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/JavascriptLogger.java (added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/JavascriptLogger.java Tue Jan 22 12:08:10 2013
@@ -0,0 +1,73 @@
+package org.apache.archiva.web.api;
+/*
+ * 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.
+ */
+
+import org.apache.archiva.redback.authorization.RedbackAuthorization;
+import org.apache.archiva.web.model.JavascriptLog;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M4
+ */
+@Path( "/javascriptLogger/" )
+public interface JavascriptLogger
+{
+
+ @PUT
+ @Path( "trace" )
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( noRestriction = true, noPermission = true)
+ Boolean trace( JavascriptLog javascriptLog );
+
+ @PUT
+ @Path( "debug" )
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( noRestriction = true, noPermission = true)
+ Boolean debug( JavascriptLog javascriptLog );
+
+ @PUT
+ @Path( "info" )
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( noRestriction = true, noPermission = true)
+ Boolean info( JavascriptLog javascriptLog );
+
+ @PUT
+ @Path( "warn" )
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( noRestriction = true, noPermission = true)
+ Boolean warn( JavascriptLog javascriptLog );
+
+ @PUT
+ @Path( "error" )
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( noRestriction = true, noPermission = true)
+ Boolean error( JavascriptLog javascriptLog );
+
+}
Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/JavascriptLogger.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/JavascriptLogger.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/JavascriptLog.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/JavascriptLog.java?rev=1436858&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/JavascriptLog.java (added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/JavascriptLog.java Tue Jan 22 12:08:10 2013
@@ -0,0 +1,72 @@
+package org.apache.archiva.web.model;
+/*
+ * 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.
+ */
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M4
+ */
+@XmlRootElement( name = "javascriptLog" )
+public class JavascriptLog
+ implements Serializable
+{
+
+ private String loggerName;
+
+ private String message;
+
+ public JavascriptLog()
+ {
+ // no op
+ }
+
+ public String getLoggerName()
+ {
+ return loggerName;
+ }
+
+ public void setLoggerName( String loggerName )
+ {
+ this.loggerName = loggerName;
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ public void setMessage( String message )
+ {
+ this.message = message;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "JavascriptLog" );
+ sb.append( "{loggerName='" ).append( loggerName ).append( '\'' );
+ sb.append( ", message='" ).append( message ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/JavascriptLog.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/JavascriptLog.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml?rev=1436858&r1=1436857&r2=1436858&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml Tue Jan 22 12:08:10 2013
@@ -51,6 +51,7 @@
<ref bean="runtimeInfoService#rest"/>
<ref bean="dataValidatorService#rest"/>
<ref bean="fileUploadService#rest"/>
+ <ref bean="javascriptLogger#default"/>
</jaxrs:serviceBeans>
<jaxrs:outInterceptors>
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js?rev=1436858&r1=1436857&r2=1436858&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js Tue Jan 22 12:08:10 2013
@@ -495,6 +495,53 @@ require(["jquery","jquery.tmpl","i18n","
mainContent.find(".tooltip-doc" ).tooltip({html: true, trigger: 'hover'});
}
+ //------------------------------------
+ // remote logging
+ //------------------------------------
+ JavascriptLog=function(loggerName,message){
+ this.loggerName=loggerName;
+ this.message=message;
+ }
+
+ remoteLogTrace=function(loggerName,message){
+ var javascriptLog=new JavascriptLog(loggerName,message);
+ remoteLog("trace",javascriptLog);
+ }
+
+ remoteLogDebug=function(loggerName,message){
+ var javascriptLog=new JavascriptLog(loggerName,message);
+ remoteLog("debug",javascriptLog);
+ }
+
+ remoteLogInfo=function(loggerName,message){
+ var javascriptLog=new JavascriptLog(loggerName,message);
+ remoteLog("info",javascriptLog);
+ }
+
+ remoteLogWarn=function(loggerName,message){
+ var javascriptLog=new JavascriptLog(loggerName,message);
+ remoteLog("warn",javascriptLog);
+ }
+
+ remoteLogError=function(loggerName,message){
+ var javascriptLog=new JavascriptLog(loggerName,message);
+ remoteLog("error",javascriptLog);
+ }
+
+ /**
+ *
+ * @param level trace/debug/info/warn/error
+ * @param javascriptLog
+ */
+ remoteLog=function(level,javascriptLog){
+ $.ajax("restServices/archivaUiServices/javascriptLogger/"+level,{
+ type: "PUT",
+ contentType: 'application/json',
+ data: $.toJSON(javascriptLog)
+ }
+ );
+ }
+
//-----------------------------------------
// extends jquery tmpl to support var def
//-----------------------------------------