Subversion Repositories XServices

Rev

Rev 97 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 97 Rev 114
Line 25... Line 25...
25
import javax.activation.DataHandler;
25
import javax.activation.DataHandler;
26
import javax.jws.WebMethod;
26
import javax.jws.WebMethod;
27
import javax.jws.WebParam;
27
import javax.jws.WebParam;
28
import javax.jws.WebService;
28
import javax.jws.WebService;
Line 29... Line -...
29
 
-
 
30
import net.brutex.xservices.types.ArchiveResource;
-
 
31
import net.brutex.xservices.types.AttachmentType;
-
 
32
import net.brutex.xservices.types.FileResource;
-
 
33
import net.brutex.xservices.types.FileSetResource;
29
 
34
import net.brutex.xservices.types.ReplacePattern;
30
import net.brutex.xservices.types.ReplacePattern;
-
 
31
import net.brutex.xservices.types.ReturnCode;
-
 
32
import net.brutex.xservices.types.ant.ArchiveResource;
-
 
33
import net.brutex.xservices.types.ant.AttachmentType;
-
 
34
import net.brutex.xservices.types.ant.FileResource;
35
import net.brutex.xservices.types.ReturnCode;
35
import net.brutex.xservices.types.ant.FileSetResource;
36
import net.brutex.xservices.util.BrutexNamespaces;
36
import net.brutex.xservices.util.BrutexNamespaces;
37
import net.brutex.xservices.util.RunTask;
37
import net.brutex.xservices.util.RunTask;
38
import net.brutex.xservices.ws.FileService;
38
import net.brutex.xservices.ws.FileService;
Line 282... Line 282...
282
	 * @see net.brutex.xservices.ws.impl.FileService#echo2file(java.lang.String,
282
	 * @see net.brutex.xservices.ws.impl.FileService#echo2file(java.lang.String,
283
	 * java.lang.String, java.lang.String, boolean)
283
	 * java.lang.String, java.lang.String, boolean)
284
	 */
284
	 */
Line 285... Line 285...
285
	
285
	
286
	public ReturnCode echo2file(String message, String file, String encoding,
286
	public ReturnCode echo2file(String message, String file, String encoding,
Line 287... Line 287...
287
			boolean append) throws XServicesFault {
287
			boolean append, boolean create) throws XServicesFault {
288
 
288
 
289
		Echo echo = new Echo();
289
		Echo echo = new Echo();
290
		echo.setTaskName("toFile");
290
		echo.setTaskName("toFile");
291
		RunTask runTask = new RunTask(echo);
291
		RunTask runTask = new RunTask(echo);
292
		echo.addText(message);
292
		echo.addText(message);
-
 
293
		echo.setEncoding(encoding);
293
		echo.setEncoding(encoding);
294
		File f = new File(file);
-
 
295
 
294
		File f = new File(file);
296
		try {
295
		try {
-
 
296
			if (!f.canWrite())
297
			if(!f.exists() && create) f.createNewFile();
297
 
298
			if (!f.canWrite())
Line 298... Line 299...
298
				throw new XServicesFault("Cannot write to file: "
299
				throw new XServicesFault("Cannot write to file: "
299
						+ f.getCanonicalPath());
300
						+ f.getCanonicalPath());
300
 
301
 
301
			echo.setFile(f);
302
			echo.setFile(f);
302
			echo.setAppend(append);
303
			echo.setAppend(append);
303
			ReturnCode c = runTask.postTask();
304
			ReturnCode c = runTask.postTask();
304
			return c;
305
			return c;
305
		} catch (BuildException e) {
306
		} catch (BuildException e) {
306
			throw new XServicesFault("Error in echo2file.", e);
307
			throw new XServicesFault("Error in echo2file.", e);
307
		} catch (IOException e) {
308
		} catch (IOException e) {
Line 308... Line 309...
308
			throw new XServicesFault("Cannot write to file.", e);
309
			throw new XServicesFault("Cannot write to file." + e.getMessage(), e);
309
		}
310
		}