/*
g *   Copyright 2010 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 net.brutex.xservices.types.CompressionType;

import net.brutex.xservices.types.ReturnCode;
import net.brutex.xservices.types.ant.ArchiveResource;
import net.brutex.xservices.types.ant.FileResource;
import net.brutex.xservices.types.ant.FileSetResource;
import net.brutex.xservices.util.BrutexNamespaces;


/**
 * Archiving related web service.
 * 
 * @author Brian Rosenberger, bru@brutex.de
 * @since 0.4.0
 */
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES)
public interface ArchiveService {

    final String WS_OPERATION_BZIP2 = "bzip2";
    final String WS_OPERATION_BZIP2_ARCHIVE = "bzip2FromArchive";
    final String WS_OPERATION_GZIP = "gzip";
    final String WS_OPERATION_GZIP_ARCHIVE = "gzipFromArchive";
    final String WS_OPERATION_UNZIP = "unzip";
    final String WS_OPERATION_GUNZIP = "gunzip";
    final String WS_OPERATION_BUNZIP2 = "bunzip2";
    final String WS_PARAM_SOURCEFILE = "source";
    final String WS_PARAM_SOURCEFILE_STRING = "srcfile";
    final String WS_PARAM_SOURCEURL = "srcurl";
    final String WS_PARAM_SOURCEARCHIVE = "archivesource";
    final String WS_PARAM_DESTFILE = "destfile";
    final String WS_PARAM_DESTDIR = "destdir";
    final String WS_PARAM_ENCODING = "encoding";
    final String WS_PARAM_OVERWRITE = "overwrite";
    final String WS_PARAM_COMPRESS = "compresslevel";

    /**
     * @param src
     * @param file
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = WS_OPERATION_BZIP2, action = WS_OPERATION_BZIP2)
    public ReturnCode bzip2(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src,
            @WebParam(name = WS_PARAM_DESTFILE) String file) throws XServicesFault;

    /**
     * @param src
     * @param file
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = WS_OPERATION_BZIP2_ARCHIVE, action = WS_OPERATION_BZIP2_ARCHIVE)
    public ReturnCode bzip2FromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src,
            @WebParam(name = WS_PARAM_DESTFILE) String file) throws XServicesFault;

    /**
     * @param src
     * @param file
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = WS_OPERATION_GZIP, action = WS_OPERATION_GZIP)
    public ReturnCode gzip(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src,
            @WebParam(name = WS_PARAM_DESTFILE) String file) throws XServicesFault;

    /**
     * @param src
     * @param file
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = WS_OPERATION_GZIP_ARCHIVE, action = WS_OPERATION_GZIP_ARCHIVE)
    public ReturnCode gzipFromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src,
            @WebParam(name = WS_PARAM_DESTFILE) String file) throws XServicesFault;

    /**
     * @param src
     * @param dest
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = WS_OPERATION_GUNZIP, action = WS_OPERATION_GUNZIP)
    public ReturnCode gunzip(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
            @WebParam(name = WS_PARAM_DESTDIR) String dest) throws XServicesFault;

    /**
     * @param src
     * @param dest
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = WS_OPERATION_BUNZIP2)
    public ReturnCode bunzip2(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
            @WebParam(name = WS_PARAM_DESTDIR) String dest) throws XServicesFault;

    /**
     * @param src
     * @param dest
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = "gunzipFromURL")
    public ReturnCode gunzipFromURL(@WebParam(name = WS_PARAM_SOURCEURL) String src,
            @WebParam(name = WS_PARAM_DESTDIR) String dest) throws XServicesFault;

    /**
     * @param src
     * @param dest
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = "bunzip2FromURL")
    public ReturnCode bunzip2FromURL(@WebParam(name = WS_PARAM_SOURCEURL) String src,
            @WebParam(name = WS_PARAM_DESTDIR) String dest) throws XServicesFault;

    /**
     * @param src
     * @param file
     * @param overwrite
     * @param encoding
     * @param level
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = "zip")
    public ReturnCode zip(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src,
            @WebParam(name = WS_PARAM_DESTFILE) String file,
            @WebParam(name = WS_PARAM_OVERWRITE) boolean overwrite,
            @WebParam(name = WS_PARAM_ENCODING) String encoding,
            @WebParam(name = WS_PARAM_COMPRESS) int level) throws XServicesFault;

    /**
     * @param src
     * @param file
     * @param update
     * @param encoding
     * @param level
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = "zipFromArchive")
    public ReturnCode zipFromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src,
            @WebParam(name = WS_PARAM_DESTFILE) String file,
            @WebParam(name = WS_PARAM_OVERWRITE) boolean update,
            @WebParam(name = WS_PARAM_ENCODING) String encoding,
            @WebParam(name = "compresslevel") int level) throws XServicesFault;

    /**
     * @param src
     * @param dest
     * @param overwrite
     * @param encoding
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = "unzip")
    public ReturnCode unzip(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
            @WebParam(name = WS_PARAM_DESTDIR) String dest,
            @WebParam(name = WS_PARAM_OVERWRITE) boolean overwrite,
            @WebParam(name = WS_PARAM_ENCODING) String encoding) throws XServicesFault;

    /**
     * @param src
     * @param dest
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = "unrar")
    public ReturnCode unrar(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
            @WebParam(name = WS_PARAM_DESTDIR) String dest) throws XServicesFault;

    /**
     * @param src
     * @param dest
     * @param overwrite
     * @param compression
     * @return
     * @throws XServicesFault 
     */
    @WebMethod(operationName = "untar")
    public ReturnCode untar(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
            @WebParam(name = WS_PARAM_DESTDIR) String dest,
            @WebParam(name = WS_PARAM_OVERWRITE) boolean overwrite,
            @WebParam(name = "compression") CompressionType compression) throws XServicesFault;
}
