You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2011/10/04 18:15:07 UTC
svn commit: r1178851 - in
/incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki:
WikiConfig.java WikiConnector.java
Author: kwright
Date: Tue Oct 4 16:15:06 2011
New Revision: 1178851
URL: http://svn.apache.org/viewvc?rev=1178851&view=rev
Log:
Provide the basic parameters and configuration UI.
Added:
incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConfig.java (with props)
incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java (with props)
Added: incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConfig.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConfig.java?rev=1178851&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConfig.java (added)
+++ incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConfig.java Tue Oct 4 16:15:06 2011
@@ -0,0 +1,41 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.crawler.connectors.wiki;
+
+
+/** Parameters and output data for Wiki repository connector.
+*/
+public class WikiConfig
+{
+ public static final String _rcsid = "@(#)$Id$";
+
+ // Configuration parameters
+
+ /** Protocol */
+ public static final String PARAM_PROTOCOL = "Server protocol";
+ /** Server name */
+ public static final String PARAM_SERVER = "Server name";
+ /** Port */
+ public static final String PARAM_PORT = "Server port";
+ /** Path */
+ public static final String PARAM_PATH = "Server path";
+
+ // Output specification
+
+}
Propchange: incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConfig.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java?rev=1178851&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java (added)
+++ incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java Tue Oct 4 16:15:06 2011
@@ -0,0 +1,474 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.crawler.connectors.wiki;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.interfaces.*;
+import org.apache.manifoldcf.crawler.interfaces.*;
+import org.apache.manifoldcf.crawler.system.Logging;
+import java.util.*;
+import java.io.*;
+
+/** This is the repository connector for a wiki.
+*/
+public class WikiConnector extends org.apache.manifoldcf.crawler.connectors.BaseRepositoryConnector
+{
+ public static final String _rcsid = "@(#)$Id$";
+
+ // Activities that we know about
+ protected final static String ACTIVITY_FETCH = "fetch document";
+
+ // Activities list
+ protected static final String[] activitiesList = new String[]{ACTIVITY_FETCH};
+
+ // Parameters
+ protected String protocol = null;
+ protected String server = null;
+ protected int port = -1;
+ protected String path = null;
+
+ /** Constructor.
+ */
+ public WikiConnector()
+ {
+ }
+
+ /** List the activities we might report on.
+ */
+ @Override
+ public String[] getActivitiesList()
+ {
+ return activitiesList;
+ }
+
+ /** For any given document, list the bins that it is a member of.
+ */
+ @Override
+ public String[] getBinNames(String documentIdentifier)
+ {
+ // Return the host name
+ return new String[]{server};
+ }
+
+ /** Connect.
+ *@param configParameters is the set of configuration parameters, which
+ * in this case describe the target appliance, basic auth configuration, etc.
+ */
+ @Override
+ public void connect(ConfigParams configParameters)
+ {
+ super.connect(configParameters);
+ server = configParameters.getParameter(WikiConfig.PARAM_SERVER);
+ }
+
+ /** Close the connection. Call this before discarding the connection.
+ */
+ @Override
+ public void disconnect()
+ throws ManifoldCFException
+ {
+ server = null;
+ super.disconnect();
+ }
+
+ /** Queue "seed" documents. Seed documents are the starting places for crawling activity. Documents
+ * are seeded when this method calls appropriate methods in the passed in ISeedingActivity object.
+ *
+ * This method can choose to find repository changes that happen only during the specified time interval.
+ * The seeds recorded by this method will be viewed by the framework based on what the
+ * getConnectorModel() method returns.
+ *
+ * It is not a big problem if the connector chooses to create more seeds than are
+ * strictly necessary; it is merely a question of overall work required.
+ *
+ * The times passed to this method may be interpreted for greatest efficiency. The time ranges
+ * any given job uses with this connector will not overlap, but will proceed starting at 0 and going
+ * to the "current time", each time the job is run. For continuous crawling jobs, this method will
+ * be called once, when the job starts, and at various periodic intervals as the job executes.
+ *
+ * When a job's specification is changed, the framework automatically resets the seeding start time to 0. The
+ * seeding start time may also be set to 0 on each job run, depending on the connector model returned by
+ * getConnectorModel().
+ *
+ * Note that it is always ok to send MORE documents rather than less to this method.
+ *@param activities is the interface this method should use to perform whatever framework actions are desired.
+ *@param spec is a document specification (that comes from the job).
+ *@param startTime is the beginning of the time range to consider, inclusive.
+ *@param endTime is the end of the time range to consider, exclusive.
+ */
+ @Override
+ public void addSeedDocuments(ISeedingActivity activities, DocumentSpecification spec,
+ long startTime, long endTime)
+ throws ManifoldCFException, ServiceInterruption
+ {
+ // MHL
+ }
+
+ /** Get document versions given an array of document identifiers.
+ * This method is called for EVERY document that is considered. It is
+ * therefore important to perform as little work as possible here.
+ *@param documentIdentifiers is the array of local document identifiers, as understood by this connector.
+ *@param oldVersions is the corresponding array of version strings that have been saved for the document identifiers.
+ * A null value indicates that this is a first-time fetch, while an empty string indicates that the previous document
+ * had an empty version string.
+ *@param activities is the interface this method should use to perform whatever framework actions are desired.
+ *@param spec is the current document specification for the current job. If there is a dependency on this
+ * specification, then the version string should include the pertinent data, so that reingestion will occur
+ * when the specification changes. This is primarily useful for metadata.
+ *@param jobMode is an integer describing how the job is being run, whether continuous or once-only.
+ *@param usesDefaultAuthority will be true only if the authority in use for these documents is the default one.
+ *@return the corresponding version strings, with null in the places where the document no longer exists.
+ * Empty version strings indicate that there is no versioning ability for the corresponding document, and the document
+ * will always be processed.
+ */
+ @Override
+ public String[] getDocumentVersions(String[] documentIdentifiers, String[] oldVersions, IVersionActivity activities,
+ DocumentSpecification spec, int jobMode, boolean usesDefaultAuthority)
+ throws ManifoldCFException, ServiceInterruption
+ {
+ // MHL
+ return null;
+ }
+
+ /** Process a set of documents.
+ * This is the method that should cause each document to be fetched, processed, and the results either added
+ * to the queue of documents for the current job, and/or entered into the incremental ingestion manager.
+ * The document specification allows this class to filter what is done based on the job.
+ *@param documentIdentifiers is the set of document identifiers to process.
+ *@param versions is the corresponding document versions to process, as returned by getDocumentVersions() above.
+ * The implementation may choose to ignore this parameter and always process the current version.
+ *@param activities is the interface this method should use to queue up new document references
+ * and ingest documents.
+ *@param spec is the document specification.
+ *@param scanOnly is an array corresponding to the document identifiers. It is set to true to indicate when the processing
+ * should only find other references, and should not actually call the ingestion methods.
+ *@param jobMode is an integer describing how the job is being run, whether continuous or once-only.
+ */
+ public void processDocuments(String[] documentIdentifiers, String[] versions, IProcessActivity activities,
+ DocumentSpecification spec, boolean[] scanOnly, int jobMode)
+ throws ManifoldCFException, ServiceInterruption
+ {
+ // MHL
+ }
+
+ // 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 document 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.
+ */
+ @Override
+ public void outputConfigurationHeader(IThreadContext threadContext, IHTTPOutput out, ConfigParams parameters, List<String> tabsArray)
+ throws ManifoldCFException, IOException
+ {
+ tabsArray.add("Server");
+
+ out.print(
+"<script type=\"text/javascript\">\n"+
+"<!--\n"+
+"function checkConfig()\n"+
+"{\n"+
+" if (editconnection.servername.value == \"\")\n"+
+" {\n"+
+" alert(\"Please supply a valid Wiki server name\");\n"+
+" editconnection.servername.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.serverport.value != \"\" && !isInteger(editconnection.serverport.value))\n"+
+" {\n"+
+" alert(\"Wiki server port must be a valid integer\");\n"+
+" editconnection.serverport.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.serverpath.value != \"\" && editconnection.serverpath.value.indexOf(\"/\") != 0)\n"+
+" {\n"+
+" alert(\"Path must start with a '/' character\");\n"+
+" editconnection.serverpath.focus();\n"+
+" return false;\n"+
+" }\n"+
+" return true;\n"+
+"}\n"+
+"\n"+
+"function checkConfigForSave()\n"+
+"{\n"+
+" if (editconnection.servername.value == \"\")\n"+
+" {\n"+
+" alert(\"Please supply a valid Wiki server name\");\n"+
+" SelectTab(\"Server\");\n"+
+" editconnection.servername.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.serverport.value != \"\" && !isInteger(editconnection.serverport.value))\n"+
+" {\n"+
+" alert(\"WIki server port must be a valid integer\");\n"+
+" SelectTab(\"Server\");\n"+
+" editconnection.serverport.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.serverpath.value != \"\" && editconnection.serverpath.value.indexOf(\"/\") != 0)\n"+
+" {\n"+
+" alert(\"Path must start with a '/' character\");\n"+
+" SelectTab(\"Server\");\n"+
+" editconnection.serverpath.focus();\n"+
+" return false;\n"+
+" }\n"+
+" return true;\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 outputConfigurationBody(IThreadContext threadContext, IHTTPOutput out, ConfigParams parameters, String tabName)
+ throws ManifoldCFException, IOException
+ {
+ String protocol = parameters.getParameter(WikiConfig.PARAM_PROTOCOL);
+ if (protocol == null)
+ protocol = "http";
+
+ String server = parameters.getParameter(WikiConfig.PARAM_SERVER);
+ if (server == null)
+ server = "";
+
+ String port = parameters.getParameter(WikiConfig.PARAM_PORT);
+ if (port == null)
+ port = "";
+
+ String path = parameters.getParameter(WikiConfig.PARAM_PATH);
+ if (path == null)
+ path = "";
+
+ if (tabName.equals("Server"))
+ {
+ out.print(
+"<table class=\"displaytable\">\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>Protocol:</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <select name=\"serverprotocol\">\n"+
+" <option value=\"http\""+(protocol.equals("http")?" selected=\"true\"":"")+">http</option>\n"+
+" <option value=\"https\""+(protocol.equals("https")?" selected=\"true\"":"")+">https</option>\n"+
+" </select>\n"+
+" </td>\n"+
+" </tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>Server name:</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>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>\n"+
+" <td class=\"description\"><nobr>Path name:</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input name=\"serverpath\" type=\"text\" size=\"16\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(path)+"\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+"</table>\n"
+ );
+ }
+ else
+ {
+ // Server tab hiddens
+ out.print(
+"<input type=\"hidden\" name=\"serverprotocol\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(protocol)+"\"/>\n"+
+"<input type=\"hidden\" name=\"servername\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(server)+"\"/>\n"+
+"<input type=\"hidden\" name=\"serverport\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(port)+"\"/>\n"+
+"<input type=\"hidden\" name=\"serverpath\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(path)+"\"/>\n"
+ );
+ }
+
+ }
+
+ /** Process a configuration post.
+ * This method is called at the start of the connector's configuration page, whenever there is a possibility that form data for a connection has been
+ * posted. Its purpose is to gather form information and modify the configuration parameters accordingly.
+ * The name of the posted form is "editconnection".
+ *@param threadContext is the local thread context.
+ *@param variableContext is the set of variables available from the post, including binary file post information.
+ *@param parameters are the configuration parameters, as they currently exist, for this connection being configured.
+ *@return null if all is well, or a string error message if there is an error that should prevent saving of the connection (and cause a redirection to an error page).
+ */
+ @Override
+ public String processConfigurationPost(IThreadContext threadContext, IPostParameters variableContext, ConfigParams parameters)
+ throws ManifoldCFException
+ {
+ String protocol = variableContext.getParameter("serverprotocol");
+ if (protocol != null)
+ parameters.setParameter(WikiConfig.PARAM_PROTOCOL,protocol);
+
+ String server = variableContext.getParameter("servername");
+ if (server != null)
+ parameters.setParameter(WikiConfig.PARAM_SERVER,server);
+
+ String port = variableContext.getParameter("serverport");
+ if (port != null)
+ parameters.setParameter(WikiConfig.PARAM_PORT,port);
+
+ String path = variableContext.getParameter("serverpath");
+ if (path != null)
+ parameters.setParameter(WikiConfig.PARAM_PATH,path);
+
+ return null;
+ }
+
+ /** View configuration.
+ * This method is called in the body section of the connector's view configuration page. Its purpose is to present the connection information to the user.
+ * The coder can presume that the HTML that is output from this configuration will be within appropriate <html> and <body> tags.
+ *@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.
+ */
+ @Override
+ public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out, ConfigParams parameters)
+ throws ManifoldCFException, IOException
+ {
+ out.print(
+"<table class=\"displaytable\">\n"+
+" <tr>\n"+
+" <td class=\"description\" colspan=\"1\"><nobr>Parameters:</nobr></td>\n"+
+" <td class=\"value\" colspan=\"3\">\n"
+ );
+ Iterator iter = parameters.listParameters();
+ while (iter.hasNext())
+ {
+ String param = (String)iter.next();
+ String value = parameters.getParameter(param);
+ if (param.length() >= "password".length() && param.substring(param.length()-"password".length()).equalsIgnoreCase("password"))
+ {
+ out.print(
+" <nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(param)+"=********</nobr><br/>\n"
+ );
+ }
+ else if (param.length() >="keystore".length() && param.substring(param.length()-"keystore".length()).equalsIgnoreCase("keystore"))
+ {
+ IKeystoreManager kmanager = KeystoreManagerFactory.make("",value);
+ out.print(
+" <nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(param)+"=<"+Integer.toString(kmanager.getContents().length)+" certificate(s)></nobr><br/>\n"
+ );
+ }
+ else
+ {
+ out.print(
+" <nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(param)+"="+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(value)+"</nobr><br/>\n"
+ );
+ }
+ }
+
+ out.print(
+" </td>\n"+
+" </tr>\n"+
+"</table>\n"
+ );
+
+ }
+
+ /** Output the specification header section.
+ * This method is called in the head section of a job page which has selected a repository connection of the current type. Its purpose is to add the required tabs
+ * to the list, and to output any javascript methods that might be needed by the job editing HTML.
+ *@param out is the output to which any HTML should be sent.
+ *@param ds is the current document specification for this job.
+ *@param tabsArray is an array of tab names. Add to this array any tab names that are specific to the connector.
+ */
+ @Override
+ public void outputSpecificationHeader(IHTTPOutput out, DocumentSpecification ds, List<String> tabsArray)
+ throws ManifoldCFException, IOException
+ {
+ out.print(
+"<script type=\"text/javascript\">\n"+
+"<!--\n"+
+"function checkSpecification()\n"+
+"{\n"+
+" // Does nothing right now.\n"+
+" return true;\n"+
+"}\n"+
+"//-->\n"+
+"</script>\n"
+ );
+ }
+
+ /** Output the specification body section.
+ * This method is called in the body section of a job page which has selected a repository connection of the current type. 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 "editjob".
+ *@param out is the output to which any HTML should be sent.
+ *@param ds is the current document specification for this job.
+ *@param tabName is the current tab name.
+ */
+ @Override
+ public void outputSpecificationBody(IHTTPOutput out, DocumentSpecification ds, String tabName)
+ throws ManifoldCFException, IOException
+ {
+ }
+
+ /** Process a specification post.
+ * This method is called at the start of job's edit or view page, whenever there is a possibility that form data for a connection has been
+ * posted. Its purpose is to gather form information and modify the document specification accordingly.
+ * The name of the posted form is "editjob".
+ *@param variableContext contains the post data, including binary file-upload information.
+ *@param ds is the current document specification for this job.
+ *@return null if all is well, or a string error message if there is an error that should prevent saving of the job (and cause a redirection to an error page).
+ */
+ @Override
+ public String processSpecificationPost(IPostParameters variableContext, DocumentSpecification ds)
+ throws ManifoldCFException
+ {
+ return null;
+ }
+
+ /** View specification.
+ * This method is called in the body section of a job's view page. Its purpose is to present the document specification information to the user.
+ * The coder can presume that the HTML that is output from this configuration will be within appropriate <html> and <body> tags.
+ *@param out is the output to which any HTML should be sent.
+ *@param ds is the current document specification for this job.
+ */
+ @Override
+ public void viewSpecification(IHTTPOutput out, DocumentSpecification ds)
+ throws ManifoldCFException, IOException
+ {
+ }
+
+ // Protected static methods
+
+}
Propchange: incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
------------------------------------------------------------------------------
svn:keywords = Id