diff options
author | Olivier Lamy <olamy@apache.org> | 2013-01-22 12:08:10 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2013-01-22 12:08:10 +0000 |
commit | 2f96f5aceec9a49b9f605ee0e5a8fa9674f1cab4 (patch) | |
tree | 773303d3918cc928da42d2dbb62e7400d94af064 /archiva-modules/archiva-web/archiva-web-common/src | |
parent | fc0b17de624ca67b9e152d277e78d055218b8913 (diff) | |
download | archiva-2f96f5aceec9a49b9f605ee0e5a8fa9674f1cab4.tar.gz archiva-2f96f5aceec9a49b9f605ee0e5a8fa9674f1cab4.zip |
add a remote log to log from javascript to server log
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1436858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web/archiva-web-common/src')
4 files changed, 226 insertions, 0 deletions
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultJavascriptLogger.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultJavascriptLogger.java new file mode 100644 index 000000000..0594a5f18 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultJavascriptLogger.java @@ -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; + } +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/JavascriptLogger.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/JavascriptLogger.java new file mode 100644 index 000000000..cb205edbc --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/JavascriptLogger.java @@ -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 ); + +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/JavascriptLog.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/JavascriptLog.java new file mode 100644 index 000000000..8c83c6fe9 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/model/JavascriptLog.java @@ -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(); + } +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml index 4df10a85b..95179f71a 100755 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml @@ -51,6 +51,7 @@ <ref bean="runtimeInfoService#rest"/> <ref bean="dataValidatorService#rest"/> <ref bean="fileUploadService#rest"/> + <ref bean="javascriptLogger#default"/> </jaxrs:serviceBeans> <jaxrs:outInterceptors> |