Subversion Repositories XServices

Rev

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

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