chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1513857 - in /chemistry/dotcmis/trunk/DotCMIS/binding: atompub/atompub.cs http.cs
Date Wed, 14 Aug 2013 12:56:20 GMT
Author: fmui
Date: Wed Aug 14 12:56:19 2013
New Revision: 1513857

URL: http://svn.apache.org/r1513857
Log:
CMIS-699: allow ranges >Int32

Modified:
    chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs
    chemistry/dotcmis/trunk/DotCMIS/binding/http.cs

Modified: chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs
URL: http://svn.apache.org/viewvc/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs?rev=1513857&r1=1513856&r2=1513857&view=diff
==============================================================================
--- chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs (original)
+++ chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs Wed Aug 14 12:56:19 2013
@@ -1787,15 +1787,15 @@ namespace DotCMIS.Binding.AtomPub
             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)

Modified: chemistry/dotcmis/trunk/DotCMIS/binding/http.cs
URL: http://svn.apache.org/viewvc/chemistry/dotcmis/trunk/DotCMIS/binding/http.cs?rev=1513857&r1=1513856&r2=1513857&view=diff
==============================================================================
--- chemistry/dotcmis/trunk/DotCMIS/binding/http.cs (original)
+++ chemistry/dotcmis/trunk/DotCMIS/binding/http.cs Wed Aug 14 12:56:19 2013
@@ -27,6 +27,7 @@ using System.Web;
 using DotCMIS.Enums;
 using DotCMIS.Exceptions;
 using DotCMIS.Util;
+using System.Reflection;
 
 namespace DotCMIS.Binding.Impl
 {
@@ -39,7 +40,7 @@ namespace DotCMIS.Binding.Impl
             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 @@ namespace DotCMIS.Binding.Impl
         }
 
         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 @@ namespace DotCMIS.Binding.Impl
                 // 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



Mime
View raw message