extensionPosition = fileNameWithoutExtension.lastIndexOf(".");
if(extensionPosition != -1)
fileExtension = repo.getName().substring(extensionPosition + 1);
}
// Is this file extension recognised by Salesforce Metadata API?
DescribeMetadataObject metadataObject = repositoryScanResult.metadataFolderBySuffix.get(fileExtension);
if(metadataObject==null)
{
// Is this a Document file which supports any file extension?
String[] folders = repo.getPath().split("/");
// A document file within a sub-directory of the 'documents' folder?
if(folders.length>3 && folders[folders.length-3].equals("documents"))
{
// Metadata describe for Document
metadataObject = repositoryScanResult.metadataFolderBySuffix.get(null);
}
// A file within the root of the 'document' folder?
else if(folders.length>2 && folders[folders.length-2].equals("documents"))
{
// There is no DescribeMetadataObject for Folders metadata types, emulate one to represent a "documents" Folder
metadataObject = new DescribeMetadataObject();
metadataObject.setDirectoryName("documents");
metadataObject.setInFolder(false);
metadataObject.setXmlName("Document");
metadataObject.setMetaFile(true);
metadataObject.setSuffix("dir");
}
else
continue;
}
// Add file
RepositoryItem repositoryItem = new RepositoryItem();
repositoryItem.repositoryItem = repo;
repositoryItem.metadataFolder = metadataObject.getDirectoryName();
repositoryItem.metadataType = metadataObject.getXmlName();
repositoryItem.metadataFile = metadataObject.getMetaFile();
repositoryItem.metadataInFolder = metadataObject.getInFolder();
repositoryItem.metadataSuffix = metadataObject.getSuffix();
repositoryContainer.repositoryItems.add(repositoryItem);
}
// Process directories
for(RepositoryContents repo : contents)
{