Subversion Repositories XServices

Rev

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

Rev 60 Rev 63
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.BufferedInputStream;
18
import java.io.File;
19
import java.io.File;
19
import java.io.FileInputStream;
20
import java.io.FileInputStream;
20
import java.io.FileNotFoundException;
21
import java.io.FileNotFoundException;
21
import java.io.FileOutputStream;
22
import java.io.FileOutputStream;
22
import java.io.IOException;
23
import java.io.IOException;
23
import java.io.InputStream;
24
import java.io.InputStream;
24
import java.io.UnsupportedEncodingException;
25
import java.io.UnsupportedEncodingException;
25
import java.util.List;
26
import java.util.List;
26
 
27
 
27
import javax.activation.DataHandler;
28
import javax.activation.DataHandler;
28
import javax.jws.WebMethod;
29
import javax.jws.WebMethod;
29
import javax.jws.WebParam;
30
import javax.jws.WebParam;
30
import javax.jws.WebService;
31
import javax.jws.WebService;
31
 
32
 
32
import net.brutex.xservices.types.AntProperty;
33
import net.brutex.xservices.types.AntProperty;
33
import net.brutex.xservices.types.ArchiveResource;
34
import net.brutex.xservices.types.ArchiveResource;
34
import net.brutex.xservices.types.AttachmentType;
35
import net.brutex.xservices.types.AttachmentType;
35
import net.brutex.xservices.types.FileResource;
36
import net.brutex.xservices.types.FileResource;
36
import net.brutex.xservices.types.FileSetResource;
37
import net.brutex.xservices.types.FileSetResource;
-
 
38
import net.brutex.xservices.types.ReplacePattern;
37
import net.brutex.xservices.types.ResourceInterface;
39
import net.brutex.xservices.types.ResourceInterface;
38
import net.brutex.xservices.types.ReturnCode;
40
import net.brutex.xservices.types.ReturnCode;
39
import net.brutex.xservices.util.BrutexNamespaces;
41
import net.brutex.xservices.util.BrutexNamespaces;
40
import net.brutex.xservices.util.RunTask;
42
import net.brutex.xservices.util.RunTask;
41
import net.brutex.xservices.ws.FileService;
43
import net.brutex.xservices.ws.FileService;
42
import net.brutex.xservices.ws.XServicesFault;
44
import net.brutex.xservices.ws.XServicesFault;
43
 
45
 
44
import org.apache.commons.codec.binary.Base64;
46
import org.apache.commons.codec.binary.Base64;
45
import org.apache.commons.codec.binary.Base64InputStream;
47
import org.apache.commons.codec.binary.Base64InputStream;
46
import org.apache.cxf.aegis.type.mtom.StreamDataSource;
48
import org.apache.cxf.aegis.type.mtom.StreamDataSource;
47
import org.apache.tools.ant.BuildException;
49
import org.apache.tools.ant.BuildException;
48
import org.apache.tools.ant.taskdefs.Basename;
50
import org.apache.tools.ant.taskdefs.Basename;
49
import org.apache.tools.ant.taskdefs.Chmod;
51
import org.apache.tools.ant.taskdefs.Chmod;
50
import org.apache.tools.ant.taskdefs.Copy;
52
import org.apache.tools.ant.taskdefs.Copy;
51
import org.apache.tools.ant.taskdefs.Echo;
53
import org.apache.tools.ant.taskdefs.Echo;
52
import org.apache.tools.ant.taskdefs.LoadResource;
54
import org.apache.tools.ant.taskdefs.LoadResource;
-
 
55
import org.apache.tools.ant.taskdefs.Replace;
-
 
56
import org.apache.tools.ant.taskdefs.optional.ReplaceRegExp;
53
import org.apache.tools.ant.taskdefs.optional.unix.Chgrp;
57
import org.apache.tools.ant.taskdefs.optional.unix.Chgrp;
54
import org.apache.tools.ant.taskdefs.optional.unix.Chown;
58
import org.apache.tools.ant.taskdefs.optional.unix.Chown;
55
import org.apache.tools.ant.types.FileSet;
59
import org.apache.tools.ant.types.FileSet;
56
 
60
 
57
/**
61
/**
58
 * 
62
 * 
59
 * @author Brian Rosenberger, bru@brutex.de
63
 * @author Brian Rosenberger, bru@brutex.de
60
 */
64
 */
61
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES, endpointInterface = "net.brutex.xservices.ws.FileService", serviceName = "FileService")
65
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES, endpointInterface = "net.brutex.xservices.ws.FileService", serviceName = "FileService")
62
public class FileServiceImpl implements FileService {
66
public class FileServiceImpl implements FileService {
63
 
67
 
64
	/*
68
	/*
65
	 * (non-Javadoc)
69
	 * (non-Javadoc)
66
	 * 
70
	 * 
67
	 * @see net.brutex.xservices.ws.impl.FileService#basename(java.lang.String,
71
	 * @see net.brutex.xservices.ws.impl.FileService#basename(java.lang.String,
68
	 * java.lang.String)
72
	 * java.lang.String)
69
	 */
73
	 */
70
	@Override
74
	@Override
71
	@WebMethod(operationName = "basename")
75
	@WebMethod(operationName = "basename")
72
	public ReturnCode basename(@WebParam(name = "file") String filename,
76
	public ReturnCode basename(@WebParam(name = "file") String filename,
73
			@WebParam(name = "suffix") String suffix) {
77
			@WebParam(name = "suffix") String suffix) {
74
		return basename(new File(filename), suffix);
78
		return basename(new File(filename), suffix);
75
	}
79
	}
-
 
80
 
-
 
81
	@WebMethod(operationName = "replaceInFile")
-
 
82
	public ReturnCode replaceInFile(
-
 
83
			@WebParam(name = "file") FileResource res,
-
 
84
			@WebParam(name = "search") String search,
-
 
85
			@WebParam(name = "replace") String replace) {
-
 
86
		ReturnCode r = null;
-
 
87
		Replace rep = new Replace();
-
 
88
		rep.setTaskName("Replace");
-
 
89
		RunTask runner = new RunTask(rep);
-
 
90
		rep.addConfigured(res.getAntResource(rep.getProject()));
-
 
91
		rep.setToken(search);
-
 
92
		rep.setValue(replace);
-
 
93
		r = runner.postTask();
-
 
94
		return r;
-
 
95
	}
-
 
96
	
-
 
97
	@WebMethod(operationName = "replaceInFile2")
-
 
98
	public ReturnCode replaceInFile2(
-
 
99
			@WebParam(name = "file") FileResource res,
-
 
100
			@WebParam(name = "patternList") List<ReplacePattern> patternList) {
-
 
101
		ReturnCode r = null;
-
 
102
		for (ReplacePattern pat : patternList) {
-
 
103
			Replace rep = new Replace();
-
 
104
			rep.setTaskName("Replace");
-
 
105
			RunTask runner = new RunTask(rep);
-
 
106
			rep.addConfigured(res.getAntResource(rep.getProject()));
-
 
107
			rep.setToken(pat.search);
-
 
108
			rep.setValue(pat.replace);
-
 
109
			r = runner.postTask();
-
 
110
		}
-
 
111
		return r;
-
 
112
	}
-
 
113
	
-
 
114
	@WebMethod(operationName = "replaceInFileRegEx")
-
 
115
	public ReturnCode replaceInFileRegEx(
-
 
116
			@WebParam(name = "file") FileResource res,
-
 
117
			@WebParam(name = "search") String search,
-
 
118
			@WebParam(name = "replace") String replace,
-
 
119
			@WebParam(name = "flags") String flags) {		
-
 
120
		ReplaceRegExp rep = new ReplaceRegExp();
-
 
121
		rep.setTaskName("ReplaceRegExp");
-
 
122
		RunTask runner = new RunTask(rep);
-
 
123
		File infile = new File(res.uri);
-
 
124
		rep.setFile(infile);
-
 
125
		rep.setMatch(search);
-
 
126
		rep.setReplace(replace);
-
 
127
		rep.setFlags(flags);
-
 
128
		ReturnCode r = runner.postTask();		
-
 
129
		return r;
-
 
130
	}
-
 
131
	
76
 
132
	
77
	/*
133
	/*
78
	 * (non-Javadoc)
134
	 * (non-Javadoc)
79
	 * 
135
	 * 
80
	 * @see
136
	 * @see
81
	 * net.brutex.xservices.ws.impl.FileService#base64Encode(net.brutex.xservices
137
	 * net.brutex.xservices.ws.impl.FileService#base64Encode(net.brutex.xservices
82
	 * .types.FileSetResource)
138
	 * .types.FileSetResource)
83
	 */
139
	 */
84
	@Override
140
	@Override
85
	@WebMethod(operationName = "downloadFile")
141
	@WebMethod(operationName = "downloadFile")
86
	public AttachmentType downloadFile(@WebParam(name = "file") FileResource res) {
142
	public AttachmentType downloadFile(@WebParam(name = "file") FileResource res) {
87
		InputStream is = null;
143
		InputStream is = null;
88
		try {
144
		try {
89
			is = res.getAntResource(null).getInputStream();
145
			is = res.getAntResource(null).getInputStream();
90
		} catch (IOException e) {
146
		} catch (IOException e) {
91
			// TODO Auto-generated catch block
147
			// TODO Auto-generated catch block
92
			e.printStackTrace();
148
			e.printStackTrace();
93
		}
149
		}
94
		DataHandler h = new DataHandler(new StreamDataSource(
150
		DataHandler h = new DataHandler(new StreamDataSource(
95
				"application/binary", is));
151
				"application/binary", is));
96
		AttachmentType t = new AttachmentType();
152
		AttachmentType t = new AttachmentType();
97
		t.setContent(h);
153
		t.setContent(h);
98
		t.setFilename(res.getAntResource(null).getName());
154
		t.setFilename(res.getAntResource(null).getName());
99
		return t;
155
		return t;
100
	}
156
	}
101
 
157
 
102
	/*
158
	/*
103
	 * (non-Javadoc)
159
	 * (non-Javadoc)
104
	 * 
160
	 * 
105
	 * @see
161
	 * @see
106
	 * net.brutex.xservices.ws.impl.FileService#base64Decode(net.brutex.xservices
162
	 * net.brutex.xservices.ws.impl.FileService#base64Decode(net.brutex.xservices
107
	 * .types.AttachmentType)
163
	 * .types.AttachmentType)
108
	 */
164
	 */
109
	@Override
165
	@Override
110
	@WebMethod(operationName = "uploadFile")
166
	@WebMethod(operationName = "uploadFile")
111
	public String uploadFile(@WebParam(name = "file") AttachmentType file) {
167
	public String uploadFile(@WebParam(name = "file") AttachmentType file) {
112
		DataHandler h =  file.getContent();
168
		DataHandler h =  file.getContent();
113
		File f = new File(file.getFilename());
169
		File f = new File(file.getFilename());
114
		FileOutputStream fout;
170
		FileOutputStream fout;
115
		try {
171
		try {
116
			fout = new FileOutputStream(f);
172
			fout = new FileOutputStream(f);
117
			/*
173
			/*
118
			 * InputStream in = h.getInputStream();
174
			 * InputStream in = h.getInputStream();
119
			int b;
175
			int b;
120
			while( (b=in.read())!= -1 ) {
176
			while( (b=in.read())!= -1 ) {
121
				fout.write(b);
177
				fout.write(b);
122
			}
178
			}
123
			*/
179
			*/
124
			h.writeTo(fout);
180
			h.writeTo(fout);
125
			fout.flush();
181
			fout.flush();
126
			fout.close();
182
			fout.close();
127
			//in.close();
183
			//in.close();
128
		} catch (FileNotFoundException e) {
184
		} catch (FileNotFoundException e) {
129
			throw new BuildException(e);
185
			throw new BuildException(e);
130
		} catch (IOException e) {
186
		} catch (IOException e) {
131
			throw new BuildException(e);
187
			throw new BuildException(e);
132
		}
188
		}
133
		return file.getFilename();
189
		return file.getFilename();
134
	}
190
	}
135
 
191
 
136
	/*
192
	/*
137
	 * (non-Javadoc)
193
	 * (non-Javadoc)
138
	 * 
194
	 * 
139
	 * @see
195
	 * @see
140
	 * net.brutex.xservices.ws.impl.FileService#copy(net.brutex.xservices.types
196
	 * net.brutex.xservices.ws.impl.FileService#copy(net.brutex.xservices.types
141
	 * .FileSetResource, java.lang.String, boolean, boolean, java.lang.String)
197
	 * .FileSetResource, java.lang.String, boolean, boolean, java.lang.String)
142
	 */
198
	 */
143
	@Override
199
	@Override
144
	@WebMethod(operationName = "copy")
200
	@WebMethod(operationName = "copy")
145
	public ReturnCode copy(@WebParam(name = "fileset") FileSetResource src,
201
	public ReturnCode copy(@WebParam(name = "fileset") FileSetResource src,
146
			@WebParam(name = "todir") String todir,
202
			@WebParam(name = "todir") String todir,
147
			@WebParam(name = "preservelastmodified") boolean plm,
203
			@WebParam(name = "preservelastmodified") boolean plm,
148
			@WebParam(name = "overwrite") boolean overwrite,
204
			@WebParam(name = "overwrite") boolean overwrite,
149
			@WebParam(name = "encoding") String encoding) throws XServicesFault {
205
			@WebParam(name = "encoding") String encoding) throws XServicesFault {
150
		return copy(src, new File(todir), plm, overwrite, encoding);
206
		return copy(src, new File(todir), plm, overwrite, encoding);
151
	}
207
	}
152
 
208
 
153
	/*
209
	/*
154
	 * (non-Javadoc)
210
	 * (non-Javadoc)
155
	 * 
211
	 * 
156
	 * @see
212
	 * @see
157
	 * net.brutex.xservices.ws.impl.FileService#loadRes(net.brutex.xservices
213
	 * net.brutex.xservices.ws.impl.FileService#loadRes(net.brutex.xservices
158
	 * .types.FileResource, java.lang.String)
214
	 * .types.FileResource, java.lang.String)
159
	 */
215
	 */
160
	@Override
216
	@Override
161
	@WebMethod(operationName = "loadResource")
217
	@WebMethod(operationName = "loadResource")
162
	public ReturnCode loadRes(@WebParam(name = "resource") FileResource res,
218
	public ReturnCode loadRes(@WebParam(name = "resource") FileResource res,
163
			@WebParam(name = "encoding") String encoding) {
219
			@WebParam(name = "encoding") String encoding) {
164
		if (encoding == null || encoding.equals("")) {
220
		if (encoding == null || encoding.equals("")) {
165
			encoding = System.getProperty("file.encoding");
221
			encoding = System.getProperty("file.encoding");
166
		}
222
		}
167
		return loadResource(res, encoding);
223
		return loadResource(res, encoding);
168
	}
224
	}
169
 
225
 
170
	/*
226
	/*
171
	 * (non-Javadoc)
227
	 * (non-Javadoc)
172
	 * 
228
	 * 
173
	 * @see
229
	 * @see
174
	 * net.brutex.xservices.ws.impl.FileService#loadResFromArchive(net.brutex
230
	 * net.brutex.xservices.ws.impl.FileService#loadResFromArchive(net.brutex
175
	 * .xservices.types.ArchiveResource, java.lang.String)
231
	 * .xservices.types.ArchiveResource, java.lang.String)
176
	 */
232
	 */
177
	@Override
233
	@Override
178
	@WebMethod(operationName = "loadResourceFromArchive")
234
	@WebMethod(operationName = "loadResourceFromArchive")
179
	public ReturnCode loadResFromArchive(
235
	public ReturnCode loadResFromArchive(
180
			@WebParam(name = "archiveresource") ArchiveResource res,
236
			@WebParam(name = "archiveresource") ArchiveResource res,
181
			@WebParam(name = "encoding") String encoding) {
237
			@WebParam(name = "encoding") String encoding) {
182
		if (encoding == null || encoding.equals("")) {
238
		if (encoding == null || encoding.equals("")) {
183
			encoding = System.getProperty("file.encoding");
239
			encoding = System.getProperty("file.encoding");
184
		}
240
		}
185
		return loadResource(res, encoding);
241
		return loadResource(res, encoding);
186
	}
242
	}
187
 
243
 
188
	/*
244
	/*
189
	 * (non-Javadoc)
245
	 * (non-Javadoc)
190
	 * 
246
	 * 
191
	 * @see net.brutex.xservices.ws.impl.FileService#echo2file(java.lang.String,
247
	 * @see net.brutex.xservices.ws.impl.FileService#echo2file(java.lang.String,
192
	 * java.lang.String, java.lang.String, boolean)
248
	 * java.lang.String, java.lang.String, boolean)
193
	 */
249
	 */
194
	@Override
250
	@Override
195
	@WebMethod(operationName = "echoToFile")
251
	@WebMethod(operationName = "echoToFile")
196
	public ReturnCode echo2file(@WebParam(name = "message") String message,
252
	public ReturnCode echo2file(@WebParam(name = "message") String message,
197
			@WebParam(name = "file") String file,
253
			@WebParam(name = "file") String file,
198
			@WebParam(name = "encoding") String encoding,
254
			@WebParam(name = "encoding") String encoding,
199
			@WebParam(name = "append") boolean append) {
255
			@WebParam(name = "append") boolean append) {
200
		return echo(message, new File(file), encoding, append);
256
		return echo(message, new File(file), encoding, append);
201
	}
257
	}
202
 
258
 
203
	/*
259
	/*
204
	 * (non-Javadoc)
260
	 * (non-Javadoc)
205
	 * 
261
	 * 
206
	 * @see
262
	 * @see
207
	 * net.brutex.xservices.ws.impl.FileService#changeOwner(net.brutex.xservices
263
	 * net.brutex.xservices.ws.impl.FileService#changeOwner(net.brutex.xservices
208
	 * .types.FileSetResource, java.lang.String)
264
	 * .types.FileSetResource, java.lang.String)
209
	 */
265
	 */
210
	@Override
266
	@Override
211
	@WebMethod(operationName = "changeOwner")
267
	@WebMethod(operationName = "changeOwner")
212
	public ReturnCode changeOwner(
268
	public ReturnCode changeOwner(
213
			@WebParam(name = "fileset") FileSetResource res,
269
			@WebParam(name = "fileset") FileSetResource res,
214
			@WebParam(name = "owner") String owner) {
270
			@WebParam(name = "owner") String owner) {
215
		return chown(res, owner);
271
		return chown(res, owner);
216
	}
272
	}
217
 
273
 
218
	/*
274
	/*
219
	 * (non-Javadoc)
275
	 * (non-Javadoc)
220
	 * 
276
	 * 
221
	 * @see
277
	 * @see
222
	 * net.brutex.xservices.ws.impl.FileService#changeGroup(net.brutex.xservices
278
	 * net.brutex.xservices.ws.impl.FileService#changeGroup(net.brutex.xservices
223
	 * .types.FileSetResource, java.lang.String)
279
	 * .types.FileSetResource, java.lang.String)
224
	 */
280
	 */
225
	@Override
281
	@Override
226
	@WebMethod(operationName = "changeGroup")
282
	@WebMethod(operationName = "changeGroup")
227
	public ReturnCode changeGroup(
283
	public ReturnCode changeGroup(
228
			@WebParam(name = "fileset") FileSetResource res,
284
			@WebParam(name = "fileset") FileSetResource res,
229
			@WebParam(name = "group") String group) {
285
			@WebParam(name = "group") String group) {
230
		return chgrp(res, group);
286
		return chgrp(res, group);
231
	}
287
	}
232
 
288
 
233
	/*
289
	/*
234
	 * (non-Javadoc)
290
	 * (non-Javadoc)
235
	 * 
291
	 * 
236
	 * @see
292
	 * @see
237
	 * net.brutex.xservices.ws.impl.FileService#changeMode(net.brutex.xservices
293
	 * net.brutex.xservices.ws.impl.FileService#changeMode(net.brutex.xservices
238
	 * .types.FileSetResource, java.lang.String)
294
	 * .types.FileSetResource, java.lang.String)
239
	 */
295
	 */
240
	@Override
296
	@Override
241
	@WebMethod(operationName = "changeMode")
297
	@WebMethod(operationName = "changeMode")
242
	public ReturnCode changeMode(
298
	public ReturnCode changeMode(
243
			@WebParam(name = "fileset") FileSetResource res,
299
			@WebParam(name = "fileset") FileSetResource res,
244
			@WebParam(name = "permissions") String perm) {
300
			@WebParam(name = "permissions") String perm) {
245
		return chmod(res, perm);
301
		return chmod(res, perm);
246
	}
302
	}
247
 
303
 
248
	@WebMethod(exclude = true)
304
	@WebMethod(exclude = true)
249
	private ReturnCode basename(File file, String suffix) {
305
	private ReturnCode basename(File file, String suffix) {
250
		Basename basename = new Basename();
306
		Basename basename = new Basename();
251
		RunTask runner = new RunTask(basename);
307
		RunTask runner = new RunTask(basename);
252
		basename.setFile(file);
308
		basename.setFile(file);
253
		if (suffix != null && !suffix.equals("")) {
309
		if (suffix != null && !suffix.equals("")) {
254
			basename.setSuffix(suffix);
310
			basename.setSuffix(suffix);
255
		}
311
		}
256
		basename.setProperty("basename.value");
312
		basename.setProperty("basename.value");
257
		return runner.postTask();
313
		return runner.postTask();
258
	}
314
	}
259
 
315
 
260
	@WebMethod(exclude = true)
316
	@WebMethod(exclude = true)
261
	private ReturnCode loadResource(ResourceInterface src, String encoding) {
317
	private ReturnCode loadResource(ResourceInterface src, String encoding) {
262
		LoadResource lr = new LoadResource();
318
		LoadResource lr = new LoadResource();
263
		lr.setTaskName("LoadResource");
319
		lr.setTaskName("LoadResource");
264
		RunTask runner = new RunTask(lr);
320
		RunTask runner = new RunTask(lr);
265
		lr.addConfigured(src.getAntResource(lr.getProject()));
321
		lr.addConfigured(src.getAntResource(lr.getProject()));
266
		lr.setEncoding(encoding);
322
		lr.setEncoding(encoding);
267
		System.out.println("Using encoding: " + encoding);
323
		System.out.println("Using encoding: " + encoding);
268
		lr.setProperty("LoadResource.out");
324
		lr.setProperty("LoadResource.out");
269
		return runner.postTask();
325
		return runner.postTask();
270
	}
326
	}
271
 
327
 
272
	@WebMethod(exclude = true)
328
	@WebMethod(exclude = true)
273
	private ReturnCode echo(String msg, File file, String encoding,
329
	private ReturnCode echo(String msg, File file, String encoding,
274
			boolean append) {
330
			boolean append) {
275
		Echo echo = new Echo();
331
		Echo echo = new Echo();
276
		echo.setTaskName("toFile");
332
		echo.setTaskName("toFile");
277
		RunTask runTask = new RunTask(echo);
333
		RunTask runTask = new RunTask(echo);
278
		echo.addText(msg);
334
		echo.addText(msg);
279
		echo.setEncoding(encoding);
335
		echo.setEncoding(encoding);
280
		echo.setFile(file);
336
		echo.setFile(file);
281
		echo.setAppend(append);
337
		echo.setAppend(append);
282
		return runTask.postTask();
338
		return runTask.postTask();
283
	}
339
	}
284
 
340
 
285
	@WebMethod(exclude = true)
341
	@WebMethod(exclude = true)
286
	private ReturnCode copy(FileSetResource src, File dst,
342
	private ReturnCode copy(FileSetResource src, File dst,
287
			boolean preservelastmodified, boolean overwrite, String encoding) {
343
			boolean preservelastmodified, boolean overwrite, String encoding) {
288
		Copy copy = new Copy();
344
		Copy copy = new Copy();
289
		copy.setTaskName("Copy");
345
		copy.setTaskName("Copy");
290
		RunTask runner = new RunTask(copy);
346
		RunTask runner = new RunTask(copy);
291
		FileSet set = src.getAntResource(copy.getProject());
347
		FileSet set = src.getAntResource(copy.getProject());
292
		copy.add(set);
348
		copy.add(set);
293
 
349
 
294
		if (dst.isDirectory()) {
350
		if (dst.isDirectory()) {
295
			copy.setTodir(dst);
351
			copy.setTodir(dst);
296
		}
352
		}
297
		if (dst.isFile()) {
353
		if (dst.isFile()) {
298
			copy.setTofile(dst);
354
			copy.setTofile(dst);
299
		}
355
		}
300
		copy.setOverwrite(overwrite);
356
		copy.setOverwrite(overwrite);
301
		copy.setPreserveLastModified(preservelastmodified);
357
		copy.setPreserveLastModified(preservelastmodified);
302
		if (encoding != null && !encoding.equals("")) {
358
		if (encoding != null && !encoding.equals("")) {
303
			copy.setOutputEncoding(encoding);
359
			copy.setOutputEncoding(encoding);
304
		} else {
360
		} else {
305
			copy.setOutputEncoding(System.getProperty("file.encoding"));
361
			copy.setOutputEncoding(System.getProperty("file.encoding"));
306
		}
362
		}
307
 
363
 
308
		return runner.postTask();
364
		return runner.postTask();
309
	}
365
	}
310
 
366
 
311
	@WebMethod(exclude = true)
367
	@WebMethod(exclude = true)
312
	private ReturnCode chown(FileSetResource src, String owner) {
368
	private ReturnCode chown(FileSetResource src, String owner) {
313
		Chown chown = new Chown();
369
		Chown chown = new Chown();
314
		chown.setTaskName("Chown");
370
		chown.setTaskName("Chown");
315
		RunTask runner = new RunTask(chown);
371
		RunTask runner = new RunTask(chown);
316
		chown.setOwner(owner);
372
		chown.setOwner(owner);
317
		FileSet set = src.getAntResource(chown.getProject());
373
		FileSet set = src.getAntResource(chown.getProject());
318
		chown.add(set);
374
		chown.add(set);
319
		chown.setMaxParallel(300);
375
		chown.setMaxParallel(300);
320
		return runner.postTask();
376
		return runner.postTask();
321
	}
377
	}
322
 
378
 
323
	@WebMethod(exclude = true)
379
	@WebMethod(exclude = true)
324
	private ReturnCode chgrp(FileSetResource src, String group) {
380
	private ReturnCode chgrp(FileSetResource src, String group) {
325
		Chgrp chgrp = new Chgrp();
381
		Chgrp chgrp = new Chgrp();
326
		chgrp.setTaskName("Chgrp");
382
		chgrp.setTaskName("Chgrp");
327
		RunTask runner = new RunTask(chgrp);
383
		RunTask runner = new RunTask(chgrp);
328
		chgrp.setGroup(group);
384
		chgrp.setGroup(group);
329
		FileSet set = src.getAntResource(chgrp.getProject());
385
		FileSet set = src.getAntResource(chgrp.getProject());
330
		chgrp.add(set);
386
		chgrp.add(set);
331
		chgrp.setMaxParallel(300);
387
		chgrp.setMaxParallel(300);
332
		return runner.postTask();
388
		return runner.postTask();
333
	}
389
	}
334
 
390
 
335
	@WebMethod(exclude = true)
391
	@WebMethod(exclude = true)
336
	private ReturnCode chmod(FileSetResource src, String perm) {
392
	private ReturnCode chmod(FileSetResource src, String perm) {
337
		Chmod chmod = new Chmod();
393
		Chmod chmod = new Chmod();
338
		chmod.setTaskName("Chmod");
394
		chmod.setTaskName("Chmod");
339
		RunTask runner = new RunTask(chmod);
395
		RunTask runner = new RunTask(chmod);
340
		FileSet set = src.getAntResource(chmod.getProject());
396
		FileSet set = src.getAntResource(chmod.getProject());
341
		chmod.add(set);
397
		chmod.add(set);
342
		chmod.setMaxParallel(300);
398
		chmod.setMaxParallel(300);
343
		chmod.setPerm(perm);
399
		chmod.setPerm(perm);
344
		chmod.setVerbose(true);
400
		chmod.setVerbose(true);
345
		return runner.postTask();
401
		return runner.postTask();
346
	}
402
	}
347
 
403
 
348
}
404
}