Subversion Repositories XServices

Rev

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

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