CMIS-699: allow ranges >Int32
git-svn-id: https://svn.apache.org/repos/asf/chemistry/dotcmis/trunk@1513857 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/DotCMIS/binding/atompub/atompub.cs b/DotCMIS/binding/atompub/atompub.cs
index 286166f..f2de6bc 100644
--- a/DotCMIS/binding/atompub/atompub.cs
+++ b/DotCMIS/binding/atompub/atompub.cs
@@ -1787,15 +1787,15 @@
url.AddParameter(AtomPubConstants.ParamStreamId, streamId);
// get the content
- if (offset != null && offset > Int32.MaxValue)
+ if (offset != null && offset > Int64.MaxValue)
{
- throw new CmisInvalidArgumentException("Offset >" + Int32.MaxValue.ToString());
+ throw new CmisInvalidArgumentException("Offset >" + Int64.MaxValue.ToString());
}
- if (length != null && length > Int32.MaxValue)
+ if (length != null && length > Int64.MaxValue)
{
- throw new CmisInvalidArgumentException("Length >" + Int32.MaxValue.ToString());
+ throw new CmisInvalidArgumentException("Length >" + Int64.MaxValue.ToString());
}
- HttpUtils.Response resp = HttpUtils.InvokeGET(url, Session, (int?)offset, (int?)length);
+ HttpUtils.Response resp = HttpUtils.InvokeGET(url, Session, offset, length);
// check response code
if (resp.StatusCode != HttpStatusCode.OK && resp.StatusCode != HttpStatusCode.PartialContent)
diff --git a/DotCMIS/binding/http.cs b/DotCMIS/binding/http.cs
index 0e3fc2f..1dc63eb 100644
--- a/DotCMIS/binding/http.cs
+++ b/DotCMIS/binding/http.cs
@@ -27,6 +27,7 @@
using DotCMIS.Enums;
using DotCMIS.Exceptions;
using DotCMIS.Util;
+using System.Reflection;
namespace DotCMIS.Binding.Impl
{
@@ -39,7 +40,7 @@
return Invoke(url, "GET", null, null, session, null, null, null);
}
- public static Response InvokeGET(UrlBuilder url, BindingSession session, int? offset, int? length)
+ public static Response InvokeGET(UrlBuilder url, BindingSession session, long? offset, long? length)
{
return Invoke(url, "GET", null, null, session, offset, length, null);
}
@@ -60,7 +61,7 @@
}
private static Response Invoke(UrlBuilder url, String method, String contentType, Output writer, BindingSession session,
- int? offset, int? length, IDictionary<string, string> headers)
+ long? offset, long? length, IDictionary<string, string> headers)
{
try
{
@@ -114,11 +115,41 @@
// range
if (offset != null && length != null)
{
- conn.AddRange(offset ?? 0, offset + length - 1 ?? 0);
+ if (offset < Int32.MaxValue && offset + length - 1 < Int32.MaxValue)
+ {
+ conn.AddRange((int)offset, (int)offset + (int)length - 1);
+ }
+ else
+ {
+ try
+ {
+ MethodInfo mi = conn.GetType().GetMethod("AddRange", new Type[] { typeof(Int64), typeof(Int64) });
+ mi.Invoke(conn, new object[] { offset, offset + length - 1 });
+ }
+ catch (Exception e)
+ {
+ throw new CmisInvalidArgumentException("Offset or length too big!", e);
+ }
+ }
}
else if (offset != null)
{
- conn.AddRange(offset ?? 0);
+ if (offset < Int32.MaxValue)
+ {
+ conn.AddRange((int)offset);
+ }
+ else
+ {
+ try
+ {
+ MethodInfo mi = conn.GetType().GetMethod("AddRange", new Type[] { typeof(Int64) });
+ mi.Invoke(conn, new object[] { offset });
+ }
+ catch (Exception e)
+ {
+ throw new CmisInvalidArgumentException("Offset too big!", e);
+ }
+ }
}
// compression