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