sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject svn commit: r1505809 - in /sling/whiteboard/asanso/plugins/eclipse: api/META-INF/ api/src/org/apache/sling/ide/filter/ eclipse-core/META-INF/ eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ impl-resource/META-INF/ impl-resource/OSGI-INF/ i...
Date Mon, 22 Jul 2013 20:56:52 GMT
Author: rombert
Date: Mon Jul 22 20:56:51 2013
New Revision: 1505809

URL: http://svn.apache.org/r1505809
Log:
SLING-2973 - [Tooling] Align Eclipse tooling to proposed structure

Added a basic Filter interface with a dead-simple implementation, just
to drive the API and find the right places to plug it in.

Added:
    sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/
    sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/Filter.java
  (with props)
    sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterLocator.java
  (with props)
    sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterResult.java
  (with props)
    sling/whiteboard/asanso/plugins/eclipse/impl-resource/OSGI-INF/SimpleFilterLocator.xml
  (with props)
    sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/
    sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
  (with props)
    sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilterLocator.java
  (with props)
Modified:
    sling/whiteboard/asanso/plugins/eclipse/api/META-INF/MANIFEST.MF
    sling/whiteboard/asanso/plugins/eclipse/eclipse-core/META-INF/MANIFEST.MF
    sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/Activator.java
    sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingContentModuleFactory.java
    sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
    sling/whiteboard/asanso/plugins/eclipse/impl-resource/META-INF/MANIFEST.MF

Modified: sling/whiteboard/asanso/plugins/eclipse/api/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/api/META-INF/MANIFEST.MF?rev=1505809&r1=1505808&r2=1505809&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/api/META-INF/MANIFEST.MF (original)
+++ sling/whiteboard/asanso/plugins/eclipse/api/META-INF/MANIFEST.MF Mon Jul 22 20:56:51 2013
@@ -8,4 +8,5 @@ Require-Bundle: org.eclipse.ui,
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Export-Package: org.apache.sling.ide.serialization,
- org.apache.sling.ide.transport
+ org.apache.sling.ide.transport,
+ org.apache.sling.ide.filter

Added: sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/Filter.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/Filter.java?rev=1505809&view=auto
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/Filter.java
(added)
+++ sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/Filter.java
Mon Jul 22 20:56:51 2013
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+package org.apache.sling.ide.filter;
+
+public interface Filter {
+
+    /**
+     * 
+     * @param relativeFilePath a relative path
+     * @return the filter result
+     */
+    FilterResult filter(String relativeFilePath);
+}

Propchange: sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/Filter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/Filter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterLocator.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterLocator.java?rev=1505809&view=auto
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterLocator.java
(added)
+++ sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterLocator.java
Mon Jul 22 20:56:51 2013
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+package org.apache.sling.ide.filter;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+public interface FilterLocator {
+
+    File findFilterLocation(File syncDirectory);
+
+    Filter loadFilter(InputStream filterFileContents) throws IOException;
+}

Propchange: sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterLocator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterLocator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterResult.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterResult.java?rev=1505809&view=auto
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterResult.java
(added)
+++ sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterResult.java
Mon Jul 22 20:56:51 2013
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+package org.apache.sling.ide.filter;
+
+public enum FilterResult {
+    ALLOW, DENY;
+}

Propchange: sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterResult.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/filter/FilterResult.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/whiteboard/asanso/plugins/eclipse/eclipse-core/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/eclipse-core/META-INF/MANIFEST.MF?rev=1505809&r1=1505808&r2=1505809&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/eclipse-core/META-INF/MANIFEST.MF (original)
+++ sling/whiteboard/asanso/plugins/eclipse/eclipse-core/META-INF/MANIFEST.MF Mon Jul 22 20:56:51
2013
@@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.core.runtime
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ClassPath: .
-Import-Package: org.apache.sling.ide.serialization,
+Import-Package: org.apache.sling.ide.filter,
+ org.apache.sling.ide.serialization,
  org.apache.sling.ide.transport,
  org.eclipse.core.commands,
  org.eclipse.core.commands.operations,

Modified: sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/Activator.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/Activator.java?rev=1505809&r1=1505808&r2=1505809&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/Activator.java
(original)
+++ sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/Activator.java
Mon Jul 22 20:56:51 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.sling.ide.eclipse.core.internal;
 
+import org.apache.sling.ide.filter.FilterLocator;
 import org.apache.sling.ide.serialization.SerializationManager;
 import org.apache.sling.ide.transport.Repository;
 import org.eclipse.core.runtime.Plugin;
@@ -41,10 +42,12 @@ public class Activator extends Plugin {
     private Repository repository;
     private SerializationManager serializationManager;
 	private Tracer tracer;
+    private FilterLocator filterLocator;
 
     private ServiceReference<Repository> repositoryRef;
     private ServiceReference<SerializationManager> serializationManagerRef;
     private ServiceReference<Tracer> tracerRef;
+    private ServiceReference<FilterLocator> filterLocatorRef;
 
 	/*
 	 * (non-Javadoc)
@@ -62,6 +65,9 @@ public class Activator extends Plugin {
 
         serializationManagerRef = context.getServiceReference(SerializationManager.class);
         serializationManager = context.getService(serializationManagerRef);
+
+        filterLocatorRef = context.getServiceReference(FilterLocator.class);
+        filterLocator = context.getService(filterLocatorRef);
 	}
 
 	/*
@@ -72,6 +78,7 @@ public class Activator extends Plugin {
         context.ungetService(repositoryRef);
         context.ungetService(serializationManagerRef);
         context.ungetService(tracerRef);
+        context.ungetService(filterLocatorRef);
 
         plugin = null;
 		super.stop(context);
@@ -97,4 +104,8 @@ public class Activator extends Plugin {
     public SerializationManager getSerializationManager() {
         return serializationManager;
     }
+
+    public FilterLocator getFilterLocator() {
+        return filterLocator;
+    }
 }

Modified: sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingContentModuleFactory.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingContentModuleFactory.java?rev=1505809&r1=1505808&r2=1505809&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingContentModuleFactory.java
(original)
+++ sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingContentModuleFactory.java
Mon Jul 22 20:56:51 2013
@@ -30,8 +30,6 @@ public class SlingContentModuleFactory e
     @Override
     public ModuleDelegate getModuleDelegate(IModule module) {
 
-        System.out.println("SlingContentModuleFactory.getModuleDelegate()");
-
         return new SlingContentModuleDelegate(module);
     }
 
@@ -41,15 +39,13 @@ public class SlingContentModuleFactory e
         try {
             IFacetedProject facetedProject = ProjectFacetsManager.create(project);
             for (IProjectFacetVersion facet : facetedProject.getProjectFacets()) {
-                System.out.println("Project " + project + " has facet " + facet);
                 if (facet.getProjectFacet().getId().equals(NATURE_ID)) {
                     return createModule(project.getName(), project.getName(), NATURE_ID,
"1.0", project);
                 }
             }
         } catch (CoreException ce) {
             // TODO logging
-            }
-
+        }
 
         return null;
     }
@@ -92,7 +88,7 @@ public class SlingContentModuleFactory e
                         return true;
                     }
 
-                    // urelated resource tree, stop processing
+                    // unrelated resource tree, stop processing
                     if (!syncFolder.getProjectRelativePath().isPrefixOf(relativePath)) {
                         return false;
                     }

Modified: sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java?rev=1505809&r1=1505808&r2=1505809&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
(original)
+++ sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
Mon Jul 22 20:56:51 2013
@@ -16,28 +16,33 @@
  */
 package org.apache.sling.ide.eclipse.core.internal;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.Arrays;
 import java.util.Map;
 
+import org.apache.sling.ide.eclipse.core.ProjectUtil;
 import org.apache.sling.ide.eclipse.core.ServerUtil;
+import org.apache.sling.ide.filter.Filter;
+import org.apache.sling.ide.filter.FilterLocator;
+import org.apache.sling.ide.filter.FilterResult;
 import org.apache.sling.ide.serialization.SerializationManager;
 import org.apache.sling.ide.transport.Command;
 import org.apache.sling.ide.transport.FileInfo;
 import org.apache.sling.ide.transport.Repository;
-import org.apache.sling.ide.transport.RepositoryInfo;
 import org.apache.sling.ide.transport.ResponseType;
 import org.apache.sling.ide.transport.Result;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.wst.server.core.IModule;
@@ -140,6 +145,11 @@ public class SlingLaunchpadBehaviour ext
         Repository repository = ServerUtil.getRepository(getServer(), monitor);
 
         IModuleResource[] moduleResources = getResources(module);
+        
+        // TODO it would be more efficient to have a module -> filter mapping
+        // it would be simpler to implement this in SlingContentModuleAdapter, but
+        // the behaviour for resources being filtered out is deletion, and that
+        // would be an incorrect ( or at least suprising ) behaviour at development time
 
         switch (deltaKind) {
             case ServerBehaviourDelegate.CHANGED:
@@ -250,6 +260,25 @@ public class SlingLaunchpadBehaviour ext
             return null;
         }
 
+        IProject project = file.getProject();
+
+        String syncDirectory = ProjectUtil.getSyncDirectoryValue(project);
+
+        Filter filter = null;
+        try {
+            filter = loadFilter(project, project.getFolder(syncDirectory));
+        } catch (CoreException e) {
+            // TODO error handling
+            e.printStackTrace();
+        }
+
+        if (filter != null) {
+            FilterResult filterResult = filter.filter(resource.getModuleRelativePath().toString());
+            if (filterResult == FilterResult.DENY) {
+                return null;
+            }
+        }
+
         IPath relativePath = resource.getModuleRelativePath().removeLastSegments(1);
 
         FileInfo info = new FileInfo(file.getLocation().toOSString(), relativePath.toOSString(),
file.getName());
@@ -269,4 +298,30 @@ public class SlingLaunchpadBehaviour ext
 
         return repository.newDeleteNodeCommand(info);
     }
+
+    private Filter loadFilter(IProject project, final IFolder syncFolder) throws CoreException
{
+        FilterLocator filterLocator = Activator.getDefault().getFilterLocator();
+        File filterLocation = filterLocator.findFilterLocation(syncFolder.getLocation().toFile());
+        IPath filterPath = Path.fromOSString(filterLocation.getAbsolutePath());
+        IFile filterFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(filterPath);
+        Filter filter = null;
+        if (filterFile != null && filterFile.exists()) {
+            InputStream contents = filterFile.getContents();
+            try {
+                filter = filterLocator.loadFilter(contents);
+            } catch (IOException e) {
+                throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+                        "Failed loading filter file for project " + project.getName() + "
from location " + filterFile,
+                        e));
+            } finally {
+                try {
+                    contents.close();
+                } catch (IOException e) {
+                    // TODO exception handling
+                }
+            }
+        }
+        return filter;
+    }
+
 }

Modified: sling/whiteboard/asanso/plugins/eclipse/impl-resource/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/impl-resource/META-INF/MANIFEST.MF?rev=1505809&r1=1505808&r2=1505809&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/impl-resource/META-INF/MANIFEST.MF (original)
+++ sling/whiteboard/asanso/plugins/eclipse/impl-resource/META-INF/MANIFEST.MF Mon Jul 22
20:56:51 2013
@@ -12,5 +12,6 @@ Require-Bundle: org.eclipse.ui,
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Service-Component: OSGI-INF/RepositoryImpl.xml,
- OSGI-INF/SimpleXmlSerializationManager.xml, OSGI-INF/Tracer.xml
+ OSGI-INF/SimpleXmlSerializationManager.xml, OSGI-INF/Tracer.xml,
+ OSGI-INF/SimpleFilterLocator.xml
 Import-Package: org.json

Added: sling/whiteboard/asanso/plugins/eclipse/impl-resource/OSGI-INF/SimpleFilterLocator.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/impl-resource/OSGI-INF/SimpleFilterLocator.xml?rev=1505809&view=auto
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/impl-resource/OSGI-INF/SimpleFilterLocator.xml
(added)
+++ sling/whiteboard/asanso/plugins/eclipse/impl-resource/OSGI-INF/SimpleFilterLocator.xml
Mon Jul 22 20:56:51 2013
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="false">
+   <implementation class="org.apache.sling.ide.impl.resource.filer.SimpleFilterLocator"/>
+   <service>
+      <provide interface="org.apache.sling.ide.filter.FilterLocator"/>
+   </service>>
+</scr:component>

Propchange: sling/whiteboard/asanso/plugins/eclipse/impl-resource/OSGI-INF/SimpleFilterLocator.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/asanso/plugins/eclipse/impl-resource/OSGI-INF/SimpleFilterLocator.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java?rev=1505809&view=auto
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
(added)
+++ sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
Mon Jul 22 20:56:51 2013
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+package org.apache.sling.ide.impl.resource.filer;
+
+import java.util.List;
+
+import org.apache.sling.ide.filter.Filter;
+import org.apache.sling.ide.filter.FilterResult;
+
+public class SimpleFilter implements Filter {
+
+    private final List<String> includedPathPrefixes;
+
+    public SimpleFilter(List<String> includedPathPrefixes) {
+        this.includedPathPrefixes = includedPathPrefixes;
+    }
+
+    @Override
+    public FilterResult filter(String relativeFilePath) {
+        if (relativeFilePath.charAt(0) != '/') {
+            relativeFilePath = '/' + relativeFilePath;
+        }
+        System.out.println("SimpleFilter.filter(" + relativeFilePath + ")");
+
+        if (includedPathPrefixes.isEmpty()) {
+            System.out.println(" -- no path prefixes -> " + FilterResult.ALLOW);
+            return FilterResult.ALLOW;
+        }
+
+        for (String includePath : includedPathPrefixes) {
+            System.out.println(" -- checking with " + includePath);
+            if (relativeFilePath.startsWith(includePath)) {
+                System.out.println(" --- found match -> " + FilterResult.ALLOW);
+                return FilterResult.ALLOW;
+            }
+        }
+
+        System.out.println(" -- no match " + FilterResult.DENY);
+        return FilterResult.DENY;
+    }
+}

Propchange: sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilterLocator.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilterLocator.java?rev=1505809&view=auto
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilterLocator.java
(added)
+++ sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilterLocator.java
Mon Jul 22 20:56:51 2013
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+package org.apache.sling.ide.impl.resource.filer;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.sling.ide.filter.Filter;
+import org.apache.sling.ide.filter.FilterLocator;
+
+/**
+ * The <tt>SimpleFilterLocator</tt> looks for a file named {@value #FILTERS_FILE_NAME}
in the parent folder of the
+ * specified <tt>syncDirectory</tt>.
+ * 
+ * <p>
+ * Lines starting with '#' are ignored.
+ * </p>
+ * 
+ * @see SimpleFilter
+ * 
+ */
+public class SimpleFilterLocator implements FilterLocator {
+
+    private static final String FILTERS_FILE_NAME = "filters.txt";
+
+    @Override
+    public File findFilterLocation(File syncDirectory) {
+        String parent = syncDirectory.getParent();
+
+        return new File(parent, FILTERS_FILE_NAME);
+    }
+
+    @Override
+    public Filter loadFilter(InputStream filterFileContents) throws IOException {
+
+        List<String> filters = new ArrayList<String>();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(filterFileContents));
+        String line;
+        while ((line = reader.readLine()) != null) {
+            if (line.charAt(0) == '#')
+                continue;
+            filters.add(line);
+        }
+
+        return new SimpleFilter(filters);
+    }
+}

Propchange: sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilterLocator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilterLocator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message