Skip to content

Commit

Permalink
Merge pull request #9 from jcookems/int
Browse files Browse the repository at this point in the history
Merge changes from the private branch to release branch
  • Loading branch information
jcookems committed Mar 8, 2013
2 parents 6575ffa + 7f614ec commit 48ca51e
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 4 deletions.
@@ -0,0 +1,107 @@
/**
* Copyright Microsoft Corporation
*
* 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 com.microsoft.windowsazure.services.media.implementation.content;

import java.util.Date;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

/**
* This type maps the XML returned in the odata ATOM serialization
* for ErrorDetail entities.
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
public class TaskHistoricalEventType implements MediaServiceDTO {

/** The code. */
@XmlElement(name = "Code", namespace = Constants.ODATA_DATA_NS)
protected String code;

/** The message. */
@XmlElement(name = "Message", namespace = Constants.ODATA_DATA_NS)
protected String message;

/** The time stamp. */
@XmlElement(name = "TimeStamp", namespace = Constants.ODATA_DATA_NS)
protected Date timeStamp;

/**
* Gets the code.
*
* @return the code
*/
public String getCode() {
return code;
}

/**
* Sets the code.
*
* @param code
* the id to set
* @return the error detail type
*/
public TaskHistoricalEventType setCode(String code) {
this.code = code;
return this;
}

/**
* Gets the message.
*
* @return the message
*/
public String getMessage() {
return message;
}

/**
* Sets the message.
*
* @param message
* the message to set
* @return the error detail type
*/
public TaskHistoricalEventType setMessage(String message) {
this.message = message;
return this;
}

/**
* Gets the time stamp.
*
* @return the time stamp
*/
public Date getTimeStamp() {
return timeStamp;
}

/**
* Sets the time stamp.
*
* @param timeStamp
* the time stamp
* @return the task historical event type
*/
public TaskHistoricalEventType setTimeStamp(Date timeStamp) {
this.timeStamp = timeStamp;
return this;
}

}
Expand Up @@ -44,6 +44,10 @@ public class TaskType implements MediaServiceDTO {
@XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS)
protected List<ErrorDetailType> errorDetails;

@XmlElementWrapper(name = "HistoricalEvents", namespace = Constants.ODATA_DATA_NS)
@XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS)
protected List<TaskHistoricalEventType> historicalEventTypes;

@XmlElement(name = "MediaProcessorId", namespace = Constants.ODATA_DATA_NS)
protected String mediaProcessorId;

Expand Down Expand Up @@ -269,4 +273,13 @@ public TaskType setInputMediaAssets(List<String> inputMediaAssets) {
this.inputMediaAssets = inputMediaAssets;
return this;
}

public List<TaskHistoricalEventType> getHistoricalEventTypes() {
return historicalEventTypes;
}

public TaskType setHistoricalEventTypes(List<TaskHistoricalEventType> historicalEventTypes) {
this.historicalEventTypes = historicalEventTypes;
return this;
}
}
@@ -0,0 +1,76 @@
/*
* Copyright Microsoft Corporation
*
* 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 com.microsoft.windowsazure.services.media.models;

import java.util.Date;

/**
* The Class TaskHistoricalEvent.
*/
public class TaskHistoricalEvent {

/** The code. */
private final String code;

/** The message. */
private final String message;

/** The time stamp. */
private final Date timeStamp;

/**
* Instantiates a new error detail.
*
* @param code
* the code
* @param message
* the message
* @param timeStamp
* the time stamp
*/
public TaskHistoricalEvent(String code, String message, Date timeStamp) {
this.code = code;
this.message = message;
this.timeStamp = timeStamp;
}

/**
* Gets the code.
*
* @return the code
*/
public String getCode() {
return this.code;
}

/**
* Gets the message.
*
* @return the message
*/
public String getMessage() {
return this.message;
}

/**
* Gets the time stamp.
*
* @return the time stamp
*/
public Date getTimeStamp() {
return this.timeStamp;
}
}
Expand Up @@ -22,6 +22,7 @@
import com.microsoft.windowsazure.services.media.implementation.ODataEntity;
import com.microsoft.windowsazure.services.media.implementation.atom.EntryType;
import com.microsoft.windowsazure.services.media.implementation.content.ErrorDetailType;
import com.microsoft.windowsazure.services.media.implementation.content.TaskHistoricalEventType;
import com.microsoft.windowsazure.services.media.implementation.content.TaskType;

/**
Expand Down Expand Up @@ -86,6 +87,30 @@ public List<ErrorDetail> getErrorDetails() {
return null;
}

/**
* Gets the task historical events.
*
* @return the task historical events
*/
public List<TaskHistoricalEvent> getHistoricalEvents() {
List<TaskHistoricalEvent> result = new ArrayList<TaskHistoricalEvent>();
List<TaskHistoricalEventType> historicalEventTypes = getContent().getHistoricalEventTypes();

if (historicalEventTypes != null) {
for (TaskHistoricalEventType taskHistoricalEventType : historicalEventTypes) {
String message = taskHistoricalEventType.getMessage();
if ((message != null) && (message.isEmpty())) {
message = null;
}
TaskHistoricalEvent taskHistoricalEvent = new TaskHistoricalEvent(taskHistoricalEventType.getCode(),
message, taskHistoricalEventType.getTimeStamp());
result.add(taskHistoricalEvent);
}
}

return result;
}

/**
* Gets the media processor id.
*
Expand Down Expand Up @@ -213,7 +238,7 @@ public String getInitializationVector() {
}

/**
* Gets link to the task's input assets
* Gets link to the task's input assets.
*
* @return the link
*/
Expand All @@ -222,7 +247,7 @@ public LinkInfo<AssetInfo> getInputAssetsLink() {
}

/**
* Gets link to the task's output assets
* Gets link to the task's output assets.
*
* @return the link
*/
Expand Down
Expand Up @@ -98,7 +98,7 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception {
uploadEncryptedAssetFile(assetInfo, blobWriter, "MPEG4-H264.mp4", encryptedContent, contentKeyId, iv);

// submit and execute the decoding job.
JobInfo jobInfo = decodeAsset("uploadAesProtectedAssetSuccess", assetInfo.getId());
JobInfo jobInfo = decodeAsset(testJobPrefix + "uploadAesProtectedAssetSuccess", assetInfo.getId());

// assert
LinkInfo<TaskInfo> taskLinkInfo = jobInfo.getTasksLink();
Expand Down
Expand Up @@ -101,8 +101,8 @@ protected static void cleanupEnvironment() {
removeAllTestLocators();
removeAllTestAssets();
removeAllTestAccessPolicies();
removeAllTestContentKeys();
removeAllTestJobs();
removeAllTestContentKeys();
}

private static void removeAllTestContentKeys() {
Expand Down
Expand Up @@ -35,6 +35,7 @@
import com.microsoft.windowsazure.services.media.models.ListResult;
import com.microsoft.windowsazure.services.media.models.Task;
import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation;
import com.microsoft.windowsazure.services.media.models.TaskHistoricalEvent;
import com.microsoft.windowsazure.services.media.models.TaskInfo;

public class JobIntegrationTest extends IntegrationTestBase {
Expand Down Expand Up @@ -343,4 +344,32 @@ public void canGetInputOutputAssetsFromTask() throws Exception {
assertTrue(outputs.get(0).getName().contains(name));
}

@Test
public void canGetTaskHistoricalEventsFromTask() throws Exception {
// Arrange
String jobName = testJobPrefix + "canGetTaskHistoricalEventsFromTask";
int priority = 3;
int retryCounter = 0;

// Act
JobInfo actualJobInfo = service.create(Job.create().setName(jobName).setPriority(priority)
.addInputMediaAsset(assetInfo.getId()).addTaskCreator(getTaskCreator(0)));

while (actualJobInfo.getState().getCode() < 3 && retryCounter < 30) {
Thread.sleep(10000);
actualJobInfo = service.get(Job.get(actualJobInfo.getId()));
retryCounter++;
}
ListResult<TaskInfo> tasks = service.list(Task.list(actualJobInfo.getTasksLink()));
TaskInfo taskInfo = tasks.get(0);
List<TaskHistoricalEvent> historicalEvents = taskInfo.getHistoricalEvents();
TaskHistoricalEvent historicalEvent = historicalEvents.get(0);

// Assert
assertTrue(historicalEvents.size() >= 5);
assertNotNull(historicalEvent.getCode());
assertNotNull(historicalEvent.getTimeStamp());
assertNull(historicalEvent.getMessage());
}

}

0 comments on commit 48ca51e

Please sign in to comment.