Search in sources :

Example 1 with SpecificationNode

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

the class CmisRepositoryConnector method fillInCMISQuerySpecificationMap.

/**
 * Fill in specification Velocity parameter map for CMISQuery tab.
 */
private static void fillInCMISQuerySpecificationMap(Map<String, String> newMap, Specification ds) {
    int i = 0;
    String cmisQuery = StringUtils.EMPTY;
    while (i < ds.getChildCount()) {
        SpecificationNode sn = ds.getChild(i);
        if (sn.getType().equals(JOB_STARTPOINT_NODE_TYPE)) {
            cmisQuery = sn.getAttributeValue(CmisConfig.CMIS_QUERY_PARAM);
        }
        i++;
    }
    newMap.put(CmisConfig.CMIS_QUERY_PARAM, cmisQuery);
}
Also used : SpecificationNode(org.apache.manifoldcf.core.interfaces.SpecificationNode)

Example 2 with SpecificationNode

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

the class CmisRepositoryConnector method addSeedDocuments.

/**
 * Queue "seed" documents.  Seed documents are the starting places for crawling activity.  Documents
 * are seeded when this method calls appropriate methods in the passed in ISeedingActivity object.
 *
 * This method can choose to find repository changes that happen only during the specified time interval.
 * The seeds recorded by this method will be viewed by the framework based on what the
 * getConnectorModel() method returns.
 *
 * It is not a big problem if the connector chooses to create more seeds than are
 * strictly necessary; it is merely a question of overall work required.
 *
 * The end time and seeding version string passed to this method may be interpreted for greatest efficiency.
 * For continuous crawling jobs, this method will
 * be called once, when the job starts, and at various periodic intervals as the job executes.
 *
 * When a job's specification is changed, the framework automatically resets the seeding version string to null.  The
 * seeding version string may also be set to null on each job run, depending on the connector model returned by
 * getConnectorModel().
 *
 * Note that it is always ok to send MORE documents rather than less to this method.
 * The connector will be connected before this method can be called.
 *@param activities is the interface this method should use to perform whatever framework actions are desired.
 *@param spec is a document specification (that comes from the job).
 *@param seedTime is the end of the time range of documents to consider, exclusive.
 *@param lastSeedVersion is the last seeding version string for this job, or null if the job has no previous seeding version string.
 *@param jobMode is an integer describing how the job is being run, whether continuous or once-only.
 *@return an updated seeding version string, to be stored with the job.
 */
@Override
public String addSeedDocuments(ISeedingActivity activities, Specification spec, String lastSeedVersion, long seedTime, int jobMode) throws ManifoldCFException, ServiceInterruption {
    getSession();
    String cmisQuery = StringUtils.EMPTY;
    for (int i = 0; i < spec.getChildCount(); i++) {
        SpecificationNode sn = spec.getChild(i);
        if (sn.getType().equals(JOB_STARTPOINT_NODE_TYPE)) {
            cmisQuery = sn.getAttributeValue(CmisConfig.CMIS_QUERY_PARAM);
            break;
        }
    }
    if (StringUtils.isEmpty(cmisQuery)) {
        // get root Documents from the CMIS Repository
        ItemIterable<CmisObject> cmisObjects = session.getRootFolder().getChildren();
        for (CmisObject cmisObject : cmisObjects) {
            activities.addSeedDocument(cmisObject.getId());
        }
    } else {
        cmisQuery = CmisRepositoryConnectorUtils.getCmisQueryWithObjectId(cmisQuery);
        ItemIterable<QueryResult> results = session.query(cmisQuery, false).getPage(1000000000);
        for (QueryResult result : results) {
            String id = result.getPropertyValueById(PropertyIds.OBJECT_ID);
            activities.addSeedDocument(id);
        }
    }
    return StringUtils.EMPTY;
}
Also used : SpecificationNode(org.apache.manifoldcf.core.interfaces.SpecificationNode) QueryResult(org.apache.chemistry.opencmis.client.api.QueryResult) CmisObject(org.apache.chemistry.opencmis.client.api.CmisObject)

Example 3 with SpecificationNode

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

the class AlfrescoRepositoryConnector method fillInLuceneQueryParameters.

/**
 * Fill in Velocity parameters for the LuceneQuery tab.
 */
private static void fillInLuceneQueryParameters(Map<String, String> paramMap, Specification ds) {
    int i = 0;
    String luceneQuery = "";
    while (i < ds.getChildCount()) {
        SpecificationNode sn = ds.getChild(i);
        if (sn.getType().equals(JOB_STARTPOINT_NODE_TYPE)) {
            luceneQuery = sn.getAttributeValue(AlfrescoConfig.LUCENE_QUERY_PARAM);
        }
        i++;
    }
    paramMap.put(AlfrescoConfig.LUCENE_QUERY_PARAM, luceneQuery);
}
Also used : SpecificationNode(org.apache.manifoldcf.core.interfaces.SpecificationNode)

Example 4 with SpecificationNode

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

the class AlfrescoRepositoryConnector method processSpecificationPost.

/**
 * Process a specification post.
 * This method is called at the start of job's edit or view page, whenever there is a possibility that form
 * data for a connection has been posted.  Its purpose is to gather form information and modify the
 * document specification accordingly.  The name of the posted form is always "editjob".
 * The connector will be connected before this method can be called.
 *@param variableContext contains the post data, including binary file-upload information.
 *@param locale is the locale the output is preferred to be in.
 *@param ds is the current document specification for this job.
 *@param connectionSequenceNumber is the unique number of this connection within the job.
 *@return null if all is well, or a string error message if there is an error that should prevent saving of
 * the job (and cause a redirection to an error page).
 */
@Override
public String processSpecificationPost(IPostParameters variableContext, Locale locale, Specification ds, int connectionSequenceNumber) throws ManifoldCFException {
    String seqPrefix = "s" + connectionSequenceNumber + "_";
    String luceneQuery = variableContext.getParameter(seqPrefix + AlfrescoConfig.LUCENE_QUERY_PARAM);
    if (luceneQuery != null) {
        int i = 0;
        while (i < ds.getChildCount()) {
            SpecificationNode oldNode = ds.getChild(i);
            if (oldNode.getType().equals(JOB_STARTPOINT_NODE_TYPE)) {
                ds.removeChild(i);
            } else
                i++;
        }
        SpecificationNode node = new SpecificationNode(JOB_STARTPOINT_NODE_TYPE);
        node.setAttribute(AlfrescoConfig.LUCENE_QUERY_PARAM, luceneQuery);
        ds.addChild(ds.getChildCount(), node);
    }
    return null;
}
Also used : SpecificationNode(org.apache.manifoldcf.core.interfaces.SpecificationNode)

Example 5 with SpecificationNode

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

the class SlackConnector method sendSlackMessage.

protected void sendSlackMessage(final Specification spec, final String nodeType) throws ManifoldCFException, ServiceInterruption {
    String channel = "";
    String message = "";
    for (int i = 0; i < spec.getChildCount(); i++) {
        SpecificationNode sn = spec.getChild(i);
        if (sn.getType().equals(SlackConfig.NODE_CHANNEL))
            channel = sn.getAttributeValue(SlackConfig.ATTRIBUTE_VALUE);
        else if (sn.getType().equals(SlackConfig.NODE_MESSAGE))
            message = sn.getAttributeValue(SlackConfig.ATTRIBUTE_VALUE);
    }
    // Look for node of the specified type
    if (nodeType != null) {
        for (int i = 0; i < spec.getChildCount(); i++) {
            SpecificationNode childNode = spec.getChild(i);
            if (childNode.getType().equals(nodeType)) {
                for (int j = 0; j < childNode.getChildCount(); j++) {
                    SpecificationNode sn = childNode.getChild(j);
                    if (sn.getType().equals(SlackConfig.NODE_CHANNEL))
                        channel = sn.getAttributeValue(SlackConfig.ATTRIBUTE_VALUE);
                    else if (sn.getType().equals(SlackConfig.NODE_MESSAGE))
                        message = sn.getAttributeValue(SlackConfig.ATTRIBUTE_VALUE);
                }
            }
        }
    }
    if (StringUtils.isBlank(message)) {
        return;
    }
    // Construct and send a slack message
    getSession();
    SendThread st = new SendThread(session, channel, message);
    st.start();
    try {
        st.finishUp();
    } catch (InterruptedException e) {
        throw new ManifoldCFException(e.getMessage(), ManifoldCFException.INTERRUPTED);
    } catch (IOException e) {
        handleIOException(e, "sending slack message");
    }
}
Also used : SpecificationNode(org.apache.manifoldcf.core.interfaces.SpecificationNode) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) IOException(java.io.IOException)

Aggregations

SpecificationNode (org.apache.manifoldcf.core.interfaces.SpecificationNode)58 ManifoldCFException (org.apache.manifoldcf.core.interfaces.ManifoldCFException)15 HashMap (java.util.HashMap)10 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)8 Map (java.util.Map)7 InterruptedIOException (java.io.InterruptedIOException)5 MalformedURLException (java.net.MalformedURLException)5 UnknownHostException (java.net.UnknownHostException)4 Date (java.util.Date)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 InputStream (java.io.InputStream)3 RepositoryDocument (org.apache.manifoldcf.agents.interfaces.RepositoryDocument)3 KeyManagementException (java.security.KeyManagementException)2 KeyStoreException (java.security.KeyStoreException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 CmisObject (org.apache.chemistry.opencmis.client.api.CmisObject)2 HttpException (org.apache.http.HttpException)2 Specification (org.apache.manifoldcf.core.interfaces.Specification)2