Update

Errors

This API updates a media file object either by updating the file content in all the existing servers or copying the file to additional servers.

  • This operation takes file content and an optional list of servers as parameters.

  • The update operation can be used to upload a file that is the same as the existing file to different set of servers. In this scenario, the uploaded file content must be same as the existing one (that is, the checksum of the uploaded content should match the checksum of the previous file).

  • The update operation is also used to modify the content of an existing file in all the relevant servers. In this scenario, no server list must be specified.

  • If the media file object does not exist, the operation fails with "404 Not Found" error.

  • If the operation fails on some servers but not on all servers, the file is treated as copied on the servers where the operation is successful. The user must perform a PUT operation on the failed servers again, to ensure that the file is deployed on all.

For this API, a 200 OK response is returned on the successful update of the media file object in the management database, but the media file is copied to the media servers. Use the READ (GET) API to poll for the copying status on the individual servers.

To obtain the summary details, the summary=true flag must be used in the GET API.

  • When the update operation is still in progress, the status of the object is shown as updating.

  • If the operation is completed on all servers, the status of the object changes to created and errorflag as false. Note that the creating or updating status changes to created as the final status.

  • If the requested operation cannot be completed due to an error, the status of the object is shown as created but the errorflag is displayed astrue. The details of the errors is obtained using the GET API without the summary parameter, to provide a server-wise status description.

Parameters of Media Files - Update

URL

https://<ipaddress>:8111/cvp-config /mediafile

HTTP Method

PUT

API Type

Synchronous

Input Format

multipart/form-data

Output Format

JSON/XML

Parameters

The parameters should be passed as multipart/form-data contents, with the text parameters in a JSON/XML part followed by the binary data as a separate part.

Name: path

Description:: Text parameter containing the relative path in the media location.

Required: Yes

Values: Relative path names e.g. en-us/app as used by the application.

Validations: Should not contain any (.) or should not be an absolute path.

Notes: Passed in XML/JSON body.

Name: filename

Description: Text parameter containing the media file name.

Required: Yes

Values: String values with less than 100 characters

Validations: Should not contain special characters like “~”, >, <.

Notes: Passed in XML/JSON body.

Name: Servers

Description: List of servers reference URLs.

Required: No.

Values: Contains multiple <server> elements.

Validations:

Notes: Optional parameter containing the server ref list, passed in XML/JSON body.

Name: server

Description: Reference of individual CVP Media Server.

Required: No.

Values : As depicted in Server section.

Validations:

Notes: Optional parameter containing the server ref, passed in XML/JSON body.

Name: mediafile

Description: This will be the attachment containing the media file data.

Required: Yes.

Values: Multipart/form-data as handled by the FORM POST method.

Validations: Size of a file should not exceed MAX_FILE_SIZE (3MB).

Notes: Need to be appended by either browser after FORM POST is run or by equivalent code, if done programmatically.

Name: mediaUploadConfig

Description: This will be the attachment name for the configuration file to be uploaded.

Required: Yes.

Values: Multipart/form-data as handled by the FORM POST method.

Example Request Payload

This server list body is passed as the first part of multipart/form-data. The WAV file that contains the media content is attached as the second part.

Key

Sample Value

mediaUploadConfig

XML
Code Snippet
Copy
<mediafile>
	<path>en-us</path>
	<filename>agentgreeting.wav</filename>
	<servers>
		<server>ref-url of server1</server>
		<server>ref-url of server2</server>
	</servers>
</mediafile>
JSON
Code Snippet
Copy
{
	"mediafile": {
		"path": "en-us",
			"filename": "agentgreeting.wav",
		"servers": {
			"server": [
				"ref-url of server1",
				"ref-url of server2"
			]
		}
	}
}

mediafile

The WAV file that contains the media content.

Code Snippets

Sample Java code

Code Snippet
Copy
/**
 * Updated the media file in the servers.
 * The request has two parts.
 * 1. mediaUploadConfig - The configuration file containing the filename, path and server details.
 * 2. mediafile - The octet stream of the file attached.
 */

private static void updateMediafileRequest() {
	Client client = getSSLClient();
	ClientFilter authFilter = new HTTPBasicAuthFilter("wsmadmin", "<password set 
during installation>");
	client.addFilter(authFilter);

	WebResource webResource = null;
	webResource = client.resource("https://<OAMP IP Address>:8111/cvp-config");

	// Populate config for Media File and convert it into JSON/XML
	MediaUploadConfig config = populateConfig();
	String requestString = convertToJson(config);

	// Construct a MultiPart with two body parts
	byte mediaContent[] = readFile();
	FormDataMultiPart formPart = new FormDataMultiPart();
        formPart.field("mediafile", mediaContent, 
MediaType.APPLICATION_OCTET_STREAM_TYPE);
        formPart.field("mediaUploadConfig", requestString, 
MediaType.APPLICATION_XML_TYPE);

 // PUT the request
	ClientResponse clientResponse = webResource.path("/mediafile").accept
(MediaType.APPLICATION_XML_TYPE).type(MediaType.MULTIPART_FORM_DATA).
put(ClientResponse.class, formPart);
}

Sample Response Header

Code Snippet
Copy
Response HTTP Status : 200
Response Headers : {Transfer-Encoding=[chunked], 
Date=[Mon, 01 Apr 2013 21:11:53 GMT], Expires=[Wed, 31 Dec 1969 16:00:00 PST], 
Content-Type=[application/xml], Server=[Apache-Coyote/1.1], Pragma=[No-cache], 
Cache-Control=[no-cache]
}
Response Content : MEDIA_UPDATE_1364825940354
List of Errors for Media File - Update

Category

HTTP Status

Error Code

Error Description

Authentication

401

authorization.unathorized

Unauthorized request.

authentication.notAuthorized

User is not authorized to access the requested resource.

authentication.noAccess

User is not allowed to access the resource. Access to a resource is based on the role of a user.

Input Output Formatting

401

processing.jsonSyntaxError

JSON syntax error occurs while processing the request attachment.

processing.xmlSyntaxError

XML Syntax error occurs while processing the request attachment.

UPDATE Media Validation

400

invalid.noOfAttachments

Incorrect number of attachments received.

UPDATE Media file Validation

400

invalid.format

URL cannot be decoded using UTF-8.

invalid.inputUploadConfig

Input xml/json is empty.

invalid.inputMediaFile

Input media file is missing.

invalid.requestAttachment

Malformed JSON in request attachment.

invalid.attachment

Request attachment in an IO error.

invalidInput.invalidCharacter

Invalid characters in the input field.

invalidInput.invalidFieldLength

Invalid length of the input field.

invalidInput.invalidMediaServerRef

Invalid Media Server Ref URL.

invalidInput.invalidMediaFileExtension

Invalid Media File Extension.

invalidInput.requiredInputfieldMissing

Required Input Field is missing.

invalidInput.incompatibleServerVersion

Listed Media Server version is incompatible.

invalidInput.serverInformationNotAvailable

Listed server information not available.

invalidInput.invalidDirDepth

The Directory dept in the path field is greater than the maximum allowed.

invalidInput.duplicateServerRef

A duplicate entry in the Server list sent in the request.

invalid.inputMediaFile

File Size out of valid range.

invalid.updateOpertionNotAllowed

Media file cannot be updated on the set of specified servers in the request.

invalid.operationInProgress

UPDATE request cannot be serviced due to an existing operation on the file being in progress. You should try this request after some time.

404

invalid.inputMediaFile

Media file is not found.

Generic

400

invalid.vxmlApplication

VXML Application archive is invalid.

404

invalid.url

Requested URL not found.

406

invalid.acceptHeader

Invalid accept header. The header should contain either XML or JSON.

500

processing.failed

Internal error.

processing.databaseProcessingFailed

Database processing failed.

processing.fileProcessingFailed

File processing failed.

processing.internal

Internal server error.

internal.serverError

An internal error has occurred.