in connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkConnector.java [2364:2866]
public String processSpecificationPost(IPostParameters variableContext, Locale locale, Specification ds,
int connectionSequenceNumber)
throws ManifoldCFException
{
String seqPrefix = "s"+connectionSequenceNumber+"_";
String userWorkspacesPresent = variableContext.getParameter(seqPrefix+"userworkspace_present");
if (userWorkspacesPresent != null)
{
String value = variableContext.getParameter(seqPrefix+"userworkspace");
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals("userworkspace"))
ds.removeChild(i);
else
i++;
}
SpecificationNode sn = new SpecificationNode("userworkspace");
sn.setAttribute("value",value);
ds.addChild(ds.getChildCount(),sn);
}
String xc = variableContext.getParameter(seqPrefix+"pathcount");
if (xc != null)
{
// Delete all path specs first
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals("startpoint"))
ds.removeChild(i);
else
i++;
}
// Find out how many children were sent
int pathCount = Integer.parseInt(xc);
// Gather up these
i = 0;
while (i < pathCount)
{
String pathDescription = "_"+Integer.toString(i);
String pathOpName = seqPrefix+"pathop"+pathDescription;
xc = variableContext.getParameter(pathOpName);
if (xc != null && xc.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("startpoint");
node.setAttribute("path",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("startpoint");
node.setAttribute("path",path);
ds.addChild(ds.getChildCount(),node);
}
else if (op != null && op.equals("Up"))
{
// Strip off end
String path = variableContext.getParameter(seqPrefix+"specpath");
int lastSlash = -1;
int k = 0;
while (k < path.length())
{
char x = path.charAt(k++);
if (x == '/')
{
lastSlash = k-1;
continue;
}
if (x == '\\')
k++;
}
if (lastSlash == -1)
path = "";
else
path = path.substring(0,lastSlash);
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)
{
StringBuilder sb = new StringBuilder();
int k = 0;
while (k < addon.length())
{
char x = addon.charAt(k++);
if (x == '/' || x == '\\' || x == ':')
sb.append('\\');
sb.append(x);
}
if (path.length() == 0)
path = sb.toString();
else
path += "/" + sb.toString();
}
currentContext.save(seqPrefix+"specpath",path);
}
}
xc = variableContext.getParameter(seqPrefix+"filecount");
if (xc != null)
{
// Delete all file specs first
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals("include") || sn.getType().equals("exclude"))
ds.removeChild(i);
else
i++;
}
int fileCount = Integer.parseInt(xc);
i = 0;
while (i < fileCount)
{
String fileSpecDescription = "_"+Integer.toString(i);
String fileOpName = seqPrefix+"fileop"+fileSpecDescription;
xc = variableContext.getParameter(fileOpName);
if (xc != null && xc.equals("Delete"))
{
// Next row
i++;
continue;
}
// Get the stuff we need
String filespecType = variableContext.getParameter(seqPrefix+"specfiletype"+fileSpecDescription);
String filespec = variableContext.getParameter(seqPrefix+"specfile"+fileSpecDescription);
SpecificationNode node = new SpecificationNode(filespecType);
node.setAttribute("filespec",filespec);
ds.addChild(ds.getChildCount(),node);
i++;
}
String op = variableContext.getParameter(seqPrefix+"fileop");
if (op != null && op.equals("Add"))
{
String filespec = variableContext.getParameter(seqPrefix+"specfile");
String filespectype = variableContext.getParameter(seqPrefix+"specfiletype");
SpecificationNode node = new SpecificationNode(filespectype);
node.setAttribute("filespec",filespec);
ds.addChild(ds.getChildCount(),node);
}
}
xc = variableContext.getParameter(seqPrefix+"specsecurity");
if (xc != null)
{
// Delete all security entries first
int 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",xc);
ds.addChild(ds.getChildCount(),node);
}
xc = variableContext.getParameter(seqPrefix+"tokencount");
if (xc != null)
{
// Delete all file specs first
int 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(xc);
i = 0;
while (i < accessCount)
{
String accessDescription = "_"+Integer.toString(i);
String accessOpName = seqPrefix+"accessop"+accessDescription;
xc = variableContext.getParameter(accessOpName);
if (xc != null && xc.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);
}
}
xc = variableContext.getParameter(seqPrefix+"specallmetadata");
if (xc != null)
{
// Look for the 'all metadata' checkbox
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals("allmetadata"))
ds.removeChild(i);
else
i++;
}
if (xc.equals("true"))
{
SpecificationNode newNode = new SpecificationNode("allmetadata");
newNode.setAttribute("all",xc);
ds.addChild(ds.getChildCount(),newNode);
}
}
xc = variableContext.getParameter(seqPrefix+"metadatacount");
if (xc != null)
{
// Delete all metadata specs first
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals("metadata"))
ds.removeChild(i);
else
i++;
}
// Find out how many children were sent
int metadataCount = Integer.parseInt(xc);
// Gather up these
i = 0;
while (i < metadataCount)
{
String pathDescription = "_"+Integer.toString(i);
String pathOpName = seqPrefix+"metadataop"+pathDescription;
xc = variableContext.getParameter(pathOpName);
if (xc != null && xc.equals("Delete"))
{
// Skip to the next
i++;
continue;
}
// Metadata inserts won't happen until the very end
String category = variableContext.getParameter(seqPrefix+"speccategory"+pathDescription);
String attributeName = variableContext.getParameter(seqPrefix+"specattribute"+pathDescription);
String isAll = variableContext.getParameter(seqPrefix+"specattributeall"+pathDescription);
SpecificationNode node = new SpecificationNode("metadata");
node.setAttribute("category",category);
if (isAll != null && isAll.equals("true"))
node.setAttribute("all","true");
else
node.setAttribute("attribute",attributeName);
ds.addChild(ds.getChildCount(),node);
i++;
}
// See if there's a global add operation
String op = variableContext.getParameter(seqPrefix+"metadataop");
if (op != null && op.equals("Add"))
{
String category = variableContext.getParameter(seqPrefix+"speccategory");
String isAll = variableContext.getParameter(seqPrefix+"attributeall");
if (isAll != null && isAll.equals("true"))
{
SpecificationNode node = new SpecificationNode("metadata");
node.setAttribute("category",category);
node.setAttribute("all","true");
ds.addChild(ds.getChildCount(),node);
}
else
{
String[] attributes = variableContext.getParameterValues(seqPrefix+"attributeselect");
if (attributes != null && attributes.length > 0)
{
int k = 0;
while (k < attributes.length)
{
String attribute = attributes[k++];
SpecificationNode node = new SpecificationNode("metadata");
node.setAttribute("category",category);
node.setAttribute("attribute",attribute);
ds.addChild(ds.getChildCount(),node);
}
}
}
}
else if (op != null && op.equals("Up"))
{
// Strip off end
String category = variableContext.getParameter(seqPrefix+"speccategory");
int lastSlash = -1;
int firstColon = -1;
int k = 0;
while (k < category.length())
{
char x = category.charAt(k++);
if (x == '/')
{
lastSlash = k-1;
continue;
}
if (x == ':')
{
firstColon = k;
continue;
}
if (x == '\\')
k++;
}
if (lastSlash == -1)
{
if (firstColon == -1 || firstColon == category.length())
category = "";
else
category = category.substring(0,firstColon);
}
else
category = category.substring(0,lastSlash);
currentContext.save(seqPrefix+"speccategory",category);
}
else if (op != null && op.equals("AddToPath"))
{
String category = variableContext.getParameter(seqPrefix+"speccategory");
String addon = variableContext.getParameter(seqPrefix+"metadataaddon");
if (addon != null && addon.length() > 0)
{
StringBuilder sb = new StringBuilder();
int k = 0;
while (k < addon.length())
{
char x = addon.charAt(k++);
if (x == '/' || x == '\\' || x == ':')
sb.append('\\');
sb.append(x);
}
if (category.length() == 0 || category.endsWith(":"))
category += sb.toString();
else
category += "/" + sb.toString();
}
currentContext.save(seqPrefix+"speccategory",category);
}
else if (op != null && op.equals("SetWorkspace"))
{
String addon = variableContext.getParameter(seqPrefix+"metadataaddon");
if (addon != null && addon.length() > 0)
{
StringBuilder sb = new StringBuilder();
int k = 0;
while (k < addon.length())
{
char x = addon.charAt(k++);
if (x == '/' || x == '\\' || x == ':')
sb.append('\\');
sb.append(x);
}
String category = sb.toString() + ":";
currentContext.save(seqPrefix+"speccategory",category);
}
}
else if (op != null && op.equals("AddCategory"))
{
String category = variableContext.getParameter(seqPrefix+"speccategory");
String addon = variableContext.getParameter(seqPrefix+"categoryaddon");
if (addon != null && addon.length() > 0)
{
StringBuilder sb = new StringBuilder();
int k = 0;
while (k < addon.length())
{
char x = addon.charAt(k++);
if (x == '/' || x == '\\' || x == ':')
sb.append('\\');
sb.append(x);
}
if (category.length() == 0 || category.endsWith(":"))
category += sb.toString();
else
category += "/" + sb.toString();
}
currentContext.save(seqPrefix+"speccategory",category);
}
}
xc = variableContext.getParameter(seqPrefix+"specpathnameattribute");
if (xc != null)
{
String separator = variableContext.getParameter(seqPrefix+"specpathnameseparator");
if (separator == null)
separator = "/";
// Delete old one
int i = 0;
while (i < ds.getChildCount())
{
SpecificationNode sn = ds.getChild(i);
if (sn.getType().equals("pathnameattribute"))
ds.removeChild(i);
else
i++;
}
if (xc.length() > 0)
{
SpecificationNode node = new SpecificationNode("pathnameattribute");
node.setAttribute("value",xc);
node.setAttribute("separator",separator);
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("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("pathmap");
node.setAttribute("match",match);
node.setAttribute("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("pathmap");
node.setAttribute("match",match);
node.setAttribute("replace",replace);
ds.addChild(ds.getChildCount(),node);
}
}
return null;
}