Modified: manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/SolrConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/SolrConnector.java?rev=1910246&r1=1910245&r2=1910246&view=diff ============================================================================== --- manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/SolrConnector.java (original) +++ manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/SolrConnector.java Tue Jun 6 01:35:45 2023 @@ -21,20 +21,21 @@ package org.apache.manifoldcf.agents.out import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.HashSet; import org.apache.manifoldcf.agents.interfaces.IOutputAddActivity; +import org.apache.manifoldcf.agents.interfaces.IOutputCheckActivity; import org.apache.manifoldcf.agents.interfaces.IOutputNotifyActivity; import org.apache.manifoldcf.agents.interfaces.IOutputRemoveActivity; -import org.apache.manifoldcf.agents.interfaces.IOutputCheckActivity; import org.apache.manifoldcf.agents.interfaces.RepositoryDocument; import org.apache.manifoldcf.agents.interfaces.ServiceInterruption; -import org.apache.manifoldcf.core.interfaces.Specification; +import org.apache.manifoldcf.connectorcommon.interfaces.IKeystoreManager; +import org.apache.manifoldcf.connectorcommon.interfaces.KeystoreManagerFactory; import org.apache.manifoldcf.core.interfaces.ConfigNode; import org.apache.manifoldcf.core.interfaces.ConfigParams; import org.apache.manifoldcf.core.interfaces.ConfigurationNode; @@ -43,16 +44,13 @@ import org.apache.manifoldcf.core.interf import org.apache.manifoldcf.core.interfaces.IPostParameters; import org.apache.manifoldcf.core.interfaces.IThreadContext; import org.apache.manifoldcf.core.interfaces.ManifoldCFException; -import org.apache.manifoldcf.core.interfaces.SpecificationNode; +import org.apache.manifoldcf.core.interfaces.Specification; import org.apache.manifoldcf.core.interfaces.VersionContext; -import org.apache.manifoldcf.connectorcommon.interfaces.KeystoreManagerFactory; -import org.apache.manifoldcf.connectorcommon.interfaces.IKeystoreManager; - -/** This is the output connector for SOLR. Currently, no frills. -*/ -public class SolrConnector extends org.apache.manifoldcf.agents.output.BaseOutputConnector -{ +/** + * This is the output connector for SOLR. Currently, no frills. + */ +public class SolrConnector extends org.apache.manifoldcf.agents.output.BaseOutputConnector { public static final String _rcsid = "@(#)$Id: SolrConnector.java 998081 2010-09-17 11:33:15Z kwright $"; // Activities we log @@ -64,10 +62,10 @@ public class SolrConnector extends org.a /** Local connection */ protected HttpPoster poster = null; - + /** Expiration */ protected long expirationTime = -1L; - + /** The allow attribute name */ protected String allowAttributeName = "allow_token_"; /** The deny attribute name */ @@ -82,7 +80,7 @@ public class SolrConnector extends org.a protected String excludedMimeTypesString = null; /** Excluded mime types */ protected Set<String> excludedMimeTypes = null; - + // Attributes going into Solr protected String idAttributeName = null; protected String originalSizeAttributeName = null; @@ -94,7 +92,7 @@ public class SolrConnector extends org.a protected String contentAttributeName = null; /** Use extractiing update handler? */ protected boolean useExtractUpdateHandler = true; - /** Allow compression? Currently static */ + /** Allow compression? Currently static */ protected final static boolean allowCompression = true; /** Whether or not to commit */ @@ -102,52 +100,48 @@ public class SolrConnector extends org.a /** Collection name (non-empty only if SolrCloud) */ protected String collectionName = null; - + /** Idle connection expiration interval */ protected final static long EXPIRATION_INTERVAL = 300000L; - static - { - System.setProperty("jdk.xml.maxGeneralEntitySizeLimit",new Integer(Integer.MAX_VALUE).toString()); - } - - /** Constructor. - */ - public SolrConnector() - { + static { + System.setProperty("jdk.xml.maxGeneralEntitySizeLimit", new Integer(Integer.MAX_VALUE).toString()); + } + + /** + * Constructor. + */ + public SolrConnector() { } - /** Return the list of activities that this connector supports (i.e. writes into the log). - *@return the list. - */ + /** + * Return the list of activities that this connector supports (i.e. writes into the log). + * + * @return the list. + */ @Override - public String[] getActivitiesList() - { - return new String[]{INGEST_ACTIVITY,REMOVE_ACTIVITY}; + public String[] getActivitiesList() { + return new String[] { INGEST_ACTIVITY, REMOVE_ACTIVITY }; } - /** Connect. - *@param configParameters is the set of configuration parameters, which - * in this case describe the target appliance, basic auth configuration, etc. (This formerly came - * out of the ini file.) - */ + /** + * Connect. + * + * @param configParameters + * is the set of configuration parameters, which in this case describe the target appliance, basic auth configuration, etc. (This formerly came out of the ini file.) + */ @Override - public void connect(ConfigParams configParameters) - { + public void connect(final ConfigParams configParameters) { super.connect(configParameters); } - /** This method is periodically called for all connectors that are connected but not - * in active use. - */ + /** + * This method is periodically called for all connectors that are connected but not in active use. + */ @Override - public void poll() - throws ManifoldCFException - { - if (poster != null) - { - if (expirationTime <= System.currentTimeMillis()) - { + public void poll() throws ManifoldCFException { + if (poster != null) { + if (expirationTime <= System.currentTimeMillis()) { // Expire connection poster.shutdown(); poster = null; @@ -156,24 +150,22 @@ public class SolrConnector extends org.a } } - /** This method is called to assess whether to count this connector instance should - * actually be counted as being connected. - *@return true if the connector instance is actually connected. - */ + /** + * This method is called to assess whether to count this connector instance should actually be counted as being connected. + * + * @return true if the connector instance is actually connected. + */ @Override - public boolean isConnected() - { + public boolean isConnected() { return poster != null; } - /** Close the connection. Call this before discarding the connection. - */ + /** + * Close the connection. Call this before discarding the connection. + */ @Override - public void disconnect() - throws ManifoldCFException - { - if (poster != null) - { + public void disconnect() throws ManifoldCFException { + if (poster != null) { poster.shutdown(); poster = null; expirationTime = -1L; @@ -197,11 +189,8 @@ public class SolrConnector extends org.a } /** Set up a session */ - protected void getSession() - throws ManifoldCFException - { - if (poster == null) - { + protected void getSession() throws ManifoldCFException { + if (poster == null) { String updatePath = params.getParameter(SolrConfig.PARAM_UPDATEPATH); if (updatePath == null || updatePath.length() == 0) updatePath = ""; @@ -221,7 +210,7 @@ public class SolrConnector extends org.a originalSizeAttributeName = params.getParameter(SolrConfig.PARAM_ORIGINALSIZEFIELD); if (originalSizeAttributeName == null || originalSizeAttributeName.length() == 0) originalSizeAttributeName = null; - + modifiedDateAttributeName = params.getParameter(SolrConfig.PARAM_MODIFIEDDATEFIELD); if (modifiedDateAttributeName == null || modifiedDateAttributeName.length() == 0) modifiedDateAttributeName = null; @@ -229,7 +218,7 @@ public class SolrConnector extends org.a createdDateAttributeName = params.getParameter(SolrConfig.PARAM_CREATEDDATEFIELD); if (createdDateAttributeName == null || createdDateAttributeName.length() == 0) createdDateAttributeName = null; - + indexedDateAttributeName = params.getParameter(SolrConfig.PARAM_INDEXEDDATEFIELD); if (indexedDateAttributeName == null || indexedDateAttributeName.length() == 0) indexedDateAttributeName = null; @@ -245,8 +234,8 @@ public class SolrConnector extends org.a contentAttributeName = params.getParameter(SolrConfig.PARAM_CONTENTFIELD); if (contentAttributeName == null || contentAttributeName.length() == 0) contentAttributeName = null; - - String useExtractUpdateHandlerValue = params.getParameter(SolrConfig.PARAM_EXTRACTUPDATE); + + final String useExtractUpdateHandlerValue = params.getParameter(SolrConfig.PARAM_EXTRACTUPDATE); if (useExtractUpdateHandlerValue == null || useExtractUpdateHandlerValue.length() == 0) useExtractUpdateHandler = true; else @@ -257,80 +246,70 @@ public class SolrConnector extends org.a String commits = params.getParameter(SolrConfig.PARAM_COMMITS); if (commits == null || commits.length() == 0) commits = "true"; - + doCommits = commits.equals("true"); - + String commitWithin = params.getParameter(SolrConfig.PARAM_COMMITWITHIN); if (commitWithin == null || commitWithin.length() == 0) commitWithin = null; - - String docMax = params.getParameter(SolrConfig.PARAM_MAXLENGTH); + + final String docMax = params.getParameter(SolrConfig.PARAM_MAXLENGTH); if (docMax == null || docMax.length() == 0) maxDocumentLength = null; else maxDocumentLength = new Long(docMax); if (maxDocumentLength == null && !useExtractUpdateHandler) throw new ManifoldCFException("Maximum document length required for non-extract-update indexing"); - + includedMimeTypesString = params.getParameter(SolrConfig.PARAM_INCLUDEDMIMETYPES); - if (includedMimeTypesString == null || includedMimeTypesString.length() == 0) - { + if (includedMimeTypesString == null || includedMimeTypesString.length() == 0) { includedMimeTypesString = null; includedMimeTypes = null; - } - else - { + } else { // Parse the included mime types includedMimeTypes = parseMimeTypes(includedMimeTypesString); - if (includedMimeTypes.size() == 0) - { + if (includedMimeTypes.size() == 0) { includedMimeTypesString = null; includedMimeTypes = null; } } excludedMimeTypesString = params.getParameter(SolrConfig.PARAM_EXCLUDEDMIMETYPES); - if (excludedMimeTypesString == null || excludedMimeTypesString.length() == 0) - { + if (excludedMimeTypesString == null || excludedMimeTypesString.length() == 0) { excludedMimeTypesString = null; excludedMimeTypes = null; - } - else - { + } else { // Parse the included mime types excludedMimeTypes = parseMimeTypes(excludedMimeTypesString); - if (excludedMimeTypes.size() == 0) - { + if (excludedMimeTypes.size() == 0) { excludedMimeTypesString = null; excludedMimeTypes = null; } } - // Now, initialize Solr-j String solrType = params.getParameter(SolrConfig.PARAM_SOLR_TYPE); if (solrType == null) solrType = SolrConfig.SOLR_TYPE_STANDARD; - if (solrType.equals(SolrConfig.SOLR_TYPE_STANDARD)) - { - String userID = params.getParameter(SolrConfig.PARAM_USERID); - String password = params.getObfuscatedParameter(SolrConfig.PARAM_PASSWORD); - String realm = params.getParameter(SolrConfig.PARAM_REALM); - String keystoreData = params.getParameter(SolrConfig.PARAM_KEYSTORE); + if (solrType.equals(SolrConfig.SOLR_TYPE_STANDARD)) { + final String userID = params.getParameter(SolrConfig.PARAM_USERID); + final String password = params.getObfuscatedParameter(SolrConfig.PARAM_PASSWORD); + final String realm = params.getParameter(SolrConfig.PARAM_REALM); + final String keystoreData = params.getParameter(SolrConfig.PARAM_KEYSTORE); IKeystoreManager keystoreManager; if (keystoreData != null) - keystoreManager = KeystoreManagerFactory.make("",keystoreData); + keystoreManager = KeystoreManagerFactory.make("", keystoreData); else keystoreManager = null; - String protocol = params.getParameter(SolrConfig.PARAM_PROTOCOL); + final String protocol = params.getParameter(SolrConfig.PARAM_PROTOCOL); if (protocol == null || protocol.length() == 0) - throw new ManifoldCFException("Missing parameter: "+SolrConfig.PARAM_PROTOCOL); + throw new ManifoldCFException("Missing parameter: " + SolrConfig.PARAM_PROTOCOL); - String server = params.getParameter(SolrConfig.PARAM_SERVER); + final String server = params.getParameter(SolrConfig.PARAM_SERVER); if (server == null || server.length() == 0) - throw new ManifoldCFException("Missing parameter: "+SolrConfig.PARAM_SERVER); + throw new ManifoldCFException("Missing parameter: " + SolrConfig.PARAM_SERVER); String port = params.getParameter(SolrConfig.PARAM_PORT); if (port == null || port.length() == 0) @@ -351,52 +330,33 @@ public class SolrConnector extends org.a String connectTimeoutString = params.getParameter(SolrConfig.PARAM_CONNECTION_TIMEOUT); if (connectTimeoutString == null) connectTimeoutString = "60"; - + collectionName = null; - - try - { - int socketTimeout = Integer.parseInt(socketTimeoutString) * 1000; - int connectTimeout = Integer.parseInt(connectTimeoutString) * 1000; - - poster = new HttpPoster(protocol,server,Integer.parseInt(port),webapp,core, - connectTimeout,socketTimeout, - updatePath,removePath,statusPath,realm,userID,password, - allowAttributeName,denyAttributeName,idAttributeName, - originalSizeAttributeName,modifiedDateAttributeName,createdDateAttributeName,indexedDateAttributeName, - fileNameAttributeName,mimeTypeAttributeName,contentAttributeName, - keystoreManager,maxDocumentLength,commitWithin,useExtractUpdateHandler, - includedMimeTypes,excludedMimeTypes, - allowCompression); - - } - catch (NumberFormatException e) - { + + try { + final int socketTimeout = Integer.parseInt(socketTimeoutString) * 1000; + final int connectTimeout = Integer.parseInt(connectTimeoutString) * 1000; + + poster = new HttpPoster(protocol, server, Integer.parseInt(port), webapp, core, connectTimeout, socketTimeout, updatePath, removePath, statusPath, realm, userID, password, allowAttributeName, denyAttributeName, idAttributeName, + originalSizeAttributeName, modifiedDateAttributeName, createdDateAttributeName, indexedDateAttributeName, fileNameAttributeName, mimeTypeAttributeName, contentAttributeName, keystoreManager, maxDocumentLength, commitWithin, + useExtractUpdateHandler, includedMimeTypes, excludedMimeTypes, allowCompression); + + } catch (final NumberFormatException e) { throw new ManifoldCFException(e.getMessage()); } - } - else if (solrType.equals(SolrConfig.SOLR_TYPE_SOLRCLOUD)) - { - StringBuilder zookeeperString = new StringBuilder(); + } else if (solrType.equals(SolrConfig.SOLR_TYPE_SOLRCLOUD)) { + final List<String> zookeeperHosts = new ArrayList<>(); // Pull together the zookeeper string describing the zookeeper nodes - for (int i = 0; i < params.getChildCount(); i++) - { - ConfigurationNode cn = params.getChild(i); - if (cn.getType().equals(SolrConfig.NODE_ZOOKEEPER)) - { - if (zookeeperString.length() > 0) - zookeeperString.append(","); - zookeeperString.append(cn.getAttributeValue(SolrConfig.ATTR_HOST)).append(":").append(cn.getAttributeValue(SolrConfig.ATTR_PORT)); + for (int i = 0; i < params.getChildCount(); i++) { + final ConfigurationNode cn = params.getChild(i); + if (cn.getType().equals(SolrConfig.NODE_ZOOKEEPER)) { + zookeeperHosts.add(cn.getAttributeValue(SolrConfig.ATTR_HOST) + ":" + cn.getAttributeValue(SolrConfig.ATTR_PORT)); } } - + String znodePath = params.getParameter(SolrConfig.PARAM_ZOOKEEPER_ZNODE_PATH); - if (znodePath == null) - znodePath = ""; - - String zookeeperHost = zookeeperString.toString() + znodePath; - + // Get collection String collection = params.getParameter(SolrConfig.PARAM_COLLECTION); if (collection == null) @@ -404,59 +364,43 @@ public class SolrConnector extends org.a collectionName = collection; // Pick up timeouts - String zkClientTimeoutString = params.getParameter(SolrConfig.PARAM_ZOOKEEPER_CLIENT_TIMEOUT); - if (zkClientTimeoutString == null) - zkClientTimeoutString = "60"; - String zkConnectTimeoutString = params.getParameter(SolrConfig.PARAM_ZOOKEEPER_CONNECT_TIMEOUT); - if (zkConnectTimeoutString == null) - zkConnectTimeoutString = "60"; - + String zkSocketTimeoutString = params.getParameter(SolrConfig.PARAM_ZOOKEEPER_SOCKET_TIMEOUT); + if (zkSocketTimeoutString == null) + zkSocketTimeoutString = "60"; + String zkConnectionTimeoutString = params.getParameter(SolrConfig.PARAM_ZOOKEEPER_CONNECTION_TIMEOUT); + if (zkConnectionTimeoutString == null) + zkConnectionTimeoutString = "60"; + // Create an httpposter - try - { - int zkClientTimeout = Integer.parseInt(zkClientTimeoutString) * 1000; - int zkConnectTimeout = Integer.parseInt(zkConnectTimeoutString) * 1000; - - poster = new HttpPoster(zookeeperHost,collection, - zkClientTimeout,zkConnectTimeout, - updatePath,removePath,statusPath, - allowAttributeName,denyAttributeName,idAttributeName, - originalSizeAttributeName,modifiedDateAttributeName,createdDateAttributeName,indexedDateAttributeName, - fileNameAttributeName,mimeTypeAttributeName,contentAttributeName, - maxDocumentLength,commitWithin,useExtractUpdateHandler, - includedMimeTypes,excludedMimeTypes, - allowCompression); - - } - catch (NumberFormatException e) - { + try { + final int zkClientTimeout = Integer.parseInt(zkSocketTimeoutString) * 1000; + final int zkConnectTimeout = Integer.parseInt(zkConnectionTimeoutString) * 1000; + + poster = new HttpPoster(zookeeperHosts, znodePath, collection, zkClientTimeout, zkConnectTimeout, updatePath, removePath, statusPath, allowAttributeName, denyAttributeName, idAttributeName, originalSizeAttributeName, + modifiedDateAttributeName, createdDateAttributeName, indexedDateAttributeName, fileNameAttributeName, mimeTypeAttributeName, contentAttributeName, maxDocumentLength, commitWithin, useExtractUpdateHandler, includedMimeTypes, + excludedMimeTypes, allowCompression); + + } catch (final NumberFormatException e) { throw new ManifoldCFException(e.getMessage()); } - } - else - throw new ManifoldCFException("Illegal value for parameter '"+SolrConfig.PARAM_SOLR_TYPE+"': '"+solrType+"'"); - + } else + throw new ManifoldCFException("Illegal value for parameter '" + SolrConfig.PARAM_SOLR_TYPE + "': '" + solrType + "'"); + } expirationTime = System.currentTimeMillis() + EXPIRATION_INTERVAL; } /** Parse a mime type field into individual mime types in a hash */ - protected static Set<String> parseMimeTypes(final String mimeTypes) - throws ManifoldCFException - { - Set<String> rval = new HashSet<>(); - try - { - java.io.Reader str = new java.io.StringReader(mimeTypes); - try - { - java.io.BufferedReader is = new java.io.BufferedReader(str); - try - { - while (true) - { - String nextString = is.readLine(); + protected static Set<String> parseMimeTypes(final String mimeTypes) throws ManifoldCFException { + final Set<String> rval = new HashSet<>(); + try { + final java.io.Reader str = new java.io.StringReader(mimeTypes); + try { + final java.io.BufferedReader is = new java.io.BufferedReader(str); + try { + while (true) { + final String nextString = is.readLine(); if (nextString == null) break; if (nextString.length() == 0) @@ -464,497 +408,280 @@ public class SolrConnector extends org.a rval.add(nextString.toLowerCase(Locale.ROOT)); } return rval; - } - finally - { + } finally { is.close(); } - } - finally - { + } finally { str.close(); } - } - catch (java.io.IOException e) - { - throw new ManifoldCFException("IO error: "+e.getMessage(),e); + } catch (final java.io.IOException e) { + throw new ManifoldCFException("IO error: " + e.getMessage(), e); } } - /** Test the connection. Returns a string describing the connection integrity. - *@return the connection's status as a displayable string. - */ + /** + * Test the connection. Returns a string describing the connection integrity. + * + * @return the connection's status as a displayable string. + */ @Override - public String check() - throws ManifoldCFException - { - try - { + public String check() throws ManifoldCFException { + try { getSession(); poster.checkPost(); return super.check(); - } - catch (ServiceInterruption e) - { - return "Transient error: "+e.getMessage(); + } catch (final ServiceInterruption e) { + return "Transient error: " + e.getMessage(); } } - /** Get an output version string, given an output specification. The output version string is used to uniquely describe the pertinent details of - * the output specification and the configuration, to allow the Connector Framework to determine whether a document will need to be output again. - * Note that the contents of the document cannot be considered by this method, and that a different version string (defined in IRepositoryConnector) - * is used to describe the version of the actual document. - * - * This method presumes that the connector object has been configured, and it is thus able to communicate with the output data store should that be - * necessary. - *@param spec is the current output specification for the job that is doing the crawling. - *@return a string, of unlimited length, which uniquely describes output configuration and specification in such a way that if two such strings are equal, - * the document will not need to be sent again to the output data store. - */ + /** + * Get an output version string, given an output specification. The output version string is used to uniquely describe the pertinent details of the output specification and the configuration, to + * allow the Connector Framework to determine whether a document will need to be output again. Note that the contents of the document cannot be considered by this method, and that a different + * version string (defined in IRepositoryConnector) is used to describe the version of the actual document. + * + * This method presumes that the connector object has been configured, and it is thus able to communicate with the output data store should that be necessary. + * + * @param spec + * is the current output specification for the job that is doing the crawling. + * @return a string, of unlimited length, which uniquely describes output configuration and specification in such a way that if two such strings are equal, the document will not need to be sent + * again to the output data store. + */ @Override - public VersionContext getPipelineDescription(Specification spec) - throws ManifoldCFException, ServiceInterruption - { + public VersionContext getPipelineDescription(final Specification spec) throws ManifoldCFException, ServiceInterruption { getSession(); - SpecPacker sp = new SpecPacker(spec); - return new VersionContext(sp.toPackedString(),params,spec); + final SpecPacker sp = new SpecPacker(spec); + return new VersionContext(sp.toPackedString(), params, spec); } - /** Detect if a mime type is indexable or not. This method is used by participating repository connectors to pre-filter the number of - * unusable documents that will be passed to this output connector. - *@param outputDescription is the document's output version. - *@param mimeType is the mime type of the document. - *@return true if the mime type is indexable by this connector. - */ + /** + * Detect if a mime type is indexable or not. This method is used by participating repository connectors to pre-filter the number of unusable documents that will be passed to this output connector. + * + * @param outputDescription + * is the document's output version. + * @param mimeType + * is the mime type of the document. + * @return true if the mime type is indexable by this connector. + */ @Override - public boolean checkMimeTypeIndexable(VersionContext outputDescription, String mimeType, IOutputCheckActivity activities) - throws ManifoldCFException, ServiceInterruption - { + public boolean checkMimeTypeIndexable(final VersionContext outputDescription, final String mimeType, final IOutputCheckActivity activities) throws ManifoldCFException, ServiceInterruption { getSession(); return HttpPoster.checkMimeTypeIndexable(mimeType, useExtractUpdateHandler, includedMimeTypes, excludedMimeTypes); } - /** Pre-determine whether a document's length is indexable by this connector. This method is used by participating repository connectors - * to help filter out documents that are too long to be indexable. - *@param outputDescription is the document's output version. - *@param length is the length of the document. - *@return true if the file is indexable. - */ + /** + * Pre-determine whether a document's length is indexable by this connector. This method is used by participating repository connectors to help filter out documents that are too long to be + * indexable. + * + * @param outputDescription + * is the document's output version. + * @param length + * is the length of the document. + * @return true if the file is indexable. + */ @Override - public boolean checkLengthIndexable(VersionContext outputDescription, long length, IOutputCheckActivity activities) - throws ManifoldCFException, ServiceInterruption - { + public boolean checkLengthIndexable(final VersionContext outputDescription, final long length, final IOutputCheckActivity activities) throws ManifoldCFException, ServiceInterruption { getSession(); if (maxDocumentLength != null && length > maxDocumentLength.longValue()) return false; return true; } - /** Add (or replace) a document in the output data store using the connector. - * This method presumes that the connector object has been configured, and it is thus able to communicate with the output data store should that be - * necessary. - *@param documentURI is the URI of the document. The URI is presumed to be the unique identifier which the output data store will use to process - * and serve the document. This URI is constructed by the repository connector which fetches the document, and is thus universal across all output connectors. - *@param pipelineDescription includes the description string that was constructed for this document by the getOutputDescription() method. - *@param document is the document data to be processed (handed to the output data store). - *@param authorityNameString is the name of the authority responsible for authorizing any access tokens passed in with the repository document. May be null. - *@param activities is the handle to an object that the implementer of a pipeline connector may use to perform operations, such as logging processing activity, - * or sending a modified document to the next stage in the pipeline. - *@return the document status (accepted or permanently rejected). - *@throws IOException only if there's a stream error reading the document data. - */ + /** + * Add (or replace) a document in the output data store using the connector. This method presumes that the connector object has been configured, and it is thus able to communicate with the output + * data store should that be necessary. + * + * @param documentURI + * is the URI of the document. The URI is presumed to be the unique identifier which the output data store will use to process and serve the document. This URI is constructed by the + * repository connector which fetches the document, and is thus universal across all output connectors. + * @param pipelineDescription + * includes the description string that was constructed for this document by the getOutputDescription() method. + * @param document + * is the document data to be processed (handed to the output data store). + * @param authorityNameString + * is the name of the authority responsible for authorizing any access tokens passed in with the repository document. May be null. + * @param activities + * is the handle to an object that the implementer of a pipeline connector may use to perform operations, such as logging processing activity, or sending a modified document to the next + * stage in the pipeline. + * @return the document status (accepted or permanently rejected). + * @throws IOException + * only if there's a stream error reading the document data. + */ @Override - public int addOrReplaceDocumentWithException(String documentURI, VersionContext pipelineDescription, RepositoryDocument document, String authorityNameString, IOutputAddActivity activities) - throws ManifoldCFException, ServiceInterruption, IOException - { - SpecPacker sp = new SpecPacker(pipelineDescription.getSpecification()); + public int addOrReplaceDocumentWithException(final String documentURI, final VersionContext pipelineDescription, final RepositoryDocument document, final String authorityNameString, final IOutputAddActivity activities) + throws ManifoldCFException, ServiceInterruption, IOException { + final SpecPacker sp = new SpecPacker(pipelineDescription.getSpecification()); // Establish a session getSession(); // Now, go off and call the ingest API. - if (poster.indexPost(documentURI,document,sp.getArgs(),authorityNameString,activities)) + if (poster.indexPost(documentURI, document, sp.getArgs(), authorityNameString, activities)) return DOCUMENTSTATUS_ACCEPTED; return DOCUMENTSTATUS_REJECTED; } - /** Remove a document using the connector. - * Note that the last outputDescription is included, since it may be necessary for the connector to use such information to know how to properly remove the document. - *@param documentURI is the URI of the document. The URI is presumed to be the unique identifier which the output data store will use to process - * and serve the document. This URI is constructed by the repository connector which fetches the document, and is thus universal across all output connectors. - *@param outputDescription is the last description string that was constructed for this document by the getOutputDescription() method above. - *@param activities is the handle to an object that the implementer of an output connector may use to perform operations, such as logging processing activity. - */ + /** + * Remove a document using the connector. Note that the last outputDescription is included, since it may be necessary for the connector to use such information to know how to properly remove the + * document. + * + * @param documentURI + * is the URI of the document. The URI is presumed to be the unique identifier which the output data store will use to process and serve the document. This URI is constructed by the + * repository connector which fetches the document, and is thus universal across all output connectors. + * @param outputDescription + * is the last description string that was constructed for this document by the getOutputDescription() method above. + * @param activities + * is the handle to an object that the implementer of an output connector may use to perform operations, such as logging processing activity. + */ @Override - public void removeDocument(String documentURI, String outputDescription, IOutputRemoveActivity activities) - throws ManifoldCFException, ServiceInterruption - { + public void removeDocument(final String documentURI, final String outputDescription, final IOutputRemoveActivity activities) throws ManifoldCFException, ServiceInterruption { // Establish a session getSession(); - poster.deletePost(documentURI,activities); + poster.deletePost(documentURI, activities); } - /** Notify the connector of a completed job. - * This is meant to allow the connector to flush any internal data structures it has been keeping around, or to tell the output repository that this - * is a good time to synchronize things. It is called whenever a job is either completed or aborted. - *@param activities is the handle to an object that the implementer of an output connector may use to perform operations, such as logging processing activity. - */ + /** + * Notify the connector of a completed job. This is meant to allow the connector to flush any internal data structures it has been keeping around, or to tell the output repository that this is a + * good time to synchronize things. It is called whenever a job is either completed or aborted. + * + * @param activities + * is the handle to an object that the implementer of an output connector may use to perform operations, such as logging processing activity. + */ @Override - public void noteJobComplete(IOutputNotifyActivity activities) - throws ManifoldCFException, ServiceInterruption - { + public void noteJobComplete(final IOutputNotifyActivity activities) throws ManifoldCFException, ServiceInterruption { // Establish a session getSession(); - + // Do a commit post - if (doCommits) - { + if (doCommits) { poster.commitPost(); } } // UI support methods. // - // These support methods come in two varieties. The first bunch is involved in setting up connection configuration information. The second bunch - // is involved in presenting and editing output specification information for a job. The two kinds of methods are accordingly treated differently, - // in that the first bunch cannot assume that the current connector object is connected, while the second bunch can. That is why the first bunch + // These support methods come in two varieties. The first bunch is involved in setting up connection configuration information. The second bunch + // is involved in presenting and editing output specification information for a job. The two kinds of methods are accordingly treated differently, + // in that the first bunch cannot assume that the current connector object is connected, while the second bunch can. That is why the first bunch // receives a thread context argument for all UI methods, while the second bunch does not need one (since it has already been applied via the connect() // method, above). - - /** Output the configuration header section. - * This method is called in the head section of the connector's configuration page. Its purpose is to add the required tabs to the list, and to output any - * javascript methods that might be needed by the configuration editing HTML. - *@param threadContext is the local thread context. - *@param out is the output to which any HTML should be sent. - *@param parameters are the configuration parameters, as they currently exist, for this connection being configured. - *@param tabsArray is an array of tab names. Add to this array any tab names that are specific to the connector. - */ + + /** + * Output the configuration header section. This method is called in the head section of the connector's configuration page. Its purpose is to add the required tabs to the list, and to output any + * javascript methods that might be needed by the configuration editing HTML. + * + * @param threadContext + * is the local thread context. + * @param out + * is the output to which any HTML should be sent. + * @param parameters + * are the configuration parameters, as they currently exist, for this connection being configured. + * @param tabsArray + * is an array of tab names. Add to this array any tab names that are specific to the connector. + */ @Override - public void outputConfigurationHeader(IThreadContext threadContext, IHTTPOutput out, - Locale locale, ConfigParams parameters, List<String> tabsArray) - throws ManifoldCFException, IOException - { - tabsArray.add(Messages.getString(locale,"SolrConnector.SolrType")); - tabsArray.add(Messages.getString(locale,"SolrConnector.Server")); - tabsArray.add(Messages.getString(locale,"SolrConnector.Zookeeper")); - tabsArray.add(Messages.getString(locale,"SolrConnector.Paths")); - tabsArray.add(Messages.getString(locale,"SolrConnector.Schema")); - tabsArray.add(Messages.getString(locale,"SolrConnector.Arguments")); - tabsArray.add(Messages.getString(locale,"SolrConnector.Documents")); - tabsArray.add(Messages.getString(locale,"SolrConnector.Commits")); - - out.print( -"<script type=\"text/javascript\">\n"+ -"<!--\n"+ -"function SolrDeleteCertificate(aliasName)\n"+ -"{\n"+ -" editconnection.solrkeystorealias.value = aliasName;\n"+ -" editconnection.configop.value = \"Delete\";\n"+ -" postForm();\n"+ -"}\n"+ -"\n"+ -"function SolrAddCertificate()\n"+ -"{\n"+ -" if (editconnection.solrcertificate.value == \"\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.ChooseACertificateFile")+"\");\n"+ -" editconnection.solrcertificate.focus();\n"+ -" }\n"+ -" else\n"+ -" {\n"+ -" editconnection.configop.value = \"Add\";\n"+ -" postForm();\n"+ -" }\n"+ -"}\n"+ -"\n"+ -"function checkConfig()\n"+ -"{\n"+ -" if (editconnection.servername.value == \"\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.PleaseSupplyAValidSolrServerName")+"\");\n"+ -" editconnection.servername.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.serverport.value != \"\" && !isInteger(editconnection.serverport.value))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.SolrServerPortMustBeAValidInteger")+"\");\n"+ -" editconnection.serverport.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.webappname.value != \"\" && editconnection.webappname.value.indexOf(\"/\") != -1)\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.WebApplicationNameCannotHaveCharacters")+"\");\n"+ -" editconnection.webappname.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.core.value != \"\" && editconnection.core.value.indexOf(\"/\") != -1)\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.CoreNameCannotHaveCharacters")+"\");\n"+ -" editconnection.core.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.webappname.value == \"\" && editconnection.core.value != \"\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.WebApplicationMustBeSpecifiedIfCoreIsSpecified")+"\");\n"+ -" editconnection.webappname.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (!isInteger(editconnection.connectiontimeout.value))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.ConnectionTimeoutMustBeInteger")+"\");\n"+ -" editconnection.connectiontimeout.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (!isInteger(editconnection.sockettimeout.value))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.SocketTimeoutMustBeInteger")+"\");\n"+ -" editconnection.sockettimeout.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.updatepath.value != \"\" && editconnection.updatepath.value.substring(0,1) != \"/\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.UpdatePathMustStartWithACharacter")+"\");\n"+ -" editconnection.updatepath.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.removepath.value != \"\" && editconnection.removepath.value.substring(0,1) != \"/\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.RemovePathMustStartWithACharacter")+"\");\n"+ -" editconnection.removepath.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.statuspath.value != \"\" && editconnection.statuspath.value.substring(0,1) != \"/\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.StatusPathMustStartWithACharacter")+"\");\n"+ -" editconnection.statuspath.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.maxdocumentlength.value != \"\" && !isInteger(editconnection.maxdocumentlength.value))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.MaximumDocumentLengthMustBAnInteger")+"\");\n"+ -" editconnection.maxdocumentlength.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.commitwithin.value != \"\" && !isInteger(editconnection.commitwithin.value))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.CommitWithinValueMustBeAnInteger")+"\");\n"+ -" editconnection.commitwithin.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.znodepath.value != \"\" && editconnection.znodepath.value.substring(0,1) != \"/\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.ZnodePathMustStartWithACharacter")+"\");\n"+ -" editconnection.znodepath.focus();\n"+ -" return false;\n"+ -" }\n"+ -" return true;\n"+ -"}\n"+ -"\n"+ -"function checkConfigForSave()\n"+ -"{\n"+ -" if (editconnection.servername.value == \"\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.PleaseSupplyAValidSolrServerName")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Server")+"\");\n"+ -" editconnection.servername.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.serverport.value != \"\" && !isInteger(editconnection.serverport.value))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.SolrServerPortMustBeAValidInteger")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Server")+"\");\n"+ -" editconnection.serverport.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.webappname.value != \"\" && editconnection.webappname.value.indexOf(\"/\") != -1)\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.WebApplicationNameCannotHaveCharacters")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Server")+"\");\n"+ -" editconnection.webappname.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.core.value == \"\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.PleaseSupplySolrCoreName")+"\");\n"+ -" editconnection.core.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.core.value != \"\" && editconnection.core.value.indexOf(\"/\") != -1)\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.CoreNameCannotHaveCharacters")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Server")+"\");\n"+ -" editconnection.core.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.webappname.value == \"\" && editconnection.core.value != \"\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.WebApplicationMustBeSpecifiedIfCoreIsSpecified")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Server")+"\");\n"+ -" editconnection.webappname.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (!isInteger(editconnection.connectiontimeout.value))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.ConnectionTimeoutMustBeInteger")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Server")+"\");\n"+ -" editconnection.connectiontimeout.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (!isInteger(editconnection.sockettimeout.value))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.SocketTimeoutMustBeInteger")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Server")+"\");\n"+ -" editconnection.sockettimeout.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.updatepath.value != \"\" && editconnection.updatepath.value.substring(0,1) != \"/\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.UpdatePathMustStartWithACharacter")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Paths")+"\");\n"+ -" editconnection.updatepath.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.removepath.value != \"\" && editconnection.removepath.value.substring(0,1) != \"/\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.RemovePathMustStartWithACharacter")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Paths")+"\");\n"+ -" editconnection.removepath.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.statuspath.value != \"\" && editconnection.statuspath.value.substring(0,1) != \"/\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.StatusPathMustStartWithACharacter")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Paths")+"\");\n"+ -" editconnection.statuspath.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.maxdocumentlength.value != \"\" && !isInteger(editconnection.maxdocumentlength.value))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.MaximumDocumentLengthMustBeAnInteger")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Documents")+"\");\n"+ -" editconnection.maxdocumentlength.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.maxdocumentlength.value == \"\" && ((editconnection.extractupdatecheckbox.value == \"true\" && editconnection.extractupdate.checked == false) || (editconnection.extractupdatecheckbox.value != \"true\" && editconnection.extractupdate.value != \"true\")))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.MaximumDocumentLengthRequiredUnlessExtractingUpdateHandler")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Documents")+"\");\n"+ -" editconnection.maxdocumentlength.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.contentfield.value == \"\" && ((editconnection.extractupdatecheckbox.value == \"true\" && editconnection.extractupdate.checked == false) || (editconnection.extractupdatecheckbox.value != \"true\" && editconnection.extractupdate.value != \"true\")))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.ContentFieldNameRequiredUnlessExtractingUpdateHandler")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Schema")+"\");\n"+ -" editconnection.contentfield.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.commitwithin.value != \"\" && !isInteger(editconnection.commitwithin.value))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.CommitWithinValueMustBeAnInteger")+"\");\n"+ -" SelectTab(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.Commits")+"\");\n"+ -" editconnection.commitwithin.focus();\n"+ -" return false;\n"+ -" }\n"+ -" if (editconnection.znodepath.value != \"\" && editconnection.znodepath.value.substring(0,1) != \"/\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.ZnodePathMustStartWithACharacter")+"\");\n"+ -" editconnection.znodepath.focus();\n"+ -" return false;\n"+ -" }\n"+ -" return true;\n"+ -"}\n"+ -"\n"+ -"function deleteZookeeperHost(i)\n"+ -"{\n"+ -" // Set the operation\n"+ -" eval(\"editconnection.op_zookeeper_\"+i+\".value=\\\"Delete\\\"\");\n"+ -" // Submit\n"+ -" if (editconnection.count_zookeeper.value==i)\n"+ -" postFormSetAnchor(\"zookeeper\");\n"+ -" else\n"+ -" postFormSetAnchor(\"zookeeper_\"+i)\n"+ -" // Undo, so we won't get two deletes next time\n"+ -" eval(\"editconnection.op_zookeeper_\"+i+\".value=\\\"Continue\\\"\");\n"+ -"}\n"+ -"\n"+ -"function addZookeeperHost()\n"+ -"{\n"+ -" if (editconnection.host_zookeeper.value == \"\")\n"+ -" {\n"+ -" alert(\"" + Messages.getBodyJavascriptString(locale,"SolrConnector.ZookeeperHostCannotBeNull")+"\");\n"+ -" editconnection.host_zookeeper.focus();\n"+ -" return;\n"+ -" }\n"+ -" if (editconnection.port_zookeeper.value == \"\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.ZookeeperPortCannotBeNull")+"\");\n"+ -" editconnection.port_zookeeper.focus();\n"+ -" return;\n"+ -" }\n"+ -" if (!isInteger(editconnection.port_zookeeper.value))\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.ZookeeperPortMustBeAnInteger")+"\");\n"+ -" editconnection.port_zookeeper.focus();\n"+ -" return;\n"+ -" }\n"+ -" editconnection.op_zookeeper.value=\"Add\";\n"+ -" postFormSetAnchor(\"zookeeper\");\n"+ -"}\n"+ -"\n"+ -"function deleteArgument(i)\n"+ -"{\n"+ -" // Set the operation\n"+ -" eval(\"editconnection.argument_\"+i+\"_op.value=\\\"Delete\\\"\");\n"+ -" // Submit\n"+ -" if (editconnection.argument_count.value==i)\n"+ -" postFormSetAnchor(\"argument\");\n"+ -" else\n"+ -" postFormSetAnchor(\"argument_\"+i)\n"+ -" // Undo, so we won't get two deletes next time\n"+ -" eval(\"editconnection.argument_\"+i+\"_op.value=\\\"Continue\\\"\");\n"+ -"}\n"+ -"\n"+ -"function addArgument()\n"+ -"{\n"+ -" if (editconnection.argument_name.value == \"\")\n"+ -" {\n"+ -" alert(\""+Messages.getBodyJavascriptString(locale,"SolrConnector.ArgumentNameCannotBeAnEmptyString")+"\");\n"+ -" editconnection.argument_name.focus();\n"+ -" return;\n"+ -" }\n"+ -" editconnection.argument_op.value=\"Add\";\n"+ -" postFormSetAnchor(\"argument\");\n"+ -"}\n"+ -"\n"+ -"//-->\n"+ -"</script>\n" - ); - - } - - /** Output the configuration body section. - * This method is called in the body section of the connector's configuration page. Its purpose is to present the required form elements for editing. - * The coder can presume that the HTML that is output from this configuration will be within appropriate <html>, <body>, and <form> tags. The name of the - * form is "editconnection". - *@param threadContext is the local thread context. - *@param out is the output to which any HTML should be sent. - *@param parameters are the configuration parameters, as they currently exist, for this connection being configured. - *@param tabName is the current tab name. - */ + public void outputConfigurationHeader(final IThreadContext threadContext, final IHTTPOutput out, final Locale locale, final ConfigParams parameters, final List<String> tabsArray) throws ManifoldCFException, IOException { + tabsArray.add(Messages.getString(locale, "SolrConnector.SolrType")); + tabsArray.add(Messages.getString(locale, "SolrConnector.Server")); + tabsArray.add(Messages.getString(locale, "SolrConnector.Zookeeper")); + tabsArray.add(Messages.getString(locale, "SolrConnector.Paths")); + tabsArray.add(Messages.getString(locale, "SolrConnector.Schema")); + tabsArray.add(Messages.getString(locale, "SolrConnector.Arguments")); + tabsArray.add(Messages.getString(locale, "SolrConnector.Documents")); + tabsArray.add(Messages.getString(locale, "SolrConnector.Commits")); + + out.print("<script type=\"text/javascript\">\n" + "<!--\n" + "function SolrDeleteCertificate(aliasName)\n" + "{\n" + " editconnection.solrkeystorealias.value = aliasName;\n" + " editconnection.configop.value = \"Delete\";\n" + " postForm();\n" + + "}\n" + "\n" + "function SolrAddCertificate()\n" + "{\n" + " if (editconnection.solrcertificate.value == \"\")\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.ChooseACertificateFile") + "\");\n" + + " editconnection.solrcertificate.focus();\n" + " }\n" + " else\n" + " {\n" + " editconnection.configop.value = \"Add\";\n" + " postForm();\n" + " }\n" + "}\n" + "\n" + "function checkConfig()\n" + "{\n" + + " if (editconnection.servername.value == \"\")\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.PleaseSupplyAValidSolrServerName") + "\");\n" + " editconnection.servername.focus();\n" + + " return false;\n" + " }\n" + " if (editconnection.serverport.value != \"\" && !isInteger(editconnection.serverport.value))\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.SolrServerPortMustBeAValidInteger") + "\");\n" + " editconnection.serverport.focus();\n" + " return false;\n" + " }\n" + + " if (editconnection.webappname.value != \"\" && editconnection.webappname.value.indexOf(\"/\") != -1)\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.WebApplicationNameCannotHaveCharacters") + + "\");\n" + " editconnection.webappname.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.core.value != \"\" && editconnection.core.value.indexOf(\"/\") != -1)\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.CoreNameCannotHaveCharacters") + "\");\n" + " editconnection.core.focus();\n" + " return false;\n" + " }\n" + + " if (editconnection.webappname.value == \"\" && editconnection.core.value != \"\")\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.WebApplicationMustBeSpecifiedIfCoreIsSpecified") + "\");\n" + + " editconnection.webappname.focus();\n" + " return false;\n" + " }\n" + " if (!isInteger(editconnection.connectiontimeout.value))\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.ConnectionTimeoutMustBeInteger") + "\");\n" + " editconnection.connectiontimeout.focus();\n" + " return false;\n" + " }\n" + + " if (!isInteger(editconnection.sockettimeout.value))\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.SocketTimeoutMustBeInteger") + "\");\n" + " editconnection.sockettimeout.focus();\n" + + " return false;\n" + " }\n" + " if (editconnection.updatepath.value != \"\" && editconnection.updatepath.value.substring(0,1) != \"/\")\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.UpdatePathMustStartWithACharacter") + "\");\n" + " editconnection.updatepath.focus();\n" + " return false;\n" + " }\n" + + " if (editconnection.removepath.value != \"\" && editconnection.removepath.value.substring(0,1) != \"/\")\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.RemovePathMustStartWithACharacter") + + "\");\n" + " editconnection.removepath.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.statuspath.value != \"\" && editconnection.statuspath.value.substring(0,1) != \"/\")\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.StatusPathMustStartWithACharacter") + "\");\n" + " editconnection.statuspath.focus();\n" + " return false;\n" + " }\n" + + " if (editconnection.maxdocumentlength.value != \"\" && !isInteger(editconnection.maxdocumentlength.value))\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.MaximumDocumentLengthMustBAnInteger") + + "\");\n" + " editconnection.maxdocumentlength.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.commitwithin.value != \"\" && !isInteger(editconnection.commitwithin.value))\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.CommitWithinValueMustBeAnInteger") + "\");\n" + " editconnection.commitwithin.focus();\n" + " return false;\n" + " }\n" + + " if (editconnection.znodepath.value != \"\" && editconnection.znodepath.value.substring(0,1) != \"/\")\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.ZnodePathMustStartWithACharacter") + "\");\n" + + " editconnection.znodepath.focus();\n" + " return false;\n" + " }\n" + " return true;\n" + "}\n" + "\n" + "function checkConfigForSave()\n" + "{\n" + " if (editconnection.servername.value == \"\")\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.PleaseSupplyAValidSolrServerName") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Server") + "\");\n" + + " editconnection.servername.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.serverport.value != \"\" && !isInteger(editconnection.serverport.value))\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.SolrServerPortMustBeAValidInteger") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Server") + "\");\n" + + " editconnection.serverport.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.webappname.value != \"\" && editconnection.webappname.value.indexOf(\"/\") != -1)\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.WebApplicationNameCannotHaveCharacters") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Server") + "\");\n" + + " editconnection.webappname.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.core.value == \"\")\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.PleaseSupplySolrCoreName") + + "\");\n" + " editconnection.core.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.core.value != \"\" && editconnection.core.value.indexOf(\"/\") != -1)\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.CoreNameCannotHaveCharacters") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Server") + "\");\n" + " editconnection.core.focus();\n" + + " return false;\n" + " }\n" + " if (editconnection.webappname.value == \"\" && editconnection.core.value != \"\")\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.WebApplicationMustBeSpecifiedIfCoreIsSpecified") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Server") + "\");\n" + + " editconnection.webappname.focus();\n" + " return false;\n" + " }\n" + " if (!isInteger(editconnection.connectiontimeout.value))\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.ConnectionTimeoutMustBeInteger") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Server") + "\");\n" + + " editconnection.connectiontimeout.focus();\n" + " return false;\n" + " }\n" + " if (!isInteger(editconnection.sockettimeout.value))\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.SocketTimeoutMustBeInteger") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Server") + "\");\n" + + " editconnection.sockettimeout.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.updatepath.value != \"\" && editconnection.updatepath.value.substring(0,1) != \"/\")\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.UpdatePathMustStartWithACharacter") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Paths") + "\");\n" + + " editconnection.updatepath.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.removepath.value != \"\" && editconnection.removepath.value.substring(0,1) != \"/\")\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.RemovePathMustStartWithACharacter") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Paths") + "\");\n" + + " editconnection.removepath.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.statuspath.value != \"\" && editconnection.statuspath.value.substring(0,1) != \"/\")\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.StatusPathMustStartWithACharacter") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Paths") + "\");\n" + + " editconnection.statuspath.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.maxdocumentlength.value != \"\" && !isInteger(editconnection.maxdocumentlength.value))\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.MaximumDocumentLengthMustBeAnInteger") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Documents") + "\");\n" + + " editconnection.maxdocumentlength.focus();\n" + " return false;\n" + " }\n" + + " if (editconnection.maxdocumentlength.value == \"\" && ((editconnection.extractupdatecheckbox.value == \"true\" && editconnection.extractupdate.checked == false) || (editconnection.extractupdatecheckbox.value != \"true\" && editconnection.extractupdate.value != \"true\")))\n" + + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.MaximumDocumentLengthRequiredUnlessExtractingUpdateHandler") + "\");\n" + " SelectTab(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.Documents") + "\");\n" + " editconnection.maxdocumentlength.focus();\n" + " return false;\n" + " }\n" + + " if (editconnection.contentfield.value == \"\" && ((editconnection.extractupdatecheckbox.value == \"true\" && editconnection.extractupdate.checked == false) || (editconnection.extractupdatecheckbox.value != \"true\" && editconnection.extractupdate.value != \"true\")))\n" + + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.ContentFieldNameRequiredUnlessExtractingUpdateHandler") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Schema") + + "\");\n" + " editconnection.contentfield.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.commitwithin.value != \"\" && !isInteger(editconnection.commitwithin.value))\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.CommitWithinValueMustBeAnInteger") + "\");\n" + " SelectTab(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.Commits") + "\");\n" + + " editconnection.commitwithin.focus();\n" + " return false;\n" + " }\n" + " if (editconnection.znodepath.value != \"\" && editconnection.znodepath.value.substring(0,1) != \"/\")\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.ZnodePathMustStartWithACharacter") + "\");\n" + " editconnection.znodepath.focus();\n" + " return false;\n" + " }\n" + " return true;\n" + "}\n" + "\n" + + "function deleteZookeeperHost(i)\n" + "{\n" + " // Set the operation\n" + " eval(\"editconnection.op_zookeeper_\"+i+\".value=\\\"Delete\\\"\");\n" + " // Submit\n" + " if (editconnection.count_zookeeper.value==i)\n" + + " postFormSetAnchor(\"zookeeper\");\n" + " else\n" + " postFormSetAnchor(\"zookeeper_\"+i)\n" + " // Undo, so we won't get two deletes next time\n" + " eval(\"editconnection.op_zookeeper_\"+i+\".value=\\\"Continue\\\"\");\n" + + "}\n" + "\n" + "function addZookeeperHost()\n" + "{\n" + " if (editconnection.host_zookeeper.value == \"\")\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.ZookeeperHostCannotBeNull") + "\");\n" + + " editconnection.host_zookeeper.focus();\n" + " return;\n" + " }\n" + " if (editconnection.port_zookeeper.value == \"\")\n" + " {\n" + " alert(\"" + + Messages.getBodyJavascriptString(locale, "SolrConnector.ZookeeperPortCannotBeNull") + "\");\n" + " editconnection.port_zookeeper.focus();\n" + " return;\n" + " }\n" + " if (!isInteger(editconnection.port_zookeeper.value))\n" + + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.ZookeeperPortMustBeAnInteger") + "\");\n" + " editconnection.port_zookeeper.focus();\n" + " return;\n" + " }\n" + + " editconnection.op_zookeeper.value=\"Add\";\n" + " postFormSetAnchor(\"zookeeper\");\n" + "}\n" + "\n" + "function deleteArgument(i)\n" + "{\n" + " // Set the operation\n" + + " eval(\"editconnection.argument_\"+i+\"_op.value=\\\"Delete\\\"\");\n" + " // Submit\n" + " if (editconnection.argument_count.value==i)\n" + " postFormSetAnchor(\"argument\");\n" + " else\n" + + " postFormSetAnchor(\"argument_\"+i)\n" + " // Undo, so we won't get two deletes next time\n" + " eval(\"editconnection.argument_\"+i+\"_op.value=\\\"Continue\\\"\");\n" + "}\n" + "\n" + "function addArgument()\n" + "{\n" + + " if (editconnection.argument_name.value == \"\")\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "SolrConnector.ArgumentNameCannotBeAnEmptyString") + "\");\n" + " editconnection.argument_name.focus();\n" + + " return;\n" + " }\n" + " editconnection.argument_op.value=\"Add\";\n" + " postFormSetAnchor(\"argument\");\n" + "}\n" + "\n" + "//-->\n" + "</script>\n"); + + } + + /** + * Output the configuration body section. This method is called in the body section of the connector's configuration page. Its purpose is to present the required form elements for editing. The coder + * can presume that the HTML that is output from this configuration will be within appropriate <html>, <body>, and <form> tags. The name of the form is "editconnection". + * + * @param threadContext + * is the local thread context. + * @param out + * is the output to which any HTML should be sent. + * @param parameters + * are the configuration parameters, as they currently exist, for this connection being configured. + * @param tabName + * is the current tab name. + */ @Override - public void outputConfigurationBody(IThreadContext threadContext, IHTTPOutput out, - Locale locale, ConfigParams parameters, String tabName) - throws ManifoldCFException, IOException - { + public void outputConfigurationBody(final IThreadContext threadContext, final IHTTPOutput out, final Locale locale, final ConfigParams parameters, final String tabName) throws ManifoldCFException, IOException { String type = parameters.getParameter(SolrConfig.PARAM_SOLR_TYPE); if (type == null) type = SolrConfig.SOLR_TYPE_STANDARD; - + String protocol = parameters.getParameter(SolrConfig.PARAM_PROTOCOL); if (protocol == null) protocol = SolrConfig.PROTOCOL_TYPE_HTTP; - + String server = parameters.getParameter(SolrConfig.PARAM_SERVER); if (server == null) server = "localhost"; @@ -973,28 +700,28 @@ public class SolrConnector extends org.a String znodePath = parameters.getParameter(SolrConfig.PARAM_ZOOKEEPER_ZNODE_PATH); if (znodePath == null) - znodePath = ""; - + znodePath = ""; + String collection = parameters.getParameter(SolrConfig.PARAM_COLLECTION); if (collection == null) collection = "collection1"; - + String connectionTimeout = parameters.getParameter(SolrConfig.PARAM_CONNECTION_TIMEOUT); if (connectionTimeout == null) connectionTimeout = "60"; - + String socketTimeout = parameters.getParameter(SolrConfig.PARAM_SOCKET_TIMEOUT); if (socketTimeout == null) socketTimeout = "900"; - String zkClientTimeout = parameters.getParameter(SolrConfig.PARAM_ZOOKEEPER_CLIENT_TIMEOUT); - if (zkClientTimeout == null) - zkClientTimeout = "60"; - - String zkConnectTimeout = parameters.getParameter(SolrConfig.PARAM_ZOOKEEPER_CONNECT_TIMEOUT); - if (zkConnectTimeout == null) - zkConnectTimeout = "60"; - + String zkSocketTimeout = parameters.getParameter(SolrConfig.PARAM_ZOOKEEPER_SOCKET_TIMEOUT); + if (zkSocketTimeout == null) + zkSocketTimeout = "60"; + + String zkConnectionTimeout = parameters.getParameter(SolrConfig.PARAM_ZOOKEEPER_CONNECTION_TIMEOUT); + if (zkConnectionTimeout == null) + zkConnectionTimeout = "60"; + String updatePath = parameters.getParameter(SolrConfig.PARAM_UPDATEPATH); if (updatePath == null) updatePath = "/update/extract"; @@ -1014,11 +741,11 @@ public class SolrConnector extends org.a String originalSizeField = parameters.getParameter(SolrConfig.PARAM_ORIGINALSIZEFIELD); if (originalSizeField == null) originalSizeField = ""; - + String modifiedDateField = parameters.getParameter(SolrConfig.PARAM_MODIFIEDDATEFIELD); if (modifiedDateField == null) modifiedDateField = ""; - + String createdDateField = parameters.getParameter(SolrConfig.PARAM_CREATEDDATEFIELD); if (createdDateField == null) createdDateField = ""; @@ -1026,11 +753,11 @@ public class SolrConnector extends org.a String indexedDateField = parameters.getParameter(SolrConfig.PARAM_INDEXEDDATEFIELD); if (indexedDateField == null) indexedDateField = ""; - + String fileNameField = parameters.getParameter(SolrConfig.PARAM_FILENAMEFIELD); if (fileNameField == null) fileNameField = ""; - + String mimeTypeField = parameters.getParameter(SolrConfig.PARAM_MIMETYPEFIELD); if (mimeTypeField == null) mimeTypeField = ""; @@ -1038,7 +765,7 @@ public class SolrConnector extends org.a String contentField = parameters.getParameter(SolrConfig.PARAM_CONTENTFIELD); if (contentField == null) contentField = ""; - + String useExtractUpdate = parameters.getParameter(SolrConfig.PARAM_EXTRACTUPDATE); if (useExtractUpdate == null || useExtractUpdate.length() == 0) useExtractUpdate = "true"; @@ -1050,1281 +777,795 @@ public class SolrConnector extends org.a String userID = parameters.getParameter(SolrConfig.PARAM_USERID); if (userID == null) userID = ""; - + String password = parameters.getObfuscatedParameter(SolrConfig.PARAM_PASSWORD); if (password == null) password = ""; else password = out.mapPasswordToKey(password); - + String commits = parameters.getParameter(SolrConfig.PARAM_COMMITS); if (commits == null) commits = "true"; - + String commitWithin = parameters.getParameter(SolrConfig.PARAM_COMMITWITHIN); if (commitWithin == null) commitWithin = ""; - String solrKeystore = parameters.getParameter(SolrConfig.PARAM_KEYSTORE); + final String solrKeystore = parameters.getParameter(SolrConfig.PARAM_KEYSTORE); IKeystoreManager localKeystore; if (solrKeystore == null) localKeystore = KeystoreManagerFactory.make(""); else - localKeystore = KeystoreManagerFactory.make("",solrKeystore); + localKeystore = KeystoreManagerFactory.make("", solrKeystore); String maxLength = parameters.getParameter(SolrConfig.PARAM_MAXLENGTH); if (maxLength == null) maxLength = ""; - + String includedMimeTypes = parameters.getParameter(SolrConfig.PARAM_INCLUDEDMIMETYPES); if (includedMimeTypes == null) includedMimeTypes = ""; - + String excludedMimeTypes = parameters.getParameter(SolrConfig.PARAM_EXCLUDEDMIMETYPES); if (excludedMimeTypes == null) excludedMimeTypes = ""; - + // "SOLR type" tab - if (tabName.equals(Messages.getString(locale,"SolrConnector.SolrType"))) - { - out.print( -"<table class=\"displaytable\">\n"+ -" <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n"+ -" <tr>\n"+ -" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.SolrType2") + "</nobr></td>\n"+ -" <td class=\"value\">\n"+ -" <select name=\"solrtype\">\n"+ -" <option value=\""+SolrConfig.SOLR_TYPE_STANDARD+"\""+(type.equals(SolrConfig.SOLR_TYPE_STANDARD)?" selected=\"true\"":"")+">"+Messages.getBodyString(locale,"SolrConnector.SingleServer")+"</option>\n"+ -" <option value=\""+SolrConfig.SOLR_TYPE_SOLRCLOUD+"\""+(type.equals(SolrConfig.SOLR_TYPE_SOLRCLOUD)?" selected=\"true\"":"")+">"+Messages.getBodyString(locale,"SolrConnector.SolrCloud")+"</option>\n"+ -" </select>\n"+ -" </td>\n"+ -" </tr>\n"+ -"</table>\n" - ); - } - else - { + if (tabName.equals(Messages.getString(locale, "SolrConnector.SolrType"))) { + out.print("<table class=\"displaytable\">\n" + " <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n" + " <tr>\n" + " <td class=\"description\"><nobr>" + Messages.getBodyString(locale, "SolrConnector.SolrType2") + "</nobr></td>\n" + + " <td class=\"value\">\n" + " <select name=\"solrtype\">\n" + " <option value=\"" + SolrConfig.SOLR_TYPE_STANDARD + "\"" + (type.equals(SolrConfig.SOLR_TYPE_STANDARD) ? " selected=\"true\"" : "") + ">" + + Messages.getBodyString(locale, "SolrConnector.SingleServer") + "</option>\n" + " <option value=\"" + SolrConfig.SOLR_TYPE_SOLRCLOUD + "\"" + (type.equals(SolrConfig.SOLR_TYPE_SOLRCLOUD) ? " selected=\"true\"" : "") + ">" + + Messages.getBodyString(locale, "SolrConnector.SolrCloud") + "</option>\n" + " </select>\n" + " </td>\n" + " </tr>\n" + "</table>\n"); + } else { // Type tab hiddens - out.print( -"<input type=\"hidden\" name=\"solrtype\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(type)+"\"/>\n" - ); + out.print("<input type=\"hidden\" name=\"solrtype\" value=\"" + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(type) + "\"/>\n"); } // "Server" tab // Always pass the whole keystore as a hidden. - if (solrKeystore != null) - { - out.print( -"<input type=\"hidden\" name=\"keystoredata\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(solrKeystore)+"\"/>\n" - ); + if (solrKeystore != null) { + out.print("<input type=\"hidden\" name=\"keystoredata\" value=\"" + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(solrKeystore) + "\"/>\n"); } - out.print( -"<input name=\"configop\" type=\"hidden\" value=\"Continue\"/>\n" - ); - - if (tabName.equals(Messages.getString(locale,"SolrConnector.Server"))) - { - out.print( -"<table class=\"displaytable\">\n"+ -" <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n"+ -" <tr>\n"+ -" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.Protocol") + "</nobr></td>\n"+ -" <td class=\"value\">\n"+ -" <select name=\"serverprotocol\">\n"+ -" <option value=\""+SolrConfig.PROTOCOL_TYPE_HTTP+"\""+(protocol.equals(SolrConfig.PROTOCOL_TYPE_HTTP)?" selected=\"true\"":"")+">http</option>\n"+ -" <option value=\""+SolrConfig.PROTOCOL_TYPE_HTTPS+"\""+(protocol.equals(SolrConfig.PROTOCOL_TYPE_HTTPS)?" selected=\"true\"":"")+">https</option>\n"+ -" </select>\n"+ -" </td>\n"+ -" </tr>\n"+ -" <tr>\n"+ -" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.ServerName") + "</nobr></td>\n"+ -" <td class=\"value\">\n"+ -" <input name=\"servername\" type=\"text\" size=\"32\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(server)+"\"/>\n"+ -" </td>\n"+ -" </tr>\n"+ -" <tr>\n"+ -" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.Port") + "</nobr></td>\n"+ -" <td class=\"value\">\n"+ -" <input name=\"serverport\" type=\"text\" size=\"5\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(port)+"\"/>\n"+ -" </td>\n"+ -" </tr>\n"+ -" <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n"+ -" <tr>\n"+ -" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.WebApplicationName") + "</nobr></td>\n"+ -" <td class=\"value\">\n"+ -" <input name=\"webappname\" type=\"text\" size=\"16\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(webapp)+"\"/>\n"+ -" </td>\n"+ -" </tr>\n"+ -" <tr>\n"+ -" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.CoreName") + "</nobr></td>\n"+ -" <td class=\"value\">\n"+ -" <input name=\"core\" type=\"text\" size=\"16\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(core)+"\"/>\n"+ -" </td>\n"+ -" </tr>\n"+ -" <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n"+ -" <tr>\n"+ -" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.ConnectionTimeout") + "</nobr></td>\n"+ -" <td class=\"value\">\n"+ -" <input name=\"connectiontimeout\" type=\"text\" size=\"5\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(connectionTimeout)+"\"/>\n"+ -" </td>\n"+ -" </tr>\n"+ -" <tr>\n"+ -" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.SocketTimeout") + "</nobr></td>\n"+ -" <td class=\"value\">\n"+ -" <input name=\"sockettimeout\" type=\"text\" size=\"5\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(socketTimeout)+"\"/>\n"+ -" </td>\n"+ -" </tr>\n"+ -" <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n"+ -" <tr>\n"+ -" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.Realm") + "</nobr></td>\n"+ -" <td class=\"value\">\n"+ -" <input name=\"realm\" type=\"text\" size=\"32\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(realm)+"\"/>\n"+ -" </td>\n"+ -" </tr>\n"+ -" <tr>\n"+ -" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.UserID") + "</nobr></td>\n"+ -" <td class=\"value\">\n"+ -" <input name=\"userid\" type=\"text\" size=\"32\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(userID)+"\"/>\n"+ -" </td>\n"+ -" </tr>\n"+ -" <tr>\n"+ -" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.Password") + "</nobr></td>\n"+ -" <td class=\"value\">\n"+ -" <input type=\"password\" size=\"32\" name=\"password\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(password)+"\"/>\n"+ -" </td>\n"+ -" </tr>\n"+ -" <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"+ -" <tr>\n"+ -" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.SSLTrustCertificateList") + "</nobr></td>\n"+ -" <td class=\"value\">\n"+ -" <input type=\"hidden\" name=\"solrkeystorealias\" value=\"\"/>\n"+ -" <table class=\"displaytable\">\n" - ); + out.print("<input name=\"configop\" type=\"hidden\" value=\"Continue\"/>\n"); + + if (tabName.equals(Messages.getString(locale, "SolrConnector.Server"))) { + out.print("<table class=\"displaytable\">\n" + " <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n" + " <tr>\n" + " <td class=\"description\"><nobr>" + Messages.getBodyString(locale, "SolrConnector.Protocol") + "</nobr></td>\n" + + " <td class=\"value\">\n" + " <select name=\"serverprotocol\">\n" + " <option value=\"" + SolrConfig.PROTOCOL_TYPE_HTTP + "\"" + (protocol.equals(SolrConfig.PROTOCOL_TYPE_HTTP) ? " selected=\"true\"" : "") + + ">http</option>\n" + " <option value=\"" + SolrConfig.PROTOCOL_TYPE_HTTPS + "\"" + (protocol.equals(SolrConfig.PROTOCOL_TYPE_HTTPS) ? " selected=\"true\"" : "") + ">https</option>\n" + " </select>\n" + " </td>\n" + + " </tr>\n" + " <tr>\n" + " <td class=\"description\"><nobr>" + Messages.getBodyString(locale, "SolrConnector.ServerName") + "</nobr></td>\n" + " <td class=\"value\">\n" + + " <input name=\"servername\" type=\"text\" size=\"32\" value=\"" + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(server) + "\"/>\n" + " </td>\n" + " </tr>\n" + " <tr>\n" + " <td class=\"description\"><nobr>" + + Messages.getBodyString(locale, "SolrConnector.Port") + "</nobr></td>\n" + " <td class=\"value\">\n" + " <input name=\"serverport\" type=\"text\" size=\"5\" value=\"" + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(port) + + "\"/>\n" + " </td>\n" + " </tr>\n" + " <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n" + " <tr>\n" + " <td class=\"description\"><nobr>" + Messages.getBodyString(locale, "SolrConnector.WebApplicationName") + + "</nobr></td>\n" + " <td class=\"value\">\n" + " <input name=\"webappname\" type=\"text\" size=\"16\" value=\"" + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(webapp) + "\"/>\n" + " </td>\n" + " </tr>\n" + " <tr>\n" + + " <td class=\"description\"><nobr>" + Messages.getBodyString(locale, "SolrConnector.CoreName") + "</nobr></td>\n" + " <td class=\"value\">\n" + " <input name=\"core\" type=\"text\" size=\"16\" value=\"" + + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(core) + "\"/>\n" + " </td>\n" + " </tr>\n" + " <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n" + " <tr>\n" + " <td class=\"description\"><nobr>" + + Messages.getBodyString(locale, "SolrConnector.ConnectionTimeout") + "</nobr></td>\n" + " <td class=\"value\">\n" + " <input name=\"connectiontimeout\" type=\"text\" size=\"5\" value=\"" + + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(connectionTimeout) + "\"/>\n" + " </td>\n" + " </tr>\n" + " <tr>\n" + " <td class=\"description\"><nobr>" + Messages.getBodyString(locale, "SolrConnector.SocketTimeout") + + "</nobr></td>\n" + " <td class=\"value\">\n" + " <input name=\"sockettimeout\" type=\"text\" size=\"5\" value=\"" + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(socketTimeout) + "\"/>\n" + " </td>\n" + " </tr>\n" + + " <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n" + " <tr>\n" + " <td class=\"description\"><nobr>" + Messages.getBodyString(locale, "SolrConnector.Realm") + "</nobr></td>\n" + " <td class=\"value\">\n" + + " <input name=\"realm\" type=\"text\" size=\"32\" value=\"" + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(realm) + "\"/>\n" + " </td>\n" + " </tr>\n" + " <tr>\n" + " <td class=\"description\"><nobr>" + + Messages.getBodyString(locale, "SolrConnector.UserID") + "</nobr></td>\n" + " <td class=\"value\">\n" + " <input name=\"userid\" type=\"text\" size=\"32\" value=\"" + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(userID) + + "\"/>\n" + " </td>\n" + " </tr>\n" + " <tr>\n" + " <td class=\"description\"><nobr>" + Messages.getBodyString(locale, "SolrConnector.Password") + "</nobr></td>\n" + " <td class=\"value\">\n" + + " <input type=\"password\" size=\"32\" name=\"password\" value=\"" + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(password) + "\"/>\n" + " </td>\n" + " </tr>\n" + + " <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n" + " <tr>\n" + " <td class=\"description\"><nobr>" + Messages.getBodyString(locale, "SolrConnector.SSLTrustCertificateList") + "</nobr></td>\n" + + " <td class=\"value\">\n" + " <input type=\"hidden\" name=\"solrkeystorealias\" value=\"\"/>\n" + " <table class=\"displaytable\">\n"); // List the individual certificates in the store, with a delete button for each - String[] contents = localKeystore.getContents(); - if (contents.length == 0) - { - out.print( -" <tr><td class=\"message\" colspan=\"2\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.NoCertificatesPresent") + "</nobr></td></tr>\n" - ); - } - else - { + final String[] contents = localKeystore.getContents(); + if (contents.length == 0) { + out.print(" <tr><td class=\"message\" colspan=\"2\"><nobr>" + Messages.getBodyString(locale, "SolrConnector.NoCertificatesPresent") + "</nobr></td></tr>\n"); + } else { int i = 0; - while (i < contents.length) - { - String alias = contents[i]; + while (i < contents.length) { + final String alias = contents[i]; String description = localKeystore.getDescription(alias); if (description.length() > 128) - description = description.substring(0,125) + "..."; - out.print( -" <tr>\n"+ -" <td class=\"value\"><input type=\"button\" onclick='Javascript:SolrDeleteCertificate(\""+org.apache.manifoldcf.ui.util.Encoder.attributeJavascriptEscape(alias)+"\")' alt=\""+Messages.getAttributeString(locale,"SolrConnector.DeleteCert")+" "+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(alias)+"\" value=\"Delete\"/></td>\n"+ -" <td>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(description)+"</td>\n"+ -" </tr>\n" - ); + description = description.substring(0, 125) + "..."; + out.print(" <tr>\n" + " <td class=\"value\"><input type=\"button\" onclick='Javascript:SolrDeleteCertificate(\"" + org.apache.manifoldcf.ui.util.Encoder.attributeJavascriptEscape(alias) + "\")' alt=\"" + + Messages.getAttributeString(locale, "SolrConnector.DeleteCert") + " " + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(alias) + "\" value=\"Delete\"/></td>\n" + " <td>" + + org.apache.manifoldcf.ui.util.Encoder.bodyEscape(description) + "</td>\n" + " </tr>\n"); i++; } } out.print( -" </table>\n"+ -" <input type=\"button\" onclick='Javascript:SolrAddCertificate()' alt=\"" + Messages.getAttributeString(locale,"SolrConnector.AddCert") + "\" value=\"" + Messages.getAttributeString(locale,"SolrConnector.Add") + "\"/> \n"+ -" " + Messages.getBodyString(locale,"SolrConnector.Certificate") + " <input name=\"solrcertificate\" size=\"50\" type=\"file\"/>\n"+ -" </td>\n"+ -" </tr>\n"+ -"</table>\n" - ); - } - else - { + " </table>\n" + " <input type=\"button\" onclick='Javascript:SolrAddCertificate()' alt=\"" + Messages.getAttributeString(locale, "SolrConnector.AddCert") + "\" value=\"" + Messages.getAttributeString(locale, "SolrConnector.Add") + + "\"/> \n" + " " + Messages.getBodyString(locale, "SolrConnector.Certificate") + " <input name=\"solrcertificate\" size=\"50\" type=\"file\"/>\n" + " </td>\n" + " </tr>\n" + "</table>\n"); + } else { // Server tab hiddens - out.print(
[... 1623 lines stripped ...]