This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch issue/SLING-7599 in repository https://gitbox.apache.org/repos/asf/sling-ide-tooling.git
commit a5153e8470c7d1f665610a250265acfcbf01e2e8 Author: Robert Munteanu <[email protected]> AuthorDate: Thu May 22 15:43:21 2025 +0200 WIP on SLING-7599 --- .../test/impl/DefaultCommandFactoryImplTest.java | 8 ++++---- .../ui/internal/ImportRepositoryContentAction.java | 23 +++++++++++----------- .../serialization/VltSerializationDataBuilder.java | 4 ++-- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/eclipse/eclipse-test/src/org/apache/sling/ide/test/impl/DefaultCommandFactoryImplTest.java b/eclipse/eclipse-test/src/org/apache/sling/ide/test/impl/DefaultCommandFactoryImplTest.java index 5f8b88ab..3d4dbf4d 100644 --- a/eclipse/eclipse-test/src/org/apache/sling/ide/test/impl/DefaultCommandFactoryImplTest.java +++ b/eclipse/eclipse-test/src/org/apache/sling/ide/test/impl/DefaultCommandFactoryImplTest.java @@ -105,14 +105,14 @@ public class DefaultCommandFactoryImplTest { SpyCommand<?> command = (SpyCommand<?>) factory.newCommandForAddedOrUpdatedResource(spyRepo, EclipseResources.create(contentProject.findMember("jcr_root/content/test-root/nested/gitignore"))); assertThat("command.path", command.getPath(), nullValue()); - assertThat("command.resource.path", command.getResourceProxy().getPath(), equalTo("/content/test-root/nested/gitignore")); + assertThat("command.resource.path", command.getResourceProxy().getPath().asString(), equalTo("/content/test-root/nested/gitignore")); assertThat("command.resource.properties", command.getResourceProxy().getProperties(), equalTo(singletonMap("jcr:primaryType", (Object) "nt:file"))); assertThat("command.kind", command.getSpyKind(), equalTo(SpyCommand.Kind.ADD_OR_UPDATE)); command = (SpyCommand<?>) factory.newCommandForRemovedResource(spyRepo, EclipseResources.create(contentProject.findMember("jcr_root/content/test-root/nested/gitignore"))); - assertThat("command.path", command.getPath(), equalTo("/content/test-root/nested/gitignore")); + assertThat("command.path", command.getPath().asString(), equalTo("/content/test-root/nested/gitignore")); assertThat("command.kind", command.getSpyKind(), equalTo(SpyCommand.Kind.DELETE)); } @@ -128,7 +128,7 @@ public class DefaultCommandFactoryImplTest { EclipseResources.create(contentProject.findMember("jcr_root/content/test-root"))); assertThat("command.path", command.getPath(), nullValue()); - assertThat("command.resource.path", command.getResourceProxy().getPath(), equalTo("/content/test-root")); + assertThat("command.resource.path", command.getResourceProxy().getPath().asString(), equalTo("/content/test-root")); assertThat("command.resource.properties", command.getResourceProxy().getProperties(), equalTo(singletonMap("jcr:primaryType", (Object) "nt:folder"))); assertThat("command.fileinfo", command.getFileInfo(), nullValue()); @@ -151,7 +151,7 @@ public class DefaultCommandFactoryImplTest { props.put("jcr:title", "Some Folder"); assertThat("command.path", command.getPath(), nullValue()); - assertThat("command.resource.path", command.getResourceProxy().getPath(), equalTo("/content/test-root/nested")); + assertThat("command.resource.path", command.getResourceProxy().getPath().asString(), equalTo("/content/test-root/nested")); assertThat("command.resource.properties", command.getResourceProxy().getProperties(), equalTo(props)); assertThat("command.fileinfo", command.getFileInfo(), nullValue()); assertThat("command.kind", command.getSpyKind(), equalTo(SpyCommand.Kind.ADD_OR_UPDATE)); diff --git a/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportRepositoryContentAction.java b/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportRepositoryContentAction.java index f69cf60b..4b21f2b1 100644 --- a/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportRepositoryContentAction.java +++ b/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportRepositoryContentAction.java @@ -151,8 +151,10 @@ public class ImportRepositoryContentAction { recordNotIgnoredResources(); ProgressUtils.advance(monitor, 1); + + RepositoryPath repositoryPath = serializationManager.getRepositoryPath(new WorkspacePath(repositoryImportRoot.toPortableString())); - crawlChildrenAndImport(repositoryImportRoot.toPortableString()); + crawlChildrenAndImport(repositoryPath); removeNotIgnoredAndNotUpdatedResources(new NullProgressMonitor()); @@ -253,13 +255,10 @@ public class ImportRepositoryContentAction { * @throws IOException */ // TODO: This probably should be pushed into the service layer - private void crawlChildrenAndImport(String path) + private void crawlChildrenAndImport(RepositoryPath repositoryPath) throws RepositoryException, CoreException, IOException, SerializationException { - logger.trace("crawlChildrenAndImport({0}, {1}, {2}, {3}", repository, path, project, projectRelativePath); - - RepositoryPath repositoryPath = serializationManager.getRepositoryPath(new WorkspacePath(path)); - + logger.trace("crawlChildrenAndImport({0}, {1}, {2}, {3}", repository, repositoryPath, project, projectRelativePath); ResourceProxy resource = executeCommand(repository.newListChildrenNodeCommand(repositoryPath)); SerializationData serializationData = builder.buildSerializationData(contentSyncRoot, resource); @@ -302,7 +301,7 @@ public class ImportRepositoryContentAction { // 2. recursively handle all resources for (ResourceProxy grandChild : reloadedChildResource.getChildren()) { - crawlChildrenAndImport(path + "/" + serializationManager.getLocalName(child.getPath().getName()) + "/" + serializationManager.getLocalName(grandChild.getPath().getName())); + crawlChildrenAndImport(grandChild.getPath()); } } @@ -318,7 +317,7 @@ public class ImportRepositoryContentAction { IFolder folder = createFolder(project, serializationFolderPath); - parseIgnoreFiles(folder, path); + parseIgnoreFiles(folder, repositoryPath.asString()); if (serializationData.hasContents()) { createFile(project, serializationFolderPath.append(serializationData.getFileName()), @@ -360,7 +359,7 @@ public class ImportRepositoryContentAction { } } - crawlChildrenAndImport(path + "/" + serializationManager.getLocalName(child.getPath().getName())); + crawlChildrenAndImport(child.getPath()); } } @@ -385,7 +384,7 @@ public class ImportRepositoryContentAction { return serializationFolderPath.removeLastSegments(1).append(name); } - private void parseIgnoreFiles(IFolder folder, String path) throws IOException, CoreException { + private void parseIgnoreFiles(IFolder folder, String repositoryPath) throws IOException, CoreException { // TODO - the parsing should be extracted IResource vltIgnore = folder.findMember(".vltignore"); if (vltIgnore != null && vltIgnore instanceof IFile) { @@ -396,8 +395,8 @@ public class ImportRepositoryContentAction { try (InputStream contents = ((IFile) vltIgnore).getContents()) { List<String> ignoreLines = IOUtils.readLines(contents); for (String ignoreLine : ignoreLines) { - logger.trace("Registering ignore rule {0}:{1}", path, ignoreLine); - ignoredResources.registerRegExpIgnoreRule(path, ignoreLine); + logger.trace("Registering ignore rule {0}:{1}", repositoryPath, ignoreLine); + ignoredResources.registerRegExpIgnoreRule(repositoryPath, ignoreLine); } } } diff --git a/shared/impl-vlt/src/main/java/org/apache/sling/ide/impl/vlt/serialization/VltSerializationDataBuilder.java b/shared/impl-vlt/src/main/java/org/apache/sling/ide/impl/vlt/serialization/VltSerializationDataBuilder.java index 91f5aaf8..52ec8f10 100644 --- a/shared/impl-vlt/src/main/java/org/apache/sling/ide/impl/vlt/serialization/VltSerializationDataBuilder.java +++ b/shared/impl-vlt/src/main/java/org/apache/sling/ide/impl/vlt/serialization/VltSerializationDataBuilder.java @@ -134,7 +134,7 @@ public class VltSerializationDataBuilder implements SerializationDataBuilder { SerializationKind serializationKind = getSerializationKind(aggregate); - if (resource.getPath().equals("/") || serializationKind == SerializationKind.METADATA_PARTIAL + if (resource.getPath().asString().equals("/") || serializationKind == SerializationKind.METADATA_PARTIAL || serializationKind == SerializationKind.FILE || serializationKind == SerializationKind.FOLDER) { nameHint = Constants.DOT_CONTENT_XML; } else if (serializationKind == SerializationKind.METADATA_FULL) { @@ -335,7 +335,7 @@ public class VltSerializationDataBuilder implements SerializationDataBuilder { } for (Aggregate leaf : leaves) { - if (leaf.getPath().equals(resource.getPath())) { + if (leaf.getPath().equals(resource.getPath().asString())) { chain.add(leaf); return chain; } else if (Text.isDescendant(leaf.getPath(), resource.getPath().asString())) {
