Subversion Repositories XServices

Rev

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

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