Subversion Repositories XServices

Rev

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

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