Subversion Repositories XServices

Rev

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

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