Subversion Repositories XServices

Rev

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

Rev 63 Rev 64
Line 21... Line 21...
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;
Line 27... Line 28...
27
 
28
 
28
import javax.activation.DataHandler;
29
import javax.activation.DataHandler;
29
import javax.jws.WebMethod;
30
import javax.jws.WebMethod;
Line 55... Line 56...
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;
Line 60... Line 63...
60
 
63
 
61
/**
64
/**
62
 * 
65
 * 
63
 * @author Brian Rosenberger, bru@brutex.de
66
 * @author Brian Rosenberger, bru@brutex.de
Line 71... Line 74...
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
	}
Line 80... Line 92...
80
 
92
 
81
	@WebMethod(operationName = "replaceInFile")
93
	@WebMethod(operationName = "replaceInFile")
82
	public ReturnCode replaceInFile(
94
	public ReturnCode replaceInFile(
Line 204... Line 216...
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
	}
Line -... Line 220...
-
 
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");
-
 
249
		}
-
 
250
		LoadResource lr = new LoadResource();
-
 
251
		lr.setTaskName("LoadResource");
-
 
252
		RunTask runner = new RunTask(lr);
222
		}
253
		lr.addConfigured(res.getAntResource(lr.getProject()));
-
 
254
		lr.setEncoding(encoding);
-
 
255
		System.out.println("Using encoding: " + encoding);
-
 
256
		lr.setProperty("LoadResource.out");
-
 
257
		ReturnCode r = runner.postTask();
223
		return loadResource(res, encoding);
258
		return r.getProperty("LoadResource.out");
Line 224... Line 259...
224
	}
259
	}
225
 
260
 
226
	/*
261
	/*
Line 230... Line 265...
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
	}
Line 243... Line 287...
243
 
287
 
244
	/*
288
	/*
245
	 * (non-Javadoc)
289
	 * (non-Javadoc)
Line 300... Line 344...
300
			@WebParam(name = "permissions") String perm) {
344
			@WebParam(name = "permissions") String perm) {
301
		return chmod(res, perm);
345
		return chmod(res, perm);
302
	}
346
	}
Line 303... Line 347...
303
 
347
 
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
 
-
 
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");