Skip to content

Commit

Permalink
update sdk with latest changes including all missing API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharon Shabtai committed Dec 20, 2016
1 parent 9fd3881 commit c5f7d88
Show file tree
Hide file tree
Showing 20 changed files with 322 additions and 188 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Documents/PFRRelease v3.1.0.370.zip
Binary file not shown.
12 changes: 4 additions & 8 deletions TpfrClient/Calls/ReWrapRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,17 @@ public class ReWrapRequest : RestRequest
/// <param name="firstFrame">Timecode of the first frame requested</param>
/// <param name="lastFrame">Timecode of the last frame requested</param>
/// <param name="frameRate">Frame rate, as returned in the file status report</param>
/// <param name="inByte">Byte offset of start of partial file relative to original file</param>
/// <param name="outByte">Byte offset of end of partial file relative to original file</param>
/// <param name="partialRestoreFilePath">Full UNC path to partial restored file fragment</param>
/// <param name="outputFileName">output file name for partial media file (care should be taken that this does not clash with other part restores, e.g. from other sections of the same source file)</param>
public ReWrapRequest(string filePath, TimeCode firstFrame, TimeCode lastFrame, string frameRate, string inByte,
string outByte, string partialRestoreFilePath, string outputFileName)
/// <param name="outputFileName">output file name for partial media file (care should be taken that this does not clash with other part restores, e.g. from other sections of the same source file). This should not have an extension, as this will added automatically.</param>
public ReWrapRequest(string filePath, TimeCode firstFrame, TimeCode lastFrame, string frameRate,
string partialRestoreFilePath, string outputFileName)
{
AddQueryParam("filepath", filePath);
AddQueryParam("tcin", firstFrame.Time);
AddQueryParam("tcout", lastFrame.Time);
AddQueryParam("fileframerate", frameRate);
AddQueryParam("in_byte", inByte);
AddQueryParam("out_byte", outByte);
AddQueryParam("part_file", partialRestoreFilePath);
AddQueryParam("out_fileName", outputFileName);
AddQueryParam("out_filename", outputFileName);
}

internal override HttpVerb Verb => HttpVerb.PUT;
Expand Down
2 changes: 1 addition & 1 deletion TpfrClient/Calls/ReWrapStatusRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ReWrapStatusRequest : RestRequest
/// <summary>
///
/// </summary>
/// <param name="outputFileName">The out_filename value passed in the Partial File Request</param>
/// <param name="outputFileName">The out_filename value passed in the Partial File Request. This is Case Sensitive</param>
public ReWrapStatusRequest(string outputFileName)
{
AddQueryParam("targetpartialname", outputFileName);
Expand Down
7 changes: 3 additions & 4 deletions TpfrClient/ITpfrClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ public interface ITpfrClient
/// <summary>
/// This method will use the parameters supplied to generate a Marquis XML file that will be used to create the partial output file.
/// </summary>
/// <param name="request">
/// <seealso cref="ReWrapRequest"/>
/// </param>
void ReWrap(ReWrapRequest request);
/// <param name="request"><seealso cref="ReWrapRequest" /></param>
/// <returns></returns>
ReWrapResponse ReWrap(ReWrapRequest request);

/// <summary>
/// This method will return status (% complete) for the creation of a partial media file initiated using the Partial File Request API call.
Expand Down
31 changes: 31 additions & 0 deletions TpfrClient/Model/ReWrapResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* ******************************************************************************
* Copyright 2014 - 2016 Spectra Logic Corporation. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file.
* This file 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.
* ****************************************************************************
*/

namespace TpfrClient.Model
{
public class ReWrapResponse
{
public ReWrapResult Result { get; set; }
}

public enum ReWrapResult
{
Succeeded,
ErrorDuplicateParameter,
ErrorMissingParameter,
ErrorBadFramerate,
Unknown
}
}
19 changes: 14 additions & 5 deletions TpfrClient/ResponseParsers/ReWrapResponseParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,28 @@
*/

using System.Net;
using TpfrClient.Model;
using TpfrClient.Runtime;

namespace TpfrClient.ResponseParsers
{
internal class ReWrapResponseParser : IResponseParser<object>
internal class ReWrapResponseParser : IResponseParser<ReWrapResponse>
{
public object Parse(IHttpWebResponse response)
public ReWrapResponse Parse(IHttpWebResponse response)
{
using (response)
{
ResponseParseUtils.HandleStatusCode(response, (HttpStatusCode)200);
return null;
ResponseParseUtils.HandleStatusCode(response, (HttpStatusCode) 200, (HttpStatusCode) 400);
using (var stream = response.GetResponseStream())
{
var element = XmlExtensions.ReadDocument(stream).ElementOrThrow("partialfile");

return new ReWrapResponse
{
Result = ResponseParseUtils.GetReWrapResult(element.AttributeTextOrNull("partialfileResult")),
};
}
}
}
}
}
}
19 changes: 18 additions & 1 deletion TpfrClient/ResponseParsers/ResponseParseUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,22 @@ public static OffsetsResult GetOffsetsResult(string result)
return Phase.Unknown;
}
}

public static ReWrapResult GetReWrapResult(string result)
{
switch (result)
{
case "Succeeded":
return ReWrapResult.Succeeded;
case "Error Duplicate parameter":
return ReWrapResult.ErrorDuplicateParameter;
case "Error Missing parameter":
return ReWrapResult.ErrorMissingParameter;
case "Error Bad framerate":
return ReWrapResult.ErrorBadFramerate;
default:
return ReWrapResult.Unknown;
}
}
}
}
}
16 changes: 14 additions & 2 deletions TpfrClient/Runtime/Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,19 @@ public INetwork WithProxy(Uri proxy)
public IHttpWebResponse Invoke(RestRequest request)
{
var httpWebRequest = CreateHttpWebRequest(request);
return httpWebRequest.GetResponse();

try
{
return httpWebRequest.GetResponse();
}
catch (WebException e)
{
if (e.Response == null)
{
throw;
}
return new TpfrHttpWebResponse((HttpWebResponse) e.Response);
}
}

private IHttpWebRequest CreateHttpWebRequest(RestRequest request)
Expand All @@ -57,7 +69,7 @@ private IHttpWebRequest CreateHttpWebRequest(RestRequest request)

var httpRequest = (HttpWebRequest) WebRequest.Create(uriBuilder.Uri);
httpRequest.Method = request.Verb.ToString();

if (Proxy != null)
{
var webProxy = new WebProxy
Expand Down
61 changes: 43 additions & 18 deletions TpfrClient/TpfrClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,45 +35,70 @@ public TpfrClient(INetwork network)
_network = network;
}

public TpfrClient WithProxy(string proxy)
{
return !string.IsNullOrEmpty(proxy) ? WithProxy(new Uri(proxy)) : this;
}
private TpfrClient WithProxy(Uri proxy)
{
_network.WithProxy(proxy);
return this;
}

/// <summary>
/// This method will block while the index is created and will only return when either the index file has been created or for some reason it has not been possible to create the index file.
/// On HFS systems that leave stub files on disk, such as StorNext, if a request is made to create an index for a media file which has been truncated by StorNext, this call will cause the entire media file to be restored by StorNext.
/// The Web Service will support multiple concurrent calls to this command.
/// </summary>
/// <param name="request"><seealso cref="IndexFileRequest" /></param>
/// <returns></returns>
public IndexStatus IndexFile(IndexFileRequest request)
{
return new IndexFileResponseParser().Parse(_network.Invoke(request));
}

/// <summary>
/// This method will block while retrieving the index status for a previously indexed file.
/// This method internally uses an XML file, generated by the indexer to retrieve the detailed status.This XML file is only generated by Quantum PFR version 1.1 and later.For files that were indexed in an earlier version of Quantum PFR, minimal information will be retrieved (just whether the file had been indexed or not).
/// The Web Service will support multiple concurrent calls to this API call.
/// </summary>
/// <param name="request"><seealso cref="FileStatusRequest" /></param>
/// <returns></returns>
public IndexStatus FileStatus(FileStatusRequest request)
{
return new FileStatusResponseParser().Parse(_network.Invoke(request));
}

[Obsolete("Not Implemented")]
/// <summary>
/// This method will block whilst retrieving the start and end byte offsets for the requested timecodes. The offsets are extended in order to handle GOP and interleave ordering.
/// Timecode format should be in form hh:mm:ss:ff for non-drop framerates and hh:mm:ss;ff for drop framerates
/// </summary>
/// <param name="request"><seealso cref="QuestionTimecodeRequest" /></param>
/// <returns></returns>
public OffsetsStatus QuestionTimecode(QuestionTimecodeRequest request)
{
throw new NotImplementedException();
return new QuestionTimecodeResponseParser().Parse(_network.Invoke(request));
}

[Obsolete("Not Implemented")]
public void ReWrap(ReWrapRequest request)
/// <summary>
/// This method will use the parameters supplied to generate a Marquis XML file that will be used to create the partial output file.
/// </summary>
/// <param name="request"><seealso cref="ReWrapRequest" /></param>
/// <returns></returns>
public ReWrapResponse ReWrap(ReWrapRequest request)
{
throw new NotImplementedException();
new ReWrapResponseParser().Parse(_network.Invoke(request));
return new ReWrapResponseParser().Parse(_network.Invoke(request));
}

[Obsolete("Not Implemented")]
/// <summary>
/// This method will return status (% complete) for the creation of a partial media file initiated using the Partial File Request API call.
/// </summary>
/// <param name="request"><seealso cref="ReWrapStatusRequest" /></param>
/// <returns></returns>
public ReWrapStatus ReWrapStatus(ReWrapStatusRequest request)
{
throw new NotImplementedException();
return new ReWrapStatusResponseParser().Parse(_network.Invoke(request));
}

public TpfrClient WithProxy(string proxy)
{
return !string.IsNullOrEmpty(proxy) ? WithProxy(new Uri(proxy)) : this;
}

private TpfrClient WithProxy(Uri proxy)
{
_network.WithProxy(proxy);
return this;
}
}
}
3 changes: 3 additions & 0 deletions TpfrClient/TpfrClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\TpfrClient.XML</DocumentationFile>
<RegisterForComInterop>false</RegisterForComInterop>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -31,6 +32,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\TpfrClient.XML</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand All @@ -49,6 +51,7 @@
<Compile Include="Calls\ReWrapRequest.cs" />
<Compile Include="Calls\ReWrapStatusRequest.cs" />
<Compile Include="Model\OffsetsStatus.cs" />
<Compile Include="Model\ReWrapResponse.cs" />
<Compile Include="Model\ReWrapStatus.cs" />
<Compile Include="Model\TimeCode.cs" />
<Compile Include="ResponseParsers\IndexFileResponseParser.cs" />
Expand Down
Loading

0 comments on commit c5f7d88

Please sign in to comment.