public String extractSubject(String htmlContent) { String html = StringUtils.getTagContents(htmlContent, "html", 0); String head = StringUtils.getTagContents(html, "head", 0); return StringUtils.getTagContents(head, "title", 0); } }
public String extractBody(String htmlContent) { String html = StringUtils.getTagContents(htmlContent, "html", 0); return StringUtils.getTagContents(html, "body", 0); }
public static LatLng getLatLng(String address, String city, String state, String zip) throws IOException { String url = "https://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address="; url += encodeUrl(String.format("%s, %s, %s %s", address, city, state, zip)); URLConnection connection = new URL(url).openConnection(); String data = IoUtils.toString(connection.getInputStream()); data = getTagContents(data, "location", 0); return new LatLng( getTagContents(data, "lat", 0), getTagContents(data, "lng", 0) ); } }
private SesEmailPush(@JsonProperty("toAddress") String toAddress, @JsonProperty("fromAddress") String fromAddress, @JsonProperty("emailSubject") String emailSubject, @JsonProperty("htmlContent") String htmlContent, @JsonProperty("callbackUrl") String callbackUrl, @JsonProperty("remoteHost") String remoteHost, @JsonProperty("remoteAddress") String remoteAddress, @JsonProperty("traits") Map<String, String> traits) { this.toAddress = toAddress; this.fromAddress = fromAddress; this.emailSubject = emailSubject; String content = StringUtils.getTagContents(htmlContent, "body", 0); this.htmlContent = StringUtils.isNotBlank(content) ? content : htmlContent; this.callbackUrl = callbackUrl; this.remoteHost = remoteHost; this.remoteAddress = remoteAddress; // Get a list of all the keys so that we can loop on the map // and remove anything without an actual value (purge nulls). if (traits != null) { this.traits.putAll(traits); } String[] keys = ReflectUtils.toArray(String.class, this.traits.keySet()); for (String key : keys) { if (StringUtils.isBlank(this.traits.get(key))) { this.traits.remove(key); } } }
private SesEmailPush(@JsonProperty("toAddress") String toAddress, @JsonProperty("fromAddress") String fromAddress, @JsonProperty("emailSubject") String emailSubject, @JsonProperty("htmlContent") String htmlContent, @JsonProperty("callbackUrl") String callbackUrl, @JsonProperty("remoteHost") String remoteHost, @JsonProperty("remoteAddress") String remoteAddress, @JsonProperty("traits") Map<String, String> traits) { this.toAddress = toAddress; this.fromAddress = fromAddress; this.emailSubject = emailSubject; String content = StringUtils.getTagContents(htmlContent, "body", 0); this.htmlContent = StringUtils.isNotBlank(content) ? content : htmlContent; this.callbackUrl = callbackUrl; this.remoteHost = remoteHost; this.remoteAddress = remoteAddress; // Get a list of all the keys so that we can loop on the map // and remove anything without an actual value (purge nulls). if (traits != null) { this.traits.putAll(traits); } String[] keys = ReflectUtils.toArray(String.class, this.traits.keySet()); for (String key : keys) { if (StringUtils.isBlank(this.traits.get(key))) { this.traits.remove(key); } } }
private SmtpEmailPush(@JsonProperty("toAddress") String toAddress, @JsonProperty("fromAddress") String fromAddress, @JsonProperty("emailSubject") String emailSubject, @JsonProperty("htmlContent") String htmlContent, @JsonProperty("callbackUrl") String callbackUrl, @JsonProperty("remoteHost") String remoteHost, @JsonProperty("remoteAddress") String remoteAddress, @JsonProperty("traits") Map<String, String> traits) { this.toAddress = toAddress; this.fromAddress = fromAddress; this.emailSubject = emailSubject; String content = StringUtils.getTagContents(htmlContent, "body", 0); this.htmlContent = StringUtils.isNotBlank(content) ? content : htmlContent; this.callbackUrl = callbackUrl; this.remoteHost = remoteHost; this.remoteAddress = remoteAddress; // Get a list of all the keys so that we can loop on the map // and remove anything without an actual value (purge nulls). if (traits != null) { this.traits.putAll(traits); } String[] keys = ReflectUtils.toArray(String.class, this.traits.keySet()); for (String key : keys) { if (StringUtils.isBlank(this.traits.get(key))) { this.traits.remove(key); } } }
private SmtpEmailPush(@JsonProperty("toAddress") String toAddress, @JsonProperty("fromAddress") String fromAddress, @JsonProperty("emailSubject") String emailSubject, @JsonProperty("htmlContent") String htmlContent, @JsonProperty("callbackUrl") String callbackUrl, @JsonProperty("remoteHost") String remoteHost, @JsonProperty("remoteAddress") String remoteAddress, @JsonProperty("traits") Map<String, String> traits) { this.toAddress = toAddress; this.fromAddress = fromAddress; this.emailSubject = emailSubject; String content = StringUtils.getTagContents(htmlContent, "body", 0); this.htmlContent = StringUtils.isNotBlank(content) ? content : htmlContent; this.callbackUrl = callbackUrl; this.remoteHost = remoteHost; this.remoteAddress = remoteAddress; // Get a list of all the keys so that we can loop on the map // and remove anything without an actual value (purge nulls). if (traits != null) { this.traits.putAll(traits); } String[] keys = ReflectUtils.toArray(String.class, this.traits.keySet()); for (String key : keys) { if (StringUtils.isBlank(this.traits.get(key))) { this.traits.remove(key); } } }