Search in sources :

Example 6 with ManifoldCFException

use of org.apache.manifoldcf.core.interfaces.ManifoldCFException in project manifoldcf by apache.

the class CmisRepositoryConnector method checkConnection.

protected void checkConnection() throws ManifoldCFException, ServiceInterruption {
    while (true) {
        boolean noSession = (session == null);
        getSession();
        long currentTime;
        CheckConnectionThread t = new CheckConnectionThread();
        try {
            t.start();
            t.join();
            Throwable thr = t.getException();
            if (thr != null) {
                if (thr instanceof RemoteException)
                    throw (RemoteException) thr;
                else if (thr instanceof CmisConnectionException)
                    throw new ManifoldCFException("CMIS: Error during checking connection: " + thr.getMessage(), thr);
                else
                    throw (Error) thr;
            }
            return;
        } catch (InterruptedException e) {
            t.interrupt();
            throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED);
        } catch (RemoteException e) {
            Throwable e2 = e.getCause();
            if (e2 instanceof InterruptedException || e2 instanceof InterruptedIOException)
                throw new ManifoldCFException(e2.getMessage(), e2, ManifoldCFException.INTERRUPTED);
            if (noSession) {
                currentTime = System.currentTimeMillis();
                throw new ServiceInterruption("Transient error connecting to filenet service: " + e.getMessage(), currentTime + 60000L);
            }
            session = null;
            lastSessionFetch = -1L;
            continue;
        }
    }
}
Also used : ServiceInterruption(org.apache.manifoldcf.agents.interfaces.ServiceInterruption) InterruptedIOException(java.io.InterruptedIOException) CmisConnectionException(org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) RemoteException(java.rmi.RemoteException)

Example 7 with ManifoldCFException

use of org.apache.manifoldcf.core.interfaces.ManifoldCFException in project manifoldcf by apache.

the class CmisRepositoryConnector method releaseCheck.

/**
 * Release the session, if it's time.
 */
protected void releaseCheck() throws ManifoldCFException {
    if (lastSessionFetch == -1L)
        return;
    long currentTime = System.currentTimeMillis();
    if (currentTime >= lastSessionFetch + timeToRelease) {
        DestroySessionThread t = new DestroySessionThread();
        try {
            t.start();
            t.join();
            Throwable thr = t.getException();
            if (thr != null) {
                if (thr instanceof RemoteException)
                    throw (RemoteException) thr;
                else
                    throw (Error) thr;
            }
            session = null;
            lastSessionFetch = -1L;
        } catch (InterruptedException e) {
            t.interrupt();
            throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED);
        } catch (RemoteException e) {
            Throwable e2 = e.getCause();
            if (e2 instanceof InterruptedException || e2 instanceof InterruptedIOException)
                throw new ManifoldCFException(e2.getMessage(), e2, ManifoldCFException.INTERRUPTED);
            session = null;
            lastSessionFetch = -1L;
            // Treat this as a transient problem
            Logging.connectors.warn("CMIS: Transient remote exception closing session: " + e.getMessage(), e);
        }
    }
}
Also used : InterruptedIOException(java.io.InterruptedIOException) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) RemoteException(java.rmi.RemoteException)

Example 8 with ManifoldCFException

use of org.apache.manifoldcf.core.interfaces.ManifoldCFException in project manifoldcf by apache.

the class APISanityHSQLDBIT method waitJobInactive.

protected void waitJobInactive(String jobIDString, long maxTime) throws Exception {
    long startTime = System.currentTimeMillis();
    while (System.currentTimeMillis() < startTime + maxTime) {
        String status = getJobStatus(jobIDString);
        if (status == null)
            throw new Exception("No such job: '" + jobIDString + "'");
        if (status.equals("not yet run"))
            throw new Exception("Job was never started.");
        if (status.equals("done"))
            return;
        if (status.equals("error"))
            throw new Exception("Job reports error.");
        ManifoldCF.sleep(1000L);
        continue;
    }
    throw new ManifoldCFException("ManifoldCF did not terminate in the allotted time of " + new Long(maxTime).toString() + " milliseconds");
}
Also used : ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) IOException(java.io.IOException)

Example 9 with ManifoldCFException

use of org.apache.manifoldcf.core.interfaces.ManifoldCFException in project manifoldcf by apache.

the class AmazonS3Connector method check.

/**
 */
@Override
public String check() throws ManifoldCFException {
    // connect with amazons3 client
    Logging.connectors.info("Checking connection");
    try {
        // invokes the check thread
        CheckThread checkThread = new CheckThread(getClient());
        checkThread.start();
        // should wait for join
        checkThread.join();
        if (checkThread.getException() != null) {
            Throwable thr = checkThread.getException();
            return "Check exception: " + thr.getMessage();
        }
        return checkThread.getResult();
    } catch (InterruptedException ex) {
        Logging.connectors.error("Error while checking connection", ex);
        throw new ManifoldCFException(ex.getMessage(), ex, ManifoldCFException.INTERRUPTED);
    }
}
Also used : ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException)

Example 10 with ManifoldCFException

use of org.apache.manifoldcf.core.interfaces.ManifoldCFException in project manifoldcf by apache.

the class AmazonS3Connector method getSeeds.

private void getSeeds(ISeedingActivity activities, String[] buckets) throws ManifoldCFException, ServiceInterruption {
    GetSeedsThread t = new GetSeedsThread(getClient(), buckets);
    try {
        t.start();
        boolean wasInterrupted = false;
        try {
            XThreadBuffer<S3Artifact> seedBuffer = t.getBuffer();
            // join with the child thread.
            while (true) {
                // The only kind of exceptions this can throw are going to
                // shut the process down.
                S3Artifact s3Artifact = seedBuffer.fetch();
                if (s3Artifact == null) {
                    Logging.connectors.info("No artifact retured");
                    break;
                }
                String issueKey = s3Artifact.getBucketName() + STD_SEPARATOR_BUCKET_AND_KEY + s3Artifact.getKey();
                Logging.connectors.info("Issue key is : " + issueKey);
                activities.addSeedDocument(issueKey);
            }
        } catch (InterruptedException e) {
            Logging.connectors.error(e);
            wasInterrupted = true;
            throw e;
        } catch (ManifoldCFException e) {
            Logging.connectors.error(e);
            if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                wasInterrupted = true;
            throw e;
        } finally {
            if (!wasInterrupted)
                t.finishUp();
        }
    } catch (InterruptedException e) {
        Logging.connectors.error(e);
        t.interrupt();
        throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED);
    } catch (java.net.SocketTimeoutException e) {
        Logging.connectors.error(e);
        handleIOException(e);
    } catch (InterruptedIOException e) {
        Logging.connectors.error(e);
        t.interrupt();
        handleIOException(e);
    } catch (IOException e) {
        Logging.connectors.error(e);
        handleIOException(e);
    } catch (ResponseException e) {
        Logging.connectors.error(e);
        handleResponseException(e);
    }
}
Also used : InterruptedIOException(java.io.InterruptedIOException) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) S3Artifact(org.apache.manifoldcf.amazons3.S3Artifact)

Aggregations

ManifoldCFException (org.apache.manifoldcf.core.interfaces.ManifoldCFException)174 IOException (java.io.IOException)81 InterruptedIOException (java.io.InterruptedIOException)71 ServiceInterruption (org.apache.manifoldcf.agents.interfaces.ServiceInterruption)32 ArrayList (java.util.ArrayList)27 MessageElement (org.apache.axis.message.MessageElement)23 RemoteException (java.rmi.RemoteException)22 InputStream (java.io.InputStream)18 SpecificationNode (org.apache.manifoldcf.core.interfaces.SpecificationNode)17 QName (javax.xml.namespace.QName)15 Date (java.util.Date)14 RepositoryDocument (org.apache.manifoldcf.agents.interfaces.RepositoryDocument)14 XMLDoc (org.apache.manifoldcf.core.common.XMLDoc)12 MalformedURLException (java.net.MalformedURLException)11 UnknownHostException (java.net.UnknownHostException)11 SmbFile (jcifs.smb.SmbFile)9 Iterator (java.util.Iterator)8 ConfigurationNode (org.apache.manifoldcf.core.interfaces.ConfigurationNode)8 HashMap (java.util.HashMap)7 CmisConnectionException (org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException)7