in connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java [3718:4228]
public String processSpecificationPost(IPostParameters variableContext, Locale locale, Specification ds,
int connectionSequenceNumber)
throws ManifoldCFException
{
String seqPrefix = "s"+connectionSequenceNumber+"_";
String x = variableContext.getParameter(seqPrefix+"pathcount");
if (x != null)
{
// Delete all path specs first
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_STARTPOINT))
ds.removeChild(i);
else
i++;
}
// Find out how many children were sent
int pathCount = Integer.parseInt(x);
// Gather up these
i = 0;
while (i < pathCount)
{
String pathDescription = "_"+Integer.toString(i);
String pathOpName = seqPrefix+"pathop"+pathDescription;
x = variableContext.getParameter(pathOpName);
if (x != null && x.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(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_STARTPOINT);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_PATH,path);
// Now, get the number of children
String y = variableContext.getParameter(seqPrefix+"specchildcount"+pathDescription);
int childCount = Integer.parseInt(y);
int j = 0;
int w = 0;
while (j < childCount)
{
String instanceDescription = "_"+Integer.toString(i)+"_"+Integer.toString(j);
// Look for an insert or a delete at this point
String instanceOp = seqPrefix+"specop"+instanceDescription;
String z = variableContext.getParameter(instanceOp);
String flavor;
String type;
String indexable;
String match;
SpecificationNode sn;
if (z != null && z.equals("Delete"))
{
// Process the deletion as we gather
j++;
continue;
}
if (z != null && z.equals("Insert Here"))
{
// Process the insertion as we gather.
flavor = variableContext.getParameter(seqPrefix+"specfl_i"+instanceDescription);
indexable = "";
type = "";
String xxx = variableContext.getParameter(seqPrefix+"spectin_i"+instanceDescription);
if (xxx.equals("file") || xxx.equals("directory"))
type = xxx;
else if (xxx.equals("indexable-file"))
{
indexable = "yes";
type = "file";
}
else if (xxx.equals("unindexable-file"))
{
indexable = "no";
type = "file";
}
match = variableContext.getParameter(seqPrefix+"specfile_i"+instanceDescription);
sn = new SpecificationNode(flavor);
if (type != null && type.length() > 0)
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_TYPE,type);
if (indexable != null && indexable.length() > 0)
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_INDEXABLE,indexable);
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_FILESPEC,match);
node.addChild(w++,sn);
}
flavor = variableContext.getParameter(seqPrefix+"specfl"+instanceDescription);
type = variableContext.getParameter(seqPrefix+"specty"+instanceDescription);
match = variableContext.getParameter(seqPrefix+"specfile"+instanceDescription);
indexable = variableContext.getParameter(seqPrefix+"specin"+instanceDescription);
sn = new SpecificationNode(flavor);
if (type != null && type.length() > 0)
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_TYPE,type);
if (indexable != null && indexable.length() > 0)
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_INDEXABLE,indexable);
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_FILESPEC,match);
node.addChild(w++,sn);
j++;
}
if (x != null && x.equals("Add"))
{
// Process adds to the end of the rules in-line
String match = variableContext.getParameter(seqPrefix+"specfile"+pathDescription);
String indexable = "";
String type = "";
String xxx = variableContext.getParameter(seqPrefix+"spectin"+pathDescription);
if (xxx.equals("file") || xxx.equals("directory"))
type = xxx;
else if (xxx.equals("indexable-file"))
{
indexable = "yes";
type = "file";
}
else if (xxx.equals("unindexable-file"))
{
indexable = "no";
type = "file";
}
String flavor = variableContext.getParameter(seqPrefix+"specfl"+pathDescription);
SpecificationNode sn = new SpecificationNode(flavor);
if (type != null && type.length() > 0)
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_TYPE,type);
if (indexable != null && indexable.length() > 0)
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_INDEXABLE,indexable);
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_FILESPEC,match);
node.addChild(w,sn);
}
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(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_STARTPOINT);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_PATH,path);
ds.addChild(ds.getChildCount(),node);
// Now add in the defaults; these will be "include all directories" and "include all indexable files".
SpecificationNode sn = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_INCLUDE);
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_TYPE,"file");
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_INDEXABLE,"yes");
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_FILESPEC,"*");
node.addChild(node.getChildCount(),sn);
sn = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_INCLUDE);
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_TYPE,"directory");
sn.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_FILESPEC,"*");
node.addChild(node.getChildCount(),sn);
}
else if (op != null && op.equals("Up"))
{
// Strip off end
String path = variableContext.getParameter(seqPrefix+"specpath");
int k = path.lastIndexOf("/");
if (k == -1)
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");
String typein = variableContext.getParameter(seqPrefix+"pathtypein");
if (addon != null && addon.length() > 0)
{
if (path.length() == 0)
path = addon;
else
path += "/" + addon;
}
else if (typein != null && typein.length() > 0)
{
String trialPath = path;
if (trialPath.length() == 0)
trialPath = typein;
else
trialPath += "/" + typein;
// Validate trial path
try
{
trialPath = validateFolderName(trialPath);
if (trialPath != null)
path = trialPath;
}
catch (ManifoldCFException e)
{
// Effectively, this just means we can't add a typein to the path right now.
}
}
currentContext.save(seqPrefix+"specpath",path);
}
}
x = variableContext.getParameter(seqPrefix+"specmaxlength");
if (x != null)
{
// Delete max length entry
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_MAXLENGTH))
ds.removeChild(i);
else
i++;
}
if (x.length() > 0)
{
SpecificationNode node = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_MAXLENGTH);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_VALUE,x);
ds.addChild(ds.getChildCount(),node);
}
}
x = variableContext.getParameter(seqPrefix+"specsecurity");
if (x != null)
{
// Delete all security entries first
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_SECURITY))
ds.removeChild(i);
else
i++;
}
SpecificationNode node = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_SECURITY);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_VALUE,x);
ds.addChild(ds.getChildCount(),node);
}
x = variableContext.getParameter(seqPrefix+"tokencount");
if (x != null)
{
// Delete all file specs first
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_ACCESS))
ds.removeChild(i);
else
i++;
}
int accessCount = Integer.parseInt(x);
i = 0;
while (i < accessCount)
{
String accessDescription = "_"+Integer.toString(i);
String accessOpName = seqPrefix+"accessop"+accessDescription;
x = variableContext.getParameter(accessOpName);
if (x != null && x.equals("Delete"))
{
// Next row
i++;
continue;
}
// Get the stuff we need
String accessSpec = variableContext.getParameter(seqPrefix+"spectoken"+accessDescription);
SpecificationNode node = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_ACCESS);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_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(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_ACCESS);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_TOKEN,accessspec);
ds.addChild(ds.getChildCount(),node);
}
}
x = variableContext.getParameter(seqPrefix+"specsharesecurity");
if (x != null)
{
// Delete all security entries first
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_SHARESECURITY))
ds.removeChild(i);
else
i++;
}
SpecificationNode node = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_SHARESECURITY);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_VALUE,x);
ds.addChild(ds.getChildCount(),node);
}
x = variableContext.getParameter(seqPrefix+"specparentfoldersecurity");
if (x != null)
{
// Delete all security entries first
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_PARENTFOLDERSECURITY))
ds.removeChild(i);
else
i++;
}
SpecificationNode node = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_PARENTFOLDERSECURITY);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_VALUE,x);
ds.addChild(ds.getChildCount(),node);
}
String xc = variableContext.getParameter(seqPrefix+"specpathnameattribute");
if (xc != null)
{
// Delete old one
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_PATHNAMEATTRIBUTE))
ds.removeChild(i);
else
i++;
}
if (xc.length() > 0)
{
SpecificationNode node = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_PATHNAMEATTRIBUTE);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_VALUE,xc);
ds.addChild(ds.getChildCount(),node);
}
}
xc = variableContext.getParameter(seqPrefix+"specmappingcount");
if (xc != null)
{
// Delete old spec
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_PATHMAP))
ds.removeChild(i);
else
i++;
}
// Now, go through the data and assemble a new list.
int mappingCount = Integer.parseInt(xc);
// Gather up these
i = 0;
while (i < mappingCount)
{
String pathDescription = "_"+Integer.toString(i);
String pathOpName = seqPrefix+"specmappingop"+pathDescription;
xc = variableContext.getParameter(pathOpName);
if (xc != null && xc.equals("Delete"))
{
// Skip to the next
i++;
continue;
}
// Inserts won't happen until the very end
String match = variableContext.getParameter(seqPrefix+"specmatch"+pathDescription);
String replace = variableContext.getParameter(seqPrefix+"specreplace"+pathDescription);
SpecificationNode node = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_PATHMAP);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_MATCH,match);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_REPLACE,replace);
ds.addChild(ds.getChildCount(),node);
i++;
}
// Check for add
xc = variableContext.getParameter(seqPrefix+"specmappingop");
if (xc != null && xc.equals("Add"))
{
String match = variableContext.getParameter(seqPrefix+"specmatch");
String replace = variableContext.getParameter(seqPrefix+"specreplace");
SpecificationNode node = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_PATHMAP);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_MATCH,match);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_REPLACE,replace);
ds.addChild(ds.getChildCount(),node);
}
}
xc = variableContext.getParameter(seqPrefix+"specfmapcount");
if (xc != null)
{
// Delete old spec
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_FILEMAP))
ds.removeChild(i);
else
i++;
}
// Now, go through the data and assemble a new list.
int mappingCount = Integer.parseInt(xc);
// Gather up these
i = 0;
while (i < mappingCount)
{
String pathDescription = "_"+Integer.toString(i);
String pathOpName = seqPrefix+"specfmapop"+pathDescription;
xc = variableContext.getParameter(pathOpName);
if (xc != null && xc.equals("Delete"))
{
// Skip to the next
i++;
continue;
}
// Inserts won't happen until the very end
String match = variableContext.getParameter(seqPrefix+"specfmapmatch"+pathDescription);
String replace = variableContext.getParameter(seqPrefix+"specfmapreplace"+pathDescription);
SpecificationNode node = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_FILEMAP);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_MATCH,match);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_REPLACE,replace);
ds.addChild(ds.getChildCount(),node);
i++;
}
// Check for add
xc = variableContext.getParameter(seqPrefix+"specfmapop");
if (xc != null && xc.equals("Add"))
{
String match = variableContext.getParameter(seqPrefix+"specfmapmatch");
String replace = variableContext.getParameter(seqPrefix+"specfmapreplace");
SpecificationNode node = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_FILEMAP);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_MATCH,match);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_REPLACE,replace);
ds.addChild(ds.getChildCount(),node);
}
}
xc = variableContext.getParameter(seqPrefix+"specumapcount");
if (xc != null)
{
// Delete old spec
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_URIMAP))
ds.removeChild(i);
else
i++;
}
// Now, go through the data and assemble a new list.
int mappingCount = Integer.parseInt(xc);
// Gather up these
i = 0;
while (i < mappingCount)
{
String pathDescription = "_"+Integer.toString(i);
String pathOpName = seqPrefix+"specumapop"+pathDescription;
xc = variableContext.getParameter(pathOpName);
if (xc != null && xc.equals("Delete"))
{
// Skip to the next
i++;
continue;
}
// Inserts won't happen until the very end
String match = variableContext.getParameter(seqPrefix+"specumapmatch"+pathDescription);
String replace = variableContext.getParameter(seqPrefix+"specumapreplace"+pathDescription);
SpecificationNode node = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_URIMAP);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_MATCH,match);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_REPLACE,replace);
ds.addChild(ds.getChildCount(),node);
i++;
}
// Check for add
xc = variableContext.getParameter(seqPrefix+"specumapop");
if (xc != null && xc.equals("Add"))
{
String match = variableContext.getParameter(seqPrefix+"specumapmatch");
String replace = variableContext.getParameter(seqPrefix+"specumapreplace");
SpecificationNode node = new SpecificationNode(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.NODE_URIMAP);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_MATCH,match);
node.setAttribute(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveConnector.ATTRIBUTE_REPLACE,replace);
ds.addChild(ds.getChildCount(),node);
}
}
return null;
}