You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2018/04/18 16:16:09 UTC

[sling-ide-tooling] 04/08: SLING-7587 - Create a CLI-only tool to sync content

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-ide-tooling.git

commit a17f5e14fb105135089f109abc03f00301287a36
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Apr 17 15:09:03 2018 +0300

    SLING-7587 - Create a CLI-only tool to sync content
    
    sync-fs: bugfix and allow usage in OSGi environments
---
 shared/modules/sync-fs/bnd.bnd                     |  1 +
 shared/modules/sync-fs/pom.xml                     |  9 ++++++
 .../sling/ide/content/sync/fs/FSResources.java}    | 35 +++++-----------------
 .../content/sync/fs/impl/FSWorkspaceProject.java   |  2 +-
 .../sling/ide/content/sync/fs/package-info.java    | 18 +++++++++++
 .../content/sync/fs/impl/MockFilterLocator.java    |  2 +-
 6 files changed, 38 insertions(+), 29 deletions(-)

diff --git a/shared/modules/sync-fs/bnd.bnd b/shared/modules/sync-fs/bnd.bnd
new file mode 100644
index 0000000..1e09af3
--- /dev/null
+++ b/shared/modules/sync-fs/bnd.bnd
@@ -0,0 +1 @@
+-exportcontents: ${packages;VERSIONED}
\ No newline at end of file
diff --git a/shared/modules/sync-fs/pom.xml b/shared/modules/sync-fs/pom.xml
index 43b7fe9..ce5177b 100644
--- a/shared/modules/sync-fs/pom.xml
+++ b/shared/modules/sync-fs/pom.xml
@@ -46,6 +46,15 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>
diff --git a/shared/modules/sync-fs/src/test/java/org/apache/sling/ide/content/sync/fs/impl/MockFilterLocator.java b/shared/modules/sync-fs/src/main/java/org/apache/sling/ide/content/sync/fs/FSResources.java
similarity index 50%
copy from shared/modules/sync-fs/src/test/java/org/apache/sling/ide/content/sync/fs/impl/MockFilterLocator.java
copy to shared/modules/sync-fs/src/main/java/org/apache/sling/ide/content/sync/fs/FSResources.java
index 85a935c..9185a69 100644
--- a/shared/modules/sync-fs/src/test/java/org/apache/sling/ide/content/sync/fs/impl/MockFilterLocator.java
+++ b/shared/modules/sync-fs/src/main/java/org/apache/sling/ide/content/sync/fs/FSResources.java
@@ -14,40 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.ide.content.sync.fs.impl;
+package org.apache.sling.ide.content.sync.fs;
 
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Paths;
 
-import org.apache.sling.ide.filter.Filter;
+import org.apache.sling.ide.content.sync.fs.impl.FSWorkspaceProject;
 import org.apache.sling.ide.filter.FilterLocator;
-import org.apache.sling.ide.filter.FilterResult;
+import org.apache.sling.ide.sync.content.WorkspaceProject;
 
-public class MockFilterLocator implements FilterLocator {
+public abstract class FSResources {
 
-    public static final Filter MOCK_FILTER = new Filter() {
-        
-        @Override
-        public FilterResult filter(String repositoryPath) {
-            return FilterResult.ALLOW;
-        }
-    };
+    public static WorkspaceProject create(File projectDir, File syncRoot, FilterLocator filterLocator) {
+        return new FSWorkspaceProject(projectDir, syncRoot, filterLocator);
+    }
     
-    @Override
-    public File findFilterLocation(File syncDirectory) {
-        
-        return syncDirectory.toPath().
-                resolve(Paths.get("META-INF", "vault", "filter.xml")).toFile();
+    private FSResources() {
         
     }
-
-    @Override
-    public Filter loadFilter(InputStream filterFileContents) throws IOException {
-        if ( filterFileContents == null )
-            return null;
-        return MOCK_FILTER;
-    }
-
 }
diff --git a/shared/modules/sync-fs/src/main/java/org/apache/sling/ide/content/sync/fs/impl/FSWorkspaceProject.java b/shared/modules/sync-fs/src/main/java/org/apache/sling/ide/content/sync/fs/impl/FSWorkspaceProject.java
index 424b2ea..a15385d 100644
--- a/shared/modules/sync-fs/src/main/java/org/apache/sling/ide/content/sync/fs/impl/FSWorkspaceProject.java
+++ b/shared/modules/sync-fs/src/main/java/org/apache/sling/ide/content/sync/fs/impl/FSWorkspaceProject.java
@@ -69,7 +69,7 @@ public class FSWorkspaceProject extends FSWorkspaceResource implements Workspace
 
     @Override
     public Filter getFilter() throws IOException {
-        File filterFile = filterLocator.findFilterLocation(syncRoot);
+        File filterFile = filterLocator.findFilterLocation(new File(syncRoot, "jcr_root"));
         if ( filterFile == null || !filterFile.exists() )
             return null;
         
diff --git a/shared/modules/sync-fs/src/main/java/org/apache/sling/ide/content/sync/fs/package-info.java b/shared/modules/sync-fs/src/main/java/org/apache/sling/ide/content/sync/fs/package-info.java
new file mode 100644
index 0000000..56c177b
--- /dev/null
+++ b/shared/modules/sync-fs/src/main/java/org/apache/sling/ide/content/sync/fs/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+@org.osgi.annotation.versioning.Version("1.0.0")
+package org.apache.sling.ide.content.sync.fs;
\ No newline at end of file
diff --git a/shared/modules/sync-fs/src/test/java/org/apache/sling/ide/content/sync/fs/impl/MockFilterLocator.java b/shared/modules/sync-fs/src/test/java/org/apache/sling/ide/content/sync/fs/impl/MockFilterLocator.java
index 85a935c..6b35f08 100644
--- a/shared/modules/sync-fs/src/test/java/org/apache/sling/ide/content/sync/fs/impl/MockFilterLocator.java
+++ b/shared/modules/sync-fs/src/test/java/org/apache/sling/ide/content/sync/fs/impl/MockFilterLocator.java
@@ -38,7 +38,7 @@ public class MockFilterLocator implements FilterLocator {
     @Override
     public File findFilterLocation(File syncDirectory) {
         
-        return syncDirectory.toPath().
+        return syncDirectory.getParentFile().toPath().
                 resolve(Paths.get("META-INF", "vault", "filter.xml")).toFile();
         
     }

-- 
To stop receiving notification emails like this one, please contact
rombert@apache.org.