private ResourceProxy findSerializationDataFromCoveringParent(IResource changedResource, IFolder syncDirectory,
String resourceLocation, IPath serializationFilePath) throws CoreException, IOException {
// TODO - this too should be abstracted in the service layer, rather than in the Eclipse-specific code
Logger logger = Activator.getDefault().getPluginLogger();
logger.trace("Found plain nt:folder candidate at {0}, trying to find a covering resource for it",
changedResource.getProjectRelativePath());
// don't use isRoot() to prevent infinite loop when the final path is '//'
while (serializationFilePath.segmentCount() != 0) {
serializationFilePath = serializationFilePath.removeLastSegments(1);
IFolder folderWithPossibleSerializationFile = (IFolder) syncDirectory.findMember(serializationFilePath);
if (folderWithPossibleSerializationFile == null) {
logger.trace("No folder found at {0}, moving up to the next level", serializationFilePath);
continue;
}
// it's safe to use a specific SerializationKind since this scenario is only valid for METADATA_PARTIAL
// coverage
String possibleSerializationFilePath = serializationManager.getSerializationFilePath(
((IFolder) folderWithPossibleSerializationFile).getLocation().toOSString(),
SerializationKind.METADATA_PARTIAL);
logger.trace("Looking for serialization data in {0}", possibleSerializationFilePath);
if (serializationManager.isSerializationFile(possibleSerializationFilePath)) {
IPath parentSerializationFilePath = Path.fromOSString(possibleSerializationFilePath).makeRelativeTo(
syncDirectory.getLocation());
IFile possibleSerializationFile = syncDirectory.getFile(parentSerializationFilePath);
if (!possibleSerializationFile.exists()) {
logger.trace("Potential serialization data file {0} does not exist, moving up to the next level",
possibleSerializationFile.getFullPath());
continue;
}
InputStream contents = possibleSerializationFile.getContents();
ResourceProxy serializationData;
try {
serializationData = serializationManager.readSerializationData(
parentSerializationFilePath.toPortableString(), contents);
} finally {
IOUtils.closeQuietly(contents);
}
String repositoryPath = serializationManager.getRepositoryPath(resourceLocation);
String potentialPath = serializationData.getPath();
boolean covered = serializationData.covers(repositoryPath);
logger.trace(
"Found possible serialization data at {0}. Resource :{1} ; our resource: {2}. Covered: {3}",
parentSerializationFilePath, potentialPath, repositoryPath, covered);
// note what we don't need to normalize the children here since this resource's data is covered by
// another resource
if (covered) {