incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject svn commit: r1520303 - in /sling/branches/tooling-ide-vlt/tooling/ide: api/src/org/apache/sling/ide/filter/ api/src/org/apache/sling/ide/serialization/ eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ eclipse-ui/src/org/apache/sling/ide/ecl...
Date Thu, 05 Sep 2013 13:39:58 GMT
Author: rombert
Date: Thu Sep  5 13:39:57 2013
New Revision: 1520303

URL: http://svn.apache.org/r1520303
Log:
SLING-2989 - [Tooling] integrate with vlt once available

Added basic filter support

The filter is possibly broken because we use filesystem paths for
filtering, while the filters possibly use JCR paths.

Added:
    sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/OSGI-INF/VltFilterLocator.xml   (with
props)
    sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/
    sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilter.java
  (with props)
    sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilterLocator.java
  (with props)
Modified:
    sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/filter/Filter.java
    sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/filter/FilterLocator.java
    sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/serialization/SerializationManager.java
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java
    sling/branches/tooling-ide-vlt/tooling/ide/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java
    sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
    sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java
    sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/META-INF/MANIFEST.MF
    sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VaultFsLocator.java
    sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VaultFsLocatorImpl.java
    sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java

Modified: sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/filter/Filter.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/filter/Filter.java?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/filter/Filter.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/filter/Filter.java
Thu Sep  5 13:39:57 2013
@@ -16,6 +16,10 @@
  */
 package org.apache.sling.ide.filter;
 
+import java.io.File;
+
+import org.apache.sling.ide.transport.RepositoryInfo;
+
 public interface Filter {
 
     /**
@@ -23,5 +27,5 @@ public interface Filter {
      * @param relativeFilePath a relative path
      * @return the filter result
      */
-    FilterResult filter(String relativeFilePath);
+    FilterResult filter(File contentSyncRoot, String relativeFilePath, RepositoryInfo repositoryInfo);
 }

Modified: sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/filter/FilterLocator.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/filter/FilterLocator.java?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/filter/FilterLocator.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/filter/FilterLocator.java
Thu Sep  5 13:39:57 2013
@@ -22,6 +22,7 @@ import java.io.InputStream;
 
 public interface FilterLocator {
 
+    // TODO - should be File[] to allow multiple lookups, see {filter-vlt.xml, filter.xml}
     File findFilterLocation(File syncDirectory);
 
     Filter loadFilter(InputStream filterFileContents) throws IOException;

Modified: sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/serialization/SerializationManager.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/serialization/SerializationManager.java?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/serialization/SerializationManager.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/serialization/SerializationManager.java
Thu Sep  5 13:39:57 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.sling.ide.serialization;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Map;
@@ -31,7 +32,8 @@ public interface SerializationManager {
 
     String getSerializationFilePath(String baseFilePath);
 
-    String buildSerializationData(ResourceProxy resource, RepositoryInfo repositoryInfo)
throws IOException;
+    String buildSerializationData(File contentSyncRoot, ResourceProxy resource, RepositoryInfo
repositoryInfo)
+            throws IOException;
 
     Map<String, Object> readSerializationData(InputStream source) throws IOException;
 }

Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
Thu Sep  5 13:39:57 2013
@@ -31,6 +31,7 @@ import org.apache.sling.ide.serializatio
 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.ResourceProxy;
 import org.apache.sling.ide.transport.Result;
 import org.eclipse.core.resources.IFile;
@@ -218,7 +219,7 @@ public class SlingLaunchpadBehaviour ext
 
     private Command<?> addFileCommand(Repository repository, IModuleResource resource)
throws CoreException {
 
-        FileInfo info = createFileInfo(resource);
+        FileInfo info = createFileInfo(resource, repository);
 
         System.out.println("For " + resource + " build fileInfo " + info);
         if (info == null) {
@@ -241,7 +242,7 @@ public class SlingLaunchpadBehaviour ext
         }
     }
 
-    private FileInfo createFileInfo(IModuleResource resource) {
+    private FileInfo createFileInfo(IModuleResource resource, Repository repository) {
 
         IResource file = (IFile) resource.getAdapter(IFile.class);
         if (file == null) {
@@ -258,6 +259,7 @@ public class SlingLaunchpadBehaviour ext
         IProject project = file.getProject();
 
         String syncDirectory = ProjectUtil.getSyncDirectoryValue(project);
+        File syncDirectoryAsFile = ProjectUtil.getSyncDirectoryFullPath(project).toFile();
 
         Filter filter = null;
         try {
@@ -268,7 +270,8 @@ public class SlingLaunchpadBehaviour ext
         }
 
         if (filter != null) {
-            FilterResult filterResult = getFilterResult(resource, filter);
+            FilterResult filterResult = getFilterResult(resource, filter, syncDirectoryAsFile,
+                    repository.getRepositoryInfo());
             if (filterResult == FilterResult.DENY) {
                 return null;
             }
@@ -283,7 +286,8 @@ public class SlingLaunchpadBehaviour ext
         return info;
     }
 
-    private FilterResult getFilterResult(IModuleResource resource, Filter filter) {
+    private FilterResult getFilterResult(IModuleResource resource, Filter filter, File contentSyncRoot,
+            RepositoryInfo repositoryInfo) {
 
         String filePath = resource.getModuleRelativePath().toOSString();
         if (serializationManager().isSerializationFile(filePath)) {
@@ -292,12 +296,12 @@ public class SlingLaunchpadBehaviour ext
 
         System.out.println("Filtering by " + filePath + " for " + resource);
 
-        return filter.filter(filePath);
+        return filter.filter(contentSyncRoot, filePath, repositoryInfo);
     }
 
     private Command<?> removeFileCommand(Repository repository, IModuleResource resource)
{
 
-        FileInfo info = createFileInfo(resource);
+        FileInfo info = createFileInfo(resource, repository);
 
         if (info == null) {
             return null;
@@ -309,6 +313,9 @@ public class SlingLaunchpadBehaviour ext
     private Filter loadFilter(IProject project, final IFolder syncFolder) throws CoreException
{
         FilterLocator filterLocator = Activator.getDefault().getFilterLocator();
         File filterLocation = filterLocator.findFilterLocation(syncFolder.getLocation().toFile());
+        if (filterLocation == null) {
+            return null;
+        }
         IPath filterPath = Path.fromOSString(filterLocation.getAbsolutePath());
         IFile filterFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(filterPath);
         Filter filter = null;

Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java
Thu Sep  5 13:39:57 2013
@@ -17,11 +17,13 @@
 package org.apache.sling.ide.eclipse.ui.internal;
 
 import java.io.ByteArrayInputStream;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 
 import org.apache.sling.ide.eclipse.core.ISlingLaunchpadServer;
+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;
@@ -200,7 +202,7 @@ public class ImportWizard extends Wizard
             createFolder(project, rootImportPath.removeLastSegments(i));
     }
 
-	        /**
+    /**
      * Crawls the repository and recursively imports founds resources
      * 
      * @param repository the sling repository to import from
@@ -218,6 +220,8 @@ public class ImportWizard extends Wizard
     private void crawlChildrenAndImport(Repository repository, Filter filter, String path,
IProject project,
             IPath projectRelativePath) throws RepositoryException, CoreException, IOException
{
 
+        File contentSyncRoot = ProjectUtil.getSyncDirectoryFullPath(project).toFile();
+
         System.out.println("crawlChildrenAndImport(" + repository + ", " + path + ", " +
project + ", "
                 + projectRelativePath + ")");
 
@@ -234,8 +238,8 @@ public class ImportWizard extends Wizard
 			createFolder(project, projectRelativePath.append(path));
             ResourceProxy resourceToSerialize = executeCommand(repository.newGetNodeContentCommand(path));
             
-            String out = serializationManager.buildSerializationData(resourceToSerialize,
-                    repository.getRepositoryInfo());
+            String out = serializationManager.buildSerializationData(contentSyncRoot,
+                    resourceToSerialize, repository.getRepositoryInfo());
             if (out != null) {
                 createFile(project, projectRelativePath.append(serializationManager.getSerializationFilePath(path)),
                     out.getBytes("UTF-8"));
@@ -251,7 +255,8 @@ public class ImportWizard extends Wizard
             }
 
             if (filter != null) {
-                FilterResult filterResult = filter.filter(child.getPath());
+                FilterResult filterResult = filter.filter(contentSyncRoot, child.getPath(),
+                        repository.getRepositoryInfo());
                 if (filterResult == FilterResult.DENY) {
                     continue;
                 }

Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizardPage.java
Thu Sep  5 13:39:57 2013
@@ -373,8 +373,7 @@ public class ImportWizardPage extends Wi
         if (filterFile!=null && filterFile.exists()) {
             importLabel.setText("Will apply import filter from /" + filterFile.getProjectRelativePath()
+ ".");
         } else {
-            importLabel.setText("No filter found at /" + filterFile.getProjectRelativePath()
-                    + ", will import all resources.");
+            importLabel.setText("No filter definition found, will import all resources.");
         }
         importLabel.setVisible(true);
         importLabel.getParent().layout();
@@ -394,6 +393,9 @@ public class ImportWizardPage extends Wi
 
         FilterLocator filterLocator = Activator.getDefault().getFilterLocator();
         File filterLocation = filterLocator.findFilterLocation(syncLocation.getLocation().toFile());
+        if (filterLocation == null) {
+            return null;
+        }
         IPath filterPath = Path.fromOSString(filterLocation.getAbsolutePath());
         return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(filterPath);
     }

Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java
Thu Sep  5 13:39:57 2013
@@ -37,7 +37,7 @@ public class SimpleXmlSerializationManag
     @Test
     public void emptySerializedData() throws IOException, SAXException {
 
-        String serializationData = sm.buildSerializationData(newResourceWithProperties(new
HashMap<String, Object>()), null);
+        String serializationData = sm.buildSerializationData(null, newResourceWithProperties(new
HashMap<String, Object>()), null);
 
         assertThat(serializationData, is(nullValue()));
     }
@@ -53,7 +53,7 @@ public class SimpleXmlSerializationManag
     @Test
     public void nullSerializedData() throws IOException, SAXException {
 
-        String serializationData = sm.buildSerializationData(null, null);
+        String serializationData = sm.buildSerializationData(null, null, null);
 
         assertThat(serializationData, is(nullValue()));
     }
@@ -65,7 +65,7 @@ public class SimpleXmlSerializationManag
         data.put("jcr:createdBy", "admin");
         data.put("jcr:lastModifiedBy", "author");
 
-        String serializationData = sm.buildSerializationData(newResourceWithProperties(data),
null);
+        String serializationData = sm.buildSerializationData(null, newResourceWithProperties(data),
null);
 
         String methodName = "stringSerializedData";
 
@@ -93,7 +93,7 @@ public class SimpleXmlSerializationManag
         Map<String, Object> data = new HashMap<String, Object>();
         data.put("jcr:description", "<p class=\"active\">Welcome</p>");
 
-        String serializationData = sm.buildSerializationData(newResourceWithProperties(data),
null);
+        String serializationData = sm.buildSerializationData(null, newResourceWithProperties(data),
null);
 
         String methodName = "serializedDataIsEscaped";
 

Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
Thu Sep  5 13:39:57 2013
@@ -16,10 +16,12 @@
  */
 package org.apache.sling.ide.impl.resource.filer;
 
+import java.io.File;
 import java.util.List;
 
 import org.apache.sling.ide.filter.Filter;
 import org.apache.sling.ide.filter.FilterResult;
+import org.apache.sling.ide.transport.RepositoryInfo;
 
 public class SimpleFilter implements Filter {
 
@@ -30,7 +32,7 @@ public class SimpleFilter implements Fil
     }
 
     @Override
-    public FilterResult filter(String relativeFilePath) {
+    public FilterResult filter(File contentSyncRoot, String relativeFilePath, RepositoryInfo
repositoryInfo) {
         if (relativeFilePath.isEmpty() || relativeFilePath.charAt(0) != '/') {
             relativeFilePath = '/' + relativeFilePath;
         }

Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java
Thu Sep  5 13:39:57 2013
@@ -98,7 +98,7 @@ public class SimpleXmlSerializationManag
     }
 
     @Override
-    public String buildSerializationData(ResourceProxy resource, RepositoryInfo repositoryInfo)
throws IOException {
+    public String buildSerializationData(File contentSyncRoot, ResourceProxy resource, RepositoryInfo
repositoryInfo) throws IOException {
 
         if (resource == null) {
             return null;

Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/META-INF/MANIFEST.MF?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/META-INF/MANIFEST.MF (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/META-INF/MANIFEST.MF Thu Sep  5 13:39:57
2013
@@ -15,5 +15,6 @@ Import-Package: javax.jcr,
  org.apache.jackrabbit.vault.util,
  org.apache.sling.ide.serialization,
  org.apache.sling.ide.transport,
+ org.apache.sling.ide.filter,
  org.osgi.service.event;version="1.3.0"
 Service-Component: OSGI-INF/*.xml

Added: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/OSGI-INF/VltFilterLocator.xml
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/OSGI-INF/VltFilterLocator.xml?rev=1520303&view=auto
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/OSGI-INF/VltFilterLocator.xml (added)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/OSGI-INF/VltFilterLocator.xml Thu
Sep  5 13:39:57 2013
@@ -0,0 +1,9 @@
+<?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.vlt.filter.VltFilterLocator"/>
+   <reference bind="bindVaultFsLocator" cardinality="1..1" interface="org.apache.sling.ide.impl.vlt.VaultFsLocator"
name="VaultFsLocator" policy="static" unbind="unbindVaultFsLocator"/>
+   <property name="service.ranking" type="Integer" value="100"/>
+   <service>
+      <provide interface="org.apache.sling.ide.filter.FilterLocator"/>
+   </service>   
+</scr:component>

Propchange: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/OSGI-INF/VltFilterLocator.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/OSGI-INF/VltFilterLocator.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VaultFsLocator.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VaultFsLocator.java?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VaultFsLocator.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VaultFsLocator.java
Thu Sep  5 13:39:57 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.sling.ide.impl.vlt;
 
+import java.io.File;
 import java.io.IOException;
 
 import javax.jcr.RepositoryException;
@@ -23,6 +24,7 @@ import javax.jcr.Session;
 
 import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
 import org.apache.jackrabbit.vault.fs.api.VaultFileSystem;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 
 /**
  * The <tt>VaultFsLocator</tt> locates {@linkplain VaultFileSystem} instances
@@ -30,7 +32,9 @@ import org.apache.jackrabbit.vault.fs.ap
  */
 public interface VaultFsLocator {
 
-    VaultFileSystem getFileSystem(RepositoryAddress repositoryAddress, Session session)
-            throws RepositoryException, IOException;
+    VaultFileSystem getFileSystem(RepositoryAddress repositoryAddress, File contentSyncRoot,
Session session)
+            throws RepositoryException, IOException, ConfigurationException;
+
+    File findFilterFile(File contentSyncRoot);
 
 }

Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VaultFsLocatorImpl.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VaultFsLocatorImpl.java?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VaultFsLocatorImpl.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VaultFsLocatorImpl.java
Thu Sep  5 13:39:57 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.sling.ide.impl.vlt;
 
+import java.io.File;
 import java.io.IOException;
 
 import javax.jcr.RepositoryException;
@@ -24,15 +25,61 @@ import javax.jcr.Session;
 import org.apache.jackrabbit.vault.fs.Mounter;
 import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
 import org.apache.jackrabbit.vault.fs.api.VaultFileSystem;
+import org.apache.jackrabbit.vault.fs.api.VaultFsConfig;
+import org.apache.jackrabbit.vault.fs.config.AbstractVaultFsConfig;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
 
 public class VaultFsLocatorImpl implements VaultFsLocator {
 
     @Override
-    public VaultFileSystem getFileSystem(RepositoryAddress repositoryAddress, Session session)
-            throws RepositoryException, IOException {
+    public VaultFileSystem getFileSystem(RepositoryAddress repositoryAddress, File contentSyncRoot,
Session session)
+            throws RepositoryException, IOException, ConfigurationException {
 
-        // TODO - supply filter and config
-        return Mounter.mount(null, null, repositoryAddress, "/", session);
+        // TODO - should not use File to read from FS, rather input streams
+        VaultFsConfig config = null;
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+
+        File filterFile = findFilterFile(contentSyncRoot);
+        if (filterFile != null) {
+            filter.load(filterFile);
+        }
+
+        File metaInfDir = new File(contentSyncRoot.getParent(), "META-INF");
+
+        if (metaInfDir.isDirectory()) {
+            File vaultDir = new File(metaInfDir, "vault");
+            if (vaultDir.isDirectory()) {
+
+                File configFile = new File(vaultDir, "config.xml");
+                config = AbstractVaultFsConfig.load(configFile);
+            }
+        }
+
+        return Mounter.mount(config, filter, repositoryAddress, "/", session);
+    }
+
+    @Override
+    public File findFilterFile(File contentSyncRoot) {
+
+        File metaInfDir = new File(contentSyncRoot.getParent(), "META-INF");
+        if (metaInfDir.isDirectory()) {
+            File vaultDir = new File(metaInfDir, "vault");
+            if (vaultDir.isDirectory()) {
+
+                File filterFile = new File(vaultDir, "filter-vlt.xml");
+                if (filterFile.isFile()) {
+                    return filterFile;
+                } else {
+                    filterFile = new File(vaultDir, "filter.xml");
+                    if (filterFile.isFile()) {
+                        return filterFile;
+                    }
+                }
+            }
+        }
+
+        return null;
     }
 
 }

Added: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilter.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilter.java?rev=1520303&view=auto
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilter.java
(added)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilter.java
Thu Sep  5 13:39:57 2013
@@ -0,0 +1,50 @@
+/*
+ * 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.vlt.filter;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+
+import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.sling.ide.filter.Filter;
+import org.apache.sling.ide.filter.FilterResult;
+import org.apache.sling.ide.transport.RepositoryInfo;
+
+public class VltFilter implements Filter {
+
+    private WorkspaceFilter filter;
+
+    public VltFilter(InputStream in) throws IOException, ConfigurationException {
+
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        filter.load(in);
+
+        this.filter = filter;
+    }
+
+    @Override
+    public FilterResult filter(File contentSyncRoot, String relativeFilePath, RepositoryInfo
repositoryInfo) {
+        // TODO - is this the right check? I _think_ that filter paths are repository-based,
not fs-based
+        // so this could be incorrect
+        return filter.contains(relativeFilePath) ? FilterResult.ALLOW : FilterResult.DENY;
+    }
+
+}

Propchange: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilterLocator.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilterLocator.java?rev=1520303&view=auto
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilterLocator.java
(added)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilterLocator.java
Thu Sep  5 13:39:57 2013
@@ -0,0 +1,57 @@
+/*
+ * 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.vlt.filter;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+import org.apache.sling.ide.filter.Filter;
+import org.apache.sling.ide.filter.FilterLocator;
+import org.apache.sling.ide.impl.vlt.VaultFsLocator;
+
+public class VltFilterLocator implements FilterLocator {
+
+    private VaultFsLocator fsLocator;
+
+    protected void bindVaultFsLocator(VaultFsLocator fsLocator) {
+        this.fsLocator = fsLocator;
+    }
+
+    protected void unbindVaultFsLocator(VaultFsLocator fsLocator) {
+        this.fsLocator = null;
+    }
+
+    @Override
+    public File findFilterLocation(File syncDirectory) {
+
+        return fsLocator.findFilterFile(syncDirectory);
+    }
+
+    @Override
+    public Filter loadFilter(InputStream filterFileContents) throws IOException {
+
+        try {
+            return new VltFilter(filterFileContents);
+        } catch (ConfigurationException e) {
+            // TODO proper error handling
+            throw new IOException(e);
+        }
+    }
+
+}

Propchange: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilterLocator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/filter/VltFilterLocator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java?rev=1520303&r1=1520302&r2=1520303&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java
(original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java
Thu Sep  5 13:39:57 2013
@@ -31,6 +31,7 @@ import org.apache.jackrabbit.vault.fs.ap
 import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
 import org.apache.jackrabbit.vault.fs.api.VaultFile;
 import org.apache.jackrabbit.vault.fs.api.VaultFileSystem;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 import org.apache.jackrabbit.vault.fs.impl.io.DocViewSerializer;
 import org.apache.jackrabbit.vault.util.Constants;
 import org.apache.sling.ide.impl.vlt.RepositoryUtils;
@@ -71,9 +72,11 @@ public class VltSerializationManager imp
     }
 
     @Override
-    public String buildSerializationData(ResourceProxy resource, RepositoryInfo repositoryInfo)
throws IOException {
+    public String buildSerializationData(File contentSyncRoot, ResourceProxy resource, RepositoryInfo
repositoryInfo) throws IOException {
 
         // TODO - there might be a performance problem with getting the session on-demand
each time
+        // the resolution might be to have a SerializationManager instance kept per 'transaction'
+        // which is stateful, with init(RepositoryInfo) and destroy() methods
         Session session = null;
         try {
             
@@ -84,7 +87,7 @@ public class VltSerializationManager imp
 
             RepositoryAddress address = RepositoryUtils.getRepositoryAddress(repositoryInfo);
 
-            VaultFileSystem fs = fsLocator.getFileSystem(address, session);
+            VaultFileSystem fs = fsLocator.getFileSystem(address, contentSyncRoot, session);
 
             VaultFile vaultFile = fs.getFile(resource.getPath());
             if (vaultFile == null) {
@@ -108,6 +111,8 @@ public class VltSerializationManager imp
 
         } catch (RepositoryException e) {
             throw new RuntimeException(e);
+        } catch (ConfigurationException e) {
+            throw new RuntimeException(e);
         } finally {
             if (session != null) {
                 session.logout();



Mime
View raw message