This project has retired. For details please refer to its Attic page.
DefaultJavascriptLogger xref
View Javadoc
1   package org.apache.archiva.web.api;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   * http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  import org.apache.archiva.web.model.JavascriptLog;
22  import org.slf4j.Logger;
23  import org.slf4j.LoggerFactory;
24  import org.springframework.stereotype.Service;
25  
26  /**
27   * @author Olivier Lamy
28   * @since 1.4-M4
29   */
30  @Service("javascriptLogger#default")
31  public class DefaultJavascriptLogger
32      implements JavascriptLogger
33  {
34      private Logger logger = LoggerFactory.getLogger( getClass() );
35  
36      @Override
37      public Boolean trace( JavascriptLog javascriptLog )
38      {
39          Logger toUse =
40              javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
41          if ( javascriptLog.getMessage() == null )
42          {
43              return Boolean.TRUE;
44          }
45          toUse.trace( javascriptLog.getMessage() );
46          return Boolean.TRUE;
47      }
48  
49      @Override
50      public Boolean debug( JavascriptLog javascriptLog )
51      {
52          Logger toUse =
53              javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
54  
55          if ( javascriptLog.getMessage() == null )
56          {
57              return Boolean.TRUE;
58          }
59  
60          toUse.debug( javascriptLog.getMessage() );
61          return Boolean.TRUE;
62      }
63  
64      @Override
65      public Boolean info( JavascriptLog javascriptLog )
66      {
67          Logger toUse =
68              javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
69  
70          if ( javascriptLog.getMessage() == null )
71          {
72              return Boolean.TRUE;
73          }
74  
75          toUse.info( javascriptLog.getMessage() );
76          return Boolean.TRUE;
77      }
78  
79      @Override
80      public Boolean warn( JavascriptLog javascriptLog )
81      {
82          Logger toUse =
83              javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
84  
85          if ( javascriptLog.getMessage() == null )
86          {
87              return Boolean.TRUE;
88          }
89  
90          toUse.warn( javascriptLog.getMessage() );
91          return Boolean.TRUE;
92      }
93  
94      @Override
95      public Boolean error( JavascriptLog javascriptLog )
96      {
97          Logger toUse =
98              javascriptLog.getLoggerName() == null ? logger : LoggerFactory.getLogger( javascriptLog.getLoggerName() );
99  
100         if ( javascriptLog.getMessage() == null )
101         {
102             return Boolean.TRUE;
103         }
104 
105         toUse.error( javascriptLog.getMessage() );
106         return Boolean.TRUE;
107     }
108 }