Subversion Repositories XServices

Compare Revisions

No changes between revisions

Ignore whitespace Rev 83 → Rev 85

/xservices/trunk/src/java/net/brutex/xservices/ws/impl/MailServiceImpl.java
0,0 → 1,94
/*
* Copyright 2012 Brian Rosenberger (Brutex Network)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
 
package net.brutex.xservices.ws.impl;
 
import javax.jws.WebService;
 
import net.brutex.xservices.types.HostConnection;
import net.brutex.xservices.types.MailMimeType;
import net.brutex.xservices.types.ReturnCode;
import net.brutex.xservices.types.ant.FileSetResource;
import net.brutex.xservices.util.BrutexNamespaces;
import net.brutex.xservices.util.RunTask;
import net.brutex.xservices.ws.MailService;
 
import org.apache.tools.ant.taskdefs.email.EmailTask;
 
/**
* Implements MailService
*
* @author Brian Rosenberger, bru@brutex.de
*/
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES,
endpointInterface = "net.brutex.xservices.ws.MailService",
serviceName = "MailService")
public class MailServiceImpl implements MailService {
 
 
public ReturnCode sendMailSimple(HostConnection mailhost, String from,
String tolist, String subject, String message) {
return sendMail(from, from, tolist, "", "", subject, message,
"text/plain", null, mailhost.hostname, mailhost.port,
mailhost.user, mailhost.password, "utf-8", false, false);
}
 
public ReturnCode sendMailSimpleWithAttachment(HostConnection mailhost,
String from, String tolist, String subject, String message,
FileSetResource res) {
return sendMail(from, from, tolist, "", "", subject, message,
"text/plain", res, mailhost.hostname, mailhost.port,
mailhost.user, mailhost.password, "utf-8", false, false);
}
 
public ReturnCode sendMail(HostConnection mailhost, String from,
String tolist, String cclist, String bcclist, String subject,
MailMimeType mimetype, String charset, String message,
FileSetResource res, boolean ssl, boolean tls) {
return sendMail(from, from, tolist, cclist, bcclist, subject, message,
mimetype.value(), res, mailhost.hostname, mailhost.port,
mailhost.user, mailhost.password, charset, tls, ssl);
}
 
private ReturnCode sendMail(String from, String replyto, String tolist,
String cclist, String bcclist, String subject, String message,
String messagemimetype, FileSetResource attachments,
String mailhost, int mailport, String user, String password,
String charset, boolean tls, boolean ssl) {
EmailTask mail = new EmailTask();
mail.setTaskName("Mail");
RunTask runner = new RunTask(mail);
mail.setFrom(from);
mail.setReplyTo(replyto);
mail.setToList(tolist);
mail.setCcList(cclist);
mail.setBccList(bcclist);
mail.setSubject(subject);
mail.setMessage(message);
mail.setMessageMimeType(messagemimetype);
if (attachments != null) {
mail.addFileset(attachments.getAntResource(mail.getProject()));
}
mail.setMailhost(mailhost);
mail.setMailport(mailport);
mail.setUser(user);
mail.setPassword(password);
mail.setCharset(charset);
mail.setSSL(ssl);
mail.setEnableStartTLS(tls);
return runner.postTask();
}
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/xservices/trunk/src/java/net/brutex/xservices/ws/impl/MiscServiceImpl.java
37,10 → 37,13
import org.apache.tools.ant.taskdefs.email.EmailTask;
 
/**
* Implements the web service
*
* @author Brian Rosenberger, bru@brutex.de
*/
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES, endpointInterface = "net.brutex.xservices.ws.MiscService", serviceName = "MiscService")
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES,
endpointInterface = "net.brutex.xservices.ws.MiscService",
serviceName = "MiscService")
public class MiscServiceImpl implements MiscService {
 
public HostinfoType getHostinfo(String hostname) {
49,6 → 52,7
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"),
/xservices/trunk/src/java/net/brutex/xservices/ws/MailService.java
0,0 → 1,123
/*
* Copyright 2012 Brian Rosenberger (Brutex Network)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.brutex.xservices.ws;
 
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlElement;
 
import net.brutex.xservices.types.HostConnection;
import net.brutex.xservices.types.MailMimeType;
import net.brutex.xservices.types.ReturnCode;
import net.brutex.xservices.types.ant.FileSetResource;
import net.brutex.xservices.util.BrutexNamespaces;
 
import org.apache.cxf.annotations.WSDLDocumentation;
 
/**
* Bundles various method for sending and receiving mails
*
* @author Brian Rosenberger, bru@brutex.de
* @since 2.0.0
*/
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES)
@WSDLDocumentation("Various mail service operations.")
public interface MailService {
 
final String PARAM_SMTPHOST = "mailhost";
final String PARAM_SENDER = "from";
final String PARAM_RECEIVER = "to";
final String PARAM_SUBJECT = "subject";
final String PARAM_MESSAGE = "message";
final String PARAM_ATTACHMENTS = "attachments";
/**
* Simple mail send operation with sender, single receiver, subject and message.
*
* @param mailhost connection details for the SMTP server to use
* @param from mail address to be used as sender
* @param tolist mail address of the receiver
* @param subject subject of the mail
* @param message mail body
* @return ReturnCode
*/
@WebMethod(operationName = "sendMailSimple")
@WSDLDocumentation(value = "Send an email (simple).")
public ReturnCode sendMailSimple(
@WebParam(name = PARAM_SMTPHOST) @XmlElement(required=true, nillable=false) HostConnection mailhost,
@WebParam(name = PARAM_SENDER) @XmlElement(required=true) String from,
@WebParam(name = PARAM_RECEIVER) @XmlElement(required=true, nillable=false) String tolist,
@WebParam(name = PARAM_SUBJECT) String subject,
@WebParam(name = PARAM_MESSAGE) String message);
 
/**
* Simple mail send operation with sender, single receiver, subject and message
* including support for file attachments.
*
* @param mailhost connection details for the SMTP server to use
* @param from mail address to be used as sender
* @param tolist mail address of the receiver
* @param subject subject of the mail
* @param message mail body
* @param res attachments
* @return ReturnCode
*/
@WebMethod(operationName = "sendMailSimpleWithAttachment")
@WSDLDocumentation(value = "Send an email with attachment (simple).")
public ReturnCode sendMailSimpleWithAttachment(
@WebParam(name = PARAM_SMTPHOST) @XmlElement(required=true, nillable=false) HostConnection mailhost,
@WebParam(name = PARAM_SENDER) @XmlElement(required=true, nillable=false) String from,
@WebParam(name = PARAM_RECEIVER) @XmlElement(required=true, nillable=false) String tolist,
@WebParam(name = PARAM_SUBJECT) String subject,
@WebParam(name = PARAM_MESSAGE) String message,
@WebParam(name = PARAM_ATTACHMENTS) FileSetResource res);
 
/**
* Send email with a lot of options
*
* @param mailhost connection details for the SMTP server to use
* @param from mail address to be used as sender
* @param tolist mail address of the receiver
* @param cclist mail carbon copy receiver
* @param bcclist mail blind carbon copy receiver
* @param subject subject of the mail
* @param mimetype message MIME type (i.e. text/plain)
* @param charset character set to use (i.e. utf-8, iso-8859-15)
* @param message mail body
* @param res attachments
* @param ssl use SSL
* @param tls use TLS
* @return ReturnCode
*/
@WebMethod(operationName = "sendMail")
@WSDLDocumentation(value = "Send an email (advanced).")
public ReturnCode sendMail(
@WebParam(name = PARAM_SMTPHOST) @XmlElement(required=true, nillable=false) HostConnection mailhost,
@WebParam(name = PARAM_SENDER) @XmlElement(required=true, nillable=false) String from,
@WebParam(name = PARAM_RECEIVER) @XmlElement(required=true, nillable=false) String tolist,
@WebParam(name = "cc") String cclist,
@WebParam(name = "bcc") String bcclist,
@WebParam(name = PARAM_SUBJECT) String subject,
@WebParam(name = "mimetype") MailMimeType mimetype,
@WebParam(name = "charset") String charset,
@WebParam(name = PARAM_MESSAGE) String message,
@WebParam(name = PARAM_ATTACHMENTS) FileSetResource res,
@WebParam(name = "useSSL") boolean ssl,
@WebParam(name = "useStartTLS") boolean tls);
 
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/xservices/trunk/src/java/net/brutex/xservices/ws/XServicesFault.java
28,8 → 28,10
import net.brutex.xservices.util.BrutexNamespaces;
 
/**
* Generic web service fault.
*
* @author Brian Rosenberger, bru@brutex.de
* since 0.4.0
*/
@WebFault(targetNamespace=BrutexNamespaces.WS_XSERVICES)
public class XServicesFault extends Exception {
/xservices/trunk/src/java/net/brutex/xservices/ws/MiscService.java
30,6 → 30,7
import org.apache.cxf.annotations.WSDLDocumentation;
 
/**
* Bundles various methods
*
* @author Brian Rosenberger, bru@brutex.de
* @since 0.4.0
38,9 → 39,9
@WSDLDocumentation("Various service operations.")
public interface MiscService {
 
/**
/**
* Get IP address from host name.
*
* @param hostname
* @return ReturnCode
*/
49,78 → 50,10
public HostinfoType getHostinfo(
@WebParam(name = "hostname") @XmlElement(minOccurs="1", nillable=false ) String hostname);
 
/**
*
* @param mailhost
* @param from
* @param tolist
* @param subject
* @param message
* @return ReturnCode
*/
@WebMethod(operationName = "sendMailSimple")
@WSDLDocumentation(value = "Send an email (simple).")
public ReturnCode sendMailSimple(
@WebParam(name = "mailhost") @XmlElement(minOccurs="1", nillable=false) HostConnection mailhost,
@WebParam(name = "from") @XmlElement(minOccurs="1", nillable=false) String from,
@WebParam(name = "to") @XmlElement(minOccurs="1", nillable=false) String tolist,
@WebParam(name = "subject") String subject,
@WebParam(name = "message") String message);
 
/**
*
* @param mailhost
* @param from
* @param tolist
* @param subject
* @param message
* @param res
* @return ReturnCode
*/
@WebMethod(operationName = "sendMailSimpleWithAttachment")
@WSDLDocumentation(value = "Send an email with attachment (simple).")
public ReturnCode sendMailSimpleWithAttachment(
@WebParam(name = "mailhost") @XmlElement(minOccurs="1", nillable=false) HostConnection mailhost,
@WebParam(name = "from") @XmlElement(minOccurs="1", nillable=false) String from,
@WebParam(name = "to") @XmlElement(minOccurs="1", nillable=false) String tolist,
@WebParam(name = "subject") String subject,
@WebParam(name = "message") String message,
@WebParam(name = "attachments") FileSetResource res);
 
/**
*
* @param mailhost
* @param from
* @param tolist
* @param cclist
* @param bcclist
* @param subject
* @param mimetype
* @param charset
* @param message
* @param res
* @param ssl
* @param tls
* @return ReturnCode
*/
@WebMethod(operationName = "sendMail")
@WSDLDocumentation(value = "Send an email (advanced).")
public ReturnCode sendMail(
@WebParam(name = "mailhost") @XmlElement(minOccurs="1", nillable=false) HostConnection mailhost,
@WebParam(name = "from") @XmlElement(minOccurs="1", nillable=false) String from,
@WebParam(name = "to") @XmlElement(minOccurs="1", nillable=false) String tolist,
@WebParam(name = "cc") String cclist,
@WebParam(name = "bcc") String bcclist,
@WebParam(name = "subject") String subject,
@WebParam(name = "mimetype") MailMimeType mimetype,
@WebParam(name = "charset") String charset,
@WebParam(name = "message") String message,
@WebParam(name = "attachments") FileSetResource res,
@WebParam(name = "useSSL") boolean ssl,
@WebParam(name = "useStartTLS") boolean tls);
 
/**
*
* Delay execution for a given time.
*
* @param minutes
* @param seconds
* @return ReturnCode