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 68e64544f79526b0b052c86072a00a8e3916d539
Author: Robert Munteanu <[email protected]>
AuthorDate: Thu May 22 11:54:38 2025 +0200

    WIP for SLING-7599
---
 .../ide/eclipse/core/internal/SlingLaunchpadBehaviour.java    |  8 ++++----
 .../sling/ide/test/impl/DefaultCommandFactoryImplTest.java    |  3 +--
 .../org/apache/sling/ide/test/impl/helpers/SpyCommand.java    |  7 ++++---
 .../org/apache/sling/ide/test/impl/helpers/SpyRepository.java |  9 +++++----
 .../eclipse/ui/internal/ImportRepositoryContentAction.java    | 11 +++++++----
 5 files changed, 21 insertions(+), 17 deletions(-)

diff --git 
a/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
 
b/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
index 0812f3db..f25794cb 100644
--- 
a/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
+++ 
b/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
@@ -42,6 +42,7 @@ import org.apache.sling.ide.transport.Batcher;
 import org.apache.sling.ide.transport.Command;
 import org.apache.sling.ide.transport.Repository;
 import org.apache.sling.ide.transport.RepositoryInfo;
+import org.apache.sling.ide.transport.RepositoryPath;
 import org.apache.sling.ide.transport.ResourceProxy;
 import org.apache.sling.ide.transport.Result;
 import org.eclipse.core.resources.IFile;
@@ -63,7 +64,6 @@ import org.eclipse.wst.server.core.IServer;
 import org.eclipse.wst.server.core.model.IModuleResource;
 import org.eclipse.wst.server.core.model.IModuleResourceDelta;
 import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
-import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
 
 public class SlingLaunchpadBehaviour extends 
ServerBehaviourDelegateWithModulePublishSupport {
@@ -128,7 +128,7 @@ public class SlingLaunchpadBehaviour extends 
ServerBehaviourDelegateWithModulePu
        
                    } else {
                        
-                       Command<ResourceProxy> command = 
repository.newListChildrenNodeCommand("/");
+                       Command<ResourceProxy> command = 
repository.newListChildrenNodeCommand(new RepositoryPath("/"));
                        result = command.execute();
                        success = result.isSuccess();
                        
@@ -592,9 +592,9 @@ public class SlingLaunchpadBehaviour extends 
ServerBehaviourDelegateWithModulePu
 
     private IResource getResource(IModuleResource resource) {
 
-        IResource file = (IFile) resource.getAdapter(IFile.class);
+        IResource file = resource.getAdapter(IFile.class);
         if (file == null) {
-            file = (IFolder) resource.getAdapter(IFolder.class);
+            file = resource.getAdapter(IFolder.class);
         }
 
         if (file == null) {
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 7c7c89af..5f8b88ab 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
@@ -39,7 +39,6 @@ import org.apache.sling.ide.test.impl.helpers.SpyRepository;
 import org.apache.sling.ide.test.impl.helpers.TemporaryProject;
 import org.apache.sling.ide.transport.Repository;
 import org.apache.sling.ide.transport.ResourceProxy;
-import org.apache.sling.ide.util.PathUtil;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.NullProgressMonitor;
@@ -207,6 +206,6 @@ public class DefaultCommandFactoryImplTest {
         List<ResourceProxy> children = 
command.getResourceProxy().getChildren();
 
         assertThat("command.resource.children.size", children.size(), 
equalTo(3));
-        assertThat("command.resource.children[2].name", 
PathUtil.getName(children.get(2).getPath()), equalTo("folder2"));
+        assertThat("command.resource.children[2].name", 
children.get(2).getPath().getName(), equalTo("folder2"));
     }
 }
diff --git 
a/eclipse/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SpyCommand.java
 
b/eclipse/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SpyCommand.java
index 4917ab08..dd0ef3b6 100644
--- 
a/eclipse/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SpyCommand.java
+++ 
b/eclipse/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SpyCommand.java
@@ -23,6 +23,7 @@ import java.util.Set;
 import org.apache.sling.ide.sync.content.WorkspaceFile;
 import org.apache.sling.ide.transport.Command;
 import org.apache.sling.ide.transport.Repository.CommandExecutionFlag;
+import org.apache.sling.ide.transport.RepositoryPath;
 import org.apache.sling.ide.transport.ResourceProxy;
 import org.apache.sling.ide.transport.Result;
 
@@ -41,11 +42,11 @@ public class SpyCommand<T> implements Command<T> {
 
     private final ResourceProxy resourceProxy;
     private final WorkspaceFile fileInfo;
-    private final String path;
+    private final RepositoryPath path;
     private final SpyCommand.Kind kind;
     private final EnumSet<CommandExecutionFlag> flags;
 
-    public SpyCommand(ResourceProxy resourceProxy, WorkspaceFile fileInfo, 
String path, SpyCommand.Kind kind,
+    public SpyCommand(ResourceProxy resourceProxy, WorkspaceFile fileInfo, 
RepositoryPath path, SpyCommand.Kind kind,
             CommandExecutionFlag... flags) {
         this.resourceProxy = resourceProxy;
         this.fileInfo = fileInfo;
@@ -61,7 +62,7 @@ public class SpyCommand<T> implements Command<T> {
     }
 
     @Override
-    public String getPath() {
+    public RepositoryPath getPath() {
         return path;
     }
 
diff --git 
a/eclipse/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SpyRepository.java
 
b/eclipse/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SpyRepository.java
index ad02b714..1b78a361 100644
--- 
a/eclipse/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SpyRepository.java
+++ 
b/eclipse/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/SpyRepository.java
@@ -23,6 +23,7 @@ import 
org.apache.sling.ide.transport.FallbackNodeTypeRegistry;
 import org.apache.sling.ide.transport.NodeTypeRegistry;
 import org.apache.sling.ide.transport.Repository;
 import org.apache.sling.ide.transport.RepositoryInfo;
+import org.apache.sling.ide.transport.RepositoryPath;
 import org.apache.sling.ide.transport.ResourceProxy;
 
 /**
@@ -50,22 +51,22 @@ public class SpyRepository implements Repository {
     }
 
     @Override
-    public Command<Void> newDeleteNodeCommand(String path) {
+    public Command<Void> newDeleteNodeCommand(RepositoryPath path) {
         return new SpyCommand<>(null, null, path, SpyCommand.Kind.DELETE);
     }
 
     @Override
-    public Command<ResourceProxy> newListChildrenNodeCommand(String path) {
+    public Command<ResourceProxy> newListChildrenNodeCommand(RepositoryPath 
path) {
         throw new UnsupportedOperationException("Not implemented");
     }
 
     @Override
-    public Command<ResourceProxy> newGetNodeContentCommand(String path) {
+    public Command<ResourceProxy> newGetNodeContentCommand(RepositoryPath 
path) {
         throw new UnsupportedOperationException("Not implemented");
     }
 
     @Override
-    public Command<byte[]> newGetNodeCommand(String path) {
+    public Command<byte[]> newGetNodeCommand(RepositoryPath path) {
         throw new UnsupportedOperationException("Not implemented");
     }
 
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 f67ed1f3..f69cf60b 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
@@ -44,6 +44,7 @@ import org.apache.sling.ide.serialization.SerializationKind;
 import org.apache.sling.ide.serialization.SerializationKindManager;
 import org.apache.sling.ide.serialization.SerializationManager;
 import org.apache.sling.ide.sync.content.SyncCommandFactory;
+import org.apache.sling.ide.sync.content.WorkspacePath;
 import org.apache.sling.ide.transport.Command;
 import org.apache.sling.ide.transport.Repository;
 import org.apache.sling.ide.transport.RepositoryException;
@@ -256,8 +257,10 @@ public class ImportRepositoryContentAction {
             throws RepositoryException, CoreException, IOException, 
SerializationException {
 
         logger.trace("crawlChildrenAndImport({0},  {1}, {2}, {3}", repository, 
path, project, projectRelativePath);
+        
+        RepositoryPath repositoryPath = 
serializationManager.getRepositoryPath(new WorkspacePath(path));
 
-        ResourceProxy resource = 
executeCommand(repository.newListChildrenNodeCommand(path));
+        ResourceProxy resource = 
executeCommand(repository.newListChildrenNodeCommand(repositoryPath));
         
         SerializationData serializationData = 
builder.buildSerializationData(contentSyncRoot, resource);
         logger.trace("For resource at path {0} got serialization data {1}", 
resource.getPath(), serializationData);
@@ -270,7 +273,7 @@ public class ImportRepositoryContentAction {
        
                switch (serializationData.getSerializationKind()) {
                    case FILE: {
-                       byte[] contents = 
executeCommand(repository.newGetNodeCommand(path));
+                       byte[] contents = 
executeCommand(repository.newGetNodeCommand(repositoryPath));
                     createFile(project, getPathForPlainFileNode(resource, 
serializationFolderPath), contents);
        
                        if (serializationData.hasContents()) {
@@ -299,7 +302,7 @@ public class ImportRepositoryContentAction {
 
                                     // 2. recursively handle all resources
                                     for (ResourceProxy grandChild : 
reloadedChildResource.getChildren()) {
-                                        
crawlChildrenAndImport(grandChild.getPath());
+                                        crawlChildrenAndImport(path + "/" + 
serializationManager.getLocalName(child.getPath().getName()) + "/" + 
serializationManager.getLocalName(grandChild.getPath().getName()));
                                     }
                                 }
                                    
@@ -357,7 +360,7 @@ public class ImportRepositoryContentAction {
                 }
             }
 
-            crawlChildrenAndImport(child.getPath());
+            crawlChildrenAndImport(path + "/" + 
serializationManager.getLocalName(child.getPath().getName()));
         }
     }
 

Reply via email to