Author: kwright
Date: Wed May 15 18:13:30 2013
New Revision: 1482987
URL: http://svn.apache.org/r1482987
Log:
Add ListUsers thread.
Added:
manifoldcf/branches/CONNECTORS-689/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/IDQueue.java
(with props)
Modified:
manifoldcf/branches/CONNECTORS-689/connectors/livelink/build-stub/src/main/java/com/opentext/api/LLValueEnumeration.java
manifoldcf/branches/CONNECTORS-689/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkConnector.java
Modified:
manifoldcf/branches/CONNECTORS-689/connectors/livelink/build-stub/src/main/java/com/opentext/api/LLValueEnumeration.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-689/connectors/livelink/build-stub/src/main/java/com/opentext/api/LLValueEnumeration.java?rev=1482987&r1=1482986&r2=1482987&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-689/connectors/livelink/build-stub/src/main/java/com/opentext/api/LLValueEnumeration.java
(original)
+++
manifoldcf/branches/CONNECTORS-689/connectors/livelink/build-stub/src/main/java/com/opentext/api/LLValueEnumeration.java
Wed May 15 18:13:30 2013
@@ -22,7 +22,7 @@ import java.util.Enumeration;
/** Stub classes to get connector to build.
*/
-public class LLValueEnumeration
+public class LLValueEnumeration implements Enumeration
{
public LLValueEnumeration()
{
Added:
manifoldcf/branches/CONNECTORS-689/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/IDQueue.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-689/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/IDQueue.java?rev=1482987&view=auto
==============================================================================
---
manifoldcf/branches/CONNECTORS-689/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/IDQueue.java
(added)
+++
manifoldcf/branches/CONNECTORS-689/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/IDQueue.java
Wed May 15 18:13:30 2013
@@ -0,0 +1,89 @@
+/* $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.livelink;
+
+import java.util.*;
+
+/** Thread-safe class that functions as a limited-size buffer of Livelink ID's
*/
+public class IDQueue
+{
+ protected static int MAX_SIZE = 1024;
+
+ protected List<Integer> buffer = new ArrayList<Integer>(MAX_SIZE);
+
+ protected boolean complete = false;
+ protected boolean abandoned = false;
+
+ /** Constructor */
+ public IDQueue()
+ {
+ }
+
+ /** Add an id to the buffer, and block if the buffer is full */
+ public synchronized void add(Integer id)
+ throws InterruptedException
+ {
+ while (buffer.size() == MAX_SIZE && !abandoned)
+ wait();
+ if (abandoned)
+ return;
+ buffer.add(id);
+ // Notify threads that are waiting on there being stuff in the queue
+ notifyAll();
+ }
+
+ /** Signal that the buffer should be abandoned */
+ public synchronized void abandon()
+ {
+ abandoned = true;
+ // Notify waiting threads
+ notifyAll();
+ }
+
+ /** Signal that the operation is complete, and that no more pageID's
+ * will be added.
+ */
+ public synchronized void done()
+ {
+ complete = true;
+ // Notify threads that are waiting for stuff to appear, because it won't
+ notifyAll();
+ }
+
+ /** Pull an id off the buffer, and wait if there's more to come.
+ * Returns null if the operation is complete.
+ */
+ public synchronized Integer fetch()
+ throws InterruptedException
+ {
+ while (buffer.size() == 0 && !complete)
+ wait();
+ if (buffer.size() == 0)
+ return null;
+ boolean isBufferFull = (buffer.size() == MAX_SIZE);
+ Integer rval = buffer.remove(buffer.size()-1);
+ // Notify those threads waiting on buffer being not completely full to wake
+ if (isBufferFull)
+ notifyAll();
+ return rval;
+ }
+
+}
+
+
Propchange:
manifoldcf/branches/CONNECTORS-689/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/IDQueue.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
manifoldcf/branches/CONNECTORS-689/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/IDQueue.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified:
manifoldcf/branches/CONNECTORS-689/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkConnector.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-689/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkConnector.java?rev=1482987&r1=1482986&r2=1482987&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-689/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkConnector.java
(original)
+++
manifoldcf/branches/CONNECTORS-689/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkConnector.java
Wed May 15 18:13:30 2013
@@ -922,8 +922,8 @@ public class LivelinkConnector extends o
// Walk the specification for the "startpoint" types. Amalgamate these
into a list of strings.
// Presume that all roots are startpoint nodes
- int i = 0;
- while (i < spec.getChildCount())
+ boolean doUserWorkspaces = false;
+ for (int i = 0; i < spec.getChildCount(); i++)
{
SpecificationNode n = spec.getChild(i);
if (n.getType().equals("startpoint"))
@@ -948,7 +948,20 @@ public class LivelinkConnector extends o
path,"NOT FOUND",null,null);
}
}
- i++;
+ else if (n.getType().equals("userworkspace"))
+ {
+ if (n.getAttributeValue("value").equals("true"))
+ doUserWorkspaces = true;
+ else if (n.getAttributeValue("value").equals("false"))
+ doUserWorkspaces = false;
+ }
+
+ if (doUserWorkspaces)
+ {
+ // Do ListUsers and enumerate the values.
+ // MHL
+ }
+
}
}
@@ -4734,7 +4747,7 @@ public class LivelinkConnector extends o
return null;
String[] rval = new String[children.size()];
- Enumeration en = children.enumerateValues();
+ LLValueEnumeration en = children.enumerateValues();
int j = 0;
while (en.hasMoreElements())
@@ -4955,7 +4968,7 @@ public class LivelinkConnector extends o
if (children == null)
return null;
String[] rval = new String[children.size()];
- Enumeration en = children.enumerateValues();
+ LLValueEnumeration en = children.enumerateValues();
int j = 0;
while (en.hasMoreElements())
@@ -5823,7 +5836,69 @@ public class LivelinkConnector extends o
}
}
-
+ /** Thread we can abandon that lists all users (except admin).
+ */
+ protected class ListUsersThread extends Thread
+ {
+ protected final IDQueue queue;
+ protected Throwable exception = null;
+
+ public ListUsersThread(IDQueue queue)
+ {
+ super();
+ setDaemon(true);
+ this.queue = queue;
+ }
+
+ public void run()
+ {
+ try
+ {
+ LLValue userList = new LLValue();
+ int status = LLUsers.ListUsers(userList);
+
+ if (Logging.connectors.isDebugEnabled())
+ {
+ Logging.connectors.debug("Livelink: User list retrieved:
status="+Integer.toString(status));
+ }
+
+ if (status < 0)
+ {
+ Logging.connectors.debug("Livelink: User list inaccessable
("+llServer.getErrors()+")");
+ return;
+ }
+
+ if (status != 0)
+ {
+ throw new ManifoldCFException("Error retrieving user list:
status="+Integer.toString(status)+" ("+llServer.getErrors()+")");
+ }
+
+ // Enumerate the list and stuff the id queue
+ LLValueEnumeration enumeration = userList.enumerateValues();
+ while (enumeration.hasMoreElements())
+ {
+ LLValue elem = (LLValue)enumeration.nextElement();
+ int objID = elem.toInteger("ID");
+ if (objID == 1000 || objID == 1001)
+ // Skip administrator ID's
+ continue;
+ queue.add(new Integer(objID));
+ }
+ queue.done();
+ }
+ catch (Throwable e)
+ {
+ this.exception = e;
+ }
+ }
+
+ public Throwable getException()
+ {
+ return exception;
+ }
+
+ }
+
/** Thread we can abandon that gets user information for a userID.
*/
protected class GetUserInfoThread extends Thread