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 2013/07/19 17:02:36 UTC
svn commit: r1504895 - in /sling/whiteboard/asanso/plugins/eclipse:
slingclipse-api/src/org/apache/sling/slingclipse/api/
slingclipse-plugin/META-INF/ slingclipse-wst/META-INF/
slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/
Author: rombert
Date: Fri Jul 19 15:02:35 2013
New Revision: 1504895
URL: http://svn.apache.org/r1504895
Log:
SLING-2793 - [Tooling] Align Eclipse tooling to proposed structure
Implement very limited resource sync from the workspace to the
repository.
Modified:
sling/whiteboard/asanso/plugins/eclipse/slingclipse-api/src/org/apache/sling/slingclipse/api/Repository.java
sling/whiteboard/asanso/plugins/eclipse/slingclipse-plugin/META-INF/MANIFEST.MF
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/META-INF/MANIFEST.MF
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingContentModuleFactory.java
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadBehaviour.java
Modified: sling/whiteboard/asanso/plugins/eclipse/slingclipse-api/src/org/apache/sling/slingclipse/api/Repository.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/slingclipse-api/src/org/apache/sling/slingclipse/api/Repository.java?rev=1504895&r1=1504894&r2=1504895&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/slingclipse-api/src/org/apache/sling/slingclipse/api/Repository.java (original)
+++ sling/whiteboard/asanso/plugins/eclipse/slingclipse-api/src/org/apache/sling/slingclipse/api/Repository.java Fri Jul 19 15:02:35 2013
@@ -78,6 +78,7 @@ public interface Repository {
public static String JCR_CHILD_VERSION_HISTORY= "jcr:childVersionHistory";
//TODO change with properties
+ // FIXME this is not thread-safe and with multiple sling servers will fail intermitently
public void setRepositoryInfo(RepositoryInfo repositoryInfo);
Command<Void> newAddNodeCommand(FileInfo fileInfo);
Modified: sling/whiteboard/asanso/plugins/eclipse/slingclipse-plugin/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/slingclipse-plugin/META-INF/MANIFEST.MF?rev=1504895&r1=1504894&r2=1504895&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/slingclipse-plugin/META-INF/MANIFEST.MF (original)
+++ sling/whiteboard/asanso/plugins/eclipse/slingclipse-plugin/META-INF/MANIFEST.MF Fri Jul 19 15:02:35 2013
@@ -18,3 +18,4 @@ Bundle-RequiredExecutionEnvironment: Jav
Bundle-ClassPath: .
Service-Component: OSGI-INF/component.xml
Import-Package: org.osgi.service.component;version="1.1.0"
+Export-Package: org.apache.sling.slingclipse
Modified: sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/META-INF/MANIFEST.MF?rev=1504895&r1=1504894&r2=1504895&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/META-INF/MANIFEST.MF (original)
+++ sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/META-INF/MANIFEST.MF Fri Jul 19 15:02:35 2013
@@ -5,7 +5,9 @@ Bundle-SymbolicName: org.apache.sling.sl
Bundle-Version: 0.0.1.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: .
-Import-Package: org.eclipse.core.resources,
+Import-Package: org.apache.sling.slingclipse,
+ org.apache.sling.slingclipse.api,
+ org.eclipse.core.resources,
org.eclipse.core.runtime;version="3.4.0",
org.eclipse.core.runtime.jobs,
org.eclipse.debug.core,
Modified: sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingContentModuleFactory.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingContentModuleFactory.java?rev=1504895&r1=1504894&r2=1504895&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingContentModuleFactory.java (original)
+++ sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingContentModuleFactory.java Fri Jul 19 15:02:35 2013
@@ -1,8 +1,13 @@
package org.apache.sling.ide.eclipse.wst.internal;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -12,6 +17,7 @@ import org.eclipse.wst.common.project.fa
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.ModuleDelegate;
+import org.eclipse.wst.server.core.util.ModuleFile;
import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate;
public class SlingContentModuleFactory extends ProjectModuleFactoryDelegate {
@@ -19,11 +25,11 @@ public class SlingContentModuleFactory e
private static final String NATURE_ID = "sling.content";
@Override
- public ModuleDelegate getModuleDelegate(IModule arg0) {
+ public ModuleDelegate getModuleDelegate(IModule module) {
System.out.println("SlingContentModuleFactory.getModuleDelegate()");
- return new SlingContentModuleDelegate();
+ return new SlingContentModuleDelegate(module);
}
@Override
@@ -46,6 +52,13 @@ public class SlingContentModuleFactory e
}
static class SlingContentModuleDelegate extends ModuleDelegate {
+
+ private final IModule module;
+
+ public SlingContentModuleDelegate(IModule module) {
+ this.module = module;
+ }
+
@Override
public IStatus validate() {
return Status.OK_STATUS; // TODO actually validate
@@ -53,7 +66,24 @@ public class SlingContentModuleFactory e
@Override
public IModuleResource[] members() throws CoreException {
- return new IModuleResource[0]; // TODO revisit, do we have members?
+ IProject project = module.getProject();
+ final List<IModuleResource> resources = new ArrayList<IModuleResource>();
+ // TODO just a hack to get some files
+ project.accept(new IResourceVisitor() {
+ @Override
+ public boolean visit(IResource resource) throws CoreException {
+ System.out.println(resource.getName() + " -> " + resource.getFileExtension());
+ if (resource.getType() == IResource.FILE && resource.getFileExtension().equals("txt")) {
+ resources.add(new ModuleFile((IFile) resource, resource.getName(), resource
+ .getProjectRelativePath()));
+ }
+ return true;
+ }
+ });
+
+ System.out.println("SlingContentModuleFactory.SlingContentModuleDelegate.members() returned " + resources);
+
+ return resources.toArray(new IModuleResource[resources.size()]);
}
@Override
Modified: sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadBehaviour.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadBehaviour.java?rev=1504895&r1=1504894&r2=1504895&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadBehaviour.java (original)
+++ sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadBehaviour.java Fri Jul 19 15:02:35 2013
@@ -16,13 +16,27 @@
*/
package org.apache.sling.ide.eclipse.wst.internal;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+
+import org.apache.sling.slingclipse.SlingclipsePlugin;
+import org.apache.sling.slingclipse.api.FileInfo;
+import org.apache.sling.slingclipse.api.Repository;
+import org.apache.sling.slingclipse.api.RepositoryInfo;
+import org.apache.sling.slingclipse.api.Result;
+import org.eclipse.core.resources.IFile;
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.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
public class SlingLaunchpadBehaviour extends ServerBehaviourDelegate {
@@ -56,8 +70,9 @@ public class SlingLaunchpadBehaviour ext
@Override
public boolean canPublishModule(IModule[] module) {
- System.out.println("SlingLaunchpadBehaviour.canPublishModule()");
- return super.canPublishModule(module);
+ boolean result = super.canPublishModule(module);
+ System.out.println("SlingLaunchpadBehaviour.canPublishModule() is " + result);
+ return result;
}
@Override
@@ -66,6 +81,93 @@ public class SlingLaunchpadBehaviour ext
super.publishServer(kind, monitor);
}
+ @Override
+ protected void publishModule(int kind, int deltaKind, IModule[] module, IProgressMonitor monitor)
+ throws CoreException {
+
+ StringBuilder trace = new StringBuilder();
+ trace.append("SlingLaunchpadBehaviour.publishModule(");
+
+ switch (kind) {
+ case IServer.PUBLISH_CLEAN:
+ trace.append("PUBLISH_CLEAN, ");
+ break;
+ case IServer.PUBLISH_INCREMENTAL:
+ trace.append("PUBLISH_INCREMENTAL, ");
+ break;
+ case IServer.PUBLISH_AUTO:
+ trace.append("PUBLISH_AUTO, ");
+ break;
+ case IServer.PUBLISH_FULL:
+ trace.append("PUBLISH_FULL, ");
+ break;
+ default:
+ trace.append("UNKNOWN - ").append(kind).append(", ");
+ }
+
+ switch (deltaKind) {
+ case ServerBehaviourDelegate.ADDED:
+ trace.append("ADDED, ");
+ break;
+ case ServerBehaviourDelegate.CHANGED:
+ trace.append("CHANGED, ");
+ break;
+ case ServerBehaviourDelegate.NO_CHANGE:
+ trace.append("NO_CHANGE, ");
+ break;
+ case ServerBehaviourDelegate.REMOVED:
+ trace.append("REMOVED, ");
+ break;
+ default:
+ trace.append("UNKONWN - ").append(deltaKind).append(", ");
+ break;
+ }
+
+ trace.append(Arrays.toString(module)).append(")");
+
+ System.out.println(trace.toString());
+
+ SlingLaunchpadServer launchpadServer = (SlingLaunchpadServer) getServer().loadAdapter(
+ SlingLaunchpadServer.class, monitor);
+ SlingLaunchpadConfiguration configuration = launchpadServer.getConfiguration();
+
+ IModuleResource[] moduleResources = getResources(module);
+ Repository repository = SlingclipsePlugin.getDefault().getRepository();
+ try {
+ // TODO configurable scheme?
+ URI uri = new URI("http", null, getServer().getHost(), configuration.getPort(),
+ configuration.getContextPath(), null, null);
+ RepositoryInfo repositoryInfo = new RepositoryInfo(configuration.getUsername(),
+ configuration.getPassword(), uri.toString());
+ repository.setRepositoryInfo(repositoryInfo);
+ System.out.println("RepositoryInfo=" + repository);
+ } catch (URISyntaxException e) {
+ // TODO handle error
+ }
+
+ for (IModuleResource resource : moduleResources) {
+
+ IFile file = (IFile) resource.getAdapter(IFile.class);
+
+ IPath projectPath = file.getProject().getFullPath();
+ IPath filePath = file.getFullPath();
+ IPath relativePath = filePath.makeRelativeTo(projectPath);
+ IPath rootPath = relativePath.removeLastSegments(1); // TODO correct name
+
+ FileInfo info = new FileInfo(file.getLocation().toOSString(), rootPath.toOSString(),
+ file.getName());
+
+ System.out.println("For " + resource + " build fileInfo " + info);
+
+ Result<Void> result = repository.newAddNodeCommand(info).execute();
+ if (!result.isSuccess())
+ throw new CoreException(new Status(Status.ERROR, "some.plugin", result.toString()));
+ }
+
+ // set state to published
+ super.publishModule(kind, deltaKind, module, monitor);
+ }
+
/*
* (non-Javadoc)
*
@@ -78,4 +180,5 @@ public class SlingLaunchpadBehaviour ext
System.out.println("SlingLaunchpadBehaviour.setupLaunchConfiguration()");
super.setupLaunchConfiguration(workingCopy, monitor);
}
+
}