本文整理匯總了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);
}