001 package org.apache.archiva.web.api; 002 /* 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 */ 020 021 import org.apache.archiva.web.model.JavascriptLog; 022 import org.slf4j.Logger; 023 import org.slf4j.LoggerFactory; 024 import org.springframework.stereotype.Service; 025 026 /** 027 * @author Olivier Lamy 028 * @since 1.4-M4 029 */ 030 @Service("javascriptLogger#default") 031 public class DefaultJavascriptLogger 032 implements JavascriptLogger 033 { 034 private Logger logger = LoggerFactory.getLogger( getClass() ); 035 036 public Boolean trace( JavascriptLog javascriptLog ) 037 { 038 Logger toUse = 039 javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() ); 040 if ( javascriptLog.getMessage() == null ) 041 { 042 return Boolean.TRUE; 043 } 044 toUse.trace( javascriptLog.getMessage() ); 045 return Boolean.TRUE; 046 } 047 048 public Boolean debug( JavascriptLog javascriptLog ) 049 { 050 Logger toUse = 051 javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() ); 052 053 if ( javascriptLog.getMessage() == null ) 054 { 055 return Boolean.TRUE; 056 } 057 058 toUse.debug( javascriptLog.getMessage() ); 059 return Boolean.TRUE; 060 } 061 062 public Boolean info( JavascriptLog javascriptLog ) 063 { 064 Logger toUse = 065 javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() ); 066 067 if ( javascriptLog.getMessage() == null ) 068 { 069 return Boolean.TRUE; 070 } 071 072 toUse.info( javascriptLog.getMessage() ); 073 return Boolean.TRUE; 074 } 075 076 public Boolean warn( JavascriptLog javascriptLog ) 077 { 078 Logger toUse = 079 javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() ); 080 081 if ( javascriptLog.getMessage() == null ) 082 { 083 return Boolean.TRUE; 084 } 085 086 toUse.warn( javascriptLog.getMessage() ); 087 return Boolean.TRUE; 088 } 089 090 public Boolean error( JavascriptLog javascriptLog ) 091 { 092 Logger toUse = 093 javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() ); 094 095 if ( javascriptLog.getMessage() == null ) 096 { 097 return Boolean.TRUE; 098 } 099 100 toUse.error( javascriptLog.getMessage() ); 101 return Boolean.TRUE; 102 } 103 }