Search in sources :

Example 11 with ManifoldCFException

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

the class AmazonS3DocumentProcessUtility method getS3Artifact.

/**
 * Get the s3artifact (document) using the document identifier ( bucket,key)
 * @param documentIdentifier
 * @return
 * @throws ManifoldCFException
 */
protected S3Artifact getS3Artifact(String documentIdentifier) throws ManifoldCFException {
    String key;
    String bucketName = documentIdentifier.split(AmazonS3Config.STD_SEPARATOR_BUCKET_AND_KEY)[0];
    key = documentIdentifier.split(AmazonS3Config.STD_SEPARATOR_BUCKET_AND_KEY)[1];
    if (StringUtils.isEmpty(bucketName) || StringUtils.isEmpty(key))
        throw new ManifoldCFException("bucket or key name is empty");
    return new S3Artifact(bucketName, key);
}
Also used : ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) S3Artifact(org.apache.manifoldcf.amazons3.S3Artifact)

Example 12 with ManifoldCFException

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

the class CmisOutputConnector method removeDocument.

@Override
public void removeDocument(String documentURI, String outputDescription, IOutputRemoveActivity activities) throws ManifoldCFException, ServiceInterruption {
    getSession();
    long startTime = System.currentTimeMillis();
    String result = StringUtils.EMPTY;
    boolean isDropZoneFolder = isDropZoneFolder(cmisQuery);
    // append the prefix for the relative path in the target repo
    try {
        if (isDropZoneFolder && parentDropZoneFolder != null && StringUtils.isNotEmpty(documentURI)) {
            String parentDropZonePath = parentDropZoneFolder.getPath();
            String contentPath = getContentPath(documentURI);
            String fullDocumentURIinTargetRepo = parentDropZonePath + contentPath;
            if (session.existsPath(fullDocumentURIinTargetRepo)) {
                session.deleteByPath(fullDocumentURIinTargetRepo);
                result = DOCUMENT_DELETION_STATUS_ACCEPTED;
            } else {
                result = DOCUMENT_DELETION_STATUS_REJECTED;
            }
        } else {
            result = DOCUMENT_DELETION_STATUS_REJECTED;
        }
    } catch (Exception e) {
        result = DOCUMENT_DELETION_STATUS_REJECTED;
        throw new ManifoldCFException(e.getMessage(), e);
    } finally {
        activities.recordActivity(startTime, ACTIVITY_DELETE, null, documentURI, null, result);
    }
}
Also used : ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) CmisContentAlreadyExistsException(org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException) URISyntaxException(java.net.URISyntaxException) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) NotBoundException(java.rmi.NotBoundException) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) RemoteException(java.rmi.RemoteException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) CmisPermissionDeniedException(org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException) InterruptedIOException(java.io.InterruptedIOException) CmisNameConstraintViolationException(org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException) CmisConnectionException(org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException) IOException(java.io.IOException)

Example 13 with ManifoldCFException

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

the class CmisOutputConnector method disconnect.

/**
 * Close the connection. Call this before discarding the connection.
 */
@Override
public void disconnect() throws ManifoldCFException {
    if (session != null) {
        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);
        }
    }
    username = null;
    password = null;
    protocol = null;
    server = null;
    port = null;
    path = null;
    binding = null;
    repositoryId = null;
    cmisQuery = null;
    createTimestampTree = Boolean.FALSE.toString();
    versioningState = VersioningState.NONE;
}
Also used : InterruptedIOException(java.io.InterruptedIOException) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) RemoteException(java.rmi.RemoteException)

Example 14 with ManifoldCFException

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

the class APISanityHSQLDBIT method sanityCheck.

@Test
public void sanityCheck() throws Exception {
    try {
        int i;
        // Create a basic file system connection, and save it.
        ConfigurationNode connectionObject;
        ConfigurationNode child;
        Configuration requestObject;
        Configuration result;
        connectionObject = new ConfigurationNode("repositoryconnection");
        child = new ConfigurationNode("name");
        child.setValue("Alfresco Connector");
        connectionObject.addChild(connectionObject.getChildCount(), child);
        child = new ConfigurationNode("class_name");
        child.setValue("org.apache.manifoldcf.crawler.connectors.alfrescowebscript.AlfrescoConnector");
        connectionObject.addChild(connectionObject.getChildCount(), child);
        child = new ConfigurationNode("description");
        child.setValue("Alfresco Repository Connector");
        connectionObject.addChild(connectionObject.getChildCount(), child);
        child = new ConfigurationNode("max_connections");
        child.setValue("10");
        connectionObject.addChild(connectionObject.getChildCount(), child);
        child = new ConfigurationNode("configuration");
        // Alfresco Repository Connector parameters
        // protocol
        ConfigurationNode alfrescoProtocolNode = new ConfigurationNode("_PARAMETER_");
        alfrescoProtocolNode.setAttribute("name", ALFRESCO_PROTOCOL_PARAM);
        alfrescoProtocolNode.setValue(ALFRESCO_PROTOCOL);
        child.addChild(child.getChildCount(), alfrescoProtocolNode);
        // server
        ConfigurationNode alfrescoServerNode = new ConfigurationNode("_PARAMETER_");
        alfrescoServerNode.setAttribute("name", ALFRESCO_HOSTNAME_PARAM);
        alfrescoServerNode.setValue(ALFRESCO_HOSTNAME);
        child.addChild(child.getChildCount(), alfrescoServerNode);
        // port
        ConfigurationNode alfrescoPortNode = new ConfigurationNode("_PARAMETER_");
        alfrescoPortNode.setAttribute("name", ALFRESCO_PORT_PARAM);
        alfrescoPortNode.setValue(ALFRESCO_PORT);
        child.addChild(child.getChildCount(), alfrescoPortNode);
        // endpoint
        ConfigurationNode alfrescoEndpointNode = new ConfigurationNode("_PARAMETER_");
        alfrescoEndpointNode.setAttribute("name", ALFRESCO_ENDPOINT_PARAM);
        alfrescoEndpointNode.setValue(ALFRESCO_ENDPOINT);
        child.addChild(child.getChildCount(), alfrescoEndpointNode);
        // storeProtocol
        ConfigurationNode alfrescoStoreProtocol = new ConfigurationNode("_PARAMETER_");
        alfrescoStoreProtocol.setAttribute("name", ALFRESCO_STOREPROTOCOL_PARAM);
        alfrescoStoreProtocol.setValue(ALFRESCO_STOREPROTOCOL);
        child.addChild(child.getChildCount(), alfrescoStoreProtocol);
        // storeId
        ConfigurationNode alfrescoStoreId = new ConfigurationNode("_PARAMETER_");
        alfrescoStoreId.setAttribute("name", ALFRESCO_STOREID_PARAM);
        alfrescoStoreId.setValue(ALFRESCO_STOREID);
        child.addChild(child.getChildCount(), alfrescoStoreId);
        // username
        ConfigurationNode alfrescoUsernameNode = new ConfigurationNode("_PARAMETER_");
        alfrescoUsernameNode.setAttribute("name", ALFRESCO_USERNAME_PARAM);
        alfrescoUsernameNode.setValue(ALFRESCO_USERNAME);
        child.addChild(child.getChildCount(), alfrescoUsernameNode);
        // password
        ConfigurationNode alfrescoPasswordNode = new ConfigurationNode("_PARAMETER_");
        alfrescoPasswordNode.setAttribute("name", ALFRESCO_PASSWORD_PARAM);
        alfrescoPasswordNode.setValue(ManifoldCF.obfuscate(ALFRESCO_PASSWORD));
        child.addChild(child.getChildCount(), alfrescoPasswordNode);
        connectionObject.addChild(connectionObject.getChildCount(), child);
        requestObject = new Configuration();
        requestObject.addChild(0, connectionObject);
        result = performAPIPutOperationViaNodes("repositoryconnections/Alfresco%20Connector", 201, requestObject);
        i = 0;
        while (i < result.getChildCount()) {
            ConfigurationNode resultNode = result.findChild(i++);
            if (resultNode.getType().equals("error"))
                throw new Exception(resultNode.getValue());
        }
        // Create a basic null output connection, and save it.
        connectionObject = new ConfigurationNode("outputconnection");
        child = new ConfigurationNode("name");
        child.setValue("Null Connection");
        connectionObject.addChild(connectionObject.getChildCount(), child);
        child = new ConfigurationNode("class_name");
        child.setValue("org.apache.manifoldcf.agents.tests.TestingOutputConnector");
        connectionObject.addChild(connectionObject.getChildCount(), child);
        child = new ConfigurationNode("description");
        child.setValue("Null Connection");
        connectionObject.addChild(connectionObject.getChildCount(), child);
        child = new ConfigurationNode("max_connections");
        child.setValue("100");
        connectionObject.addChild(connectionObject.getChildCount(), child);
        requestObject = new Configuration();
        requestObject.addChild(0, connectionObject);
        result = performAPIPutOperationViaNodes("outputconnections/Null%20Connection", 201, requestObject);
        i = 0;
        while (i < result.getChildCount()) {
            ConfigurationNode resultNode = result.findChild(i++);
            if (resultNode.getType().equals("error"))
                throw new Exception(resultNode.getValue());
        }
        // Create a job.
        ConfigurationNode jobObject = new ConfigurationNode("job");
        child = new ConfigurationNode("description");
        child.setValue("Test Job");
        jobObject.addChild(jobObject.getChildCount(), child);
        child = new ConfigurationNode("repository_connection");
        child.setValue("Alfresco Connector");
        jobObject.addChild(jobObject.getChildCount(), child);
        // Revamped way of adding output connection
        child = new ConfigurationNode("pipelinestage");
        ConfigurationNode pipelineChild = new ConfigurationNode("stage_id");
        pipelineChild.setValue("0");
        child.addChild(child.getChildCount(), pipelineChild);
        pipelineChild = new ConfigurationNode("stage_isoutput");
        pipelineChild.setValue("true");
        child.addChild(child.getChildCount(), pipelineChild);
        pipelineChild = new ConfigurationNode("stage_connectionname");
        pipelineChild.setValue("Null Connection");
        child.addChild(child.getChildCount(), pipelineChild);
        jobObject.addChild(jobObject.getChildCount(), child);
        child = new ConfigurationNode("run_mode");
        child.setValue("scan once");
        jobObject.addChild(jobObject.getChildCount(), child);
        child = new ConfigurationNode("start_mode");
        child.setValue("manual");
        jobObject.addChild(jobObject.getChildCount(), child);
        child = new ConfigurationNode("hopcount_mode");
        child.setValue("accurate");
        jobObject.addChild(jobObject.getChildCount(), child);
        child = new ConfigurationNode("document_specification");
        jobObject.addChild(jobObject.getChildCount(), child);
        requestObject = new Configuration();
        requestObject.addChild(0, jobObject);
        result = performAPIPostOperationViaNodes("jobs", 201, requestObject);
        String jobIDString = null;
        i = 0;
        while (i < result.getChildCount()) {
            ConfigurationNode resultNode = result.findChild(i++);
            if (resultNode.getType().equals("error"))
                throw new Exception(resultNode.getValue());
            else if (resultNode.getType().equals("job_id"))
                jobIDString = resultNode.getValue();
        }
        if (jobIDString == null)
            throw new Exception("Missing job_id from return!");
        // Now, start the job, and wait until it completes.
        startJob(jobIDString);
        waitJobInactive(jobIDString, 120000L);
        // Check to be sure we actually processed the right number of documents.
        // The test data area has 3 documents and one directory, and we have to count the root directory too.
        long count;
        count = getJobDocumentsProcessed(jobIDString);
        if (count == 0)
            throw new ManifoldCFException("No documents processed");
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
}
Also used : Configuration(org.apache.manifoldcf.core.interfaces.Configuration) ConfigurationNode(org.apache.manifoldcf.core.interfaces.ConfigurationNode) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) Test(org.junit.Test)

Example 15 with ManifoldCFException

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

the class AlfrescoRepositoryConnector method poll.

/**
 * This method is periodically called for all connectors that are connected but not
 * in active use.
 */
@Override
public void poll() throws ManifoldCFException {
    if (lastSessionFetch == -1L)
        return;
    long currentTime = System.currentTimeMillis();
    if (currentTime >= lastSessionFetch + timeToRelease) {
        try {
            AuthenticationUtils.endSession();
            session = null;
            lastSessionFetch = -1L;
        } catch (Exception e) {
            Logging.connectors.error("Alfresco: Error during polling: " + e.getMessage(), e);
            throw new ManifoldCFException("Alfresco: Error during polling: " + e.getMessage(), e);
        }
    }
}
Also used : ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) InterruptedIOException(java.io.InterruptedIOException) ParseException(java.text.ParseException) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) IOException(java.io.IOException) WebServiceException(org.alfresco.webservice.util.WebServiceException)

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