You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by ml...@apache.org on 2013/06/24 14:13:43 UTC
svn commit: r1496002 - in /manifoldcf/branches/CONNECTORS-727: ./
connectors/ connectors/generic/
connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/
connectors/generic/src/
Author: mlizewski
Date: Mon Jun 24 12:13:42 2013
New Revision: 1496002
URL: http://svn.apache.org/r1496002
Log:
added ant build
check, fetching versions refactored as additional threads
table style changed
Added:
manifoldcf/branches/CONNECTORS-727/connectors/generic/build.xml
Removed:
manifoldcf/branches/CONNECTORS-727/connectors/generic/src/
Modified:
manifoldcf/branches/CONNECTORS-727/build.xml
manifoldcf/branches/CONNECTORS-727/connectors/connector-build.xml
manifoldcf/branches/CONNECTORS-727/connectors/generic/ (props changed)
manifoldcf/branches/CONNECTORS-727/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java
manifoldcf/branches/CONNECTORS-727/connectors/generic/pom.xml
Modified: manifoldcf/branches/CONNECTORS-727/build.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-727/build.xml?rev=1496002&r1=1496001&r2=1496002&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-727/build.xml (original)
+++ manifoldcf/branches/CONNECTORS-727/build.xml Mon Jun 24 12:13:42 2013
@@ -59,6 +59,7 @@
<ant dir="connectors/alfresco" target="clean"/>
<ant dir="connectors/cmis" target="clean"/>
<ant dir="connectors/dropbox" target="clean"/>
+ <ant dir="connectors/generic" target="clean"/>
<ant dir="connectors/googledrive" target="clean"/>
<ant dir="connectors/activedirectory" target="clean"/>
<ant dir="connectors/ldap" target="clean"/>
@@ -111,6 +112,7 @@
<ant dir="connectors/alfresco" target="clean"/>
<ant dir="connectors/cmis" target="clean"/>
<ant dir="connectors/dropbox" target="clean"/>
+ <ant dir="connectors/generic" target="clean"/>
<ant dir="connectors/googledrive" target="clean"/>
<ant dir="connectors/activedirectory" target="clean"/>
<ant dir="connectors/ldap" target="clean"/>
@@ -284,6 +286,8 @@
<target name="setup-dropbox-connector" depends="build-framework" if="downloaded"/>
+ <target name="setup-generic-connector" depends="build-framework" if="downloaded"/>
+
<target name="setup-googledrive-connector" depends="build-framework" if="downloaded"/>
<target name="setup-alfresco-connector-tests" depends="build-tests-framework" if="downloaded"/>
@@ -306,6 +310,9 @@
<ant dir="connectors/dropbox" target="build"/>
</target>
+ <target name="build-generic-connector" depends="setup-generic-connector" if="downloaded">
+ <ant dir="connectors/generic" target="build"/>
+ </target>
<target name="build-googledrive-connector" depends="setup-googledrive-connector" if="downloaded">
<ant dir="connectors/googledrive" target="build"/>
@@ -316,6 +323,10 @@
<ant dir="connectors/dropbox" target="doc"/>
</target>
+ <target name="doc-generic-connector" depends="setup-generic-connector" if="downloaded">
+ <ant dir="connectors/generic" target="doc"/>
+ </target>
+
<target name="doc-googledrive-connector" depends="setup-googledrive-connector" if="downloaded">
<ant dir="connectors/googledrive" target="doc"/>
</target>
@@ -1410,7 +1421,26 @@
</condition>
</target>
+ <target name="calculate-generic-condition" depends="build-generic-connector">
+ <available file="connectors/generic/dist/lib" type="dir" property="generic.exists"/>
+ <condition property="generic.include">
+ <and>
+ <isset property="generic.exists"/>
+ <isset property="downloaded"/>
+ </and>
+ </condition>
+ </target>
+ <target name="calculate-generic-doc-condition" depends="doc-generic-connector">
+ <available file="connectors/generic/dist/doc" type="dir" property="generic-doc.exists"/>
+ <condition property="generic-doc.include">
+ <and>
+ <isset property="generic-doc.exists"/>
+ <isset property="downloaded"/>
+ </and>
+ </condition>
+ </target>
+
<target name="calculate-googledrive-condition" depends="build-googledrive-connector">
<available file="connectors/googledrive/dist/lib" type="dir" property="googledrive.exists"/>
<condition property="googledrive.include">
@@ -1476,6 +1506,23 @@
</antcall>
</target>
+ <target name="deliver-generic-connector" depends="calculate-generic-condition" if="generic.include">
+ <antcall target="general-connector-delivery">
+ <param name="connector-name" value="generic"/>
+ </antcall>
+ <antcall target="general-add-repository-connector">
+ <param name="connector-name" value="generic"/>
+ <param name="connector-label" value="generic"/>
+ <param name="connector-class" value="org.apache.manifoldcf.crawler.connectors.generic.GenericRepositoryConnector"/>
+ </antcall>
+ </target>
+
+ <target name="deliver-generic-connector-doc" depends="calculate-generic-doc-condition" if="generic-doc.include">
+ <antcall target="general-connector-doc-delivery">
+ <param name="connector-name" value="generic"/>
+ </antcall>
+ </target>
+
<target name="deliver-googledrive-connector" depends="calculate-googledrive-condition" if="googledrive.include">
<antcall target="general-connector-delivery">
<param name="connector-name" value="googledrive"/>
@@ -2651,8 +2698,8 @@
<target name="end-to-end-loadtests-HSQLDB" depends="run-filesystem-loadtests-HSQLDB,run-rss-loadtests-HSQLDB,run-wiki-loadtests-HSQLDB,run-alfresco-loadtests-HSQLDB,run-cmis-loadtests-HSQLDB,run-sharepoint-loadtests-HSQLDB"/>
- <target name="deliver-open-connectors" depends="deliver-googledrive-connector,deliver-dropbox-connector,deliver-nullauthority-connector,deliver-activedirectory-connector,deliver-ldap-connector,deliver-alfresco-connector,deliver-cmis-connector,deliver-filesystem-connector,deliver-rss-connector,deliver-webcrawler-connector,deliver-wiki-connector,deliver-jdbc-connector"/>
- <target name="deliver-open-connectors-doc" depends="deliver-googledrive-connector-doc,deliver-dropbox-connector-doc,deliver-nullauthority-connector-doc,deliver-activedirectory-connector-doc,deliver-ldap-connector-doc,deliver-alfresco-connector-doc,deliver-cmis-connector-doc,deliver-filesystem-connector-doc,deliver-rss-connector-doc,deliver-webcrawler-connector-doc,deliver-wiki-connector-doc,deliver-jdbc-connector-doc"/>
+ <target name="deliver-open-connectors" depends="deliver-generic-connector,deliver-googledrive-connector,deliver-dropbox-connector,deliver-nullauthority-connector,deliver-activedirectory-connector,deliver-ldap-connector,deliver-alfresco-connector,deliver-cmis-connector,deliver-filesystem-connector,deliver-rss-connector,deliver-webcrawler-connector,deliver-wiki-connector,deliver-jdbc-connector"/>
+ <target name="deliver-open-connectors-doc" depends="deliver-generic-connector-doc,deliver-googledrive-connector-doc,deliver-dropbox-connector-doc,deliver-nullauthority-connector-doc,deliver-activedirectory-connector-doc,deliver-ldap-connector-doc,deliver-alfresco-connector-doc,deliver-cmis-connector-doc,deliver-filesystem-connector-doc,deliver-rss-connector-doc,deliver-webcrawler-connector-doc,deliver-wiki-connector-doc,deliver-jdbc-connector-doc"/>
<target name="deliver-output-connectors" depends="deliver-gts-connector,deliver-solr-connector,deliver-nulloutput-connector,deliver-opensearchserver-connector,deliver-elasticsearch-connector"/>
<target name="deliver-output-connectors-doc" depends="deliver-gts-connector-doc,deliver-solr-connector-doc,deliver-nulloutput-connector-doc,deliver-opensearchserver-connector-doc,deliver-elasticsearch-connector-doc"/>
@@ -3659,7 +3706,6 @@ Use Apache Forrest version forrest-0.9-d
<param name="artifact-type" value="jar"/>
</antcall>
</target>
-
<target name="download-google-api-client">
<mkdir dir="lib"/>
@@ -3790,6 +3836,7 @@ Use Apache Forrest version forrest-0.9-d
<target name="make-deps" depends="download-proprietary-dependencies">
<ant dir="connectors/alfresco" target="download-dependencies"/>
<ant dir="connectors/cmis" target="download-dependencies"/>
+ <ant dir="connectors/generic" target="download-dependencies"/>
<ant dir="connectors/dropbox" target="download-dependencies"/>
<ant dir="connectors/googledrive" target="download-dependencies"/>
<ant dir="connectors/activedirectory" target="download-dependencies"/>
@@ -3828,6 +3875,7 @@ Use Apache Forrest version forrest-0.9-d
<target name="clean-deps" depends="download-proprietary-cleanup">
<ant dir="connectors/alfresco" target="download-cleanup"/>
<ant dir="connectors/cmis" target="download-cleanup"/>
+ <ant dir="connectors/generic" target="download-cleanup"/>
<ant dir="connectors/dropbox" target="download-cleanup"/>
<ant dir="connectors/googledrive" target="download-cleanup"/>
<ant dir="connectors/activedirectory" target="download-cleanup"/>
Modified: manifoldcf/branches/CONNECTORS-727/connectors/connector-build.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-727/connectors/connector-build.xml?rev=1496002&r1=1496001&r2=1496002&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-727/connectors/connector-build.xml (original)
+++ manifoldcf/branches/CONNECTORS-727/connectors/connector-build.xml Mon Jun 24 12:13:42 2013
@@ -56,6 +56,7 @@
<include name="xercesImpl*.jar"/>
<include name="xml-apis*.jar"/>
<include name="velocity*.jar"/>
+ <include name="jaxb-impl*.jar"/>
</fileset>
<fileset dir="../../lib">
<include name="axis*.jar"/>
Propchange: manifoldcf/branches/CONNECTORS-727/connectors/generic/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jun 24 12:13:42 2013
@@ -0,0 +1,3 @@
+target
+build
+dist
Added: manifoldcf/branches/CONNECTORS-727/connectors/generic/build.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-727/connectors/generic/build.xml?rev=1496002&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-727/connectors/generic/build.xml (added)
+++ manifoldcf/branches/CONNECTORS-727/connectors/generic/build.xml Mon Jun 24 12:13:42 2013
@@ -0,0 +1,38 @@
+<!--
+ 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.
+-->
+
+<project name="generic" default="all">
+
+ <import file="../connector-build.xml"/>
+
+ <path id="connector-classpath">
+ <path refid="mcf-connector-build.connector-classpath"/>
+ <fileset dir="../../lib">
+ <include name="jaxb-impl*.jar"/>
+ </fileset>
+ </path>
+
+ <target name="lib" depends="mcf-connector-build.lib,precompile-check" if="canBuild">
+ <mkdir dir="dist/lib"/>
+ <copy todir="dist/lib">
+ <fileset dir="../../lib">
+ <include name="jaxb-impl*.jar"/>
+ </fileset>
+ </copy>
+ </target>
+
+</project>
Modified: manifoldcf/branches/CONNECTORS-727/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-727/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java?rev=1496002&r1=1496001&r2=1496002&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-727/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java (original)
+++ manifoldcf/branches/CONNECTORS-727/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java Mon Jun 24 12:13:42 2013
@@ -40,7 +40,6 @@ import javax.xml.parsers.FactoryConfigur
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import org.apache.commons.io.FileUtils;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
@@ -73,15 +72,15 @@ public class GenericConnector extends Ba
* Deny access token for default authority
*/
private final static String defaultAuthorityDenyToken = "DEAD_AUTHORITY";
-
+
private final static String ACTION_PARAM_NAME = "action";
private final static String ACTION_CHECK = "check";
-
+
private final static String ACTION_SEED = "seed";
-
+
private final static String ACTION_ITEMS = "items";
-
+
private final static String ACTION_ITEM = "item";
private String genericLogin = null;
@@ -156,21 +155,17 @@ public class GenericConnector extends Ba
@Override
public String check() throws ManifoldCFException {
HttpClient client = getClient();
- HttpGet method = new HttpGet(genericEntryPoint + "?" + ACTION_PARAM_NAME + "=" + ACTION_CHECK);
try {
- HttpResponse response = client.execute(method);
- try {
- if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
- return "Connection failed: " + response.getStatusLine().getReasonPhrase();
- }
- EntityUtils.consume(response.getEntity());
- return "Connection OK";
- } finally {
- EntityUtils.consume(response.getEntity());
- method.releaseConnection();
+ CheckThread checkThread = new CheckThread(client, genericEntryPoint + "?" + ACTION_PARAM_NAME + "=" + ACTION_CHECK);
+ checkThread.start();
+ checkThread.join();
+ if (checkThread.getException() != null) {
+ Throwable thr = checkThread.getException();
+ return "Check exception: " + thr.getMessage();
}
- } catch (IOException ex) {
- return "Error: " + ex.getMessage();
+ return checkThread.getResult();
+ } catch (InterruptedException ex) {
+ return "Check exception: " + ex.getMessage();
}
}
@@ -214,7 +209,7 @@ public class GenericConnector extends Ba
} else if (thr instanceof ServiceInterruption) {
throw (ServiceInterruption) thr;
} else if (thr instanceof IOException) {
- throw (IOException) thr;
+ handleIOException((IOException) thr);
} else if (thr instanceof RuntimeException) {
throw (RuntimeException) thr;
}
@@ -222,15 +217,6 @@ public class GenericConnector extends Ba
}
} catch (InterruptedException ex) {
throw new ManifoldCFException("addSeedDocuments error: " + ex.getMessage(), ex);
- } catch (UnsupportedEncodingException ex) {
- throw new ManifoldCFException("addSeedDocuments error: " + ex.getMessage(), ex);
- } catch (IOException ex) {
- long currentTime = System.currentTimeMillis();
- throw new ServiceInterruption("Exception while seeding, retrying: " + ex.getMessage(), ex,
- currentTime + 300000L, //powtarzaj co piÄÄ minut
- currentTime + 60L * 60000L, //powtarzaj przez 1 godzinÄ
- -1, //bez limitu powtórzeÅ
- true); //wyrzuÄ wyjÄ
tek jeÅli nie uda siÄ pobraÄ
}
}
@@ -255,13 +241,11 @@ public class GenericConnector extends Ba
}
HttpClient client = getClient();
- String[] rval = new String[documentIdentifiers.length];
+ StringBuilder url = new StringBuilder(genericEntryPoint);
try {
- StringBuilder url = new StringBuilder(genericEntryPoint);
url.append("?").append(ACTION_PARAM_NAME).append("=").append(ACTION_ITEMS);
- for (int i = 0; i < rval.length; i++) {
+ for (int i = 0; i < documentIdentifiers.length; i++) {
url.append("&id[]=").append(URLEncoder.encode(documentIdentifiers[i], "UTF-8"));
- rval[i] = null;
}
for (int i = 0; i < spec.getChildCount(); i++) {
SpecificationNode sn = spec.getChild(i);
@@ -271,47 +255,33 @@ public class GenericConnector extends Ba
url.append("&").append(URLEncoder.encode(paramName, "UTF-8")).append("=").append(URLEncoder.encode(paramValue, "UTF-8"));
}
}
- HttpGet method = new HttpGet(url.toString());
-
- HttpResponse response = client.execute(method);
- try {
- if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
- throw new ManifoldCFException("addSeedDocuments error - interface returned incorrect return code");
- }
- JAXBContext context;
- context = JAXBContext.newInstance(Items.class);
- Unmarshaller m = context.createUnmarshaller();
- Items items = (Items) m.unmarshal(response.getEntity().getContent());
- for (Item item : items.items) {
- documentCache.put(item.id, item);
- for (int i = 0; i < rval.length; i++) {
- if (documentIdentifiers[i].equals(item.id)) {
- if ("provided".equals(genericAuthMode)) {
- rval[i] = item.getVersionString();
- } else {
- rval[i] = item.version + rights;
- }
- break;
- }
+ } catch (UnsupportedEncodingException ex) {
+ throw new ManifoldCFException("getDocumentVersions error - invalid chars in id: " + ex.getMessage(), ex);
+ }
+ try {
+ DocumentVersionThread versioningThread = new DocumentVersionThread(client, url.toString(), documentIdentifiers, genericAuthMode, rights, documentCache);
+ versioningThread.start();
+ versioningThread.join();
+ if (versioningThread.getException() != null) {
+ Throwable thr = versioningThread.getException();
+ 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) {
+ handleIOException((IOException) thr);
+ } else if (thr instanceof RuntimeException) {
+ throw (RuntimeException) thr;
}
- } catch (JAXBException ex) {
- throw new ManifoldCFException("addSeedDocuments error - response is not a valid XML: " + ex.getMessage(), ex);
- } finally {
- EntityUtils.consume(response.getEntity());
- method.releaseConnection();
+ throw new ManifoldCFException("getDocumentVersions error: " + thr.getMessage(), thr);
}
- } catch (UnsupportedEncodingException ex) {
- throw new ManifoldCFException("getDocumentVersions error - invalid chars in id: " + ex.getMessage(), ex);
- } catch (IOException ex) {
- long currentTime = System.currentTimeMillis();
- throw new ServiceInterruption("Exception while seeding, retrying: " + ex.getMessage(), ex,
- currentTime + 300000L, //powtarzaj co piÄÄ minut
- currentTime + 60L * 60000L, //powtarzaj przez 1 godzinÄ
- -1, //bez limitu powtórzeÅ
- true); //wyrzuÄ wyjÄ
tek jeÅli nie uda siÄ pobraÄ
+ return versioningThread.getVersions();
+ } catch (InterruptedException ex) {
+ throw new ManifoldCFException("getDocumentVersions error: " + ex.getMessage(), ex);
}
- return rval;
}
@Override
@@ -395,24 +365,17 @@ public class GenericConnector extends Ba
}
if (item.content != null) {
try {
- File temp = File.createTempFile("manifold", ".tmp");
- temp.deleteOnExit();
+ byte[] content = item.content.getBytes("UTF-8");
+ ByteArrayInputStream is = new ByteArrayInputStream(content);
try {
- FileUtils.writeStringToFile(temp, item.content);
- FileInputStream is = new FileInputStream(temp);
- doc.setBinary(is, temp.length());
+ doc.setBinary(is, content.length);
activities.ingestDocument(documentIdentifiers[i], versions[i], item.url, doc);
is.close();
} finally {
- temp.delete();
+ is.close();
}
} catch (IOException ex) {
- long currentTime = System.currentTimeMillis();
- throw new ServiceInterruption("Exception while processing " + documentIdentifiers[i] + ", retrying: " + ex.getMessage(), ex,
- currentTime + 300000L, //powtarzaj co piÄÄ minut
- currentTime + 60L * 60000L, //powtarzaj przez 1 godzinÄ
- -1, //bez limitu powtórzeÅ
- true); //wyrzuÄ wyjÄ
tek jeÅli nie uda siÄ pobraÄ
+ handleIOException(ex);
}
} else {
try {
@@ -443,12 +406,7 @@ public class GenericConnector extends Ba
} catch (UnsupportedEncodingException ex) {
throw new ManifoldCFException("processDocuments error - invalid chars in id: " + ex.getMessage(), ex);
} catch (IOException ex) {
- long currentTime = System.currentTimeMillis();
- throw new ServiceInterruption("Exception while processing " + documentIdentifiers[i] + ", retrying: " + ex.getMessage(), ex,
- currentTime + 300000L, //powtarzaj co piÄÄ minut
- currentTime + 60L * 60000L, //powtarzaj przez 1 godzinÄ
- -1, //bez limitu powtórzeÅ
- true); //wyrzuÄ wyjÄ
tek jeÅli nie uda siÄ pobraÄ
+ handleIOException(ex);
}
}
}
@@ -610,11 +568,11 @@ public class GenericConnector extends Ba
if (tabName.equals(Messages.getString(locale, "generic.Parameters"))) {
- out.print("<table class=\"displaytable\">\n"
- + "<tr>"
- + "<th></th>"
- + "<th>" + Messages.getBodyString(locale, "generic.ParameterName") + "</th>"
- + "<th>" + Messages.getBodyString(locale, "generic.ParameterValue") + "</th>"
+ out.print("<table class=\"formtable\">\n"
+ + "<tr class=\"formheaderrow\">"
+ + "<td class=\"formcolumnheader\"></td>"
+ + "<td class=\"formcolumnheader\">" + Messages.getBodyString(locale, "generic.ParameterName") + "</td>"
+ + "<td class=\"formcolumnheader\">" + Messages.getBodyString(locale, "generic.ParameterValue") + "</td>"
+ "</tr>");
i = 0;
@@ -980,6 +938,17 @@ public class GenericConnector extends Ba
return rval;
}
+ protected static void handleIOException(IOException e)
+ throws ManifoldCFException, ServiceInterruption {
+ if (!(e instanceof java.net.SocketTimeoutException) && (e instanceof InterruptedIOException)) {
+ throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
+ ManifoldCFException.INTERRUPTED);
+ }
+ long currentTime = System.currentTimeMillis();
+ throw new ServiceInterruption("IO exception: " + e.getMessage(), e, currentTime + 300000L,
+ currentTime + 3 * 60 * 60000L, -1, false);
+ }
+
static class PreemptiveAuth implements HttpRequestInterceptor {
private Credentials credentials;
@@ -994,6 +963,53 @@ public class GenericConnector extends Ba
}
}
+ protected static class CheckThread extends Thread {
+
+ protected HttpClient client;
+
+ protected String url;
+
+ protected Throwable exception = null;
+
+ protected String result = "Unknown";
+
+ public CheckThread(HttpClient client, String url) {
+ super();
+ setDaemon(true);
+ this.client = client;
+ this.url = url;
+ }
+
+ @Override
+ public void run() {
+ HttpGet method = new HttpGet(url);
+ try {
+ HttpResponse response = client.execute(method);
+ try {
+ if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
+ result = "Connection failed: " + response.getStatusLine().getReasonPhrase();
+ return;
+ }
+ EntityUtils.consume(response.getEntity());
+ result = "Connection OK";
+ } finally {
+ EntityUtils.consume(response.getEntity());
+ method.releaseConnection();
+ }
+ } catch (IOException ex) {
+ exception = ex;
+ }
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+
+ public String getResult() {
+ return result;
+ }
+ }
+
protected static class ExecuteSeedingThread extends Thread {
protected HttpClient client;
@@ -1051,6 +1067,89 @@ public class GenericConnector extends Ba
}
}
+ protected static class DocumentVersionThread extends Thread {
+
+ protected HttpClient client;
+
+ protected String url;
+
+ protected Throwable exception = null;
+
+ protected String[] versions;
+
+ protected ConcurrentHashMap<String, Item> documentCache;
+
+ protected String[] documentIdentifiers;
+
+ protected String genericAuthMode;
+
+ protected String defaultRights;
+
+ public DocumentVersionThread(HttpClient client, String url, String[] documentIdentifiers, String genericAuthMode, String defaultRights, ConcurrentHashMap<String, Item> documentCache) {
+ super();
+ setDaemon(true);
+ this.client = client;
+ this.url = url;
+ this.documentCache = documentCache;
+ this.documentIdentifiers = documentIdentifiers;
+ this.genericAuthMode = genericAuthMode;
+ this.defaultRights = defaultRights;
+ this.versions = new String[documentIdentifiers.length];
+ for (int i = 0; i < versions.length; i++) {
+ versions[i] = null;
+ }
+ }
+
+ @Override
+ public void run() {
+ try {
+ HttpGet method = new HttpGet(url.toString());
+
+ HttpResponse response = client.execute(method);
+ try {
+ if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
+ exception = new ManifoldCFException("addSeedDocuments error - interface returned incorrect return code");
+ return;
+ }
+ JAXBContext context;
+ context = JAXBContext.newInstance(Items.class);
+ Unmarshaller m = context.createUnmarshaller();
+ Items items = (Items) m.unmarshal(response.getEntity().getContent());
+ if (items.items != null) {
+ for (Item item : items.items) {
+ documentCache.put(item.id, item);
+ for (int i = 0; i < versions.length; i++) {
+ if (documentIdentifiers[i].equals(item.id)) {
+ if ("provided".equals(genericAuthMode)) {
+ versions[i] = item.getVersionString();
+ } else {
+ versions[i] = item.version + defaultRights;
+ }
+ break;
+ }
+ }
+ }
+ }
+ } catch (JAXBException ex) {
+ exception = ex;
+ } finally {
+ EntityUtils.consume(response.getEntity());
+ method.releaseConnection();
+ }
+ } catch (Exception ex) {
+ exception = ex;
+ }
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+
+ public String[] getVersions() {
+ return versions;
+ }
+ }
+
static public class SAXSeedingHandler extends DefaultHandler {
protected ISeedingActivity activities;
Modified: manifoldcf/branches/CONNECTORS-727/connectors/generic/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-727/connectors/generic/pom.xml?rev=1496002&r1=1496001&r2=1496002&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-727/connectors/generic/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-727/connectors/generic/pom.xml Mon Jun 24 12:13:42 2013
@@ -30,6 +30,14 @@
<build>
<sourceDirectory>${basedir}/connector/src/main/java</sourceDirectory>
<testSourceDirectory>${basedir}/connector/src/test/java</testSourceDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}/connector/src/main/native2ascii</directory>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ </resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>