Author: rombert
Date: Fri Jul 19 15:02:49 2013
New Revision: 1504898
URL: http://svn.apache.org/r1504898
Log:
SLING-2973 - [Tooling] Align Eclipse tooling to proposed structure
- obey the 'jcr_root' convention, for now
- cleanup logging and command execution
Modified:
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
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadServer.java
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=1504898&r1=1504897&r2=1504898&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:49 2013
@@ -18,4 +18,5 @@ 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
+Export-Package: org.apache.sling.slingclipse,
+ org.apache.sling.slingclipse.helper
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=1504898&r1=1504897&r2=1504898&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:49 2013
@@ -7,6 +7,7 @@ Bundle-RequiredExecutionEnvironment: Jav
Bundle-ClassPath: .
Import-Package: org.apache.sling.slingclipse,
org.apache.sling.slingclipse.api,
+ org.apache.sling.slingclipse.helper,
org.eclipse.core.resources,
org.eclipse.core.runtime;version="3.4.0",
org.eclipse.core.runtime.jobs,
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=1504898&r1=1504897&r2=1504898&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:49 2013
@@ -1,14 +1,16 @@
package org.apache.sling.ide.eclipse.wst.internal;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
+import org.apache.sling.slingclipse.helper.SlingclipseHelper;
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.IResourceVisitor;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
@@ -18,6 +20,7 @@ import org.eclipse.wst.server.core.IModu
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.ModuleFolder;
import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate;
public class SlingContentModuleFactory extends ProjectModuleFactoryDelegate {
@@ -68,21 +71,34 @@ public class SlingContentModuleFactory e
public IModuleResource[] members() throws CoreException {
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()));
+
+ if (resource.getType() == IResource.PROJECT) {
+ return true;
+ }
+
+ IPath relativePath = resource.getProjectRelativePath();
+
+ // only recurse in the expected content path
+ // TODO make configurable
+ if
(!SlingclipseHelper.JCR_ROOT.equals(relativePath.segment(0))) {
+ return false;
+ }
+
+ IPath modulePath = relativePath.removeFirstSegments(1); //
remove jcr_root
+
+ if (resource.getType() == IResource.FILE) {
+
+ ModuleFile moduleFile = new ModuleFile((IFile)
resource, resource.getName(), modulePath);
+ resources.add(moduleFile);
+ System.out.println("Converted " + resource + " to " +
moduleFile);
}
return true;
}
});
-
System.out.println("SlingContentModuleFactory.SlingContentModuleDelegate.members()
returned " + resources);
-
return resources.toArray(new IModuleResource[resources.size()]);
}
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=1504898&r1=1504897&r2=1504898&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:49 2013
@@ -16,6 +16,7 @@
*/
package org.apache.sling.ide.eclipse.wst.internal;
+import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
@@ -30,15 +31,11 @@ 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.IModuleFile;
-import org.eclipse.wst.server.core.model.IModuleFolder;
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
@@ -66,26 +63,6 @@ public class SlingLaunchpadBehaviour ext
}
@Override
- public IStatus canPublish() {
- IStatus canPublish = super.canPublish();
- System.out.println("SlingLaunchpadBehaviour.canPublish() is " +
canPublish);
- return canPublish;
- }
-
- @Override
- public boolean canPublishModule(IModule[] module) {
- boolean result = super.canPublishModule(module);
- System.out.println("SlingLaunchpadBehaviour.canPublishModule() is " +
result);
- return result;
- }
-
- @Override
- protected void publishServer(int kind, IProgressMonitor monitor) throws
CoreException {
- System.out.println("SlingLaunchpadBehaviour.publishServer()");
- super.publishServer(kind, monitor);
- }
-
- @Override
protected void publishModule(int kind, int deltaKind, IModule[] module,
IProgressMonitor monitor)
throws CoreException {
@@ -145,7 +122,6 @@ public class SlingLaunchpadBehaviour ext
RepositoryInfo repositoryInfo = new
RepositoryInfo(configuration.getUsername(),
configuration.getPassword(), uri.toString());
repository.setRepositoryInfo(repositoryInfo);
- System.out.println("RepositoryInfo=" + repository);
} catch (URISyntaxException e) {
// TODO handle error
}
@@ -154,22 +130,41 @@ public class SlingLaunchpadBehaviour ext
case ServerBehaviourDelegate.CHANGED:
IModuleResourceDelta[] publishedResourceDelta =
getPublishedResourceDelta(module);
for (IModuleResourceDelta resourceDelta :
publishedResourceDelta) {
+
+ StringBuilder deltaTrace = new StringBuilder();
+ deltaTrace.append("- processing delta kind ");
+
+ switch (resourceDelta.getKind()) {
+ case IModuleResourceDelta.ADDED:
+ deltaTrace.append("ADDED ");
+ break;
+ case IModuleResourceDelta.CHANGED:
+ deltaTrace.append("CHANGED ");
+ break;
+ case IModuleResourceDelta.NO_CHANGE:
+ deltaTrace.append("NO_CHANGE ");
+ break;
+ case IModuleResourceDelta.REMOVED:
+ deltaTrace.append("REMOVED ");
+ break;
+ default:
+ deltaTrace.append("UNKNOWN -
").append(resourceDelta.getKind());
+ }
+
+ deltaTrace.append("for resource
").append(resourceDelta.getModuleResource());
+
+ System.out.println(deltaTrace);
+
if (resourceDelta.getModuleResource() instanceof
IModuleFile) {
+
switch (resourceDelta.getKind()) {
case IModuleResourceDelta.ADDED:
case IModuleResourceDelta.CHANGED:
case IModuleResourceDelta.NO_CHANGE: // TODO is
this needed?
- Result<?> result = addFileCommand(repository,
- (IModuleFile)
resourceDelta.getModuleResource()).execute();
- if (!result.isSuccess()) // TODO proper logging
- throw new CoreException(new
Status(Status.ERROR, "some.plugin", result.toString()));
+ execute(addFileCommand(repository,
(IModuleFile) resourceDelta.getModuleResource()));
break;
case IModuleResourceDelta.REMOVED:
- Result<?> deleteResult =
removeFileCommand(repository,
- (IModuleFile)
resourceDelta.getModuleResource()).execute();
- if (!deleteResult.isSuccess()) // TODO proper
logging
- throw new CoreException(new
Status(Status.ERROR, "some.plugin",
- deleteResult.toString()));
+ execute(removeFileCommand(repository,
(IModuleFile) resourceDelta.getModuleResource()));
break;
}
}
@@ -181,9 +176,7 @@ public class SlingLaunchpadBehaviour ext
for (IModuleResource resource : moduleResources) {
if (resource instanceof IModuleFile) {
- Result<?> result = addFileCommand(repository,
(IModuleFile) resource).execute();
- if (!result.isSuccess()) // TODO proper logging
- throw new CoreException(new Status(Status.ERROR,
"some.plugin", result.toString()));
+ execute(addFileCommand(repository, (IModuleFile)
resource));
} else {
// TODO log/barf
}
@@ -193,9 +186,7 @@ public class SlingLaunchpadBehaviour ext
for (IModuleResource resource : moduleResources) {
if (resource instanceof IModuleFile) {
- Result<?> result = removeFileCommand(repository,
(IModuleFile) resource).execute();
- if (!result.isSuccess()) // TODO proper logging
- throw new CoreException(new Status(Status.ERROR,
"some.plugin", result.toString()));
+ execute(removeFileCommand(repository, (IModuleFile)
resource));
} else {
// TODO log/barf
}
@@ -208,47 +199,59 @@ public class SlingLaunchpadBehaviour ext
super.publishModule(kind, deltaKind, module, monitor);
}
- private Command<?> addFileCommand(Repository repository, IModuleFile
resource) {
- IFile file = (IFile) resource.getAdapter(IFile.class);
+ private void execute(Command<?> command) throws CoreException {
+ if (command == null) {
+ return;
+ }
+ Result<?> result = command.execute();
+
+ System.out.println("COMMAND : " + command + " -> " + result);
- IPath projectPath = file.getProject().getFullPath();
- IPath filePath = file.getFullPath();
- IPath relativePath = filePath.makeRelativeTo(projectPath);
- IPath rootPath = relativePath.removeLastSegments(1); // TODO correct
name
+ if (!result.isSuccess()) // TODO proper logging
+ throw new CoreException(new Status(Status.ERROR, "some.plugin",
result.toString()));
+ }
+
+ private Command<?> addFileCommand(Repository repository, IModuleFile
resource) {
- FileInfo info = new FileInfo(file.getLocation().toOSString(),
rootPath.toOSString(), file.getName());
+ FileInfo info = createFileInfo(resource);
System.out.println("For " + resource + " build fileInfo " + info);
+ if (info == null) {
+ return null;
+ }
return repository.newAddNodeCommand(info);
}
- private Command<?> removeFileCommand(Repository repository, IModuleFile
resource) {
+ private FileInfo createFileInfo(IModuleFile resource) {
+
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
+ if (file == null) {
+ // Usually happens on server startup, it seems to be safe to
ignore for now
+ System.out.println("Got null '" + IFile.class.getSimpleName() + "'
for " + resource);
+ return null;
+ }
- FileInfo info = new FileInfo(file.getLocation().toOSString(),
rootPath.toOSString(), file.getName());
+ IPath rootPath =
resource.getModuleRelativePath().removeLastSegments(1); // TODO correct name
- System.out.println("For " + resource + " build fileInfo " + info);
+ String relativePath = rootPath.toOSString();
- return repository.newDeleteNodeCommand(info);
- }
+ FileInfo info = new FileInfo(file.getLocation().toOSString(),
relativePath, file.getName());
- /*
- * (non-Javadoc)
- *
- * @see
org.eclipse.wst.server.core.model.ServerBehaviourDelegate#setupLaunchConfiguration(org.eclipse.debug.core.
- * ILaunchConfigurationWorkingCopy,
org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy
workingCopy, IProgressMonitor monitor)
- throws CoreException {
-
System.out.println("SlingLaunchpadBehaviour.setupLaunchConfiguration()");
- super.setupLaunchConfiguration(workingCopy, monitor);
+ System.out.println("For " + resource + " built fileInfo " + info);
+
+ return info;
}
+ private Command<?> removeFileCommand(Repository repository, IModuleFile
resource) {
+
+ FileInfo info = createFileInfo(resource);
+
+ if (info == null) {
+ return null;
+ }
+
+ return repository.newDeleteNodeCommand(info);
+ }
}
Modified:
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadServer.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadServer.java?rev=1504898&r1=1504897&r2=1504898&view=diff
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadServer.java
(original)
+++
sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadServer.java
Fri Jul 19 15:02:49 2013
@@ -22,7 +22,6 @@ import org.eclipse.core.runtime.IProgres
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.server.core.FacetUtil;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.model.ServerDelegate;
@@ -74,9 +73,6 @@ public class SlingLaunchpadServer extend
@Override
public IModule[] getChildModules(IModule[] module) {
-
- System.out.println("SlingLaunchpadServer.getChildModules()");
-
if (module == null) {
return null;
}
@@ -93,8 +89,6 @@ public class SlingLaunchpadServer extend
@Override
public IModule[] getRootModules(IModule arg0) throws CoreException {
- System.out.println("SlingLaunchpadServer.getRootModules()");
-
if (MODULE_TYPE_SLING_CONTENT.equals(arg0.getModuleType().getId())) {
return new IModule[] { arg0 };
}