Subversion Repositories XServices

Rev

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

Rev 60 Rev 63
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 -... Line 17...
-
 
17
 
17
 
18
import java.io.BufferedInputStream;
18
import java.io.File;
19
import java.io.File;
19
import java.io.FileInputStream;
20
import java.io.FileInputStream;
20
import java.io.FileNotFoundException;
21
import java.io.FileNotFoundException;
21
import java.io.FileOutputStream;
22
import java.io.FileOutputStream;
Line 32... Line 33...
32
import net.brutex.xservices.types.AntProperty;
33
import net.brutex.xservices.types.AntProperty;
33
import net.brutex.xservices.types.ArchiveResource;
34
import net.brutex.xservices.types.ArchiveResource;
34
import net.brutex.xservices.types.AttachmentType;
35
import net.brutex.xservices.types.AttachmentType;
35
import net.brutex.xservices.types.FileResource;
36
import net.brutex.xservices.types.FileResource;
36
import net.brutex.xservices.types.FileSetResource;
37
import net.brutex.xservices.types.FileSetResource;
-
 
38
import net.brutex.xservices.types.ReplacePattern;
37
import net.brutex.xservices.types.ResourceInterface;
39
import net.brutex.xservices.types.ResourceInterface;
38
import net.brutex.xservices.types.ReturnCode;
40
import net.brutex.xservices.types.ReturnCode;
39
import net.brutex.xservices.util.BrutexNamespaces;
41
import net.brutex.xservices.util.BrutexNamespaces;
40
import net.brutex.xservices.util.RunTask;
42
import net.brutex.xservices.util.RunTask;
41
import net.brutex.xservices.ws.FileService;
43
import net.brutex.xservices.ws.FileService;
Line 48... Line 50...
48
import org.apache.tools.ant.taskdefs.Basename;
50
import org.apache.tools.ant.taskdefs.Basename;
49
import org.apache.tools.ant.taskdefs.Chmod;
51
import org.apache.tools.ant.taskdefs.Chmod;
50
import org.apache.tools.ant.taskdefs.Copy;
52
import org.apache.tools.ant.taskdefs.Copy;
51
import org.apache.tools.ant.taskdefs.Echo;
53
import org.apache.tools.ant.taskdefs.Echo;
52
import org.apache.tools.ant.taskdefs.LoadResource;
54
import org.apache.tools.ant.taskdefs.LoadResource;
-
 
55
import org.apache.tools.ant.taskdefs.Replace;
-
 
56
import org.apache.tools.ant.taskdefs.optional.ReplaceRegExp;
53
import org.apache.tools.ant.taskdefs.optional.unix.Chgrp;
57
import org.apache.tools.ant.taskdefs.optional.unix.Chgrp;
54
import org.apache.tools.ant.taskdefs.optional.unix.Chown;
58
import org.apache.tools.ant.taskdefs.optional.unix.Chown;
55
import org.apache.tools.ant.types.FileSet;
59
import org.apache.tools.ant.types.FileSet;
Line 56... Line 60...
56
 
60
 
Line 72... Line 76...
72
	public ReturnCode basename(@WebParam(name = "file") String filename,
76
	public ReturnCode basename(@WebParam(name = "file") String filename,
73
			@WebParam(name = "suffix") String suffix) {
77
			@WebParam(name = "suffix") String suffix) {
74
		return basename(new File(filename), suffix);
78
		return basename(new File(filename), suffix);
75
	}
79
	}
Line -... Line 80...
-
 
80
 
-
 
81
	@WebMethod(operationName = "replaceInFile")
-
 
82
	public ReturnCode replaceInFile(
-
 
83
			@WebParam(name = "file") FileResource res,
-
 
84
			@WebParam(name = "search") String search,
-
 
85
			@WebParam(name = "replace") String replace) {
-
 
86
		ReturnCode r = null;
-
 
87
		Replace rep = new Replace();
-
 
88
		rep.setTaskName("Replace");
-
 
89
		RunTask runner = new RunTask(rep);
-
 
90
		rep.addConfigured(res.getAntResource(rep.getProject()));
-
 
91
		rep.setToken(search);
-
 
92
		rep.setValue(replace);
-
 
93
		r = runner.postTask();
-
 
94
		return r;
-
 
95
	}
-
 
96
	
-
 
97
	@WebMethod(operationName = "replaceInFile2")
-
 
98
	public ReturnCode replaceInFile2(
-
 
99
			@WebParam(name = "file") FileResource res,
-
 
100
			@WebParam(name = "patternList") List<ReplacePattern> patternList) {
-
 
101
		ReturnCode r = null;
-
 
102
		for (ReplacePattern pat : patternList) {
-
 
103
			Replace rep = new Replace();
-
 
104
			rep.setTaskName("Replace");
-
 
105
			RunTask runner = new RunTask(rep);
-
 
106
			rep.addConfigured(res.getAntResource(rep.getProject()));
-
 
107
			rep.setToken(pat.search);
-
 
108
			rep.setValue(pat.replace);
-
 
109
			r = runner.postTask();
-
 
110
		}
-
 
111
		return r;
-
 
112
	}
-
 
113
	
-
 
114
	@WebMethod(operationName = "replaceInFileRegEx")
-
 
115
	public ReturnCode replaceInFileRegEx(
-
 
116
			@WebParam(name = "file") FileResource res,
-
 
117
			@WebParam(name = "search") String search,
-
 
118
			@WebParam(name = "replace") String replace,
-
 
119
			@WebParam(name = "flags") String flags) {		
-
 
120
		ReplaceRegExp rep = new ReplaceRegExp();
-
 
121
		rep.setTaskName("ReplaceRegExp");
-
 
122
		RunTask runner = new RunTask(rep);
-
 
123
		File infile = new File(res.uri);
-
 
124
		rep.setFile(infile);
-
 
125
		rep.setMatch(search);
-
 
126
		rep.setReplace(replace);
-
 
127
		rep.setFlags(flags);
-
 
128
		ReturnCode r = runner.postTask();		
-
 
129
		return r;
-
 
130
	}
-
 
131
	
76
 
132
	
77
	/*
133
	/*
78
	 * (non-Javadoc)
134
	 * (non-Javadoc)
79
	 * 
135
	 * 
80
	 * @see
136
	 * @see