13,7 → 13,6 |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
|
package net.brutex.xservices.ws; |
|
import java.io.File; |
40,7 → 39,7 |
* |
* @author Brian Rosenberger, bru@brutex.de |
*/ |
@WebService(targetNamespace="http://ws.xservices.brutex.net", name="ArchiveService") |
@WebService(targetNamespace = "http://ws.xservices.brutex.net", name = "ArchiveService") |
public class ArchiveService { |
|
public static final String WS_OPERATION_BZIP2 = "bzip2"; |
50,7 → 49,6 |
public static final String WS_OPERATION_UNZIP = "unzip"; |
public static final String WS_OPERATION_GUNZIP = "gunzip"; |
public static final String WS_OPERATION_BUNZIP2 = "bunzip2"; |
|
public static final String WS_PARAM_SOURCEFILE = "source"; |
public static final String WS_PARAM_SOURCEFILE_STRING = "srcfile"; |
public static final String WS_PARAM_SOURCEURL = "srcurl"; |
57,36 → 55,35 |
public static final String WS_PARAM_SOURCEARCHIVE = "archivesource"; |
public static final String WS_PARAM_DESTFILE = "destfile"; |
public static final String WS_PARAM_DESTDIR = "destdir"; |
|
public static final String WS_PARAM_ENCODING = "encoding"; |
public static final String WS_PARAM_OVERWRITE= "overwrite"; |
public static final String WS_PARAM_OVERWRITE = "overwrite"; |
|
@WebMethod(operationName = WS_OPERATION_BZIP2, action=WS_OPERATION_BZIP2) |
@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) { |
return bzip(src, new File(file)); |
} |
|
@WebMethod(operationName = WS_OPERATION_BZIP2_ARCHIVE, action=WS_OPERATION_BZIP2_ARCHIVE) |
@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) { |
return bzip(src, new File(file)); |
} |
|
@WebMethod(operationName = WS_OPERATION_GZIP, action=WS_OPERATION_GZIP) |
public String gzip(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src, |
@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) { |
return gzip(src, new File(file)); |
} |
|
@WebMethod(operationName = WS_OPERATION_GZIP_ARCHIVE, action=WS_OPERATION_GZIP_ARCHIVE) |
public String gzipFromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src, |
@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) { |
return gzip(src, new File(file)); |
} |
|
@WebMethod(operationName = WS_OPERATION_GUNZIP, action=WS_OPERATION_GUNZIP) |
public String gunzip(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src, |
@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) { |
File target = null; |
if (!dest.equals("") && dest != null) { |
96,7 → 93,7 |
} |
|
@WebMethod(operationName = WS_OPERATION_BUNZIP2) |
public String bunzip2(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src, |
public ReturnCode bunzip2(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src, |
@WebParam(name = WS_PARAM_DESTDIR) String dest) { |
File target = null; |
if (!dest.equals("") && dest != null) { |
106,7 → 103,7 |
} |
|
@WebMethod(operationName = "gunzipFromURL") |
public String gunzipFromURL(@WebParam(name = WS_PARAM_SOURCEURL) String src, |
public ReturnCode gunzipFromURL(@WebParam(name = WS_PARAM_SOURCEURL) String src, |
@WebParam(name = WS_PARAM_DESTDIR) String dest) { |
File target = null; |
if (!dest.equals("") && dest != null) { |
116,7 → 113,7 |
} |
|
@WebMethod(operationName = "bunzip2FromURL") |
public String bunzip2FromURL(@WebParam(name = WS_PARAM_SOURCEURL) String src, |
public ReturnCode bunzip2FromURL(@WebParam(name = WS_PARAM_SOURCEURL) String src, |
@WebParam(name = WS_PARAM_DESTDIR) String dest) { |
File target = null; |
if (!dest.equals("") && dest != null) { |
126,7 → 123,7 |
} |
|
@WebMethod(operationName = "zip") |
public String zip(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src, |
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, |
141,7 → 138,7 |
} |
|
@WebMethod(operationName = "zipFromArchive") |
public String zipFromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src, |
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, |
149,9 → 146,8 |
return zip(src, new File(file), encoding, !update, level); |
} |
|
|
@WebMethod(operationName = "unzip") |
public String unzip(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src, |
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) { |
159,13 → 155,13 |
} |
|
@WebMethod(operationName = "unrar") |
public String unrar(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src, |
public ReturnCode unrar(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src, |
@WebParam(name = WS_PARAM_DESTDIR) String dest) { |
return unrar(new File(src), new File(dest)); |
} |
|
@WebMethod(operationName = "untar") |
public String untar(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src, |
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) { |
195,12 → 191,11 |
bzip.setSrcResource(src.getAntResource(bzip.getProject())); |
bzip.setDestfile(dst); |
|
Map<String, String> result = runner.postTask(); |
return new ReturnCode(0,result.get("System.stdOut"),result.get("System.stdErr")); |
return runner.postTask(); |
} |
|
@WebMethod(exclude = true) |
private String gzip(ResourceInterface src, File dst) { |
private ReturnCode gzip(ResourceInterface src, File dst) { |
if (dst.exists() && dst.isFile()) { |
dst.delete(); |
} |
209,14 → 204,11 |
RunTask runner = new RunTask(gzip); |
gzip.addConfigured(src.getAntResource(gzip.getProject())); |
gzip.setDestfile(dst); |
Map<String, String> result = runner.postTask(); |
return "complete"; |
return runner.postTask(); |
} |
|
|
|
@WebMethod(exclude = true) |
private String zip(ResourceInterface src, File dst, String encoding, boolean update, int compresslevel) { |
private ReturnCode zip(ResourceInterface src, File dst, String encoding, boolean update, int compresslevel) { |
Zip zip = new Zip(); |
zip.setTaskName("Zip"); |
RunTask runner = new RunTask(zip); |
227,12 → 219,11 |
} |
zip.setUpdate(update); |
zip.setLevel(compresslevel); |
Map<String, String> result = runner.postTask(); |
return "complete"; |
return runner.postTask(); |
} |
|
@WebMethod(exclude = true) |
private String GUnzip(ResourceInterface src, File dst) { |
private ReturnCode GUnzip(ResourceInterface src, File dst) { |
GUnzip uz = new GUnzip(); |
uz.setTaskName("GUnzip"); |
RunTask runner = new RunTask(uz); |
240,12 → 231,11 |
if (dst != null) { |
uz.setDest(dst); |
} |
Map<String, String> result = runner.postTask(); |
return "complete"; |
return runner.postTask(); |
} |
|
@WebMethod(exclude = true) |
private String BUnzip2(ResourceInterface src, File dst) { |
private ReturnCode BUnzip2(ResourceInterface src, File dst) { |
BUnzip2 uz = new BUnzip2(); |
uz.setTaskName("BUnzip2"); |
RunTask runner = new RunTask(uz); |
253,12 → 243,11 |
if (dst != null) { |
uz.setDest(dst); |
} |
Map<String, String> result = runner.postTask(); |
return "complete"; |
return runner.postTask(); |
} |
|
@WebMethod(exclude = true) |
private String unzip(File src, File dest, boolean overwrite, String encoding) { |
private ReturnCode unzip(File src, File dest, boolean overwrite, String encoding) { |
Expand unzip = new Expand(); |
unzip.setTaskName("UnZip"); |
RunTask runner = new RunTask(unzip); |
268,13 → 257,11 |
if (encoding != null && !encoding.equals("")) { |
unzip.setEncoding(encoding); |
} |
|
Map<String, String> result = runner.postTask(); |
return "complete"; |
return runner.postTask(); |
} |
|
@WebMethod(exclude = true) |
private String untar(File src, File dest, boolean overwrite, Untar.UntarCompressionMethod compression) { |
private ReturnCode untar(File src, File dest, boolean overwrite, Untar.UntarCompressionMethod compression) { |
Untar unzip = new Untar(); |
unzip.setTaskName("Untar"); |
RunTask runner = new RunTask(unzip); |
282,20 → 269,16 |
unzip.setDest(dest); |
unzip.setOverwrite(overwrite); |
unzip.setCompression(compression); |
Map<String, String> result = runner.postTask(); |
return "complete"; |
return runner.postTask(); |
} |
|
@WebMethod(exclude = true) |
private String unrar(File src, File dst) { |
private ReturnCode unrar(File src, File dst) { |
UnRarTask unrar = new UnRarTask(); |
unrar.setTaskName("UnRar"); |
RunTask runner = new RunTask(unrar); |
unrar.setSrc(src); |
unrar.setDst(dst); |
Map<String, String> result = runner.postTask(); |
return "complete"; |
return runner.postTask(); |
} |
|
|
} |