Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 12 → Rev 11

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