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 2013/06/12 22:49:11 UTC
svn commit: r1492417 - in /manifoldcf/branches/CONNECTORS-714:
connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/
connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/liv...
Author: kwright
Date: Wed Jun 12 20:49:10 2013
New Revision: 1492417
URL: http://svn.apache.org/r1492417
Log:
Move the XThreadOutputStream to core/common, and build a thread that does what we want in the LiveLinkConnector.
Added:
manifoldcf/branches/CONNECTORS-714/framework/core/src/main/java/org/apache/manifoldcf/core/common/XThreadOutputStream.java (with props)
Modified:
manifoldcf/branches/CONNECTORS-714/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveSession.java
manifoldcf/branches/CONNECTORS-714/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkConnector.java
Modified: manifoldcf/branches/CONNECTORS-714/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveSession.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-714/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveSession.java?rev=1492417&r1=1492416&r2=1492417&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-714/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveSession.java (original)
+++ manifoldcf/branches/CONNECTORS-714/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveSession.java Wed Jun 12 20:49:10 2013
@@ -147,41 +147,4 @@ public class GoogleDriveSession {
}
}
- protected static class XThreadOutputStream extends OutputStream {
- protected final XThreadInputStream inputStream;
-
- byte[] byteBuffer = new byte[1];
-
- public XThreadOutputStream(XThreadInputStream inputStream) {
- this.inputStream = inputStream;
- }
-
- @Override
- public void write(int c)
- throws IOException {
- byteBuffer[0] = (byte)c;
- try {
- inputStream.stuffQueue(byteBuffer,0,1);
- } catch (InterruptedException e) {
- throw new InterruptedIOException(e.getMessage());
- }
- }
-
- @Override
- public void write(byte[] buffer, int pos, int amt)
- throws IOException {
- try {
- inputStream.stuffQueue(buffer,pos,amt);
- } catch (InterruptedException e) {
- throw new InterruptedIOException(e.getMessage());
- }
- }
-
- @Override
- public void close()
- throws IOException {
- inputStream.doneStuffingQueue();
- super.close();
- }
- }
}
Modified: manifoldcf/branches/CONNECTORS-714/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-714/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkConnector.java?rev=1492417&r1=1492416&r2=1492417&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-714/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkConnector.java (original)
+++ manifoldcf/branches/CONNECTORS-714/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkConnector.java Wed Jun 12 20:49:10 2013
@@ -24,6 +24,7 @@ import org.apache.manifoldcf.crawler.int
import org.apache.manifoldcf.crawler.system.Logging;
import org.apache.manifoldcf.crawler.system.ManifoldCF;
import org.apache.manifoldcf.core.common.XThreadInputStream;
+import org.apache.manifoldcf.core.common.XThreadOutputStream;
import java.io.*;
import java.util.*;
@@ -7275,6 +7276,76 @@ public class LivelinkConnector extends o
}
+ /** This thread performs a LAPI FetchVersion command, streaming the resulting
+ * document back through a XThreadInputStream to the invoking thread.
+ */
+ protected class DocumentReadingThread extends Thread
+ {
+
+ protected Throwable exception = null;
+ protected final int volumeID;
+ protected final int docID;
+ protected final int versionNumber;
+ protected final XThreadInputStream stream;
+
+ public DocumentReadingThread(int volumeID, int docID, int versionNumber)
+ {
+ super();
+ this.volumeID = volumeID;
+ this.docID = docID;
+ this.versionNumber = versionNumber;
+ this.stream = new XThreadInputStream();
+ setDaemon(true);
+ }
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ XThreadOutputStream outputStream = new XThreadOutputStream(stream);
+ try
+ {
+ int rval = LLDocs.FetchVersion(volumeID, docID, versionNumber, outputStream);
+ // MHL to do something with rval
+ }
+ finally
+ {
+ outputStream.close();
+ }
+ } catch (Throwable e) {
+ this.exception = e;
+ }
+ }
+
+ public InputStream getSafeInputStream() {
+ return stream;
+ }
+
+ public void finishUp()
+ throws InterruptedException, IOException
+ {
+ // This will be called during the finally
+ // block in the case where all is well (and
+ // the stream completed) and in the case where
+ // there were exceptions.
+ stream.abort();
+ join();
+ Throwable thr = exception;
+ if (thr != null) {
+ if (thr instanceof IOException)
+ throw (IOException) thr;
+ else if (thr instanceof RuntimeException)
+ throw (RuntimeException) thr;
+ else if (thr instanceof Error)
+ throw (Error) thr;
+ else
+ throw new RuntimeException("Unhandled exception of type: "+thr.getClass().getName(),thr);
+ }
+ }
+
+ }
+
/** This thread does the actual socket communication with the server.
* It's set up so that it can be abandoned at shutdown time.
*
Added: manifoldcf/branches/CONNECTORS-714/framework/core/src/main/java/org/apache/manifoldcf/core/common/XThreadOutputStream.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-714/framework/core/src/main/java/org/apache/manifoldcf/core/common/XThreadOutputStream.java?rev=1492417&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-714/framework/core/src/main/java/org/apache/manifoldcf/core/common/XThreadOutputStream.java (added)
+++ manifoldcf/branches/CONNECTORS-714/framework/core/src/main/java/org/apache/manifoldcf/core/common/XThreadOutputStream.java Wed Jun 12 20:49:10 2013
@@ -0,0 +1,65 @@
+/* $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.core.common;
+
+import java.io.*;
+
+/** Output stream, which writes to XThreadInputStream.
+* Use this when an API method needs to write to an output stream, but
+* you want an input stream in the other thread receiving the data.
+*/
+public class XThreadOutputStream extends OutputStream {
+
+ protected final XThreadInputStream inputStream;
+
+ byte[] byteBuffer = new byte[1];
+
+ public XThreadOutputStream(XThreadInputStream inputStream) {
+ this.inputStream = inputStream;
+ }
+
+ @Override
+ public void write(int c)
+ throws IOException {
+ byteBuffer[0] = (byte)c;
+ try {
+ inputStream.stuffQueue(byteBuffer,0,1);
+ } catch (InterruptedException e) {
+ throw new InterruptedIOException(e.getMessage());
+ }
+ }
+
+ @Override
+ public void write(byte[] buffer, int pos, int amt)
+ throws IOException {
+ try {
+ inputStream.stuffQueue(buffer,pos,amt);
+ } catch (InterruptedException e) {
+ throw new InterruptedIOException(e.getMessage());
+ }
+ }
+
+ @Override
+ public void close()
+ throws IOException {
+ inputStream.doneStuffingQueue();
+ super.close();
+ }
+}
+
Propchange: manifoldcf/branches/CONNECTORS-714/framework/core/src/main/java/org/apache/manifoldcf/core/common/XThreadOutputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-714/framework/core/src/main/java/org/apache/manifoldcf/core/common/XThreadOutputStream.java
------------------------------------------------------------------------------
svn:keywords = Id