Subversion Repositories XServices

Rev

Rev 64 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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