in shared/api/src/main/java/org/apache/sling/ide/sync/content/impl/DefaultSyncCommandFactory.java [187:276]
public ResourceAndInfo buildResourceAndInfo(WorkspaceResource resource, Repository repository) throws IOException {
if ( !resource.exists() ) {
return null;
}
if ( resource.isIgnored()) {
logger.trace("Skipping team-private resource {0}", resource);
return null;
}
Long modificationTimestamp = (Long) resource.getTransientProperty(PN_IMPORT_MODIFICATION_TIMESTAMP);
if (modificationTimestamp != null && modificationTimestamp >= resource.getLastModified()) {
logger.trace("Change for resource {0} ignored as the import timestamp {1} >= modification timestamp {2}",
resource, modificationTimestamp, resource.getLastModified());
return null;
}
WorkspaceFile info = (resource instanceof WorkspaceFile) ? (WorkspaceFile) resource : null;
logger.trace("For {0} built fileInfo {1}", resource, info);
ResourceProxy resourceProxy = null;
if (info != null && serializationManager.isSerializationFile((WorkspaceFile) resource)) {
resourceProxy = serializationManager.readSerializationData(info);
normaliseResourceChildren(info, resourceProxy, repository);
// TODO - not sure if this 100% correct, but we definitely should not refer to the FileInfo as the
// .serialization file, since for nt:file/nt:resource nodes this will overwrite the file contents
// See https://jackrabbit.apache.org/filevault/vaultfs.html#extended-file-aggregates
// where we have the following case
// |- sample.jpg
// `- sample.jpg.dir
// |- .content.xml <-- this is the file we're targeting
// `- _jcr_content
// `- _dam_thumbnails
// |- 90.jpg
// `- 120.jpg
String primaryType = (String) resourceProxy.getProperties().get(Repository.JCR_PRIMARY_TYPE);
if (Repository.NT_FILE.equals(primaryType)) {
// TODO move logic to serializationManager
WorkspacePath originalPath = info.getPathRelativeToSyncDir();
WorkspaceDirectory parent = info.getParent();
String mainFileName = info.getName().replaceAll("\\.dir^", "");
info = parent.getFile(new WorkspacePath(mainFileName));
WorkspacePath adjustedPath = info.getPathRelativeToSyncDir();
logger.trace("Adjusted original location from {0} to {1}", originalPath, adjustedPath);
}
} else {
// TODO - move logic to serializationManager
// possible .dir serialization holder
if (resource instanceof WorkspaceDirectory && resource.getName().endsWith(".dir")) {
WorkspaceDirectory folder = (WorkspaceDirectory) resource;
WorkspaceResource contentXml = folder.getFile(new WorkspacePath(".content.xml"));
// .dir serialization holder ; nothing to process here, the .content.xml will trigger the actual work
if (contentXml.exists() && (contentXml instanceof WorkspaceFile)
&& serializationManager.isSerializationFile((WorkspaceFile) contentXml)) {
return null;
}
}
resourceProxy = buildResourceProxyForPlainFileOrFolder(resource, repository);
}
if ( resourceProxy == null )
throw new RuntimeException("ResourceProxy is null for resource " + resource);
FilterResult filterResult = resource.getProject().getFilter().filter(resourceProxy.getPath());
switch (filterResult) {
case ALLOW:
return new ResourceAndInfo(resourceProxy, info);
case PREREQUISITE:
// never try to 'create' the root node, we assume it exists
if (!resourceProxy.getPath().equals("/")) {
// we don't explicitly set the primary type, which will allow the the repository to choose the best
// suited one ( typically nt:unstructured )
return new ResourceAndInfo(new ResourceProxy(resourceProxy.getPath()), null, true);
}
case DENY: // falls through
default:
return null;
}
}