if (value != null && value.length() > 0)
maxFileLength = new Long(value).longValue();
}
catch (NumberFormatException e)
{
throw new ManifoldCFException("Bad number: "+e.getMessage(),e);
}
}
}
if (fileLength > maxFileLength)
return false;
}
// Scan until we match a startpoint
i = 0;
while (i < documentSpecification.getChildCount())
{
SpecificationNode sn = documentSpecification.getChild(i++);
if (sn.getType().equals(NODE_STARTPOINT))
{
// Prepend the server URL to the path, since that's what pathpart will have.
String path = mapToIdentifier(sn.getAttributeValue(ATTRIBUTE_PATH));
// Compare with filename
if (Logging.connectors.isDebugEnabled())
Logging.connectors.debug("JCIFS: Matching startpoint '"+path+"' against actual '"+pathPart+"'");
int matchEnd = matchSubPath(path,pathPart);
if (matchEnd == -1)
{
Logging.connectors.debug("JCIFS: No match");
continue;
}
Logging.connectors.debug("JCIFS: Startpoint found!");
// If this is the root, it's always included.
if (matchEnd == fileName.length())
{
Logging.connectors.debug("JCIFS: Startpoint: always included");
return true;
}
// matchEnd is the start of the rest of the path (after the match) in fileName.
// We need to walk through the rules and see whether it's in or out.
int j = 0;
while (j < sn.getChildCount())
{
SpecificationNode node = sn.getChild(j++);
String flavor = node.getType();
if (flavor.equals(NODE_INCLUDE) || flavor.equals(NODE_EXCLUDE))
{
String type = node.getAttributeValue(ATTRIBUTE_TYPE);
if (type == null)
type = "";
String indexable = node.getAttributeValue(ATTRIBUTE_INDEXABLE);
if (indexable == null)
indexable = "";
String match = node.getAttributeValue(ATTRIBUTE_FILESPEC);
// Check if there's a match against the filespec
if (Logging.connectors.isDebugEnabled())
Logging.connectors.debug("JCIFS: Checking '"+match+"' against '"+fileName.substring(matchEnd-1)+"'");
boolean isMatch = checkMatch(fileName,matchEnd-1,match);
boolean isKnown = true;
// Check the directory/file criteria
if (isMatch)
{
Logging.connectors.debug("JCIFS: Match found.");
isMatch = type.length() == 0 ||
(type.equals(VALUE_DIRECTORY) && isDirectory) ||
(type.equals(VALUE_FILE) && !isDirectory);
}
else
Logging.connectors.debug("JCIFS: No match!");
// Check the indexable criteria
if (isMatch)
{
if (indexable.length() != 0)
{
// Directories are never considered indexable.
// But if this is not a directory, things become ambiguous.
boolean isIndexable;
if (isDirectory)
{
isIndexable = false;
isMatch = (indexable.equals("yes") && isIndexable) ||
(indexable.equals("no") && !isIndexable);
}
else
isKnown = false;
}
}
if (isKnown)
{
if (isMatch)
{
if (flavor.equals(NODE_INCLUDE))
return true;
else
return false;
}
}
else
{
// Not known
// What we do depends on whether this is an include rule or an exclude one.
// We want to err on the side of inclusion, which means for include rules
// we return true, and for exclude rules we simply continue.
if (flavor.equals(NODE_INCLUDE))
return true;
// Continue
}
}
}
}
}
return false;
}
catch (jcifs.smb.SmbAuthException e)
{
Logging.connectors.warn("JCIFS: Authorization exception checking inclusion for "+fileName+" - skipping");
return false;
}
catch (SmbException se)
{
processSMBException(se, fileName, "checking inclusion", "canonical path mapping");
return false;
}
catch (java.net.SocketTimeoutException e)
{
throw new ManifoldCFException("Couldn't map to canonical path: "+e.getMessage(),e);
}
catch (InterruptedIOException e)
{
throw new ManifoldCFException("Interrupted: "+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
}
catch (IOException e)
{
throw new ManifoldCFException("Couldn't map to canonical path: "+e.getMessage(),e);
}
finally
{
if (Logging.connectors.isDebugEnabled())
Logging.connectors.debug("JCIFS: Leaving checkInclude for '"+fileName+"'");