CMIS: added code to check if the full document stream has been retrieved. It cannot catch all cases but a few.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31552 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Florian Mü
2011-10-29 16:07:28 +00:00
parent e6ade9b51a
commit 72b3be8ce0

View File

@@ -2952,6 +2952,7 @@ public class AlfrescoCmisService extends AbstractCmisService
}
int bufferSize = 40 * 1014;
long count = 0;
try
{
@@ -2966,6 +2967,7 @@ public class AlfrescoCmisService extends AbstractCmisService
while ((i = in.read(buffer)) > -1)
{
out.write(buffer, 0, i);
count += i;
}
in.close();
@@ -2973,9 +2975,17 @@ public class AlfrescoCmisService extends AbstractCmisService
}
} catch (Exception e)
{
removeTempFile(tempFile);
throw new CmisStorageException("Unable to store content: " + e.getMessage(), e);
}
if (contentStream.getLength() > -1 && contentStream.getLength() != count)
{
removeTempFile(tempFile);
throw new CmisStorageException("Expected " + contentStream.getLength() + " bytes but retrieved " + count
+ "bytes!");
}
return tempFile;
}