Subversion Repositories XServices

Rev

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

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