in connectors/filenet/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filenet/FilenetConnector.java [2539:2797]
public String processSpecificationPost(IPostParameters variableContext, Locale locale, Specification ds,
int connectionSequenceNumber)
throws ManifoldCFException
{
String seqPrefix = "s"+connectionSequenceNumber+"_";
String[] x;
String y;
int i;
if (variableContext.getParameter(seqPrefix+"hasdocumentclasses") != null)
{
i = 0;
while (i < ds.getChildCount())
{
if (ds.getChild(i).getType().equals(SPEC_NODE_DOCUMENTCLASS))
ds.removeChild(i);
else
i++;
}
x = variableContext.getParameterValues(seqPrefix+"documentclasses");
if (x != null)
{
i = 0;
while (i < x.length)
{
String value = x[i++];
SpecificationNode node = new SpecificationNode(SPEC_NODE_DOCUMENTCLASS);
node.setAttribute(SPEC_ATTRIBUTE_VALUE,value);
// Get the allmetadata value for this document class
String allmetadata = variableContext.getParameter(seqPrefix+"allmetadata_"+value);
if (allmetadata == null)
allmetadata = "false";
if (allmetadata.equals("true"))
node.setAttribute(SPEC_ATTRIBUTE_ALLMETADATA,allmetadata);
else
{
String[] fields = variableContext.getParameterValues(seqPrefix+"metadatafield_"+value);
if (fields != null)
{
int j = 0;
while (j < fields.length)
{
String field = fields[j++];
SpecificationNode sp2 = new SpecificationNode(SPEC_NODE_METADATAFIELD);
sp2.setAttribute(SPEC_ATTRIBUTE_VALUE,field);
node.addChild(node.getChildCount(),sp2);
}
}
}
// Now, gather up matches too
String matchCountString = variableContext.getParameter(seqPrefix+"matchcount_"+value);
int matchCount = Integer.parseInt(matchCountString);
int q = 0;
while (q < matchCount)
{
String matchOp = variableContext.getParameter(seqPrefix+"matchop_"+value+"_"+Integer.toString(q));
String matchType = variableContext.getParameter(seqPrefix+"matchtype_"+value+"_"+Integer.toString(q));
String matchField = variableContext.getParameter(seqPrefix+"matchfield_"+value+"_"+Integer.toString(q));
String matchValue = variableContext.getParameter(seqPrefix+"matchvalue_"+value+"_"+Integer.toString(q));
if (matchOp == null || !matchOp.equals("Delete"))
{
SpecificationNode matchNode = new SpecificationNode(SPEC_NODE_MATCH);
matchNode.setAttribute(SPEC_ATTRIBUTE_MATCHTYPE,matchType);
matchNode.setAttribute(SPEC_ATTRIBUTE_FIELDNAME,matchField);
if (matchValue == null)
matchValue = "";
matchNode.setAttribute(SPEC_ATTRIBUTE_VALUE,matchValue);
node.addChild(node.getChildCount(),matchNode);
}
q++;
}
ds.addChild(ds.getChildCount(),node);
// Look for the add operation
String addMatchOp = variableContext.getParameter(seqPrefix+"matchop_"+value);
if (addMatchOp != null && addMatchOp.equals("Add"))
{
String matchType = variableContext.getParameter(seqPrefix+"matchtype_"+value);
String matchField = variableContext.getParameter(seqPrefix+"matchfield_"+value);
String matchValue = variableContext.getParameter(seqPrefix+"matchvalue_"+value);
SpecificationNode matchNode = new SpecificationNode(SPEC_NODE_MATCH);
matchNode.setAttribute(SPEC_ATTRIBUTE_MATCHTYPE,matchType);
matchNode.setAttribute(SPEC_ATTRIBUTE_FIELDNAME,matchField);
if (matchValue == null)
matchValue = "";
matchNode.setAttribute(SPEC_ATTRIBUTE_VALUE,matchValue);
node.addChild(node.getChildCount(),matchNode);
}
}
}
}
if (variableContext.getParameter(seqPrefix+"hasmimetypes") != null)
{
i = 0;
while (i < ds.getChildCount())
{
if (ds.getChild(i).getType().equals(SPEC_NODE_MIMETYPE))
ds.removeChild(i);
else
i++;
}
x = variableContext.getParameterValues(seqPrefix+"mimetypes");
if (x != null)
{
i = 0;
while (i < x.length)
{
String value = x[i++];
SpecificationNode node = new SpecificationNode(SPEC_NODE_MIMETYPE);
node.setAttribute(SPEC_ATTRIBUTE_VALUE,value);
ds.addChild(ds.getChildCount(),node);
}
}
}
y = variableContext.getParameter(seqPrefix+"pathcount");
if (y != null)
{
// Delete all path specs first
i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals(SPEC_NODE_FOLDER))
ds.removeChild(i);
else
i++;
}
// Find out how many children were sent
int pathCount = Integer.parseInt(y);
// Gather up these
i = 0;
while (i < pathCount)
{
String pathDescription = "_"+Integer.toString(i);
String pathOpName = seqPrefix+"pathop"+pathDescription;
y = variableContext.getParameter(pathOpName);
if (y != null && y.equals("Delete"))
{
// Skip to the next
i++;
continue;
}
// Path inserts won't happen until the very end
String path = variableContext.getParameter(seqPrefix+"specpath"+pathDescription);
SpecificationNode node = new SpecificationNode(SPEC_NODE_FOLDER);
node.setAttribute(SPEC_ATTRIBUTE_VALUE,path);
ds.addChild(ds.getChildCount(),node);
i++;
}
// See if there's a global add operation
String op = variableContext.getParameter(seqPrefix+"pathop");
if (op != null && op.equals("Add"))
{
String path = variableContext.getParameter(seqPrefix+"specpath");
SpecificationNode node = new SpecificationNode(SPEC_NODE_FOLDER);
node.setAttribute(SPEC_ATTRIBUTE_VALUE,path);
ds.addChild(ds.getChildCount(),node);
}
else if (op != null && op.equals("Up"))
{
// Strip off end
String path = variableContext.getParameter(seqPrefix+"specpath");
int k = path.lastIndexOf("/");
if (k <= 0)
path = "/";
else
path = path.substring(0,k);
currentContext.save(seqPrefix+"specpath",path);
}
else if (op != null && op.equals("AddToPath"))
{
String path = variableContext.getParameter(seqPrefix+"specpath");
String addon = variableContext.getParameter(seqPrefix+"pathaddon");
if (addon != null && addon.length() > 0)
{
if (path.length() <= 1)
path = "/" + addon;
else
path += "/" + addon;
}
currentContext.save(seqPrefix+"specpath",path);
}
}
y = variableContext.getParameter(seqPrefix+"specsecurity");
if (y != null)
{
// Delete all security entries first
i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals("security"))
ds.removeChild(i);
else
i++;
}
SpecificationNode node = new SpecificationNode("security");
node.setAttribute("value",y);
ds.addChild(ds.getChildCount(),node);
}
y = variableContext.getParameter(seqPrefix+"tokencount");
if (y != null)
{
// Delete all file specs first
i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals("access"))
ds.removeChild(i);
else
i++;
}
int accessCount = Integer.parseInt(y);
i = 0;
while (i < accessCount)
{
String accessDescription = "_"+Integer.toString(i);
String accessOpName = seqPrefix+"accessop"+accessDescription;
y = variableContext.getParameter(accessOpName);
if (y != null && y.equals("Delete"))
{
// Next row
i++;
continue;
}
// Get the stuff we need
String accessSpec = variableContext.getParameter(seqPrefix+"spectoken"+accessDescription);
SpecificationNode node = new SpecificationNode("access");
node.setAttribute("token",accessSpec);
ds.addChild(ds.getChildCount(),node);
i++;
}
String op = variableContext.getParameter(seqPrefix+"accessop");
if (op != null && op.equals("Add"))
{
String accessspec = variableContext.getParameter(seqPrefix+"spectoken");
SpecificationNode node = new SpecificationNode("access");
node.setAttribute("token",accessspec);
ds.addChild(ds.getChildCount(),node);
}
}
return null;
}