Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.

## NEXT

### Added

* Support for [notification headers](https://app.zencoder.com/docs/api/encoding/notifications/notification-headers)

## 0.0.1 - 2014-XX-XX
### Added
- Initial version
Expand Down
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@

import de.bitzeche.video.transcoding.zencoder.util.XmlUtility;

import java.util.Map;

public class ZencoderNotification {

private String notificationString;
private String format;
private Map<String, String> headers;

public ZencoderNotification(String notificationDestination) {
this.notificationString = notificationDestination;
Expand All @@ -45,6 +48,16 @@ public Element createXML(Document document) {
root.appendChild(nfNode);
}

if (this.headers != null) {
Node headersNode = document.createElement("headers");
root.appendChild(headersNode);
for (Map.Entry<String, String> headerEntry : headers.entrySet()) {
Node header = document.createElement(headerEntry.getKey());
header.setTextContent(headerEntry.getValue());
headersNode.appendChild(header);
}
}

Node urlNode = document.createElement("url");
urlNode.setTextContent(this.notificationString);
root.appendChild(urlNode);
Expand All @@ -60,6 +73,17 @@ public void setFormat(String format) {
this.format = format;
}

/**
* @param headers see https://app.zencoder.com/docs/api/encoding/notifications/notification-headers
*/
public void setHeaders(Map<String, String> headers) {
this.headers = headers;
}

public Map<String, String> getHeaders() {
return headers;
}

public String toString() {
Element elem;
Document document;
Expand All @@ -84,5 +108,4 @@ public String toString() {
}
return this.getClass().getSimpleName();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import de.bitzeche.video.transcoding.zencoder.job.ZencoderNotification;

import java.util.HashMap;

public class ZencoderNotificationTest {

@Test
Expand All @@ -42,4 +44,16 @@ public void testWithOptions() throws ParserConfigurationException {
// System.out.println(doc);
Assert.assertEquals(doc, expected);
}

@Test
public void testWithHeaders() throws ParserConfigurationException {
ZencoderNotification notif = new ZencoderNotification("[email protected]");
notif.setHeaders(new HashMap<String, String>(){{
put("cloudfront_url", "http://asdjaosidjas.cloudfront.net");
}});
String doc = StringUtil.stripSpacesAndLineBreaksFrom(notif.toString());
String expected = "<?xmlversion=\"1.0\"encoding=\"UTF-8\"?><notification><headers><cloudfront_url>http://asdjaosidjas.cloudfront.net</cloudfront_url></headers><url>[email protected]</url></notification>";
// System.out.println(doc);
Assert.assertEquals(doc, expected);
}
}