本文整理汇总了Java中com.sun.jersey.core.util.MultivaluedMapImpl.add方法的典型用法代码示例。如果您正苦于以下问题:Java MultivaluedMapImpl.add方法的具体用法?Java MultivaluedMapImpl.add怎么用?Java MultivaluedMapImpl.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jersey.core.util.MultivaluedMapImpl
的用法示例。
在下文中一共展示了MultivaluedMapImpl.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendSimpleEmail
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入方法依赖的package包/类
/**
* sendSimpleEmail
* @param mailGunEmail
* @return mail gun's client response
* @throws Exception
*/
public static ClientResponse sendSimpleEmail (
MailGunEmail mailGunEmail) throws Exception {
ArgumentsInl.checkNotEmpty(
"from-name",
mailGunEmail.getFromName(),
ExceptionType.CODE_EXCEPTION);
ArgumentsInl.checkNotEmpty(
"from-email",
mailGunEmail.getFromEmail(),
ExceptionType.CODE_EXCEPTION);
ArgumentsInl.checkNotEmpty(
"subject",
mailGunEmail.getSubject(),
ExceptionType.CODE_EXCEPTION);
ArgumentsInl.checkNotEmpty(
"body-text",
mailGunEmail.getBodyText(),
ExceptionType.CODE_EXCEPTION);
ArgumentsInl.checkNotEmpty(
"to-emails",
mailGunEmail.getToEmails(),
ExceptionType.CODE_EXCEPTION);
ArgumentsInl.checkNotEmpty(
"to-email",
mailGunEmail.getToEmails()[0],
ExceptionType.CODE_EXCEPTION);
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter(
"api",
MailGunEmailProperties.i().getStringPropterty(
MailGunEmailProperties.kMailGunApiKey) ) );
WebResource webResource =
client.resource(
"https://api.mailgun.net/v3/"
+ MailGunEmailProperties.i().getStringPropterty(
MailGunEmailProperties.kMailGunDomainName)
+ "/messages");
MultivaluedMapImpl formData = new MultivaluedMapImpl();
formData.add(
"from",
mailGunEmail.getFromName()
+ " <"
+ mailGunEmail.getFromEmail()
+ "@"
+ MailGunEmailProperties.i().getStringPropterty(
MailGunEmailProperties.kMailGunDomainName)
+ ">");
for (String toEmail : mailGunEmail.getToEmails() ) {
formData.add("to", toEmail);
}
formData.add("subject", mailGunEmail.getSubject() );
formData.add("text", mailGunEmail.getBodyText() );
return
webResource.type(
MediaType.APPLICATION_FORM_URLENCODED).post(
ClientResponse.class,
formData);
}