Subversion Repositories XServices

Rev

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

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