/*
 *   Copyright 2012 Brian Rosenberger (Brutex Network)
 *
 *   Licensed 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.
 */

package net.brutex.xservices.ws;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlElement;

import net.brutex.xservices.types.AttributeType;
import net.brutex.xservices.types.NamespaceListType;
import net.brutex.xservices.types.StringSplitType;
import net.brutex.xservices.types.ant.FileResource;

import org.apache.cxf.annotations.WSDLDocumentation;
import org.apache.shiro.authz.annotation.RequiresPermissions;

/**
 * @author Brian Rosenberger, bru(at)brutex.de
 *
 */
@WebService(targetNamespace="http://ws.xservices.brutex.net")
public abstract interface XmlService
{
  public static final String SERVICE_NAME = "XmlService";
  public static final String OPERATION_APPENDTO = "appendTo";
  public static final String OPERATION_REPLACE = "replaceNode";
  public static final String PARAM_XPATH = "xpath";
  public static final String PARAM_XML = "xmldata";

  @RequiresPermissions("insertNodes")
  @WebMethod(operationName="insertNodes")
  @WSDLDocumentation("Insert an XML fragment into an XML document given as string.")
  public abstract String insertNodes(
		  @WebParam(name="sourcexml") String source, 
		  @WebParam(name="encoding") String encoding,
		  @WebParam(name="namespaceList") NamespaceListType paramNamespaceListType, 
		  @WebParam(name="xpath") @XmlElement(required=true) String paramString1, 
		  @WebParam(name="xmldata") String paramString2)
    throws XServicesFault;
  
  @WebMethod(operationName="insertNodes2")
  @WSDLDocumentation("Insert an XML fragment into an XML document given as file.")
  public abstract String insertNodesFromFile(
		  @WebParam(name="file") FileResource paramFileResource, 
		  @WebParam(name="namespaceList") NamespaceListType paramNamespaceListType, 
		  @WebParam(name="xpath") @XmlElement(required=true) String paramString1, 
		  @WebParam(name="xmldata") String paramString2)
    throws XServicesFault;
  
  @WebMethod(operationName="replaceNodes")
  @WSDLDocumentation("Replaces matched XML nodes with an XML document given as string.")
  public abstract String replaceNodes(
		  @WebParam(name="sourcexml") String source,
		  @WebParam(name="encoding") String encoding,
		  @WebParam(name="namespaceList") NamespaceListType paramNamespaceListType, 
		  @WebParam(name="xpath") @XmlElement(required=true) String paramString1, 
		  @WebParam(name="xmldata") String paramString2)
    throws XServicesFault;
  
  @WebMethod(operationName="replaceNodes2")
  @WSDLDocumentation("Replaces matched XML nodes with an XML document given as file.")
  public abstract String replaceNodesFromFile(
		  @WebParam(name="file") FileResource paramFileResource, 
		  @WebParam(name="namespaceList") NamespaceListType paramNamespaceListType, 
		  @WebParam(name="xpath") @XmlElement(required=true) String paramString1, 
		  @WebParam(name="xmldata") String paramString2)
    throws XServicesFault;
  
  @WebMethod(operationName="wrapInCDATA")
  @WSDLDocumentation("Wraps a String into a CDATA element")
  public abstract String wrapInCDATA(@WebParam(name="data") @XmlElement(required=true) String data)
  	throws XServicesFault;
  
  @WebMethod(operationName="selectXPath")
  @WSDLDocumentation("Select from xml document given as string using an XPath expression.")
  public abstract StringSplitType selectXPath(
		  @WebParam(name="sourcexml") @XmlElement(required=true) String source,
		  @WebParam(name="encoding") String encoding,
		  @WebParam(name="namespaceList") NamespaceListType paramNamespaceListType, 
		  @WebParam(name="xpath") @XmlElement(required=true) String paramString1)
  	throws XServicesFault;
  
  @WebMethod(operationName="setAttribute")
  @WSDLDocumentation("Set an attribute.")
  public abstract String setAttribute(
		  @WebParam(name="sourcexml") @XmlElement(required=true) String source,
		  @WebParam(name="encoding") String encoding,
		  @WebParam(name="namespaceList") NamespaceListType paramNamespaceListType, 
		  @WebParam(name="xpath") @XmlElement(required=true) String paramString1,
		  @WebParam(name="attribute") @XmlElement(nillable=false, required=true) AttributeType attr)
  	throws XServicesFault;

}
