You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2017/01/22 16:45:14 UTC

svn commit: r1779835 - in /sling/trunk/tooling/ide: eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ eclipse-test/src/org/apache/sling/ide/test/impl/ eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/

Author: kwin
Date: Sun Jan 22 16:45:14 2017
New Revision: 1779835

URL: http://svn.apache.org/viewvc?rev=1779835&view=rev
Log:
SLING-6453 disable synchronisation in case filter could not be found

Modified:
    sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ResourceChangeCommandFactory.java
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrFullCoverageAggregatesDeploymentTest.java
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ResourceChangeCommandFactoryTest.java
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ExportWizardPage.java
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java

Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ResourceChangeCommandFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ResourceChangeCommandFactory.java?rev=1779835&r1=1779834&r2=1779835&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ResourceChangeCommandFactory.java (original)
+++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ResourceChangeCommandFactory.java Sun Jan 22 16:45:14 2017
@@ -240,7 +240,7 @@ public class ResourceChangeCommandFactor
      * The resourceProxy may be null, typically when a resource is already deleted.
      * 
      * <p>
-     * The filter may be null, in which case all combinations are included in the filed, i.e. allowed.
+     * In case the filter is {@code null} no resource should be added, i.e. {@link FilterResult#DENY} is returned
      * 
      * @param resource the resource to filter for, must not be <code>null</code>
      * @param resourceProxy the resource proxy to filter for, possibly <code>null</code>
@@ -250,7 +250,7 @@ public class ResourceChangeCommandFactor
     private FilterResult getFilterResult(IResource resource, ResourceProxy resourceProxy, Filter filter) {
 
         if (filter == null) {
-            return FilterResult.ALLOW;
+            return FilterResult.DENY;
         }
 
         File contentSyncRoot = ProjectUtil.getSyncDirectoryFile(resource.getProject());

Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java?rev=1779835&r1=1779834&r2=1779835&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java Sun Jan 22 16:45:14 2017
@@ -95,6 +95,8 @@ public class ContentDeploymentTest {
         ServerAdapter server = new ServerAdapter(wstServer.getServer());
         server.installModule(contentProject);
 
+        // create filter.xml
+        project.createVltFilterWithRoots("/test");
         project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.txt"), new ByteArrayInputStream(
                 "hello, world".getBytes()));
 
@@ -152,6 +154,8 @@ public class ContentDeploymentTest {
         ServerAdapter server = new ServerAdapter(wstServer.getServer());
         server.installModule(contentProject);
 
+        // create filter.xml
+        project.createVltFilterWithRoots("/test");
         project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.txt"), new ByteArrayInputStream(
                 "hello, world".getBytes()));
 
@@ -186,6 +190,8 @@ public class ContentDeploymentTest {
         ServerAdapter server = new ServerAdapter(wstServer.getServer());
         server.installModule(contentProject);
 
+        // create filter.xml
+        project.createVltFilterWithRoots("/test");
         project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.esp"), new ByteArrayInputStream(
                 "// not really javascript".getBytes()));
 
@@ -211,6 +217,8 @@ public class ContentDeploymentTest {
         ProjectAdapter project = new ProjectAdapter(contentProject);
         project.addNatures(JavaCore.NATURE_ID, "org.eclipse.wst.common.project.facet.core.nature");
 
+        // create filter.xml
+        project.createVltFilterWithRoots("/test");
         project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/hello.txt"), new ByteArrayInputStream(
                 "hello, world".getBytes()));
 
@@ -289,6 +297,8 @@ public class ContentDeploymentTest {
         ServerAdapter server = new ServerAdapter(wstServer.getServer());
         server.installModule(contentProject);
 
+        // create filter.xml
+        project.createVltFilterWithRoots("/test");
         // create sling:Folder at /test/folder
         project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/.content.xml"), getClass()
                 .getResourceAsStream("sling-folder-nodetype.xml"));

Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrFullCoverageAggregatesDeploymentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrFullCoverageAggregatesDeploymentTest.java?rev=1779835&r1=1779834&r2=1779835&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrFullCoverageAggregatesDeploymentTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrFullCoverageAggregatesDeploymentTest.java Sun Jan 22 16:45:14 2017
@@ -91,6 +91,9 @@ public class JcrFullCoverageAggregatesDe
         ServerAdapter server = new ServerAdapter(wstServer.getServer());
         server.installModule(contentProject);
 
+        // create filter.xml
+        project.createVltFilterWithRoots("/content");
+
         // create .content.xml structure
         InputStream contentXml = getClass().getResourceAsStream("content-nested-structure.xml");
         project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en.xml"), contentXml);
@@ -126,6 +129,9 @@ public class JcrFullCoverageAggregatesDe
         ServerAdapter server = new ServerAdapter(wstServer.getServer());
         server.installModule(contentProject);
 
+        // create filter.xml
+        project.createVltFilterWithRoots("/content");
+
         // create .content.xml structure
         InputStream contentXml = getClass().getResourceAsStream("content-nested-structure.xml");
         project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en.xml"), contentXml);
@@ -227,6 +233,8 @@ public class JcrFullCoverageAggregatesDe
 
         ServerAdapter server = new ServerAdapter(wstServer.getServer());
         server.installModule(contentProject);
+        // create filter.xml
+        project.createVltFilterWithRoots("/content");
 
         // create .content.xml structure
         InputStream contentXml = getClass().getResourceAsStream("content-nested-structure.xml");
@@ -323,6 +331,9 @@ public class JcrFullCoverageAggregatesDe
         
         final String baseName = "com.example.some.Component";
 
+        // create filter.xml
+        project.createVltFilterWithRoots("/content");
+
         // create .content.xml structure
         InputStream contentXml = getClass().getResourceAsStream(baseName + ".xml");
         project.createOrUpdateFile(

Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java?rev=1779835&r1=1779834&r2=1779835&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java Sun Jan 22 16:45:14 2017
@@ -91,6 +91,9 @@ public class JcrPartialCoverageAggregate
         ServerAdapter server = new ServerAdapter(wstServer.getServer());
         server.installModule(contentProject);
 
+        // create filter.xml
+        project.createVltFilterWithRoots("/content");
+
         // create a sling:Folder at /content/test-root
         InputStream contentXml = getClass().getResourceAsStream("sling-folder-nodetype.xml");
         project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.content.xml"), contentXml);
@@ -145,6 +148,9 @@ public class JcrPartialCoverageAggregate
         ServerAdapter server = new ServerAdapter(wstServer.getServer());
         server.installModule(contentProject);
 
+        // create filter.xml
+        project.createVltFilterWithRoots("/content");
+        
         // create a sling:Folder at /content/test-root
         project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/.content.xml"), getClass()
                 .getResourceAsStream("sling-folder-nodetype.xml"));
@@ -199,6 +205,8 @@ public class JcrPartialCoverageAggregate
 
         ServerAdapter server = new ServerAdapter(wstServer.getServer());
         server.installModule(contentProject);
+        // create filter.xml
+        project.createVltFilterWithRoots("/content");
 
         // create a nt:file at /content/test-root/file.txt
         project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/folder/file.txt"),
@@ -254,6 +262,9 @@ public class JcrPartialCoverageAggregate
         ServerAdapter server = new ServerAdapter(wstServer.getServer());
         server.installModule(contentProject);
 
+        // create filter.xml
+        project.createVltFilterWithRoots("/content");
+        
         // the expected repository structure is
         // mapping [sling:Mapping]
         // \- jcr:content [nt:unstructured]
@@ -319,6 +330,9 @@ public class JcrPartialCoverageAggregate
         ServerAdapter server = new ServerAdapter(wstServer.getServer());
         server.installModule(contentProject);
 
+        // create filter.xml
+        project.createVltFilterWithRoots("/content");
+        
         // the expected repository structure is
         // mapping [sling:Mapping]
         // \- jcr:content [nt:unstructured]

Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ResourceChangeCommandFactoryTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ResourceChangeCommandFactoryTest.java?rev=1779835&r1=1779834&r2=1779835&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ResourceChangeCommandFactoryTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ResourceChangeCommandFactoryTest.java Sun Jan 22 16:45:14 2017
@@ -62,6 +62,8 @@ public class ResourceChangeCommandFactor
 
         // install content facet
         project.installFacet("sling.content", "1.0");
+        // create filter.xml
+        project.createVltFilterWithRoots("/content");
 
         factory = new ResourceChangeCommandFactory(Activator.getDefault().getSerializationManager());
 

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ExportWizardPage.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ExportWizardPage.java?rev=1779835&r1=1779834&r2=1779835&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ExportWizardPage.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ExportWizardPage.java Sun Jan 22 16:45:14 2017
@@ -20,6 +20,7 @@ import org.apache.sling.ide.eclipse.core
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.swt.SWT;
@@ -37,12 +38,14 @@ public class ExportWizardPage extends Wi
 
     private SlingLaunchpadCombo repositoryCombo;
     private IResource syncStartPoint;
+    boolean hasValidFilter;
 
     public ExportWizardPage(IResource syncStartPoint) {
         super("Repository selection");
         setTitle("Repository selection");
         setDescription("Select a repository to export content to");
         this.syncStartPoint = syncStartPoint;
+        this.hasValidFilter = false;
     }
 
     @Override
@@ -106,13 +109,16 @@ public class ExportWizardPage extends Wi
         Label filterLabel = new Label(parent, SWT.NONE);
         GridDataFactory.fillDefaults().applyTo(filterLabel);
 
-        IFile filterFile = ResourcesPlugin.getWorkspace().getRoot()
-                .getFileForLocation(ProjectUtil.findFilterPath(syncStartPoint.getProject()));
+        IFile filterFile = null;
+        IPath path = ProjectUtil.findFilterPath(syncStartPoint.getProject());
+        if (path != null) {
+            filterFile  = ResourcesPlugin.getWorkspace().getRoot()
+                    .getFileForLocation(path);
+        }
 
         if (filterFile != null && filterFile.exists()) {
             filterLabel.setText("Will apply export filter from /" + filterFile.getProjectRelativePath() + ".");
-        } else {
-            filterLabel.setText("No filter definition found, will export all resources.");
+            hasValidFilter = true;
         }
     }
 
@@ -123,7 +129,17 @@ public class ExportWizardPage extends Wi
             setErrorMessage(repositoryError);
             return false;
         }
+        return true;
+    }
 
+    @Override
+    protected boolean validateSourceGroup() {
+        if (!hasValidFilter) {
+            setErrorMessage("No valid filter found in this project!");
+            return false;
+        }
         return true;
     }
+    
+    
 }

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java?rev=1779835&r1=1779834&r2=1779835&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java Sun Jan 22 16:45:14 2017
@@ -61,6 +61,7 @@ public class ImportWizardPage extends Wi
 	private Label adjustJcrRootText;
     private IFolder importRoot;
     private Composite adjustComposite;
+    boolean hasValidFilter;
 
 	/**
 	 * Creates an import wizard page for importing from a Sling Repository. If
@@ -93,6 +94,7 @@ public class ImportWizardPage extends Wi
         if (importRoot != null) {
             project = importRoot.getProject();
         }
+        hasValidFilter = false;
 	}
 	
     public IResource getResource() {
@@ -326,12 +328,10 @@ public class ImportWizardPage extends Wi
 
             if (filterFile != null && filterFile.exists()) {
                 importLabel.setText("Will apply import filter from /" + filterFile.getProjectRelativePath() + ".");
-            } else {
-                importLabel.setText("No filter definition found, will import all resources.");
+                hasValidFilter = true;
             }
             importLabel.setVisible(true);
         }
-        importLabel.setVisible(importRoot != null);
         importLabel.getParent().layout();
     }
 
@@ -355,6 +355,10 @@ public class ImportWizardPage extends Wi
 			// still under construction
 			return true;
 		}
+		if (!hasValidFilter) {
+            setErrorMessage("No valid filter found in this project!");
+            return false;
+        }
         if (adjustJcrRootText != null) {
             adjustJcrRootText();
             adjustJcrRootText.getParent().pack();
@@ -370,7 +374,6 @@ public class ImportWizardPage extends Wi
             setErrorMessage(repositoryError);
             return false;
         }
-
         return true;
 	}