Author: kwright
Date: Fri Sep 7 11:16:30 2012
New Revision: 1381978
URL: http://svn.apache.org/viewvc?rev=1381978&view=rev
Log:
Hand-merge code from contribution so that the formatting is preserved
Modified:
manifoldcf/branches/CONNECTORS-518/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
Modified:
manifoldcf/branches/CONNECTORS-518/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-518/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java?rev=1381978&r1=1381977&r2=1381978&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-518/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
(original)
+++
manifoldcf/branches/CONNECTORS-518/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
Fri Sep 7 11:16:30 2012
@@ -41,6 +41,9 @@ import java.util.*;
import java.io.*;
import java.net.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
/** This is the repository connector for a wiki.
*/
public class WikiConnector extends
org.apache.manifoldcf.crawler.connectors.BaseRepositoryConnector
@@ -64,9 +67,15 @@ public class WikiConnector extends org.a
/** Base URL */
protected String baseURL = null;
+ protected String serverLogin = null;
+ protected String serverPass = null;
+ protected String serverDomain = null;
+
/** Connection management */
protected MultiThreadedHttpConnectionManager connectionManager = null;
+ protected HttpClient httpClient = null;
+
/** Constructor.
*/
public WikiConnector()
@@ -99,6 +108,9 @@ public class WikiConnector extends org.a
{
super.connect(configParameters);
server = params.getParameter(WikiConfig.PARAM_SERVER);
+ serverLogin = params.getParameter(WikiConfig.PARAM_LOGIN);
+ serverPass = params.getObfuscatedParameter(WikiConfig.PARAM_PASSWORD);
+ serverDomain = params.getParameter(WikiConfig.PARAM_DOMAIN);
}
protected void getSession()
@@ -120,11 +132,286 @@ public class WikiConnector extends org.a
// Set up connection manager
connectionManager = new MultiThreadedHttpConnectionManager();
- connectionManager.getParams().setMaxTotalConnections(1);
+ connectionManager.getParams().setMaxTotalConnections(20);
+
+ httpClient = new HttpClient(connectionManager);
+
+ if (serverLogin != null && !"".equals(serverLogin)) {
+ loginToAPI();
+ }
hasBeenSetup = true;
}
}
+
+ protected void loginToAPI() throws ManifoldCFException, ServiceInterruption {
+ HttpClient client = getInitializedClient();
+ String loginURL = baseURL + "action=login";
+ HashMap<String, String> loginParams = new HashMap<String, String>();
+ loginParams.put("action", "login");
+ loginParams.put("lgname", serverLogin);
+ loginParams.put("lgpassword", serverPass);
+ if (serverDomain != null && !"".equals(serverDomain)) {
+ loginParams.put("lgdomain", serverDomain);
+ }
+ PostMethod method = new PostMethod(loginURL);
+ for (String key : loginParams.keySet()) {
+ method.setParameter(key, loginParams.get(key));
+ }
+ method.getParams().setParameter("http.socket.timeout", new
Integer(300000));
+
+ try {
+ APILoginResult result = new APILoginResult();
+ ExecuteAPILoginThread t = new ExecuteAPILoginThread(client, method,
loginURL, loginParams, result);
+ try {
+ t.start();
+ t.join();
+
+ Throwable thr = t.getException();
+ if (thr != null) {
+ if (thr instanceof ManifoldCFException) {
+ if (((ManifoldCFException) thr).getErrorCode() ==
ManifoldCFException.INTERRUPTED) {
+ throw new InterruptedException(thr.getMessage());
+ }
+ throw (ManifoldCFException) thr;
+ } else if (thr instanceof ServiceInterruption) {
+ throw (ServiceInterruption) thr;
+ } else if (thr instanceof IOException) {
+ throw (IOException) thr;
+ } else if (thr instanceof RuntimeException) {
+ throw (RuntimeException) thr;
+ } else {
+ throw (Error) thr;
+ }
+ }
+ } catch (ManifoldCFException e) {
+ t.interrupt();
+ throw e;
+ } catch (ServiceInterruption e) {
+ t.interrupt();
+ throw e;
+ } catch (IOException e) {
+ t.interrupt();
+ throw e;
+ } catch (InterruptedException e) {
+ t.interrupt();
+ // We need the caller to abandon any connections left around, so
rethrow in a way that forces them to process the event properly.
+ throw e;
+ }
+ if (!result.result) {
+ throw new ManifoldCFException("WIKI API login error: " +
result.reason, null, ManifoldCFException.REPOSITORY_CONNECTION_ERROR);
+ }
+ } catch (InterruptedException e) {
+ // Drop the connection on the floor
+ method = null;
+ throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
ManifoldCFException.INTERRUPTED);
+ } catch (ManifoldCFException e) {
+ if (e.getErrorCode() == ManifoldCFException.INTERRUPTED) // Drop the
connection on the floor
+ {
+ method = null;
+ }
+ throw e;
+ } catch (java.net.SocketTimeoutException e) {
+ long currentTime = System.currentTimeMillis();
+ throw new ServiceInterruption("Get namespaces timed out reading from the
Wiki server: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12L *
60000L, -1, false);
+ } catch (java.net.SocketException e) {
+ long currentTime = System.currentTimeMillis();
+ throw new ServiceInterruption("Get namespaces received a socket error
reading from Wiki server: " + e.getMessage(), e, currentTime + 300000L,
currentTime + 12L * 60000L, -1, false);
+ } catch (org.apache.commons.httpclient.ConnectTimeoutException e) {
+ long currentTime = System.currentTimeMillis();
+ throw new ServiceInterruption("Get namespaces connection timed out
reading from Wiki server: " + e.getMessage(), e, currentTime + 300000L,
currentTime + 12L * 60000L, -1, false);
+ } catch (InterruptedIOException e) {
+ method = null;
+ throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
ManifoldCFException.INTERRUPTED);
+ } catch (IOException e) {
+ throw new ManifoldCFException("Get namespaces had an IO failure: " +
e.getMessage(), e);
+ } finally {
+ if (method != null) {
+ method.releaseConnection();
+ }
+ }
+ }
+
+ protected class APILoginResult {
+
+ public boolean result = false;
+ public String reason = "";
+ }
+
+ /**
+ * Thread to execute a "get namespaces" operation. This thread both executes
+ * the operation and parses the result.
+ */
+ protected class ExecuteAPILoginThread extends Thread {
+
+ protected HttpClient client;
+ protected HttpMethodBase executeMethod;
+ protected Throwable exception = null;
+ protected String baseUrl;
+ protected HashMap<String, String> loginParams;
+ protected APILoginResult result;
+
+ public ExecuteAPILoginThread(HttpClient client, HttpMethodBase
executeMethod, String baseUrl, HashMap<String, String> loginParams,
APILoginResult result) {
+ super();
+ setDaemon(true);
+ this.client = client;
+ this.executeMethod = executeMethod;
+ this.baseUrl = baseUrl;
+ this.result = result;
+ this.loginParams = loginParams;
+ }
+
+ public void run() {
+ try {
+ // Call the execute method appropriately
+ int rval = client.executeMethod(executeMethod);
+ if (rval != 200) {
+ throw new ManifoldCFException("Unexpected response code " + rval +
": " + executeMethod.getResponseBodyAsString());
+ }
+
+ // Read response and make sure it's valid
+ InputStream is = executeMethod.getResponseBodyAsStream();
+ try {
+ // Parse the document. This will cause various things to occur,
within the instantiated XMLContext class.
+ //<api>
+ // <login
+ // result="NeedToken"
+ // token="b5780b6e2f27e20b450921d9461010b4"
+ // cookieprefix="enwiki"
+ // sessionid="17ab96bd8ffbe8ca58a78657a918558e"
+ // />
+ //</api>
+ XMLStream x = new XMLStream();
+ WikiLoginAPIContext c = new WikiLoginAPIContext(x, client, baseUrl,
loginParams, result);
+ x.setContext(c);
+ try {
+ try {
+ x.parse(is);
+ } catch (IOException e) {
+ long time = System.currentTimeMillis();
+ throw new ServiceInterruption(e.getMessage(), e, time + 300000L,
time + 12L * 60000L, -1, false);
+ }
+ } finally {
+ x.cleanup();
+ }
+ } finally {
+ try {
+ is.close();
+ } catch (IllegalStateException e) {
+ // Ignore this error
+ }
+ }
+ } catch (Throwable e) {
+ this.exception = e;
+ }
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+ }
+
+ /**
+ * Class representing the "api" context of a "get namespaces" response
+ */
+ protected class WikiLoginAPIContext extends SingleLevelContext {
+
+ protected HttpClient client;
+ protected String baseUrl;
+ protected APILoginResult result;
+ protected HashMap<String, String> loginParams;
+
+ public WikiLoginAPIContext(XMLStream theStream, HttpClient client, String
baseUrl, HashMap<String, String> loginParams, APILoginResult result) {
+ super(theStream, "api");
+ this.client = client;
+ this.baseUrl = baseUrl;
+ this.result = result;
+ this.loginParams = loginParams;
+ }
+
+ protected BaseProcessingContext createChild(String namespaceURI, String
localName, String qName, Attributes atts) {
+ return new WikiLoginAPIResultAPIContext(theStream, namespaceURI,
localName, qName, atts, client, baseUrl, loginParams, result);
+ }
+
+ protected void finishChild(BaseProcessingContext child)
+ throws ManifoldCFException {
+ }
+ }
+
+ /**
+ * Class representing the "api/query/pages/page" context of a "get doc info"
+ * response
+ */
+ protected class WikiLoginAPIResultAPIContext extends BaseProcessingContext {
+
+ protected HttpClient client;
+ protected String baseUrl;
+ protected APILoginResult result;
+ protected HashMap<String, String> loginParams;
+
+ public WikiLoginAPIResultAPIContext(XMLStream theStream, String
namespaceURI, String localName, String qName, Attributes atts, HttpClient
client, String baseUrl, HashMap<String, String> loginParams, APILoginResult
result) {
+ super(theStream, namespaceURI, localName, qName, atts);
+ this.client = client;
+ this.baseUrl = baseUrl;
+ this.result = result;
+ this.loginParams = loginParams;
+ }
+
+ protected XMLContext beginTag(String namespaceURI, String localName,
String qName, Attributes atts)
+ throws ManifoldCFException, ServiceInterruption {
+ if (qName.equals("login")) {
+ String loginResult = atts.getValue("result");
+ if ("NeedToken".equals(loginResult)) {
+ try {
+ String token = atts.getValue("token");
+ loginParams.put("lgtoken", token);
+ PostMethod method = new PostMethod(baseUrl);
+ for (String key : loginParams.keySet()) {
+ method.setParameter(key, loginParams.get(key));
+ }
+ method.getParams().setParameter("http.socket.timeout", new
Integer(300000));
+
+ int rval = client.executeMethod(method);
+ if (rval != 200) {
+ throw new ManifoldCFException("Unexpected response code " + rval
+ ": " + method.getResponseBodyAsString());
+ }
+
+ // Read response and make sure it's valid
+ InputStream is = method.getResponseBodyAsStream();
+ try {
+ XMLStream x = new XMLStream();
+ WikiLoginAPIContext c = new WikiLoginAPIContext(x, client,
baseUrl, loginParams, result);
+ x.setContext(c);
+ try {
+ try {
+ x.parse(is);
+ } catch (IOException e) {
+ long time = System.currentTimeMillis();
+ throw new ServiceInterruption(e.getMessage(), e, time +
300000L, time + 12L * 60000L, -1, false);
+ }
+ } finally {
+ x.cleanup();
+ }
+ } finally {
+ try {
+ is.close();
+ } catch (IllegalStateException e) {
+ // Ignore this error
+ }
+ }
+ method.releaseConnection();
+ } catch (IOException ex) {
+ Logger.getLogger(WikiConnector.class.getName()).log(Level.SEVERE,
null, ex);
+ }
+ } else if ("Success".equals(loginResult)) {
+ result.result = true;
+ } else {
+ result.reason = loginResult;
+ }
+ }
+ return super.beginTag(namespaceURI, localName, qName, atts);
+ }
+ }
/** Check status of connection.
*/
@@ -170,8 +457,15 @@ public class WikiConnector extends org.a
{
hasBeenSetup = false;
server = null;
+ serverLogin = null;
+ serverPass = null;
+ serverDomain = null;
baseURL = null;
+ if (httpClient != null) {
+ httpClient = null;
+ }
+
if (connectionManager != null)
{
connectionManager.shutdown();
@@ -287,6 +581,9 @@ public class WikiConnector extends org.a
DocumentSpecification spec, boolean[] scanOnly, int jobMode)
throws ManifoldCFException, ServiceInterruption
{
+ // Forced acls
+ String[] acls = getAcls(spec);
+
Map<String,String> urls = new HashMap<String,String>();
getDocURLs(documentIdentifiers,urls);
for (int i = 0 ; i < documentIdentifiers.length ; i++)
@@ -299,7 +596,33 @@ public class WikiConnector extends org.a
}
}
}
-
+
+ /**
+ * Grab forced acl out of document specification.
+ *
+ * @param spec is the document specification.
+ * @return the acls.
+ */
+ protected static String[] getAcls(DocumentSpecification spec) {
+ HashMap map = new HashMap();
+ int i = 0;
+ while (i < spec.getChildCount()) {
+ SpecificationNode sn = spec.getChild(i++);
+ if (sn.getType().equals("access")) {
+ String token = sn.getAttributeValue("token");
+ map.put(token, token);
+ }
+ }
+
+ String[] rval = new String[map.size()];
+ Iterator iter = map.keySet().iterator();
+ i = 0;
+ while (iter.hasNext()) {
+ rval[i++] = (String) iter.next();
+ }
+ return rval;
+ }
+
// UI support methods.
//
// These support methods come in two varieties. The first bunch is involved
in setting up connection configuration information. The second bunch
@@ -403,6 +726,19 @@ public class WikiConnector extends org.a
if (path == null)
path = "/w";
+ String login = parameters.getParameter(WikiConfig.PARAM_LOGIN);
+ if (login == null) {
+ login = "";
+ }
+ String pass = parameters.getObfuscatedParameter(WikiConfig.PARAM_PASSWORD);
+ if (pass == null) {
+ pass = "";
+ }
+ String domain = parameters.getParameter(WikiConfig.PARAM_DOMAIN);
+ if (domain == null) {
+ domain = "";
+ }
+
if (tabName.equals(Messages.getString(locale,"WikiConnector.Server")))
{
out.print(
@@ -434,6 +770,24 @@ public class WikiConnector extends org.a
" <input name=\"serverpath\" type=\"text\" size=\"16\"
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(path)+"\"/>\n"+
" </td>\n"+
" </tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,
"WikiConnector.ServerLogin") + "</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input name=\"serverlogin\" type=\"text\" size=\"16\" value=\"" +
org.apache.manifoldcf.ui.util.Encoder.attributeEscape(login) + "\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,
"WikiConnector.ServerPassword") + "</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input name=\"serverpass\" type=\"password\" size=\"16\" value=\"" +
org.apache.manifoldcf.ui.util.Encoder.attributeEscape(pass) + "\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,
"WikiConnector.ServerDomain") + "</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input name=\"serverdomain\" type=\"text\" size=\"16\" value=\"" +
org.apache.manifoldcf.ui.util.Encoder.attributeEscape(domain) + "\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
"</table>\n"
);
}
@@ -444,7 +798,10 @@ public class WikiConnector extends org.a
"<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"
+"<input type=\"hidden\" name=\"serverpath\"
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(path)+"\"/>\n"+
+"<input type=\"hidden\" name=\"serverlogin\" value=\"" +
org.apache.manifoldcf.ui.util.Encoder.attributeEscape(login) + "\"/>\n"+
+"<input type=\"hidden\" name=\"serverpass\" value=\"" +
org.apache.manifoldcf.ui.util.Encoder.attributeEscape(pass) + "\"/>\n"+
+"<input type=\"hidden\" name=\"serverdomain\" value=\"" +
org.apache.manifoldcf.ui.util.Encoder.attributeEscape(domain) + "\"/>\n"
);
}
@@ -480,6 +837,21 @@ public class WikiConnector extends org.a
if (path != null)
parameters.setParameter(WikiConfig.PARAM_PATH,path);
+ String login = variableContext.getParameter("serverlogin");
+ if (login != null) {
+ parameters.setParameter(WikiConfig.PARAM_LOGIN, login);
+ }
+
+ String pass = variableContext.getParameter("serverpass");
+ if (pass != null) {
+ parameters.setObfuscatedParameter(WikiConfig.PARAM_PASSWORD, pass);
+ }
+
+ String domain = variableContext.getParameter("serverdomain");
+ if (domain != null) {
+ parameters.setParameter(WikiConfig.PARAM_DOMAIN, domain);
+ }
+
return null;
}
@@ -547,6 +919,7 @@ public class WikiConnector extends org.a
throws ManifoldCFException, IOException
{
tabsArray.add(Messages.getString(locale,"WikiConnector.NamespaceAndTitles"));
+ tabsArray.add(Messages.getString(locale, "WikiConnector.Security"));
out.print(
"<script type=\"text/javascript\">\n"+
@@ -567,6 +940,17 @@ public class WikiConnector extends org.a
" SpecOp(\"nsop\", \"Add\", \"ns_\"+k);\n"+
"}\n"+
"\n"+
+"function SpecAddToken(anchorvalue)\n"+
+"{\n"+
+" if (editjob.spectoken.value == \"\")\n"+
+" {\n"+
+" alert(\"" + Messages.getBodyJavascriptString(locale,
"WikiConnector.TypeInAnAccessToken") + "\");\n"+
+" editjob.spectoken.focus();\n"+
+" return;\n"+
+" }\n"+
+" SpecOp(\"accessop\",\"Add\",anchorvalue);\n"+
+"}\n"+
+"\n"+
"function SpecOp(n, opValue, anchorvalue)\n"+
"{\n"+
" eval(\"editjob.\"+n+\".value = \\\"\"+opValue+\"\\\"\");\n"+
@@ -752,6 +1136,83 @@ public class WikiConnector extends org.a
"<input type=\"hidden\" name=\"nscount\" value=\""+new Integer(k)+"\"/>\n"
);
}
+
+ if (tabName.equals(Messages.getString(locale, "WikiConnector.Security")))
+ {
+ out.print(
+"<table class=\"displaytable\">\n"+
+" <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"
+ );
+ // Go through forced ACL
+ int i = 0;
+ int k = 0;
+ while (i < ds.getChildCount()) {
+ SpecificationNode sn = ds.getChild(i++);
+ if (sn.getType().equals("access")) {
+ String accessDescription = "_" + Integer.toString(k);
+ String accessOpName = "accessop" + accessDescription;
+ String token = sn.getAttributeValue("token");
+ out.print(
+" <tr>\n"+
+" <td class=\"description\">\n"+
+" <input type=\"hidden\" name=\"" + accessOpName + "\" value=\"\"/>\n"+
+" <input type=\"hidden\" name=\"" + "spectoken" + accessDescription + "\"
value=\"" + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(token) +
"\"/>\n"+
+" <a name=\"" + "token_" + Integer.toString(k) + "\">\n"+
+" <input type=\"button\" value=\"" +
Messages.getAttributeString(locale, "WikiConnector.Delete") + "\"
onClick='Javascript:SpecOp(\"" + accessOpName + "\",\"Delete\",\"token_" +
Integer.toString(k) + "\")' alt=\"" + Messages.getAttributeString(locale,
"WikiConnector.Delete") + Integer.toString(k) + "\"/>\n"+
+" </a> \n"+
+" </td>\n"+
+" <td class=\"value\">\n"+
+" " + org.apache.manifoldcf.ui.util.Encoder.bodyEscape(token) + "\n"+
+" </td>\n"+
+" </tr>\n"
+ );
+ k++;
+ }
+ }
+ if (k == 0) {
+ out.print(
+" <tr>\n"+
+" <td class=\"message\" colspan=\"2\">" + Messages.getBodyString(locale,
"WikiConnector.NoAccessTokensPresent") + "</td>\n"+
+" </tr>\n"
+ );
+ }
+ out.print(
+" <tr><td class=\"lightseparator\" colspan=\"2\"><hr/></td></tr>\n"+
+" <tr>\n"+
+" <td class=\"description\">\n"+
+" <input type=\"hidden\" name=\"tokencount\" value=\"" +
Integer.toString(k) + "\"/>\n"+
+" <input type=\"hidden\" name=\"accessop\" value=\"\"/>\n"+
+" <a name=\"" + "token_" + Integer.toString(k) + "\">\n"+
+" <input type=\"button\" value=\"" +
Messages.getAttributeString(locale, "WikiConnector.Add") + "\"
onClick='Javascript:SpecAddToken(\"token_" + Integer.toString(k + 1) + "\")'
alt=\"" + Messages.getAttributeString(locale, "WikiConnector.Add") + "\"/>\n"+
+" </a> \n"+
+" </td>\n"+
+" <td class=\"value\">\n"+
+" <input type=\"text\" size=\"30\" name=\"spectoken\" value=\"\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+"</table>\n"
+ );
+ }
+ else
+ {
+ // Finally, go through forced ACL
+ int i = 0;
+ int k = 0;
+ while (i < ds.getChildCount()) {
+ SpecificationNode sn = ds.getChild(i++);
+ if (sn.getType().equals("access")) {
+ String accessDescription = "_" + Integer.toString(k);
+ String token = sn.getAttributeValue("token");
+ out.print(
+"<input type=\"hidden\" name=\"" + "spectoken" + accessDescription + "\"
value=\"" + org.apache.manifoldcf.ui.util.Encoder.attributeEscape(token) +
"\"/>\n"
+ );
+ k++;
+ }
+ }
+ out.print(
+"<input type=\"hidden\" name=\"tokencount\" value=\"" + Integer.toString(k) +
"\"/>\n"
+ );
+ }
}
/** Process a specification post.
@@ -821,6 +1282,47 @@ public class WikiConnector extends org.a
}
}
+ String xc = variableContext.getParameter("tokencount");
+ if (xc != null) {
+ // Delete all tokens first
+ int i = 0;
+ while (i < ds.getChildCount()) {
+ SpecificationNode sn = ds.getChild(i);
+ if (sn.getType().equals("access")) {
+ ds.removeChild(i);
+ } else {
+ i++;
+ }
+ }
+
+ int accessCount = Integer.parseInt(xc);
+ i = 0;
+ while (i < accessCount) {
+ String accessDescription = "_" + Integer.toString(i);
+ String accessOpName = "accessop" + accessDescription;
+ xc = variableContext.getParameter(accessOpName);
+ if (xc != null && xc.equals("Delete")) {
+ // Next row
+ i++;
+ continue;
+ }
+ // Get the stuff we need
+ String accessSpec = variableContext.getParameter("spectoken" +
accessDescription);
+ SpecificationNode node = new SpecificationNode("access");
+ node.setAttribute("token", accessSpec);
+ ds.addChild(ds.getChildCount(), node);
+ i++;
+ }
+
+ String op = variableContext.getParameter("accessop");
+ if (op != null && op.equals("Add")) {
+ String accessspec = variableContext.getParameter("spectoken");
+ SpecificationNode node = new SpecificationNode("access");
+ node.setAttribute("token", accessspec);
+ ds.addChild(ds.getChildCount(), node);
+ }
+ }
+
return null;
}
@@ -881,11 +1383,43 @@ public class WikiConnector extends org.a
out.print(
" </table>\n"+
-" </td>\n"
+" </td>\n"+
+" </tr>\n"
);
+ // Go through looking for access tokens
+ boolean seenAny = false;
+ int i = 0;
+ while (i < ds.getChildCount()) {
+ SpecificationNode sn = ds.getChild(i++);
+ if (sn.getType().equals("access")) {
+ if (seenAny == false) {
+ out.print(
+" <tr>\n"+
+" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,
"WikiConnector.AccessTokens") + "</nobr></td>\n"+
+" <td class=\"value\">\n"
+ );
+ seenAny = true;
+ }
+ String token = sn.getAttributeValue("token");
+ out.print(
+" " + org.apache.manifoldcf.ui.util.Encoder.bodyEscape(token) + "<br/>\n"
+ );
+ }
+ }
+
+ if (seenAny) {
+ out.print(
+" </td>\n"+
+" </tr>\n"
+ );
+ } else {
+ out.print(
+" <tr><td class=\"message\" colspan=\"2\"><nobr>" +
Messages.getBodyString(locale, "WikiConnector.NoAccessTokensSpecified") +
"</nobr></td></tr>\n"
+ );
+ }
+
out.print(
-" </tr>\n"+
"</table>\n"
);
}
@@ -896,8 +1430,7 @@ public class WikiConnector extends org.a
protected HttpClient getInitializedClient()
throws ServiceInterruption, ManifoldCFException
{
- HttpClient client = new HttpClient(connectionManager);
- return client;
+ return httpClient;
}
/** Create and initialize an HttpMethodBase */