// more than one document, attempt to use path to determine
// document ordering if it is not root relative
List documentPaths = documentSet.getDefaultedDocumentPaths();
if (documentPaths.size() == 1)
{
DocumentSetPath documentSetPath = (DocumentSetPath) documentPaths.get(0);
if (documentSetPath.isRegexp())
{
// enforce assumption that document set paths are absolute
// and extract folder
String documentFolderPath = forceAbsoluteDocumentSetPath(documentSetPath.getPath());
int lastSlashIndex = documentFolderPath.lastIndexOf(Folder.PATH_SEPARATOR_CHAR);
if (lastSlashIndex > 2)
{
// non-root document path
documentFolderPath = documentFolderPath.substring(0, lastSlashIndex);
// iterate over search paths formed with document path
Iterator pathsIter = searchPaths.iterator();
while ((documentOrder == null) && pathsIter.hasNext())
{
// search folder path
String folderPath = (String) pathsIter.next();
if (folderPath.endsWith(Folder.PATH_SEPARATOR))
{
folderPath = folderPath.substring(0, folderPath.length()-1) + documentFolderPath;
}
else
{
folderPath = folderPath + documentFolderPath;
}
// check folder for document order
try
{
FolderImpl folder = (FolderImpl) setProfiledNodePathAndUrl((AbstractNode) folderHandler.getFolder(folderPath));
if ((folder.getMetaData() != null) && (folder.getMetaData().getDocumentOrder() != null) &&
! folder.getMetaData().getDocumentOrder().isEmpty())
{
documentOrder = folder.getMetaData().getDocumentOrder();
}
}
catch (NodeException ne)
{
}
}
}
}
}
// fallback to root search paths to determine document ordering
if (documentOrder == null)
{
Iterator pathsIter = searchPaths.iterator();
while ((documentOrder == null) && pathsIter.hasNext())
{
// root search folder path
String folderPath = (String) pathsIter.next();
if (folderPath.endsWith(Folder.PATH_SEPARATOR) && (folderPath.length() > 1))
{
folderPath = folderPath.substring(0, folderPath.length()-1);
}
// check folder for document order
try
{
FolderImpl folder = (FolderImpl) setProfiledNodePathAndUrl((AbstractNode) folderHandler.getFolder(folderPath));
if ((folder.getMetaData() != null) && (folder.getMetaData().getDocumentOrder() != null) &&
! folder.getMetaData().getDocumentOrder().isEmpty())
{
documentOrder = folder.getMetaData().getDocumentOrder();
}
}
catch (NodeException ne)
{
}
}
}
// create ordered node set
Comparator documentComparator = new DocumentOrderComparator(documentOrder);
expandedNodes = new NodeSetImpl(null, documentComparator);
}
// save doucument set name, (limits recursive expansion)
String name = documentSetNamePrefix + documentSet.getUrl();
documentSetNames.put(documentSet, name);
// profile each document path using profile locator search paths
Iterator documentSetPathsIter = documentSet.getDefaultedDocumentPaths().iterator();
while (documentSetPathsIter.hasNext())
{
DocumentSetPath documentSetPath = (DocumentSetPath) documentSetPathsIter.next();
// enforce assumption that document set paths are absolute
String path = forceAbsoluteDocumentSetPath(documentSetPath.getPath());
log.debug("expandAndProfileDocumentSet(), document set path = " + path);
// convert regexp paths to java/perl5 form
boolean regexp = documentSetPath.isRegexp();
if (regexp)
{
path = pathToPerl5Regexp(path);
}