You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by io...@apache.org on 2014/04/18 00:56:33 UTC
svn commit: r1588386 [1/2] - in /manifoldcf/trunk:
connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/
connectors/filesystem/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/filesystem/tes...
Author: iorixxx
Date: Thu Apr 17 22:56:31 2014
New Revision: 1588386
URL: http://svn.apache.org/r1588386
Log:
CONNECTORS-931: Cleanup charset handling for Java 7
Modified:
manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java
manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java
manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java
manifoldcf/trunk/connectors/filesystem/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/filesystem/tests/FileHelper.java
manifoldcf/trunk/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java
manifoldcf/trunk/connectors/gts/connector/src/main/java/org/apache/manifoldcf/agents/output/gts/HttpPoster.java
manifoldcf/trunk/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java
manifoldcf/trunk/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java
manifoldcf/trunk/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/jdbc/JDBCConnection.java
manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java
manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java
manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java
manifoldcf/trunk/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LLSERVER.java
manifoldcf/trunk/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/CommonsHTTPSender.java
manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java
manifoldcf/trunk/connectors/rss/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/rss/Robots.java
manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrServer.java
manifoldcf/trunk/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/RobotsManager.java
manifoldcf/trunk/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/ThrottledFetcher.java
manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLOutputStreamContext.java
manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLStream.java
manifoldcf/trunk/framework/api-servlet/src/main/java/org/apache/manifoldcf/apiservlet/APIServlet.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/CacheManager.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/common/CommonsHTTPSender.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/common/XMLDoc.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/fuzzyml/XMLOutputStreamParsingContext.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDFactory.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/TempFileCharacterInput.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/UTF8Stderr.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/UTF8Stdout.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/fuzzyml/TestFuzzyML.java
manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/Base.java
manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/HTMLTester.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/reprioritizationtracker/ReprioritizationTracker.java
manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/TestingRepositoryConnector.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
manifoldcf/trunk/framework/ui-core/src/main/java/org/apache/manifoldcf/ui/i18n/Messages.java
Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java (original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java Thu Apr 17 22:56:31 2014
@@ -29,6 +29,7 @@ import java.io.InputStream;
import java.io.InterruptedIOException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultRedirectStrategy;
@@ -80,8 +81,6 @@ public class ElasticSearchConnection
}
private Result result;
-
- private final static Charset UTF_8 = Charset.forName("UTF-8");
protected ElasticSearchConnection(ElasticSearchConfig config, HttpClient client)
{
@@ -291,13 +290,13 @@ public class ElasticSearchConnection
{
ContentType ct = ContentType.get(entity);
if (ct == null)
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
else
charSet = ct.getCharset();
}
catch (ParseException e)
{
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
}
char[] buffer = new char[65536];
Reader r = new InputStreamReader(is,charSet);
Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java (original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java Thu Apr 17 22:56:31 2014
@@ -38,9 +38,7 @@ public class ElasticSearchDelete extends
public void execute(String documentURI)
throws ManifoldCFException, ServiceInterruption
{
- try
- {
- String idField = java.net.URLEncoder.encode(documentURI,"utf-8");
+ String idField = urlEncode(documentURI);
HttpDelete method = new HttpDelete(config.getServerLocation() +
"/" + config.getIndexName() + "/" + config.getIndexType()
+ "/" + idField);
@@ -52,10 +50,5 @@ public class ElasticSearchDelete extends
// Log the result as an error, but proceed anyway.
setResult(Result.ERROR, error);
Logging.connectors.warn("ES: Delete failed: "+getResponse());
- }
- catch (java.io.UnsupportedEncodingException e)
- {
- throw new ManifoldCFException(e.getMessage(),e);
- }
}
}
Modified: manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java (original)
+++ manifoldcf/trunk/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java Thu Apr 17 22:56:31 2014
@@ -24,6 +24,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import org.apache.http.client.HttpClient;
@@ -112,7 +113,7 @@ public class ElasticSearchIndex extends
@Override
public void writeTo(OutputStream out)
throws IOException {
- PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, "utf-8"));
+ PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8));
try
{
pw.print("{");
@@ -267,14 +268,8 @@ public class ElasticSearchIndex extends
throws ManifoldCFException, ServiceInterruption
{
String idField;
- try
- {
- idField = java.net.URLEncoder.encode(documentURI,"utf-8");
- }
- catch (java.io.UnsupportedEncodingException e)
- {
- throw new ManifoldCFException(e.getMessage(),e);
- }
+
+ idField = urlEncode(documentURI);
StringBuffer url = getApiUrl(config.getIndexType() + "/" + idField, false);
HttpPut put = new HttpPut(url.toString());
Modified: manifoldcf/trunk/connectors/filesystem/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/filesystem/tests/FileHelper.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/filesystem/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/filesystem/tests/FileHelper.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/filesystem/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/filesystem/tests/FileHelper.java (original)
+++ manifoldcf/trunk/connectors/filesystem/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/filesystem/tests/FileHelper.java Thu Apr 17 22:56:31 2014
@@ -19,6 +19,7 @@
package org.apache.manifoldcf.crawler.connectors.filesystem.tests;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
/** Helper class for local file manipulation */
@@ -57,7 +58,7 @@ public class FileHelper
OutputStream os = new FileOutputStream(f);
try
{
- Writer w = new OutputStreamWriter(os,"utf-8");
+ Writer w = new OutputStreamWriter(os, StandardCharsets.UTF_8);
try
{
w.write(contents);
Modified: manifoldcf/trunk/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java (original)
+++ manifoldcf/trunk/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java Thu Apr 17 22:56:31 2014
@@ -21,6 +21,7 @@ import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@@ -401,7 +402,7 @@ public class GenericConnector extends Ba
}
if (item.content != null) {
try {
- byte[] content = item.content.getBytes("UTF-8");
+ byte[] content = item.content.getBytes(StandardCharsets.UTF_8);
ByteArrayInputStream is = new ByteArrayInputStream(content);
try {
doc.setBinary(is, content.length);
Modified: manifoldcf/trunk/connectors/gts/connector/src/main/java/org/apache/manifoldcf/agents/output/gts/HttpPoster.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/gts/connector/src/main/java/org/apache/manifoldcf/agents/output/gts/HttpPoster.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/gts/connector/src/main/java/org/apache/manifoldcf/agents/output/gts/HttpPoster.java (original)
+++ manifoldcf/trunk/connectors/gts/connector/src/main/java/org/apache/manifoldcf/agents/output/gts/HttpPoster.java Thu Apr 17 22:56:31 2014
@@ -25,6 +25,7 @@ import org.apache.manifoldcf.agents.syst
import java.io.*;
import java.net.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import javax.net.*;
import javax.net.ssl.*;
@@ -102,14 +103,7 @@ public class HttpPoster
{
if (userID != null && userID.length() > 0 && password != null)
{
- try
- {
- this.encodedCredentials = new org.apache.manifoldcf.core.common.Base64().encodeByteArray((userID+":"+password).getBytes("UTF-8"));
- }
- catch (java.io.UnsupportedEncodingException e)
- {
- throw new ManifoldCFException("Couldn't convert to utf-8 bytes",e);
- }
+ this.encodedCredentials = new org.apache.manifoldcf.core.common.Base64().encodeByteArray((userID+":"+password).getBytes(StandardCharsets.UTF_8));
this.realm = realm;
}
this.postURI = postURI;
@@ -553,10 +547,10 @@ public class HttpPoster
if (encodedCredentials != null)
{
Logging.ingest.debug("Applying credentials");
- byte[] tmp = ("Authorization: Basic " + encodedCredentials + "\r\n").getBytes("UTF-8");
+ byte[] tmp = ("Authorization: Basic " + encodedCredentials + "\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
- tmp = ("WWW-Authenticate: Basic realm=\"" + ((realm != null) ? realm : "") + "\"\r\n").getBytes("UTF-8");
+ tmp = ("WWW-Authenticate: Basic realm=\"" + ((realm != null) ? realm : "") + "\"\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
}
}
@@ -733,11 +727,11 @@ public class HttpPoster
String uri = url.getFile();
if (uri.length() == 0)
uri = "/";
- byte[] tmp = ("POST " + uri + " HTTP/1.0\r\n").getBytes("UTF-8");
+ byte[] tmp = ("POST " + uri + " HTTP/1.0\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
// Set all the headers
- tmp = ("Document-URI: " + documentURI + "\r\n").getBytes("UTF-8");
+ tmp = ("Document-URI: " + documentURI + "\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
writeCredentials(out);
@@ -746,7 +740,7 @@ public class HttpPoster
if (aclXmlString.length() > 0)
{
- String encodedACL = new Base64().encodeByteArray(aclXmlString.getBytes("UTF-8"));
+ String encodedACL = new Base64().encodeByteArray(aclXmlString.getBytes(StandardCharsets.UTF_8));
// Break into chunks - 4K each - 'cause otherwise we blow up the ingester.
int index = 0;
@@ -754,11 +748,11 @@ public class HttpPoster
{
if (index + HEADER_CHUNK >= encodedACL.length())
{
- tmp = ("Document-ACL: " + encodedACL.substring(index) + "\r\n").getBytes("UTF-8");
+ tmp = ("Document-ACL: " + encodedACL.substring(index) + "\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
break;
}
- tmp = ("Document-ACL: " + encodedACL.substring(index,index + HEADER_CHUNK) + "\r\n").getBytes("UTF-8");
+ tmp = ("Document-ACL: " + encodedACL.substring(index,index + HEADER_CHUNK) + "\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
index += HEADER_CHUNK;
}
@@ -773,7 +767,7 @@ public class HttpPoster
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");
+ tmp = ("Document-Metadata: collection_name="+encodedValue+"\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
}
}
@@ -781,18 +775,18 @@ public class HttpPoster
// Do the document template
if (documentTemplate != null && documentTemplate.length() > 0)
{
- String encodedTemplate = new Base64().encodeByteArray(documentTemplate.getBytes("UTF-8"));
+ String encodedTemplate = new Base64().encodeByteArray(documentTemplate.getBytes(StandardCharsets.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())
{
- tmp = ("Document-Template: " + encodedTemplate.substring(index) + "\r\n").getBytes("UTF-8");
+ tmp = ("Document-Template: " + encodedTemplate.substring(index) + "\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
break;
}
- tmp = ("Document-Template: " + encodedTemplate.substring(index,index + HEADER_CHUNK) + "\r\n").getBytes("UTF-8");
+ tmp = ("Document-Template: " + encodedTemplate.substring(index,index + HEADER_CHUNK) + "\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
index += HEADER_CHUNK;
}
@@ -812,12 +806,12 @@ public class HttpPoster
String encodedValue = metadataEncode(value);
//System.out.println("Metadata: Name = '"+fieldName+"', value = '"+encodedValue+"'");
- tmp = ("Document-Metadata: "+ fieldName+"="+encodedValue+"\r\n").getBytes("UTF-8");
+ tmp = ("Document-Metadata: "+ fieldName+"="+encodedValue+"\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
}
}
- tmp = ("Content-length: " + new Long(length).toString() + "\r\n\n").getBytes("UTF-8");
+ tmp = ("Content-length: " + new Long(length).toString() + "\r\n\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
long total = 0;
@@ -1156,16 +1150,16 @@ public class HttpPoster
{
long startTime = System.currentTimeMillis();
// Create the output stream to GTS
- byte[] tmp = ("POST " + deleteURL.getFile() + " HTTP/1.0\r\n").getBytes("UTF-8");
+ byte[] tmp = ("POST " + deleteURL.getFile() + " HTTP/1.0\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
// Set all the headers
- tmp = ("Document-URI: " + documentURI + "\r\n").getBytes("UTF-8");
+ tmp = ("Document-URI: " + documentURI + "\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
writeCredentials(out);
- tmp = ("Content-length: 0\r\n\n").getBytes("UTF-8");
+ tmp = ("Content-length: 0\r\n\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
if (Logging.ingest.isDebugEnabled())
@@ -1331,12 +1325,12 @@ public class HttpPoster
try
{
// Create the output stream to GTS
- byte[] tmp = ("GET " + infoURL.getFile() + " HTTP/1.0\r\n").getBytes("UTF-8");
+ byte[] tmp = ("GET " + infoURL.getFile() + " HTTP/1.0\r\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
writeCredentials(out);
- tmp = ("Content-length: 0\r\n\n").getBytes("UTF-8");
+ tmp = ("Content-length: 0\r\n\n").getBytes(StandardCharsets.UTF_8);
out.write(tmp, 0, tmp.length);
if (Logging.ingest.isDebugEnabled())
Modified: manifoldcf/trunk/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java (original)
+++ manifoldcf/trunk/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java Thu Apr 17 22:56:31 2014
@@ -28,6 +28,7 @@ import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -301,9 +302,8 @@ public class SharedDriveConnector extend
{
// URI translation.
// First step is to perform utf-8 translation and %-encoding.
- try
- {
- byte[] byteArray = serverPath.getBytes("utf-8");
+
+ byte[] byteArray = serverPath.getBytes(StandardCharsets.UTF_8);
StringBuilder output = new StringBuilder();
int i = 0;
while (i < byteArray.length)
@@ -325,12 +325,6 @@ public class SharedDriveConnector extend
// Second step is to perform the mapping. This strips off the server name and glues on the protocol and web server name, most likely.
return uriMap.translate(output.toString());
- }
- catch (java.io.UnsupportedEncodingException e)
- {
- // Should not happen...
- throw new ManifoldCFException(e.getMessage(),e);
- }
}
else
{
Modified: manifoldcf/trunk/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java (original)
+++ manifoldcf/trunk/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java Thu Apr 17 22:56:31 2014
@@ -28,6 +28,7 @@ import org.apache.manifoldcf.jdbc.JDBCCo
import org.apache.manifoldcf.jdbc.IDynamicResultSet;
import org.apache.manifoldcf.jdbc.IDynamicResultRow;
+import java.nio.charset.StandardCharsets;
import java.sql.*;
import javax.naming.*;
import javax.sql.*;
@@ -659,7 +660,7 @@ public class JDBCConnector extends org.a
String value = contents.toString();
try
{
- byte[] bytes = value.getBytes("utf-8");
+ byte[] bytes = value.getBytes(StandardCharsets.UTF_8);
RepositoryDocument rd = new RepositoryDocument();
// Default content type is text/plain for character data
Modified: manifoldcf/trunk/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/jdbc/JDBCConnection.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/jdbc/JDBCConnection.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/jdbc/JDBCConnection.java (original)
+++ manifoldcf/trunk/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/jdbc/JDBCConnection.java Thu Apr 17 22:56:31 2014
@@ -23,6 +23,7 @@ import org.apache.manifoldcf.core.databa
import org.apache.manifoldcf.core.jdbcpool.*;
import org.apache.manifoldcf.agents.interfaces.*;
+import java.nio.charset.StandardCharsets;
import java.sql.*;
import javax.naming.*;
import javax.sql.*;
@@ -285,7 +286,7 @@ public class JDBCConnection
InputStream is = bi.getStream();
try
{
- InputStreamReader reader = new InputStreamReader(is,"utf-8");
+ InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8);
StringBuilder sb = new StringBuilder();
while (true)
{
Modified: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java (original)
+++ manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java Thu Apr 17 22:56:31 2014
@@ -34,6 +34,7 @@ import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
@@ -100,8 +101,6 @@ public class JiraSession {
}
}
- protected static final Charset UTF_8 = Charset.forName("UTF-8");
-
/**
* Constructor. Create a session.
*/
@@ -251,13 +250,13 @@ public class JiraSession {
{
ContentType ct = ContentType.get(entity);
if (ct == null)
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
else
charSet = ct.getCharset();
}
catch (ParseException e)
{
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
}
return charSet;
}
Modified: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java (original)
+++ manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java Thu Apr 17 22:56:31 2014
@@ -25,6 +25,7 @@ import org.apache.manifoldcf.core.common
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.HashSet;
import java.util.ArrayList;
@@ -978,7 +979,7 @@ public class JiraRepositoryConnector ext
String documentURI = jiraFile.getSelf();
String document = getJiraBody(jiraFile);
try {
- byte[] documentBytes = document.getBytes("UTF-8");
+ byte[] documentBytes = document.getBytes(StandardCharsets.UTF_8);
InputStream is = new ByteArrayInputStream(documentBytes);
try {
rd.setBinary(is, documentBytes.length);
Modified: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java (original)
+++ manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java Thu Apr 17 22:56:31 2014
@@ -34,6 +34,7 @@ import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
@@ -100,8 +101,6 @@ public class JiraSession {
}
}
- protected static final Charset UTF_8 = Charset.forName("UTF-8");
-
/**
* Constructor. Create a session.
*/
@@ -251,13 +250,13 @@ public class JiraSession {
{
ContentType ct = ContentType.get(entity);
if (ct == null)
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
else
charSet = ct.getCharset();
}
catch (ParseException e)
{
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
}
return charSet;
}
Modified: manifoldcf/trunk/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LLSERVER.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LLSERVER.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LLSERVER.java (original)
+++ manifoldcf/trunk/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LLSERVER.java Thu Apr 17 22:56:31 2014
@@ -26,6 +26,7 @@ import org.apache.manifoldcf.crawler.sys
import org.apache.manifoldcf.crawler.system.ManifoldCF;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import com.opentext.api.LLSession;
import com.opentext.api.LLValue;
@@ -133,7 +134,7 @@ public class LLSERVER
OutputStream fos = new FileOutputStream(fileName);
try
{
- Writer osw = new OutputStreamWriter(fos,"utf-8");
+ Writer osw = new OutputStreamWriter(fos,StandardCharsets.UTF_8);
try
{
String certBase64 = new Base64().encodeByteArray(certData);
Modified: manifoldcf/trunk/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/CommonsHTTPSender.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/CommonsHTTPSender.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/CommonsHTTPSender.java (original)
+++ manifoldcf/trunk/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/CommonsHTTPSender.java Thu Apr 17 22:56:31 2014
@@ -83,6 +83,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
/* Class to use httpcomponents to communicate with a SOAP server.
* I've replaced the original rather complicated class with a much simpler one that
@@ -96,8 +97,6 @@ public class CommonsHTTPSender extends B
protected static Log log =
LogFactory.getLog(CommonsHTTPSender.class.getName());
- protected static final Charset UTF_8 = Charset.forName("UTF-8");
-
/** Properties */
protected CommonsHTTPClientProperties clientProperties;
@@ -365,7 +364,7 @@ public class CommonsHTTPSender extends B
{
Charset charSet = methodThread.getCharSet();
if (charSet == null)
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
char[] buffer = new char[65536];
Reader r = new InputStreamReader(is,charSet);
Writer w = new StringWriter();
Modified: manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java (original)
+++ manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java Thu Apr 17 22:56:31 2014
@@ -28,6 +28,7 @@ import java.io.InputStream;
import java.io.InterruptedIOException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -84,9 +85,7 @@ public class OpenSearchServerConnection
}
private Result result;
-
- private final static Charset UTF_8 = Charset.forName("UTF-8");
-
+
protected OpenSearchServerConnection(HttpClient client, OpenSearchServerConfig config) {
this.httpClient = client;
result = Result.UNKNOWN;
@@ -245,13 +244,13 @@ public class OpenSearchServerConnection
{
ContentType ct = ContentType.get(entity);
if (ct == null)
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
else
charSet = ct.getCharset();
}
catch (ParseException e)
{
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
}
char[] buffer = new char[65536];
Reader r = new InputStreamReader(is,charSet);
Modified: manifoldcf/trunk/connectors/rss/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/rss/Robots.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/rss/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/rss/Robots.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/rss/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/rss/Robots.java (original)
+++ manifoldcf/trunk/connectors/rss/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/rss/Robots.java Thu Apr 17 22:56:31 2014
@@ -22,6 +22,8 @@ import org.apache.manifoldcf.core.interf
import org.apache.manifoldcf.agents.interfaces.*;
import org.apache.manifoldcf.crawler.interfaces.*;
import org.apache.manifoldcf.crawler.system.Logging;
+
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.io.*;
import java.net.*;
@@ -456,7 +458,7 @@ public class Robots
InputStream is = connection.getResponseBodyStream();
try
{
- Reader r = new InputStreamReader(is,"utf-8");
+ Reader r = new InputStreamReader(is, StandardCharsets.UTF_8);
try
{
BufferedReader br = new BufferedReader(r);
Modified: manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrServer.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrServer.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrServer.java (original)
+++ manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrServer.java Thu Apr 17 22:56:31 2014
@@ -21,6 +21,7 @@ import java.io.InputStream;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
@@ -81,23 +82,11 @@ public class ModifiedHttpSolrServer exte
{
// Here we duplicate all the private fields we need
- private static final String UTF_8 = "UTF-8";
+
private static final String DEFAULT_PATH = "/select";
private static Charset UTF8_CHARSET;
- static
- {
- try
- {
- UTF8_CHARSET = Charset.forName(UTF_8);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- System.exit(-100);
- UTF8_CHARSET = null;
- }
- }
+
private final HttpClient httpClient;
private boolean followRedirects = false;
@@ -183,7 +172,7 @@ public class ModifiedHttpSolrServer exte
if (vals != null) {
for (String v : vals) {
if (isMultipart) {
- parts.add(new FormBodyPart(p, new StringBody(v, Charset.forName("UTF-8"))));
+ parts.add(new FormBodyPart(p, new StringBody(v, StandardCharsets.UTF_8)));
} else {
postParams.add(new BasicNameValuePair(p, v));
}
@@ -207,14 +196,14 @@ public class ModifiedHttpSolrServer exte
}
if (parts.size() > 0) {
- ModifiedMultipartEntity entity = new ModifiedMultipartEntity(HttpMultipartMode.STRICT, null, UTF8_CHARSET);
+ ModifiedMultipartEntity entity = new ModifiedMultipartEntity(HttpMultipartMode.STRICT, null, StandardCharsets.UTF_8);
for(FormBodyPart p: parts) {
entity.addPart(p);
}
post.setEntity(entity);
} else {
//not using multipart
- post.setEntity(new UrlEncodedFormEntity(postParams, "UTF-8"));
+ post.setEntity(new UrlEncodedFormEntity(postParams, StandardCharsets.UTF_8));
}
method = post;
@@ -338,7 +327,7 @@ public class ModifiedHttpSolrServer exte
msg.append(response.getStatusLine().getReasonPhrase());
msg.append("\n\n");
msg.append("request: " + method.getURI());
- reason = java.net.URLDecoder.decode(msg.toString(), UTF_8);
+ reason = java.net.URLDecoder.decode(msg.toString(), StandardCharsets.UTF_8.name());
}
throw new SolrException(
SolrException.ErrorCode.getErrorCode(httpStatus), reason);
Modified: manifoldcf/trunk/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/RobotsManager.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/RobotsManager.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/RobotsManager.java (original)
+++ manifoldcf/trunk/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/RobotsManager.java Thu Apr 17 22:56:31 2014
@@ -18,6 +18,7 @@
*/
package org.apache.manifoldcf.crawler.connectors.webcrawler;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.io.*;
import org.apache.manifoldcf.core.interfaces.*;
@@ -311,7 +312,7 @@ public class RobotsManager extends org.a
records = null;
return;
}
- Reader r = new InputStreamReader(is,"utf-8");
+ Reader r = new InputStreamReader(is, StandardCharsets.UTF_8);
try
{
BufferedReader br = new BufferedReader(r);
Modified: manifoldcf/trunk/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/ThrottledFetcher.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/ThrottledFetcher.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/ThrottledFetcher.java (original)
+++ manifoldcf/trunk/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/ThrottledFetcher.java Thu Apr 17 22:56:31 2014
@@ -26,6 +26,8 @@ import org.apache.manifoldcf.agents.inte
import org.apache.manifoldcf.crawler.interfaces.*;
import org.apache.manifoldcf.crawler.system.Logging;
import org.apache.manifoldcf.crawler.system.ManifoldCF;
+
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.io.*;
import java.net.*;
@@ -143,8 +145,6 @@ public class ThrottledFetcher
}
}
- protected static final Charset UTF_8 = Charset.forName("UTF-8");
-
private static final Registry<CookieSpecProvider> cookieSpecRegistry =
RegistryBuilder.<CookieSpecProvider>create()
.register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactory())
@@ -648,7 +648,7 @@ public class ThrottledFetcher
nvps.add(new BasicNameValuePair(param,value));
}
}
- postMethod.setEntity(new UrlEncodedFormEntity(nvps,UTF_8));
+ postMethod.setEntity(new UrlEncodedFormEntity(nvps, StandardCharsets.UTF_8));
fetchMethod = postMethod;
break;
default:
Modified: manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java (original)
+++ manifoldcf/trunk/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java Thu Apr 17 22:56:31 2014
@@ -70,6 +70,7 @@ import org.apache.http.HttpException;
import org.apache.http.ParseException;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.io.*;
import java.net.*;
@@ -149,8 +150,6 @@ public class WikiConnector extends org.a
}
}
- protected static final Charset UTF_8 = Charset.forName("UTF-8");
-
/** Constructor.
*/
public WikiConnector()
@@ -2010,7 +2009,7 @@ public class WikiConnector extends org.a
pairs.add(new BasicNameValuePair(key, params.get(key)));
}
- method.setEntity(new UrlEncodedFormEntity(pairs, UTF_8));
+ method.setEntity(new UrlEncodedFormEntity(pairs, StandardCharsets.UTF_8));
return method;
}
@@ -4671,13 +4670,13 @@ public class WikiConnector extends org.a
{
ContentType ct = ContentType.get(entity);
if (ct == null)
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
else
charSet = ct.getCharset();
}
catch (ParseException e)
{
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
}
char[] buffer = new char[65536];
Reader r = new InputStreamReader(is,charSet);
Modified: manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLOutputStreamContext.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLOutputStreamContext.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLOutputStreamContext.java (original)
+++ manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLOutputStreamContext.java Thu Apr 17 22:56:31 2014
@@ -30,6 +30,7 @@ import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.io.InterruptedIOException;
+import java.nio.charset.StandardCharsets;
import org.apache.manifoldcf.core.interfaces.*;
@@ -45,7 +46,7 @@ public class XMLOutputStreamContext exte
throws ManifoldCFException, UnsupportedEncodingException
{
// Construct an appropriate writer
- super(theStream,namespaceURI,localname,qname,theseAttributes,new OutputStreamWriter(os,"utf-8"));
+ super(theStream,namespaceURI,localname,qname,theseAttributes,new OutputStreamWriter(os, StandardCharsets.UTF_8));
// Save the stream
outputStream = os;
}
Modified: manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLStream.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLStream.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLStream.java (original)
+++ manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/common/XMLStream.java Thu Apr 17 22:56:31 2014
@@ -29,6 +29,7 @@ import org.xml.sax.SAXParseException;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import org.apache.manifoldcf.core.interfaces.*;
import org.apache.manifoldcf.agents.interfaces.*;
@@ -186,7 +187,7 @@ public class XMLStream
throws SAXException, java.io.IOException
{
// ALL references resolve to blank documents
- return new org.xml.sax.InputSource(new ByteArrayInputStream("<?xml version='1.0' encoding='UTF-8'?>".getBytes()));
+ return new org.xml.sax.InputSource(new ByteArrayInputStream("<?xml version='1.0' encoding='UTF-8'?>".getBytes(StandardCharsets.UTF_8)));
}
}
Modified: manifoldcf/trunk/framework/api-servlet/src/main/java/org/apache/manifoldcf/apiservlet/APIServlet.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/api-servlet/src/main/java/org/apache/manifoldcf/apiservlet/APIServlet.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/api-servlet/src/main/java/org/apache/manifoldcf/apiservlet/APIServlet.java (original)
+++ manifoldcf/trunk/framework/api-servlet/src/main/java/org/apache/manifoldcf/apiservlet/APIServlet.java Thu Apr 17 22:56:31 2014
@@ -25,6 +25,7 @@ import org.apache.manifoldcf.crawler.sys
import org.apache.manifoldcf.crawler.system.Logging;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.net.*;
@@ -259,7 +260,7 @@ public class APIServlet extends HttpServ
if (readResult == ManifoldCF.READRESULT_NOTFOUND)
response.setStatus(response.SC_NOT_FOUND);
- byte[] responseValue = outputText.getBytes("utf-8");
+ byte[] responseValue = outputText.getBytes(StandardCharsets.UTF_8);
// Set response mime type
response.setContentType("text/plain; charset=utf-8");
@@ -303,7 +304,7 @@ public class APIServlet extends HttpServ
// We presume the data is utf-8
StringBuilder sb = new StringBuilder();
char[] buffer = new char[65536];
- Reader r = new InputStreamReader(data,"utf-8");
+ Reader r = new InputStreamReader(data,StandardCharsets.UTF_8);
while (true)
{
int amt = r.read(buffer);
@@ -373,7 +374,7 @@ public class APIServlet extends HttpServ
else if (writeResult == ManifoldCF.WRITERESULT_NOTFOUND)
response.setStatus(response.SC_NOT_FOUND);
- byte[] responseValue = outputText.getBytes("utf-8");
+ byte[] responseValue = outputText.getBytes(StandardCharsets.UTF_8);
// Set response mime type
response.setContentType("text/plain; charset=utf-8");
@@ -417,7 +418,7 @@ public class APIServlet extends HttpServ
// We presume the data is utf-8
StringBuilder sb = new StringBuilder();
char[] buffer = new char[65536];
- Reader r = new InputStreamReader(data,"utf-8");
+ Reader r = new InputStreamReader(data,StandardCharsets.UTF_8);
while (true)
{
int amt = r.read(buffer);
@@ -484,7 +485,7 @@ public class APIServlet extends HttpServ
else if (writeResult == ManifoldCF.POSTRESULT_NOTFOUND)
response.setStatus(response.SC_NOT_FOUND);
- byte[] responseValue = outputText.getBytes("utf-8");
+ byte[] responseValue = outputText.getBytes(StandardCharsets.UTF_8);
// Set response mime type
response.setContentType("text/plain; charset=utf-8");
@@ -560,7 +561,7 @@ public class APIServlet extends HttpServ
if (result == ManifoldCF.DELETERESULT_NOTFOUND)
response.setStatus(response.SC_NOT_FOUND);
- byte[] responseValue = outputText.getBytes("utf-8");
+ byte[] responseValue = outputText.getBytes(StandardCharsets.UTF_8);
// Set response mime type
response.setContentType("text/plain; charset=utf-8");
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/CacheManager.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/CacheManager.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/CacheManager.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/cachemanager/CacheManager.java Thu Apr 17 22:56:31 2014
@@ -19,6 +19,8 @@
package org.apache.manifoldcf.core.cachemanager;
import org.apache.manifoldcf.core.interfaces.*;
+
+import java.nio.charset.StandardCharsets;
import java.util.*;
import org.apache.manifoldcf.core.system.Logging;
import org.apache.manifoldcf.core.system.ManifoldCF;
@@ -847,15 +849,11 @@ public class CacheManager implements ICa
byte[] cacheResourceData = lockManager.readData("cache-"+key);
if (cacheResourceData == null)
return 0L;
- try
- {
- String expiration = new String(cacheResourceData,"utf-8");
- return new Long(expiration).longValue();
- }
- catch (UnsupportedEncodingException e)
- {
- throw new ManifoldCFException(e.getMessage(),e);
- }
+
+ String expiration = new String(cacheResourceData, StandardCharsets.UTF_8);
+ return new Long(expiration).longValue();
+
+
}
/** Write the invalidation file contents.
@@ -869,14 +867,7 @@ public class CacheManager implements ICa
lockManager.writeData(key,null);
else
{
- try
- {
- lockManager.writeData("cache-"+key,Long.toString(value).getBytes("utf-8"));
- }
- catch (UnsupportedEncodingException e)
- {
- throw new ManifoldCFException(e.getMessage(),e);
- }
+ lockManager.writeData("cache-"+key,Long.toString(value).getBytes(StandardCharsets.UTF_8));
}
}
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/common/CommonsHTTPSender.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/common/CommonsHTTPSender.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/common/CommonsHTTPSender.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/common/CommonsHTTPSender.java Thu Apr 17 22:56:31 2014
@@ -74,6 +74,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
@@ -96,8 +97,6 @@ public class CommonsHTTPSender extends B
protected static Log log =
LogFactory.getLog(CommonsHTTPSender.class.getName());
- protected static final Charset UTF_8 = Charset.forName("UTF-8");
-
/** Properties */
protected CommonsHTTPClientProperties clientProperties;
@@ -366,7 +365,7 @@ public class CommonsHTTPSender extends B
{
Charset charSet = methodThread.getCharSet();
if (charSet == null)
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
char[] buffer = new char[65536];
Reader r = new InputStreamReader(is,charSet);
Writer w = new StringWriter();
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/common/XMLDoc.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/common/XMLDoc.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/common/XMLDoc.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/common/XMLDoc.java Thu Apr 17 22:56:31 2014
@@ -18,6 +18,7 @@
*/
package org.apache.manifoldcf.core.common;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.io.*;
import javax.xml.transform.*;
@@ -231,14 +232,8 @@ public class XMLDoc
public String getXML()
throws ManifoldCFException
{
- try
- {
- return new String(toByteArray(),"utf-8");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new ManifoldCFException(e.getMessage(),e);
- }
+ return new String(toByteArray(), StandardCharsets.UTF_8);
+
}
/** Get XML with no entity preamble */
@@ -287,15 +282,10 @@ public class XMLDoc
public XMLDoc(String data)
throws ManifoldCFException
{
- try
- {
- ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes("utf-8"));
+ ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
_doc = init(bis);
- }
- catch (UnsupportedEncodingException e)
- {
- throw new ManifoldCFException(e.getMessage(),e);
- }
+
+
}
/** Construct a new document tree from a StringBuilder form of
@@ -305,16 +295,10 @@ public class XMLDoc
public XMLDoc(StringBuilder data)
throws ManifoldCFException
{
- try
- {
ByteArrayInputStream bis =
- new ByteArrayInputStream(data.toString().getBytes("utf-8"));
+ new ByteArrayInputStream(data.toString().getBytes(StandardCharsets.UTF_8));
_doc = init(bis);
- }
- catch (UnsupportedEncodingException e)
- {
- throw new ManifoldCFException(e.getMessage(),e);
- }
+
}
/** Build a document object tree from an input
@@ -392,7 +376,7 @@ public class XMLDoc
{
// Append the bytes we have, and stop. Presume the encoding is utf-8;
// if we're wrong it will come out as garbage, but that can't be helped.
- sw.append(new String(buf, 0, len, "UTF-8"));
+ sw.append(new String(buf, 0, len, StandardCharsets.UTF_8));
if (len == buf.length)
sw.append("...");
}
@@ -746,7 +730,7 @@ public class XMLDoc
throws SAXException, java.io.IOException
{
// ALL references resolve to blank documents
- return new org.xml.sax.InputSource(new ByteArrayInputStream("<?xml version='1.0' encoding='UTF-8'?>".getBytes()));
+ return new org.xml.sax.InputSource(new ByteArrayInputStream("<?xml version='1.0' encoding='UTF-8'?>".getBytes(StandardCharsets.UTF_8)));
}
}
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/fuzzyml/XMLOutputStreamParsingContext.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/fuzzyml/XMLOutputStreamParsingContext.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/fuzzyml/XMLOutputStreamParsingContext.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/fuzzyml/XMLOutputStreamParsingContext.java Thu Apr 17 22:56:31 2014
@@ -20,6 +20,7 @@ package org.apache.manifoldcf.core.fuzzy
import org.apache.manifoldcf.core.interfaces.*;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
/** An instance of this class represents a parsing context within a node. Data is written to the supplied output stream in utf-8 format.
@@ -34,7 +35,7 @@ public class XMLOutputStreamParsingConte
throws ManifoldCFException, UnsupportedEncodingException
{
// Construct an appropriate writer
- super(theStream,namespace,localname,qname,theseAttributes,new OutputStreamWriter(os,"utf-8"));
+ super(theStream,namespace,localname,qname,theseAttributes,new OutputStreamWriter(os, StandardCharsets.UTF_8));
// Save the stream
outputStream = os;
}
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDFactory.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDFactory.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDFactory.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDFactory.java Thu Apr 17 22:56:31 2014
@@ -21,6 +21,7 @@ package org.apache.manifoldcf.core.inter
import org.apache.manifoldcf.core.system.ManifoldCF;
import org.apache.manifoldcf.core.system.Logging;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
/** The purpose of this class is to create global unique identifiers. For performance, every JVM has a local pool of identifiers as well
@@ -68,7 +69,7 @@ public class IDFactory
if (idData == null)
_id = 0L;
else
- _id = new Long(new String(idData,"utf-8")).longValue();
+ _id = new Long(new String(idData, StandardCharsets.UTF_8)).longValue();
int i = 0;
while (i < poolSize)
@@ -83,11 +84,7 @@ public class IDFactory
i++;
}
- lockManager.writeData(globalIDDataName,Long.toString(_id).getBytes("utf-8"));
- }
- catch (UnsupportedEncodingException e)
- {
- throw new ManifoldCFException(e.getMessage(),e);
+ lockManager.writeData(globalIDDataName,Long.toString(_id).getBytes(StandardCharsets.UTF_8));
}
finally
{
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/TempFileCharacterInput.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/TempFileCharacterInput.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/TempFileCharacterInput.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/TempFileCharacterInput.java Thu Apr 17 22:56:31 2014
@@ -19,6 +19,8 @@
package org.apache.manifoldcf.core.interfaces;
import java.io.*;
+import java.nio.charset.StandardCharsets;
+
import org.apache.manifoldcf.core.system.ManifoldCF;
/** This class represents a temporary file character input
@@ -72,7 +74,7 @@ public class TempFileCharacterInput exte
FileOutputStream outStream = new FileOutputStream(outfile);
// Create a Writer corresponding to the file output stream, and encode using utf-8
- OutputStreamWriter outWriter = new OutputStreamWriter(outStream,"utf-8");
+ OutputStreamWriter outWriter = new OutputStreamWriter(outStream,StandardCharsets.UTF_8);
try
{
char[] buffer = new char[CHUNK_SIZE];
@@ -187,16 +189,12 @@ public class TempFileCharacterInput exte
{
// Open the file and create a stream.
InputStream binaryStream = new FileInputStream(file);
- stream = new InputStreamReader(binaryStream,"utf-8");
+ stream = new InputStreamReader(binaryStream, StandardCharsets.UTF_8);
}
catch (FileNotFoundException e)
{
throw new ManifoldCFException("Can't create stream: "+e.getMessage(),e,ManifoldCFException.GENERAL_ERROR);
}
- catch (UnsupportedEncodingException e)
- {
- throw new ManifoldCFException("Can't create stream: "+e.getMessage(),e,ManifoldCFException.GENERAL_ERROR);
- }
}
/** Transfer to a new object; this causes the current object to become "already discarded" */
@@ -253,7 +251,7 @@ public class TempFileCharacterInput exte
{
// Open the file and create a stream.
InputStream binaryStream = new FileInputStream(file);
- Reader reader = new InputStreamReader(binaryStream,"utf-8");
+ Reader reader = new InputStreamReader(binaryStream,StandardCharsets.UTF_8);
try
{
// Set up hash digest and character length counter before we start anything.
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/UTF8Stderr.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/UTF8Stderr.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/UTF8Stderr.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/UTF8Stderr.java Thu Apr 17 22:56:31 2014
@@ -18,9 +18,9 @@
*/
package org.apache.manifoldcf.core.interfaces;
-import java.io.UnsupportedEncodingException;
import java.io.PrintWriter;
import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
/** This factory returns a database interface appropriate for
* a specified client connection. The client or company name is
@@ -35,14 +35,7 @@ public final class UTF8Stderr
// this is called before invoking any methods
static
{
- try
- {
- err = new PrintWriter(new OutputStreamWriter(System.err, "UTF-8"), true);
- }
- catch (UnsupportedEncodingException e)
- {
- System.err.println(e);
- }
+ err = new PrintWriter(new OutputStreamWriter(System.err, StandardCharsets.UTF_8), true);
}
private UTF8Stderr()
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/UTF8Stdout.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/UTF8Stdout.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/UTF8Stdout.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/UTF8Stdout.java Thu Apr 17 22:56:31 2014
@@ -18,9 +18,9 @@
*/
package org.apache.manifoldcf.core.interfaces;
-import java.io.UnsupportedEncodingException;
import java.io.PrintWriter;
import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
/** This factory returns a database interface appropriate for
* a specified client connection. The client or company name is
@@ -35,14 +35,7 @@ public final class UTF8Stdout
// this is called before invoking any methods
static
{
- try
- {
- out = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"), true);
- }
- catch (UnsupportedEncodingException e)
- {
- System.out.println(e);
- }
+ out = new PrintWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8), true);
}
private UTF8Stdout()
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java Thu Apr 17 22:56:31 2014
@@ -21,6 +21,8 @@ package org.apache.manifoldcf.core.lockm
import org.apache.manifoldcf.core.interfaces.*;
import org.apache.manifoldcf.core.system.Logging;
import org.apache.manifoldcf.core.system.ManifoldCF;
+
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.io.*;
@@ -574,27 +576,15 @@ public class BaseLockManager implements
byte[] bytes = readData(resourceName);
if (bytes == null)
return null;
- try
- {
- return new String(bytes, "utf-8");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException("Unsupported encoding: "+e.getMessage(),e);
- }
+
+ return new String(bytes, StandardCharsets.UTF_8);
+
}
protected void writeServiceName(String resourceName, String serviceName)
throws ManifoldCFException
{
- try
- {
- writeData(resourceName, (serviceName==null)?null:serviceName.getBytes("utf-8"));
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException("Unsupported encoding: "+e.getMessage(),e);
- }
+ writeData(resourceName, (serviceName==null)?null:serviceName.getBytes(StandardCharsets.UTF_8));
}
protected static String buildServiceListEntry(String serviceType, int i)
Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java Thu Apr 17 22:56:31 2014
@@ -20,6 +20,7 @@ package org.apache.manifoldcf.core.syste
import org.apache.manifoldcf.core.interfaces.*;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.security.MessageDigest;
@@ -584,7 +585,7 @@ public class ManifoldCF
{
try
{
- byte[] inputBytes = input.getBytes("UTF-8");
+ byte[] inputBytes = input.getBytes(StandardCharsets.UTF_8);
digest.update(inputBytes);
}
catch (Exception e)
@@ -655,14 +656,12 @@ public class ManifoldCF
public static String obfuscate(String input)
throws ManifoldCFException
{
- try
- {
if (input == null)
return null;
if (input.length() == 0)
return input;
// First, convert to binary
- byte[] array = input.getBytes("UTF-8");
+ byte[] array = input.getBytes(StandardCharsets.UTF_8);
// Shift and xor
// We shift by some number not a multiple of 4.
// The resulting hexadecimal is then not a simple shift.
@@ -686,11 +685,6 @@ public class ManifoldCF
rval.append(writeNibble(x & 0x0f));
}
return rval.toString();
- }
- catch (java.io.UnsupportedEncodingException e)
- {
- throw new ManifoldCFException("UTF-8 not supported",e,ManifoldCFException.GENERAL_ERROR);
- }
}
/** Write a hex nibble.
@@ -713,8 +707,6 @@ public class ManifoldCF
public static String deobfuscate(String input)
throws ManifoldCFException
{
- try
- {
if (input == null)
return null;
if (input.length() == 0)
@@ -748,12 +740,7 @@ public class ManifoldCF
}
// Convert from utf-8 to a string
- return new String(bytes,"UTF-8");
- }
- catch (java.io.UnsupportedEncodingException e)
- {
- throw new ManifoldCFException("UTF-8 unsupported",e,ManifoldCFException.GENERAL_ERROR);
- }
+ return new String(bytes,StandardCharsets.UTF_8);
}
/** Read a hex nibble.
@@ -1047,7 +1034,7 @@ public class ManifoldCF
public static void writeBytes(OutputStream os, byte[] byteArray)
throws IOException
{
- os.write(byteArray,0,byteArray.length);
+ os.write(byteArray, 0, byteArray.length);
}
/** Write a byte to an output stream */
@@ -1085,7 +1072,7 @@ public class ManifoldCF
buffer[1] = (byte)((dwordValue >>> 8) & 0xff);
buffer[2] = (byte)((dwordValue >>> 16) & 0xff);
buffer[3] = (byte)((dwordValue >>> 24) & 0xff);
- writeBytes(os,buffer);
+ writeBytes(os, buffer);
}
/** Write a Long to an output stream */
@@ -1119,8 +1106,8 @@ public class ManifoldCF
if (stringValue == null)
characters = null;
else
- characters = stringValue.getBytes("utf-8");
- writeByteArray(os,characters);
+ characters = stringValue.getBytes(StandardCharsets.UTF_8);
+ writeByteArray(os, characters);
}
/** Write a byte array to an output stream */
@@ -1140,7 +1127,7 @@ public class ManifoldCF
public static void writefloat(OutputStream os, float floatValue)
throws IOException
{
- writeSdword(os,Float.floatToIntBits(floatValue));
+ writeSdword(os, Float.floatToIntBits(floatValue));
}
/** Read bytes from the input stream into specified array. */
@@ -1227,7 +1214,7 @@ public class ManifoldCF
byte[] bytes = readByteArray(is);
if (bytes == null)
return null;
- return new String(bytes,"utf-8");
+ return new String(bytes,StandardCharsets.UTF_8);
}
/** Read a byte array from an input stream */
Modified: manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/fuzzyml/TestFuzzyML.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/fuzzyml/TestFuzzyML.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/fuzzyml/TestFuzzyML.java [UTF-8] (original)
+++ manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/fuzzyml/TestFuzzyML.java [UTF-8] Thu Apr 17 22:56:31 2014
@@ -22,6 +22,7 @@ import org.apache.manifoldcf.core.interf
import org.apache.manifoldcf.core.system.ManifoldCF;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import org.junit.*;
@@ -184,7 +185,7 @@ public class TestFuzzyML
throws IOException, ManifoldCFException
{
org.apache.manifoldcf.core.system.Logging.misc = org.apache.log4j.Logger.getLogger("test");
- InputStream is = new ByteArrayInputStream(fuzzyTestString.getBytes("utf-8"));
+ InputStream is = new ByteArrayInputStream(fuzzyTestString.getBytes(StandardCharsets.UTF_8));
Parser p = new Parser();
// Parse the document. This will cause various things to occur, within the instantiated XMLParsingContext class.
XMLFuzzyHierarchicalParseState x = new XMLFuzzyHierarchicalParseState();
Modified: manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/Base.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/Base.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/Base.java (original)
+++ manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/Base.java Thu Apr 17 22:56:31 2014
@@ -22,6 +22,7 @@ import org.apache.manifoldcf.core.interf
import org.apache.manifoldcf.core.system.ManifoldCF;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import org.junit.*;
@@ -250,7 +251,7 @@ public class Base
OutputStream os = new FileOutputStream(f);
try
{
- Writer w = new OutputStreamWriter(os,"UTF-8");
+ Writer w = new OutputStreamWriter(os, StandardCharsets.UTF_8);
try
{
w.write(fileContents);
Modified: manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/HTMLTester.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/HTMLTester.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/HTMLTester.java (original)
+++ manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/HTMLTester.java Thu Apr 17 22:56:31 2014
@@ -19,6 +19,7 @@
package org.apache.manifoldcf.core.tests;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import org.junit.*;
@@ -75,8 +76,8 @@ public class HTMLTester
InputStream is = getClass().getResourceAsStream(resName);
try
{
- BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os,"UTF-8"));
- BufferedReader br = new BufferedReader(new InputStreamReader(is,"UTF-8"));
+ BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8));
+ BufferedReader br = new BufferedReader(new InputStreamReader(is,StandardCharsets.UTF_8));
while (true)
{
String line = br.readLine();
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/reprioritizationtracker/ReprioritizationTracker.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/reprioritizationtracker/ReprioritizationTracker.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/reprioritizationtracker/ReprioritizationTracker.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/reprioritizationtracker/ReprioritizationTracker.java Thu Apr 17 22:56:31 2014
@@ -22,6 +22,8 @@ import org.apache.manifoldcf.core.interf
import org.apache.manifoldcf.agents.interfaces.*;
import org.apache.manifoldcf.crawler.interfaces.*;
import org.apache.manifoldcf.crawler.system.Logging;
+
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.io.*;
@@ -383,14 +385,9 @@ public class ReprioritizationTracker imp
byte[] processIDData = lockManager.readData(trackerProcessIDResource);
if (processIDData == null)
return null;
- try
- {
- return new String(processIDData, "utf-8");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException(e.getMessage(),e);
- }
+ else
+ return new String(processIDData, StandardCharsets.UTF_8);
+
}
/** Write process ID.
@@ -403,15 +400,8 @@ public class ReprioritizationTracker imp
lockManager.writeData(trackerProcessIDResource, null);
else
{
- try
- {
- byte[] processIDData = processID.getBytes("utf-8");
+ byte[] processIDData = processID.getBytes(StandardCharsets.UTF_8);
lockManager.writeData(trackerProcessIDResource, processIDData);
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException(e.getMessage(),e);
- }
}
}
@@ -424,14 +414,9 @@ public class ReprioritizationTracker imp
byte[] reproIDData = lockManager.readData(trackerReproIDResource);
if (reproIDData == null)
return null;
- try
- {
- return new String(reproIDData, "utf-8");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException(e.getMessage(),e);
- }
+ else
+ return new String(reproIDData, StandardCharsets.UTF_8);
+
}
/** Write repro ID.
@@ -444,15 +429,8 @@ public class ReprioritizationTracker imp
lockManager.writeData(trackerReproIDResource, null);
else
{
- try
- {
- byte[] reproIDData = reproID.getBytes("utf-8");
+ byte[] reproIDData = reproID.getBytes(StandardCharsets.UTF_8);
lockManager.writeData(trackerReproIDResource, reproIDData);
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException(e.getMessage(),e);
- }
}
}
Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java Thu Apr 17 22:56:31 2014
@@ -25,6 +25,7 @@ import org.apache.manifoldcf.crawler.sys
import org.apache.manifoldcf.agents.system.AgentsDaemon;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.nio.charset.Charset;
import org.junit.*;
@@ -72,8 +73,6 @@ public class ManifoldCFInstance
protected DaemonThread daemonThread = null;
protected Server server = null;
- protected static final Charset UTF_8 = Charset.forName("UTF-8");
-
public ManifoldCFInstance()
{
this("", 8346, false, true);
@@ -344,13 +343,13 @@ public class ManifoldCFInstance
{
ContentType ct = ContentType.get(entity);
if (ct == null)
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
else
charSet = ct.getCharset();
}
catch (ParseException e)
{
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
}
char[] buffer = new char[65536];
Reader r = new InputStreamReader(is,charSet);
Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/TestingRepositoryConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/TestingRepositoryConnector.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/TestingRepositoryConnector.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/TestingRepositoryConnector.java Thu Apr 17 22:56:31 2014
@@ -24,14 +24,11 @@ import org.apache.manifoldcf.crawler.int
import org.apache.manifoldcf.crawler.system.ManifoldCF;
import java.io.*;
-import java.util.*;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
/** Connector class to be used by general integration tests that need documents */
public class TestingRepositoryConnector extends org.apache.manifoldcf.crawler.connectors.BaseRepositoryConnector
{
- private final static Charset UTF_8 = Charset.forName("UTF-8");
-
public TestingRepositoryConnector()
{
}
@@ -82,7 +79,7 @@ public class TestingRepositoryConnector
if (!scanOnly[i])
{
RepositoryDocument rd = new RepositoryDocument();
- byte[] bytes = documentIdentifier.getBytes(UTF_8);
+ byte[] bytes = documentIdentifier.getBytes(StandardCharsets.UTF_8);
rd.setBinary(new ByteArrayInputStream(bytes),bytes.length);
activities.ingestDocument(documentIdentifier,version,"http://"+documentIdentifier,rd);
}
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/POSTCommand.java Thu Apr 17 22:56:31 2014
@@ -29,6 +29,7 @@ import org.apache.http.conn.ConnectTimeo
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import java.io.*;
+import java.nio.charset.StandardCharsets;
/** POST command. This performs a REST-style POST operation, designed to work
* against the ManifoldCF API. The syntax is: POST resultvariable = sendvariable to urlvariable*/
@@ -71,7 +72,7 @@ public class POSTCommand implements Comm
HttpPost method = new HttpPost(urlString);
try
{
- method.setEntity(new StringEntity(json,ContentType.create("text/plain","UTF-8")));
+ method.setEntity(new StringEntity(json,ContentType.create("text/plain", StandardCharsets.UTF_8)));
HttpResponse httpResponse = client.execute(method);
int resultCode = httpResponse.getStatusLine().getStatusCode();
String resultJSON = sp.convertToString(httpResponse);
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/PUTCommand.java Thu Apr 17 22:56:31 2014
@@ -29,6 +29,7 @@ import org.apache.http.conn.ConnectTimeo
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import java.io.*;
+import java.nio.charset.StandardCharsets;
/** PUT command. This performs a REST-style PUT operation, designed to work
* against the ManifoldCF API. The syntax is: PUT resultvariable = sendvariable to urlvariable*/
@@ -71,7 +72,7 @@ public class PUTCommand implements Comma
HttpPut method = new HttpPut(urlString);
try
{
- method.setEntity(new StringEntity(json,ContentType.create("text/plain","UTF-8")));
+ method.setEntity(new StringEntity(json,ContentType.create("text/plain", StandardCharsets.UTF_8)));
HttpResponse httpResponse = client.execute(method);
int resultCode = httpResponse.getStatusLine().getStatusCode();
String resultJSON = sp.convertToString(httpResponse);
Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java?rev=1588386&r1=1588385&r2=1588386&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java (original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java Thu Apr 17 22:56:31 2014
@@ -39,6 +39,8 @@ import org.apache.http.util.EntityUtils;
import org.apache.http.impl.client.DefaultRedirectStrategy;
import org.apache.http.entity.ContentType;
import org.apache.http.ParseException;
+
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.io.*;
import java.nio.charset.Charset;
@@ -65,8 +67,6 @@ public class ScriptParser
/** A table of "new" operations that we know how to deal with. */
protected Map<String,NewOperation> newOperations = new HashMap<String,NewOperation>();
- protected final static Charset UTF_8 = Charset.forName("UTF-8");
-
public ScriptParser()
{
}
@@ -1177,13 +1177,13 @@ public class ScriptParser
{
ContentType ct = ContentType.get(entity);
if (ct == null)
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
else
charSet = ct.getCharset();
}
catch (ParseException e)
{
- charSet = UTF_8;
+ charSet = StandardCharsets.UTF_8;
}
char[] buffer = new char[65536];
Reader r = new InputStreamReader(is,charSet);
@@ -1290,7 +1290,7 @@ public class ScriptParser
if (argv.length >= 1)
{
File inputFile = new File(argv[0]);
- reader = new InputStreamReader(new FileInputStream(inputFile),"utf-8");
+ reader = new InputStreamReader(new FileInputStream(inputFile),StandardCharsets.UTF_8);
VariableArray va = new VariableArray();
int i = 0;
while (i < argv.length - 1)