mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Use gzipped compressed streams to recover content text from repository.
This modification will also require Tomcat / NGINX configuration in order to accept HTTP GZIP requests.
This commit is contained in:
+6
-1
@@ -81,6 +81,7 @@ import java.util.Map.Entry;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import com.carrotsearch.hppc.IntArrayList;
|
||||
|
||||
@@ -2498,8 +2499,12 @@ public class SolrInformationServer implements InformationServer
|
||||
response);
|
||||
addContentPropertyMetadata(doc, propertyQName, AlfrescoSolrDataModel.ContentFieldType.TRANSFORMATION_TIME,
|
||||
response);
|
||||
|
||||
|
||||
InputStream ris = response.getContent();
|
||||
if (null != response.getContentEncoding() && response.getContentEncoding().equals("gzip"))
|
||||
{
|
||||
ris = new GZIPInputStream(ris);
|
||||
}
|
||||
String textContent = "";
|
||||
try
|
||||
{
|
||||
|
||||
+17
-7
@@ -30,6 +30,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -73,6 +74,7 @@ import org.apache.commons.codec.EncoderException;
|
||||
import org.apache.commons.codec.net.URLCodec;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.util.DateUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@@ -1118,20 +1120,21 @@ public class SOLRAPIClient
|
||||
|
||||
GetRequest req = new GetRequest(url.toString());
|
||||
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
if(modifiedSince != null)
|
||||
{
|
||||
Map<String, String> headers = new HashMap<String, String>(1, 1.0f);
|
||||
headers.put("If-Modified-Since", String.valueOf(DateUtil.formatDate(new Date(modifiedSince))));
|
||||
req.setHeaders(headers);
|
||||
}
|
||||
|
||||
headers.put("Accept-Encoding", "gzip");
|
||||
req.setHeaders(headers);
|
||||
|
||||
Response response = repositoryHttpClient.sendRequest(req);
|
||||
|
||||
if(response.getStatus() != Status.STATUS_NOT_MODIFIED && response.getStatus() != Status.STATUS_NO_CONTENT && response.getStatus() != Status.STATUS_OK)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("GetTextContentResponse return status is " + response.getStatus());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new GetTextContentResponse(response);
|
||||
}
|
||||
|
||||
@@ -1481,7 +1484,8 @@ public class SOLRAPIClient
|
||||
private SolrApiContentStatus status;
|
||||
private String transformException;
|
||||
private String transformStatusStr;
|
||||
private Long transformDuration;
|
||||
private Long transformDuration;
|
||||
private String contentEncoding;
|
||||
|
||||
public GetTextContentResponse(Response response) throws IOException
|
||||
{
|
||||
@@ -1491,7 +1495,8 @@ public class SOLRAPIClient
|
||||
this.transformStatusStr = response.getHeader("X-Alfresco-transformStatus");
|
||||
this.transformException = response.getHeader("X-Alfresco-transformException");
|
||||
String tmp = response.getHeader("X-Alfresco-transformDuration");
|
||||
this.transformDuration = (tmp != null ? Long.valueOf(tmp) : null);
|
||||
this.transformDuration = (tmp != null ? Long.valueOf(tmp) : null);
|
||||
this.contentEncoding = response.getHeader("Content-Encoding");
|
||||
setStatus();
|
||||
}
|
||||
|
||||
@@ -1557,6 +1562,11 @@ public class SOLRAPIClient
|
||||
public Long getTransformDuration()
|
||||
{
|
||||
return transformDuration;
|
||||
}
|
||||
|
||||
public String getContentEncoding()
|
||||
{
|
||||
return contentEncoding;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user