Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 96 → Rev 97

/xservices/trunk/src/java/net/brutex/xservices/ws/impl/MiscServiceImpl.java
18,15 → 18,12
 
import java.util.Enumeration;
import java.util.Properties;
import java.util.UUID;
 
import javax.jws.WebService;
import net.brutex.xservices.types.FileSetResource;
import net.brutex.xservices.types.HostConnection;
import net.brutex.xservices.types.HostinfoType;
import net.brutex.xservices.types.MailMimeType;
import net.brutex.xservices.types.ReturnCode;
import net.brutex.xservices.types.RuntimeInfoType;
import net.brutex.xservices.types.ant.FileSetResource;
import net.brutex.xservices.util.BrutexNamespaces;
import net.brutex.xservices.util.RunTask;
import net.brutex.xservices.ws.MiscService;
38,31 → 35,26
import org.apache.tools.ant.taskdefs.email.EmailTask;
 
/**
* Implements the web service
*
* @author Brian Rosenberger, bru@brutex.de
*/
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES,
@WSDLDocumentationCollection({
@WSDLDocumentation("My portType documentation"),
@WSDLDocumentation(value = "My top level documentation", placement = WSDLDocumentation.Placement.TOP),
@WSDLDocumentation(value = "My binding doc", placement = WSDLDocumentation.Placement.BINDING) })
@WebService(
targetNamespace = BrutexNamespaces.WS_XSERVICES,
endpointInterface = "net.brutex.xservices.ws.MiscService",
serviceName = "MiscService")
serviceName = "MiscService"
)
public class MiscServiceImpl implements MiscService {
 
public HostinfoType getHostinfo(String hostname) {
HostInfo info = new HostInfo();
info.setTaskName("HostInfo");
RunTask runner = new RunTask(info);
info.setHost(hostname);
// info.setPrefix(prefix);
// TODO: Does not work for IP Addresses?
ReturnCode ret = runner.postTask();
HostinfoType infotype = new HostinfoType(
ret.getProperty("NAME"),
ret.getProperty("DOMAIN"),
ret.getProperty("ADDR4"),
ret.getProperty("ADDR6"));
return infotype;
@WSDLDocumentation(value = "Get information about a host.")
public ReturnCode getHostinfo(String hostname) {
return antGetHostinfo(hostname, null);
}
 
@WSDLDocumentation(value = "Get XService information.")
public ReturnCode getInfo() {
ReturnCode r = new ReturnCode();
r.returnCode = 0;
70,20 → 62,20
Properties props = System.getProperties();
 
// Enumerate all system properties
@SuppressWarnings("unchecked")
Enumeration<String> e = (Enumeration<String>) props.propertyNames();
for (; e.hasMoreElements();) {
// Get property name
String propName = (String) e.nextElement();
for (; e.hasMoreElements(); ) {
// Get property name
String propName = (String)e.nextElement();
 
// Get property value
String propValue = (String) props.get(propName);
r.stdOut = r.stdOut + propName + ": " + propValue + "\n";
// Get property value
String propValue = (String)props.get(propName);
r.stdOut = r.stdOut + propName + ": " + propValue + "\n";
}
 
return r;
}
 
 
public ReturnCode sendMailSimple(HostConnection mailhost, String from,
String tolist, String subject, String message) {
return sendMail(from, from, tolist, "", "", subject, message,
112,8 → 104,13
return sleep(0, minutes, seconds, 0);
}
 
public String generateUUID() {
return UUID.randomUUID().toString();
private ReturnCode antGetHostinfo(String hostname, String prefix) {
HostInfo info = new HostInfo();
info.setTaskName("HostInfo");
RunTask runner = new RunTask(info);
info.setHost(hostname);
// info.setPrefix(prefix);
return runner.postTask();
}
 
private ReturnCode sendMail(String from, String replyto, String tolist,
156,8 → 153,4
sleep.setMilliseconds(milliseconds);
return runner.postTask();
}
 
public RuntimeInfoType getMemory() {
return new RuntimeInfoType();
}
}