// Apply ACL if present
if (aclXmlString.length() > 0)
{
String encodedACL = new Base64().encodeByteArray(aclXmlString.getBytes("UTF-8"));
// Break into chunks - 4K each - 'cause otherwise we blow up the ingester.
int index = 0;
while (true)
{
if (index + HEADER_CHUNK >= encodedACL.length())
{
tmp = ("Document-ACL: " + encodedACL.substring(index) + "\r\n").getBytes("UTF-8");
out.write(tmp, 0, tmp.length);
break;
}
tmp = ("Document-ACL: " + encodedACL.substring(index,index + HEADER_CHUNK) + "\r\n").getBytes("UTF-8");
out.write(tmp, 0, tmp.length);
index += HEADER_CHUNK;
}
}
// Do the collections
if (collections != null)
{
int index = 0;
while (index < collections.length)
{
String collectionName = collections[index++];
String encodedValue = metadataEncode(collectionName);
//System.out.println("collection metadata: collection_name = '"+encodedValue+"'");
tmp = ("Document-Metadata: collection_name="+encodedValue+"\r\n").getBytes("UTF-8");
out.write(tmp, 0, tmp.length);
}
}
// Do the document template
if (documentTemplate != null && documentTemplate.length() > 0)
{
String encodedTemplate = new Base64().encodeByteArray(documentTemplate.getBytes("UTF-8"));
// Break into chunks - 4K each - 'cause otherwise we blow up the ingester.
int index = 0;
while (true)
{
if (index + HEADER_CHUNK >= encodedTemplate.length())