in shared/api/src/main/java/org/apache/sling/ide/sync/content/impl/DefaultSyncCommandFactory.java [331:393]
private void normaliseResourceChildren(WorkspaceFile serializationFile, ResourceProxy resourceProxy,
Repository repository) {
// TODO - this logic should be moved to the serializationManager
try {
SerializationKindManager skm = new SerializationKindManager();
skm.init(repository);
String primaryType = (String) resourceProxy.getProperties().get(Repository.JCR_PRIMARY_TYPE);
List<String> mixinTypesList = getMixinTypes(resourceProxy);
SerializationKind serializationKind = skm.getSerializationKind(primaryType, mixinTypesList);
if (serializationKind == SerializationKind.METADATA_FULL) {
return;
}
} catch (RepositoryException e) {
// TODO proper exception handling
throw new RuntimeException(e);
}
WorkspacePath serializationDirectoryPath = serializationFile.getLocalPath().getParent();
Iterator<ResourceProxy> childIterator = resourceProxy.getChildren().iterator();
Map<String, WorkspaceResource> extraChildResources = new HashMap<>();
for (WorkspaceResource member : serializationFile.getParent().getChildren()) {
if (member.equals(serializationFile)) {
continue;
}
extraChildResources.put(member.getName(), member);
}
while (childIterator.hasNext()) {
ResourceProxy child = childIterator.next();
String childName = PathUtil.getName(child.getPath());
String osChildName = serializationManager.getLocalName(childName);
// covered children might have a FS representation, depending on their child nodes, so
// accept a directory which maps to their name
extraChildResources.remove(osChildName);
// covered children do not need a filesystem representation
if (resourceProxy.covers(child.getPath())) {
continue;
}
WorkspacePath childPath = serializationDirectoryPath.append(osChildName);
WorkspaceResource childResource = serializationFile.getParent().getDirectory(new WorkspacePath(osChildName));
if (!childResource.exists()) {
logger.trace("For resource at with serialization data {0} the serialized child resource at {1} does not exist in the filesystem and will be ignored",
serializationFile, childPath);
childIterator.remove();
}
}
for ( WorkspaceResource extraChildResource : extraChildResources.values()) {
WorkspacePath extraChildResourcePath = extraChildResource.getPathRelativeToSyncDir();
resourceProxy.addChild(new ResourceProxy(serializationManager
.getRepositoryPath(extraChildResourcePath)));
logger.trace("For resource at with serialization data {0} the found a child resource at {1} which is not listed in the serialized child resources and will be added",
serializationFile, extraChildResource);
}
}