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);
}
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;
}
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);
}
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;
}
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");
}
}
Aggregations