Package br.net.woodstock.rockframework.web.common.filter.debug

Source Code of br.net.woodstock.rockframework.web.common.filter.debug.WSDebugFilter

/*
* This file is part of rockframework.
*
* rockframework is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* rockframework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>;.
*/
package br.net.woodstock.rockframework.web.common.filter.debug;

import java.io.ByteArrayInputStream;
import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import org.xml.sax.SAXException;

import br.net.woodstock.rockframework.core.xml.dom.XmlDocument;
import br.net.woodstock.rockframework.web.WebException;

public class WSDebugFilter extends DebugFilter {

  private static final String  WSDL_PARAMETER  = "wsdl";

  public WSDebugFilter() {
    super();
  }

  @Override
  protected boolean isDebugEnabled(final HttpServletRequest request) {
    if (request.getParameter(WSDebugFilter.WSDL_PARAMETER) != null) {
      return false;
    }
    return true;
  }

  @Override
  protected String getRequestText(final byte[] bytes) throws IOException {
    return this.toXML(bytes);
  }

  @Override
  protected String getResponseText(final byte[] bytes) throws IOException {
    return this.toXML(bytes);
  }

  private String toXML(final byte[] bytes) throws IOException {
    try {
      XmlDocument document = XmlDocument.read(new ByteArrayInputStream(bytes));
      String xml = document.toString();
      return xml;
    } catch (SAXException e) {
      throw new WebException(e);
    }
  }

}
TOP

Related Classes of br.net.woodstock.rockframework.web.common.filter.debug.WSDebugFilter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.