Subversion Repositories XServices

Rev

Rev 10 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10 Rev 11
1
/*
1
/*
2
 *   Copyright 2010 Brian Rosenberger (Brutex Network)
2
 *   Copyright 2010 Brian Rosenberger (Brutex Network)
3
 *
3
 *
4
 *   Licensed under the Apache License, Version 2.0 (the "License");
4
 *   Licensed under the Apache License, Version 2.0 (the "License");
5
 *   you may not use this file except in compliance with the License.
5
 *   you may not use this file except in compliance with the License.
6
 *   You may obtain a copy of the License at
6
 *   You may obtain a copy of the License at
7
 *
7
 *
8
 *       http://www.apache.org/licenses/LICENSE-2.0
8
 *       http://www.apache.org/licenses/LICENSE-2.0
9
 *
9
 *
10
 *   Unless required by applicable law or agreed to in writing, software
10
 *   Unless required by applicable law or agreed to in writing, software
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *   See the License for the specific language governing permissions and
13
 *   See the License for the specific language governing permissions and
14
 *   limitations under the License.
14
 *   limitations under the License.
15
 */
15
 */
16
 
16
 
17
package net.brutex.xservices.ws;
17
package net.brutex.xservices.ws;
18
 
18
 
19
import java.io.File;
19
import java.io.File;
20
import java.util.Map;
20
import java.util.Map;
21
import javax.jws.WebMethod;
21
import javax.jws.WebMethod;
22
import javax.jws.WebParam;
22
import javax.jws.WebParam;
23
import javax.jws.WebService;
23
import javax.jws.WebService;
24
import net.brutex.xservices.types.ArchiveResource;
24
import net.brutex.xservices.types.ArchiveResource;
25
import net.brutex.xservices.types.CompressionType;
25
import net.brutex.xservices.types.CompressionType;
26
import net.brutex.xservices.types.FileResource;
26
import net.brutex.xservices.types.FileResource;
27
import net.brutex.xservices.types.ResourceInterface;
27
import net.brutex.xservices.types.ResourceInterface;
28
import net.brutex.xservices.types.ReturnCode;
28
import net.brutex.xservices.types.ReturnCode;
29
import net.brutex.xservices.util.RunTask;
29
import net.brutex.xservices.util.RunTask;
30
import net.brutex.xservices.util.UnRarTask;
30
import net.brutex.xservices.util.UnRarTask;
31
import org.apache.tools.ant.taskdefs.BUnzip2;
31
import org.apache.tools.ant.taskdefs.BUnzip2;
32
import org.apache.tools.ant.taskdefs.BZip2;
32
import org.apache.tools.ant.taskdefs.BZip2;
33
import org.apache.tools.ant.taskdefs.Expand;
33
import org.apache.tools.ant.taskdefs.Expand;
34
import org.apache.tools.ant.taskdefs.GUnzip;
34
import org.apache.tools.ant.taskdefs.GUnzip;
35
import org.apache.tools.ant.taskdefs.GZip;
35
import org.apache.tools.ant.taskdefs.GZip;
36
import org.apache.tools.ant.taskdefs.Untar;
36
import org.apache.tools.ant.taskdefs.Untar;
37
import org.apache.tools.ant.taskdefs.Zip;
37
import org.apache.tools.ant.taskdefs.Zip;
38
 
38
 
39
/**
39
/**
40
 *
40
 *
41
 * @author Brian Rosenberger, bru@brutex.de
41
 * @author Brian Rosenberger, bru@brutex.de
42
 */
42
 */
43
@WebService(targetNamespace="http://ws.xservices.brutex.net", name="ArchiveService")
43
@WebService(targetNamespace="http://ws.xservices.brutex.net", name="ArchiveService")
44
public class ArchiveService {
44
public class ArchiveService {
45
 
45
 
46
    public static final String WS_OPERATION_BZIP2 = "bzip2";
46
    public static final String WS_OPERATION_BZIP2 = "bzip2";
47
    public static final String WS_OPERATION_BZIP2_ARCHIVE = "bzip2FromArchive";
47
    public static final String WS_OPERATION_BZIP2_ARCHIVE = "bzip2FromArchive";
48
    public static final String WS_OPERATION_GZIP = "gzip";
48
    public static final String WS_OPERATION_GZIP = "gzip";
49
    public static final String WS_OPERATION_GZIP_ARCHIVE = "gzipFromArchive";
49
    public static final String WS_OPERATION_GZIP_ARCHIVE = "gzipFromArchive";
50
    public static final String WS_OPERATION_UNZIP = "unzip";
50
    public static final String WS_OPERATION_UNZIP = "unzip";
51
    public static final String WS_OPERATION_GUNZIP = "gunzip";
51
    public static final String WS_OPERATION_GUNZIP = "gunzip";
52
    public static final String WS_OPERATION_BUNZIP2 = "bunzip2";
52
    public static final String WS_OPERATION_BUNZIP2 = "bunzip2";
53
 
53
 
54
    public static final String WS_PARAM_SOURCEFILE = "source";
54
    public static final String WS_PARAM_SOURCEFILE = "source";
55
    public static final String WS_PARAM_SOURCEFILE_STRING = "srcfile";
55
    public static final String WS_PARAM_SOURCEFILE_STRING = "srcfile";
56
    public static final String WS_PARAM_SOURCEURL = "srcurl";
56
    public static final String WS_PARAM_SOURCEURL = "srcurl";
57
    public static final String WS_PARAM_SOURCEARCHIVE = "archivesource";
57
    public static final String WS_PARAM_SOURCEARCHIVE = "archivesource";
58
    public static final String WS_PARAM_DESTFILE = "destfile";
58
    public static final String WS_PARAM_DESTFILE = "destfile";
59
    public static final String WS_PARAM_DESTDIR = "destdir";
59
    public static final String WS_PARAM_DESTDIR = "destdir";
60
 
60
 
61
    public static final String WS_PARAM_ENCODING = "encoding";
61
    public static final String WS_PARAM_ENCODING = "encoding";
62
    public static final String WS_PARAM_OVERWRITE= "overwrite";
62
    public static final String WS_PARAM_OVERWRITE= "overwrite";
63
 
63
 
64
    @WebMethod(operationName = WS_OPERATION_BZIP2, action=WS_OPERATION_BZIP2)
64
    @WebMethod(operationName = WS_OPERATION_BZIP2, action=WS_OPERATION_BZIP2)
65
    public ReturnCode bzip2(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src,
65
    public ReturnCode bzip2(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src,
66
            @WebParam(name = WS_PARAM_DESTFILE) String file) {
66
            @WebParam(name = WS_PARAM_DESTFILE) String file) {
67
        return bzip(src, new File(file));
67
        return bzip(src, new File(file));
68
    }
68
    }
69
 
69
 
70
    @WebMethod(operationName = WS_OPERATION_BZIP2_ARCHIVE, action=WS_OPERATION_BZIP2_ARCHIVE)
70
    @WebMethod(operationName = WS_OPERATION_BZIP2_ARCHIVE, action=WS_OPERATION_BZIP2_ARCHIVE)
71
    public ReturnCode bzip2FromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src,
71
    public ReturnCode bzip2FromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src,
72
            @WebParam(name = WS_PARAM_DESTFILE) String file) {
72
            @WebParam(name = WS_PARAM_DESTFILE) String file) {
73
        return bzip(src, new File(file));
73
        return bzip(src, new File(file));
74
    }
74
    }
75
 
75
 
76
    @WebMethod(operationName = WS_OPERATION_GZIP, action=WS_OPERATION_GZIP)
76
    @WebMethod(operationName = WS_OPERATION_GZIP, action=WS_OPERATION_GZIP)
77
    public String gzip(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src,
77
    public String gzip(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src,
78
            @WebParam(name = WS_PARAM_DESTFILE) String file) {
78
            @WebParam(name = WS_PARAM_DESTFILE) String file) {
79
        return gzip(src, new File(file));
79
        return gzip(src, new File(file));
80
    }
80
    }
81
 
81
 
82
    @WebMethod(operationName = WS_OPERATION_GZIP_ARCHIVE, action=WS_OPERATION_GZIP_ARCHIVE)
82
    @WebMethod(operationName = WS_OPERATION_GZIP_ARCHIVE, action=WS_OPERATION_GZIP_ARCHIVE)
83
    public String gzipFromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src,
83
    public String gzipFromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src,
84
            @WebParam(name = WS_PARAM_DESTFILE) String file) {
84
            @WebParam(name = WS_PARAM_DESTFILE) String file) {
85
        return gzip(src, new File(file));
85
        return gzip(src, new File(file));
86
    }
86
    }
87
 
87
 
88
    @WebMethod(operationName = WS_OPERATION_GUNZIP, action=WS_OPERATION_GUNZIP)
88
    @WebMethod(operationName = WS_OPERATION_GUNZIP, action=WS_OPERATION_GUNZIP)
89
    public String gunzip(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
89
    public String gunzip(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
90
            @WebParam(name = WS_PARAM_DESTDIR) String dest) {
90
            @WebParam(name = WS_PARAM_DESTDIR) String dest) {
91
        File target = null;
91
        File target = null;
92
        if (!dest.equals("") && dest != null) {
92
        if (!dest.equals("") && dest != null) {
93
            target = new File(dest);
93
            target = new File(dest);
94
        }
94
        }
95
        return GUnzip(new FileResource(FileResource.Type.FILE, src), target);
95
        return GUnzip(new FileResource(FileResource.Type.FILE, src), target);
96
    }
96
    }
97
 
97
 
98
    @WebMethod(operationName = WS_OPERATION_BUNZIP2)
98
    @WebMethod(operationName = WS_OPERATION_BUNZIP2)
99
    public String bunzip2(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
99
    public String bunzip2(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
100
            @WebParam(name = WS_PARAM_DESTDIR) String dest) {
100
            @WebParam(name = WS_PARAM_DESTDIR) String dest) {
101
        File target = null;
101
        File target = null;
102
        if (!dest.equals("") && dest != null) {
102
        if (!dest.equals("") && dest != null) {
103
            target = new File(dest);
103
            target = new File(dest);
104
        }
104
        }
105
        return BUnzip2(new FileResource(FileResource.Type.FILE, src), target);
105
        return BUnzip2(new FileResource(FileResource.Type.FILE, src), target);
106
    }
106
    }
107
 
107
 
108
    @WebMethod(operationName = "gunzipFromURL")
108
    @WebMethod(operationName = "gunzipFromURL")
109
    public String gunzipFromURL(@WebParam(name = WS_PARAM_SOURCEURL) String src,
109
    public String gunzipFromURL(@WebParam(name = WS_PARAM_SOURCEURL) String src,
110
            @WebParam(name = WS_PARAM_DESTDIR) String dest) {
110
            @WebParam(name = WS_PARAM_DESTDIR) String dest) {
111
        File target = null;
111
        File target = null;
112
        if (!dest.equals("") && dest != null) {
112
        if (!dest.equals("") && dest != null) {
113
            target = new File(dest);
113
            target = new File(dest);
114
        }
114
        }
115
        return GUnzip(new FileResource(FileResource.Type.URL, src), target);
115
        return GUnzip(new FileResource(FileResource.Type.URL, src), target);
116
    }
116
    }
117
 
117
 
118
    @WebMethod(operationName = "bunzip2FromURL")
118
    @WebMethod(operationName = "bunzip2FromURL")
119
    public String bunzip2FromURL(@WebParam(name = WS_PARAM_SOURCEURL) String src,
119
    public String bunzip2FromURL(@WebParam(name = WS_PARAM_SOURCEURL) String src,
120
            @WebParam(name = WS_PARAM_DESTDIR) String dest) {
120
            @WebParam(name = WS_PARAM_DESTDIR) String dest) {
121
        File target = null;
121
        File target = null;
122
        if (!dest.equals("") && dest != null) {
122
        if (!dest.equals("") && dest != null) {
123
            target = new File(dest);
123
            target = new File(dest);
124
        }
124
        }
125
        return BUnzip2(new FileResource(FileResource.Type.URL, src), target);
125
        return BUnzip2(new FileResource(FileResource.Type.URL, src), target);
126
    }
126
    }
127
 
127
 
128
    @WebMethod(operationName = "zip")
128
    @WebMethod(operationName = "zip")
129
    public String zip(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src,
129
    public String zip(@WebParam(name = WS_PARAM_SOURCEFILE) FileResource src,
130
            @WebParam(name = WS_PARAM_DESTFILE) String file,
130
            @WebParam(name = WS_PARAM_DESTFILE) String file,
131
            @WebParam(name = WS_PARAM_OVERWRITE) boolean overwrite,
131
            @WebParam(name = WS_PARAM_OVERWRITE) boolean overwrite,
132
            @WebParam(name = WS_PARAM_ENCODING) String encoding,
132
            @WebParam(name = WS_PARAM_ENCODING) String encoding,
133
            @WebParam(name = "compresslevel") int level) {
133
            @WebParam(name = "compresslevel") int level) {
134
        if (level > 9) {
134
        if (level > 9) {
135
            level = 9;
135
            level = 9;
136
        }
136
        }
137
        if (level < 0) {
137
        if (level < 0) {
138
            level = 0;
138
            level = 0;
139
        }
139
        }
140
        return zip(src, new File(file), encoding, !overwrite, level);
140
        return zip(src, new File(file), encoding, !overwrite, level);
141
    }
141
    }
142
 
142
 
143
    @WebMethod(operationName = "zipFromArchive")
143
    @WebMethod(operationName = "zipFromArchive")
144
    public String zipFromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src,
144
    public String zipFromArchive(@WebParam(name = WS_PARAM_SOURCEARCHIVE) ArchiveResource src,
145
            @WebParam(name = WS_PARAM_DESTFILE) String file,
145
            @WebParam(name = WS_PARAM_DESTFILE) String file,
146
            @WebParam(name = WS_PARAM_OVERWRITE) boolean update,
146
            @WebParam(name = WS_PARAM_OVERWRITE) boolean update,
147
            @WebParam(name = WS_PARAM_ENCODING) String encoding,
147
            @WebParam(name = WS_PARAM_ENCODING) String encoding,
148
            @WebParam(name = "compresslevel") int level) {
148
            @WebParam(name = "compresslevel") int level) {
149
        return zip(src, new File(file), encoding, !update, level);
149
        return zip(src, new File(file), encoding, !update, level);
150
    }
150
    }
151
 
151
 
152
 
152
 
153
    @WebMethod(operationName = "unzip")
153
    @WebMethod(operationName = "unzip")
154
    public String unzip(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
154
    public String unzip(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
155
            @WebParam(name = WS_PARAM_DESTDIR) String dest,
155
            @WebParam(name = WS_PARAM_DESTDIR) String dest,
156
            @WebParam(name = WS_PARAM_OVERWRITE) boolean overwrite,
156
            @WebParam(name = WS_PARAM_OVERWRITE) boolean overwrite,
157
            @WebParam(name = WS_PARAM_ENCODING) String encoding) {
157
            @WebParam(name = WS_PARAM_ENCODING) String encoding) {
158
        return unzip(new File(src), new File(dest), overwrite, encoding);
158
        return unzip(new File(src), new File(dest), overwrite, encoding);
159
    }
159
    }
160
 
160
 
161
    @WebMethod(operationName = "unrar")
161
    @WebMethod(operationName = "unrar")
162
    public String unrar(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
162
    public String unrar(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
163
            @WebParam(name = WS_PARAM_DESTDIR) String dest) {
163
            @WebParam(name = WS_PARAM_DESTDIR) String dest) {
164
        return unrar(new File(src), new File(dest));
164
        return unrar(new File(src), new File(dest));
165
    }
165
    }
166
 
166
 
167
    @WebMethod(operationName = "untar")
167
    @WebMethod(operationName = "untar")
168
    public String untar(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
168
    public String untar(@WebParam(name = WS_PARAM_SOURCEFILE_STRING) String src,
169
            @WebParam(name = WS_PARAM_DESTDIR) String dest,
169
            @WebParam(name = WS_PARAM_DESTDIR) String dest,
170
            @WebParam(name = WS_PARAM_OVERWRITE) boolean overwrite,
170
            @WebParam(name = WS_PARAM_OVERWRITE) boolean overwrite,
171
            @WebParam(name = "compression") CompressionType compression) {
171
            @WebParam(name = "compression") CompressionType compression) {
172
        Untar.UntarCompressionMethod c = new Untar.UntarCompressionMethod();
172
        Untar.UntarCompressionMethod c = new Untar.UntarCompressionMethod();
173
        switch (compression) {
173
        switch (compression) {
174
            case GZIP:
174
            case GZIP:
175
                c.setValue("gzip");
175
                c.setValue("gzip");
176
                break;
176
                break;
177
            case BZIP2:
177
            case BZIP2:
178
                c.setValue("bzip2");
178
                c.setValue("bzip2");
179
                break;
179
                break;
180
            default:
180
            default:
181
                c.setValue("none");
181
                c.setValue("none");
182
                break;
182
                break;
183
        }
183
        }
184
        return untar(new File(src), new File(dest), overwrite, c);
184
        return untar(new File(src), new File(dest), overwrite, c);
185
    }
185
    }
186
 
186
 
187
    @WebMethod(exclude = true)
187
    @WebMethod(exclude = true)
188
    private ReturnCode bzip(ResourceInterface src, File dst) {
188
    private ReturnCode bzip(ResourceInterface src, File dst) {
189
        if (dst.exists() && dst.isFile()) {
189
        if (dst.exists() && dst.isFile()) {
190
            dst.delete();
190
            dst.delete();
191
        }
191
        }
192
        BZip2 bzip = new BZip2();
192
        BZip2 bzip = new BZip2();
193
        bzip.setTaskName("BZip2");
193
        bzip.setTaskName("BZip2");
194
        RunTask runner = new RunTask(bzip);
194
        RunTask runner = new RunTask(bzip);
195
        bzip.setSrcResource(src.getAntResource(bzip.getProject()));
195
        bzip.setSrcResource(src.getAntResource(bzip.getProject()));
196
        bzip.setDestfile(dst);
196
        bzip.setDestfile(dst);
197
 
197
 
198
        Map<String, String> result = runner.postTask();
198
        Map<String, String> result = runner.postTask();
199
        return new ReturnCode(0,"complete","");
199
        return new ReturnCode(0,result.get("System.stdOut"),result.get("System.stdErr"));
200
    }
200
    }
201
 
201
 
202
    @WebMethod(exclude = true)
202
    @WebMethod(exclude = true)
203
    private String gzip(ResourceInterface src, File dst) {
203
    private String gzip(ResourceInterface src, File dst) {
204
        if (dst.exists() && dst.isFile()) {
204
        if (dst.exists() && dst.isFile()) {
205
            dst.delete();
205
            dst.delete();
206
        }
206
        }
207
        GZip gzip = new GZip();
207
        GZip gzip = new GZip();
208
        gzip.setTaskName("GZip");
208
        gzip.setTaskName("GZip");
209
        RunTask runner = new RunTask(gzip);
209
        RunTask runner = new RunTask(gzip);
210
        gzip.addConfigured(src.getAntResource(gzip.getProject()));
210
        gzip.addConfigured(src.getAntResource(gzip.getProject()));
211
        gzip.setDestfile(dst);
211
        gzip.setDestfile(dst);
212
        Map<String, String> result = runner.postTask();
212
        Map<String, String> result = runner.postTask();
213
        return "complete";
213
        return "complete";
214
    }
214
    }
215
 
215
 
216
 
216
 
217
 
217
 
218
    @WebMethod(exclude = true)
218
    @WebMethod(exclude = true)
219
    private String zip(ResourceInterface src, File dst, String encoding, boolean update, int compresslevel) {
219
    private String zip(ResourceInterface src, File dst, String encoding, boolean update, int compresslevel) {
220
        Zip zip = new Zip();
220
        Zip zip = new Zip();
221
        zip.setTaskName("Zip");
221
        zip.setTaskName("Zip");
222
        RunTask runner = new RunTask(zip);
222
        RunTask runner = new RunTask(zip);
223
        zip.add(src.getAntResource(zip.getProject()));
223
        zip.add(src.getAntResource(zip.getProject()));
224
        zip.setDestFile(dst);
224
        zip.setDestFile(dst);
225
        if (encoding != null && !encoding.equals("")) {
225
        if (encoding != null && !encoding.equals("")) {
226
            zip.setEncoding(encoding);
226
            zip.setEncoding(encoding);
227
        }
227
        }
228
        zip.setUpdate(update);
228
        zip.setUpdate(update);
229
        zip.setLevel(compresslevel);
229
        zip.setLevel(compresslevel);
230
        Map<String, String> result = runner.postTask();
230
        Map<String, String> result = runner.postTask();
231
        return "complete";
231
        return "complete";
232
    }
232
    }
233
 
233
 
234
    @WebMethod(exclude = true)
234
    @WebMethod(exclude = true)
235
    private String GUnzip(ResourceInterface src, File dst) {
235
    private String GUnzip(ResourceInterface src, File dst) {
236
        GUnzip uz = new GUnzip();
236
        GUnzip uz = new GUnzip();
237
        uz.setTaskName("GUnzip");
237
        uz.setTaskName("GUnzip");
238
        RunTask runner = new RunTask(uz);
238
        RunTask runner = new RunTask(uz);
239
        uz.setSrcResource(src.getAntResource(uz.getProject()));
239
        uz.setSrcResource(src.getAntResource(uz.getProject()));
240
        if (dst != null) {
240
        if (dst != null) {
241
            uz.setDest(dst);
241
            uz.setDest(dst);
242
        }
242
        }
243
        Map<String, String> result = runner.postTask();
243
        Map<String, String> result = runner.postTask();
244
        return "complete";
244
        return "complete";
245
    }
245
    }
246
 
246
 
247
    @WebMethod(exclude = true)
247
    @WebMethod(exclude = true)
248
    private String BUnzip2(ResourceInterface src, File dst) {
248
    private String BUnzip2(ResourceInterface src, File dst) {
249
        BUnzip2 uz = new BUnzip2();
249
        BUnzip2 uz = new BUnzip2();
250
        uz.setTaskName("BUnzip2");
250
        uz.setTaskName("BUnzip2");
251
        RunTask runner = new RunTask(uz);
251
        RunTask runner = new RunTask(uz);
252
        uz.setSrcResource(src.getAntResource(uz.getProject()));
252
        uz.setSrcResource(src.getAntResource(uz.getProject()));
253
        if (dst != null) {
253
        if (dst != null) {
254
            uz.setDest(dst);
254
            uz.setDest(dst);
255
        }
255
        }
256
        Map<String, String> result = runner.postTask();
256
        Map<String, String> result = runner.postTask();
257
        return "complete";
257
        return "complete";
258
    }
258
    }
259
 
259
 
260
    @WebMethod(exclude = true)
260
    @WebMethod(exclude = true)
261
    private String unzip(File src, File dest, boolean overwrite, String encoding) {
261
    private String unzip(File src, File dest, boolean overwrite, String encoding) {
262
        Expand unzip = new Expand();
262
        Expand unzip = new Expand();
263
        unzip.setTaskName("UnZip");
263
        unzip.setTaskName("UnZip");
264
        RunTask runner = new RunTask(unzip);
264
        RunTask runner = new RunTask(unzip);
265
        unzip.setSrc(src);
265
        unzip.setSrc(src);
266
        unzip.setDest(dest);
266
        unzip.setDest(dest);
267
        unzip.setOverwrite(overwrite);
267
        unzip.setOverwrite(overwrite);
268
        if (encoding != null && !encoding.equals("")) {
268
        if (encoding != null && !encoding.equals("")) {
269
            unzip.setEncoding(encoding);
269
            unzip.setEncoding(encoding);
270
        }
270
        }
271
 
271
 
272
        Map<String, String> result = runner.postTask();
272
        Map<String, String> result = runner.postTask();
273
        return "complete";
273
        return "complete";
274
    }
274
    }
275
 
275
 
276
    @WebMethod(exclude = true)
276
    @WebMethod(exclude = true)
277
    private String untar(File src, File dest, boolean overwrite, Untar.UntarCompressionMethod compression) {
277
    private String untar(File src, File dest, boolean overwrite, Untar.UntarCompressionMethod compression) {
278
        Untar unzip = new Untar();
278
        Untar unzip = new Untar();
279
        unzip.setTaskName("Untar");
279
        unzip.setTaskName("Untar");
280
        RunTask runner = new RunTask(unzip);
280
        RunTask runner = new RunTask(unzip);
281
        unzip.setSrc(src);
281
        unzip.setSrc(src);
282
        unzip.setDest(dest);
282
        unzip.setDest(dest);
283
        unzip.setOverwrite(overwrite);
283
        unzip.setOverwrite(overwrite);
284
        unzip.setCompression(compression);
284
        unzip.setCompression(compression);
285
        Map<String, String> result = runner.postTask();
285
        Map<String, String> result = runner.postTask();
286
        return "complete";
286
        return "complete";
287
    }
287
    }
288
 
288
 
289
    @WebMethod(exclude = true)
289
    @WebMethod(exclude = true)
290
    private String unrar(File src, File dst) {
290
    private String unrar(File src, File dst) {
291
        UnRarTask unrar = new UnRarTask();
291
        UnRarTask unrar = new UnRarTask();
292
        unrar.setTaskName("UnRar");
292
        unrar.setTaskName("UnRar");
293
        RunTask runner = new RunTask(unrar);
293
        RunTask runner = new RunTask(unrar);
294
        unrar.setSrc(src);
294
        unrar.setSrc(src);
295
        unrar.setDst(dst);
295
        unrar.setDst(dst);
296
        Map<String, String> result = runner.postTask();
296
        Map<String, String> result = runner.postTask();
297
        return "complete";
297
        return "complete";
298
    }
298
    }
299
 
299
 
300
   
300
   
301
}
301
}