Coverage Report - org.codehaus.mojo.axistools.admin.AdminWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
AdminWrapper
0%
0/30
0%
0/6
4,5
 
 1  
 package org.codehaus.mojo.axistools.admin;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.axis.AxisEngine;
 23  
 import org.apache.axis.MessageContext;
 24  
 import org.apache.axis.client.AxisClient;
 25  
 import org.apache.axis.server.AxisServer;
 26  
 import org.apache.axis.utils.Admin;
 27  
 import org.apache.axis.utils.Messages;
 28  
 import org.apache.axis.utils.XMLUtils;
 29  
 import org.apache.maven.plugin.logging.Log;
 30  
 import org.codehaus.mojo.axistools.axis.AxisPluginException;
 31  
 import org.w3c.dom.Document;
 32  
 
 33  
 import java.io.BufferedWriter;
 34  
 import java.io.FileInputStream;
 35  
 import java.io.FileOutputStream;
 36  
 import java.io.OutputStreamWriter;
 37  
 import java.io.PrintWriter;
 38  
 import java.io.Writer;
 39  
 
 40  
 /**
 41  
  * @author mlake
 42  
  */
 43  
 public class AdminWrapper
 44  
     extends Admin
 45  
 {
 46  
     private Log log;
 47  
 
 48  
     public AdminWrapper( Log log )
 49  0
     {
 50  0
         this.log = log;
 51  0
     }
 52  
 
 53  
     public void execute( String[] args )
 54  
         throws AxisPluginException
 55  
     {
 56  0
         int i = 0;
 57  
 
 58  
         try
 59  
         {
 60  
             AxisEngine engine;
 61  0
             if ( args[0].equals( "client" ) )
 62  
             {
 63  0
                 engine = new AxisClient();
 64  
             }
 65  
             else
 66  
             {
 67  0
                 engine = new AxisServer();
 68  
             }
 69  
 
 70  0
             engine.setShouldSaveConfig( false );
 71  0
             engine.init();
 72  0
             MessageContext msgContext = new MessageContext( engine );
 73  0
             Writer osWriter = new OutputStreamWriter( new FileOutputStream( args[1] ), XMLUtils.getEncoding() );
 74  0
             PrintWriter writer = new PrintWriter( new BufferedWriter( osWriter ) );
 75  
 
 76  
             try
 77  
             {
 78  0
                 for ( i = 2; i < args.length; i++ )
 79  
                 {
 80  0
                     log.debug( Messages.getMessage( "process00", args[i] ) );
 81  
 
 82  0
                     Document doc = XMLUtils.newDocument( new FileInputStream( args[i] ) );
 83  0
                     Document result = process( msgContext, doc.getDocumentElement() );
 84  
 
 85  0
                     if ( result != null )
 86  
                     {
 87  0
                         System.out.println( XMLUtils.DocumentToString( result ) );
 88  
                     }
 89  
                 }
 90  0
                 Document document = Admin.listConfig( engine );
 91  0
                 XMLUtils.DocumentToWriter( document, writer );
 92  0
                 writer.println();
 93  
             }
 94  0
             catch ( Exception e )
 95  
             {
 96  0
                 log.error( Messages.getMessage( "errorProcess00", args[i] ), e );
 97  0
                 throw e;
 98  
             }
 99  
             finally
 100  
             {
 101  0
                 writer.close();
 102  0
             }
 103  
         }
 104  0
         catch ( Exception e )
 105  
         {
 106  0
             throw new AxisPluginException( "Axis Admin had a problem, it returned a failure status: "
 107  
                 + e.getMessage() );
 108  0
         }
 109  0
     }
 110  
 }