Subversion Repositories XServices

Rev

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

Rev 23 Rev 46
Line 12... Line 12...
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
 */
Line 16... Line 16...
16
 
16
 
Line 17... Line 17...
17
package net.brutex.xservices.ws;
17
package net.brutex.xservices.ws.impl;
18
 
18
 
19
import javax.jws.WebService;
19
import javax.jws.WebService;
20
import net.brutex.xservices.types.FileSetResource;
20
import net.brutex.xservices.types.FileSetResource;
21
import net.brutex.xservices.types.HostConnection;
21
import net.brutex.xservices.types.HostConnection;
-
 
22
import net.brutex.xservices.types.MailMimeType;
22
import net.brutex.xservices.types.MailMimeType;
23
import net.brutex.xservices.types.ReturnCode;
-
 
24
import net.brutex.xservices.util.BrutexNamespaces;
-
 
25
import net.brutex.xservices.util.RunTask;
23
import net.brutex.xservices.types.ReturnCode;
26
import net.brutex.xservices.ws.MiscService;
24
import net.brutex.xservices.util.RunTask;
27
 
25
import org.apache.cxf.annotations.WSDLDocumentation;
28
import org.apache.cxf.annotations.WSDLDocumentation;
26
import org.apache.cxf.annotations.WSDLDocumentationCollection;
29
import org.apache.cxf.annotations.WSDLDocumentationCollection;
27
import org.apache.tools.ant.taskdefs.HostInfo;
30
import org.apache.tools.ant.taskdefs.HostInfo;
Line 28... Line 31...
28
import org.apache.tools.ant.taskdefs.Sleep;
31
import org.apache.tools.ant.taskdefs.Sleep;
29
import org.apache.tools.ant.taskdefs.email.EmailTask;
32
import org.apache.tools.ant.taskdefs.email.EmailTask;
30
 
33
 
31
/**
34
/**
32
 *
35
 * 
33
 * @author Brian Rosenberger, bru@brutex.de
-
 
34
 */
36
 * @author Brian Rosenberger, bru@brutex.de
35
@WSDLDocumentationCollection(
37
 */
36
    {
38
@WSDLDocumentationCollection({
-
 
39
		@WSDLDocumentation("My portType documentation"),
37
        @WSDLDocumentation("My portType documentation"),
40
		@WSDLDocumentation(value = "My top level documentation", placement = WSDLDocumentation.Placement.TOP),
38
        @WSDLDocumentation(value = "My top level documentation",
41
		@WSDLDocumentation(value = "My binding doc", placement = WSDLDocumentation.Placement.BINDING) })
39
                           placement = WSDLDocumentation.Placement.TOP),
42
@WebService(
40
        @WSDLDocumentation(value = "My binding doc",
43
		targetNamespace = BrutexNamespaces.WS_XSERVICES, 
41
                           placement = WSDLDocumentation.Placement.BINDING)
-
 
42
    }
-
 
43
)
44
		endpointInterface = "net.brutex.xservices.ws.MiscService", 
Line 44... Line 45...
44
@WebService(endpointInterface="net.brutex.xservices.ws.MiscService",
45
		serviceName = "MiscService"
45
serviceName="MiscService")
46
			)
46
public class MiscServiceImpl implements MiscService {
47
public class MiscServiceImpl implements MiscService {
47
 
48
 
Line 48... Line 49...
48
    @WSDLDocumentation(value="Get information about a host.")
49
	@WSDLDocumentation(value = "Get information about a host.")
49
    public ReturnCode getHostinfo(String hostname) {
-
 
50
        return antGetHostinfo(hostname, null);
-
 
51
    }
-
 
52
 
-
 
53
    public ReturnCode sendMailSimple(HostConnection mailhost, String from, String tolist, String subject, String message) {
-
 
54
        return sendMail(from,
50
	public ReturnCode getHostinfo(String hostname) {
55
                from,
51
		return antGetHostinfo(hostname, null);
56
                tolist,
-
 
57
                "",
-
 
58
                "",
52
	}
59
                subject,
-
 
60
                message,
-
 
61
                "text/plain",
53
 
62
                null,
-
 
63
                mailhost.hostname,
-
 
64
                mailhost.port,
-
 
65
                mailhost.user,
54
	public ReturnCode sendMailSimple(HostConnection mailhost, String from,
Line 66... Line 55...
66
                mailhost.password,
55
			String tolist, String subject, String message) {
67
                "utf-8",
56
		return sendMail(from, from, tolist, "", "", subject, message,
68
                false,
57
				"text/plain", null, mailhost.hostname, mailhost.port,
69
                false);
58
				mailhost.user, mailhost.password, "utf-8", false, false);
70
    }
-
 
71
 
-
 
72
    public ReturnCode sendMailSimpleWithAttachment(HostConnection mailhost, String from,
-
 
73
            String tolist, String subject, String message,
-
 
74
            FileSetResource res) {
-
 
75
        return  sendMail(from,
-
 
76
                from,
-
 
77
                tolist,
-
 
78
                "",
59
	}
79
                "",
-
 
80
                subject,
-
 
81
                message,
60
 
82
                "text/plain",
-
 
83
                res,
-
 
84
                mailhost.hostname,
-
 
85
                mailhost.port,
61
	public ReturnCode sendMailSimpleWithAttachment(HostConnection mailhost,
Line 86... Line 62...
86
                mailhost.user,
62
			String from, String tolist, String subject, String message,
87
                mailhost.password,
63
			FileSetResource res) {
88
                "utf-8",
64
		return sendMail(from, from, tolist, "", "", subject, message,
89
                false,
65
				"text/plain", res, mailhost.hostname, mailhost.port,
90
                false);
66
				mailhost.user, mailhost.password, "utf-8", false, false);
91
    }
-
 
92
 
-
 
93
    public ReturnCode sendMail(HostConnection mailhost, String from, String tolist,
-
 
94
            String cclist, String bcclist, String subject,
-
 
95
            MailMimeType mimetype, String charset, String message,
-
 
96
            FileSetResource res, boolean ssl, boolean tls) {
-
 
97
         return  sendMail(from,
-
 
98
                from,
-
 
99
                tolist,
67
	}
100
                cclist,
-
 
101
                bcclist,
-
 
102
                subject,
68
 
103
                message,
-
 
104
                mimetype.value(),
-
 
105
                res,
-
 
106
                mailhost.hostname,
69
	public ReturnCode sendMail(HostConnection mailhost, String from,
Line 107... Line -...
107
                mailhost.port,
-
 
108
                mailhost.user,
-
 
109
                mailhost.password,
-
 
110
                charset,
-
 
111
                tls,
70
			String tolist, String cclist, String bcclist, String subject,
112
                ssl);
71
			MailMimeType mimetype, String charset, String message,
113
    }
72
			FileSetResource res, boolean ssl, boolean tls) {
Line 114... Line -...
114
 
-
 
115
 
-
 
116
 
73
		return sendMail(from, from, tolist, cclist, bcclist, subject, message,
117
 
74
				mimetype.value(), res, mailhost.hostname, mailhost.port,
118
 
75
				mailhost.user, mailhost.password, charset, tls, ssl);
119
    public ReturnCode sleep(int minutes, int seconds) {
76
	}
120
        return sleep(0, minutes, seconds, 0);
77
 
121
    }
78
	public ReturnCode sleep(int minutes, int seconds) {
122
 
79
		return sleep(0, minutes, seconds, 0);
123
 
80
	}
Line 124... Line 81...
124
 
81
 
125
    private ReturnCode antGetHostinfo(String hostname, String prefix) {
-
 
126
        HostInfo info = new HostInfo();
-
 
127
        info.setTaskName("HostInfo");
-
 
128
        RunTask runner = new RunTask(info);
-
 
129
        info.setHost(hostname);
-
 
130
        //info.setPrefix(prefix);
82
	private ReturnCode antGetHostinfo(String hostname, String prefix) {
131
        return runner.postTask();
-
 
132
    }
83
		HostInfo info = new HostInfo();
133
 
-
 
134
    private ReturnCode sendMail(String from,
-
 
135
            String replyto,
-
 
136
            String tolist,
84
		info.setTaskName("HostInfo");
137
            String cclist,
-
 
138
            String bcclist,
-
 
139
            String subject,
85
		RunTask runner = new RunTask(info);
140
            String message,
86
		info.setHost(hostname);
141
            String messagemimetype,
87
		// info.setPrefix(prefix);
142
            FileSetResource attachments,
88
		return runner.postTask();
143
            String mailhost,
89
	}
144
            int mailport,
90
 
Line 169... Line 115...
169
        mail.setSSL(ssl);
115
		mail.setSSL(ssl);
170
        mail.setEnableStartTLS(tls);
116
		mail.setEnableStartTLS(tls);
171
        return runner.postTask();
117
		return runner.postTask();
172
    }
118
	}
Line 173... Line 119...
173
 
119
 
-
 
120
	private ReturnCode sleep(int hours, int minutes, int seconds,
174
    private ReturnCode sleep(int hours, int minutes, int seconds, int milliseconds) {
121
			int milliseconds) {
175
        Sleep sleep = new Sleep();
122
		Sleep sleep = new Sleep();
176
        sleep.setTaskName("Sleep");
123
		sleep.setTaskName("Sleep");
177
        RunTask runner = new RunTask(sleep);
124
		RunTask runner = new RunTask(sleep);
178
        sleep.setHours(hours);
125
		sleep.setHours(hours);