use of org.apache.sling.ide.transport.ResourceProxy in project sling by apache.
the class SlingLaunchpadBehaviour method start.
public void start(IProgressMonitor monitor) throws CoreException {
boolean success = false;
Result<ResourceProxy> result = null;
monitor = SubMonitor.convert(monitor, "Starting server", 10).setWorkRemaining(50);
Repository repository;
RepositoryInfo repositoryInfo;
OsgiClient client;
try {
repository = ServerUtil.connectRepository(getServer(), monitor);
repositoryInfo = ServerUtil.getRepositoryInfo(getServer(), monitor);
client = Activator.getDefault().getOsgiClientFactory().createOsgiClient(repositoryInfo);
} catch (CoreException e) {
setServerState(IServer.STATE_STOPPED);
throw e;
} catch (URISyntaxException e) {
setServerState(IServer.STATE_STOPPED);
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
}
// 10/50 done
monitor.worked(10);
try {
EmbeddedArtifactLocator artifactLocator = Activator.getDefault().getArtifactLocator();
// 15/50 done
installBundle(monitor, client, artifactLocator.loadSourceSupportBundle(), SUPPORT_SOURCE_BUNDLE_SYMBOLIC_NAME);
// 20/50 done
installBundle(monitor, client, artifactLocator.loadToolingSupportBundle(), SUPPORT_BUNDLE_SYMBOLIC_NAME);
} catch (IOException | OsgiClientException e) {
Activator.getDefault().getPluginLogger().warn("Failed reading the installation support bundle", e);
}
try {
if (getServer().getMode().equals(ILaunchManager.DEBUG_MODE)) {
debuggerConnection = new JVMDebuggerConnection(client);
success = debuggerConnection.connectInDebugMode(launch, getServer(), SubMonitor.convert(monitor, 30));
// 50/50 done
} else {
Command<ResourceProxy> command = repository.newListChildrenNodeCommand("/");
result = command.execute();
success = result.isSuccess();
// 50/50 done
monitor.worked(30);
}
if (success) {
setServerState(IServer.STATE_STARTED);
} else {
setServerState(IServer.STATE_STOPPED);
String message = "Unable to connect to the Server. Please make sure a server instance is running ";
if (result != null) {
message += " (" + result.toString() + ")";
}
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, message));
}
} catch (CoreException | RuntimeException e) {
setServerState(IServer.STATE_STOPPED);
throw e;
} finally {
monitor.done();
}
}
use of org.apache.sling.ide.transport.ResourceProxy in project sling by apache.
the class ResourceChangeCommandFactory method buildResourceProxyForPlainFileOrFolder.
private ResourceProxy buildResourceProxyForPlainFileOrFolder(IResource changedResource, IFolder syncDirectory, Repository repository) throws CoreException, IOException {
SerializationKind serializationKind;
String fallbackNodeType;
if (changedResource.getType() == IResource.FILE) {
serializationKind = SerializationKind.FILE;
fallbackNodeType = Repository.NT_FILE;
} else {
// i.e. IResource.FOLDER
serializationKind = SerializationKind.FOLDER;
fallbackNodeType = Repository.NT_FOLDER;
}
String resourceLocation = '/' + changedResource.getFullPath().makeRelativeTo(syncDirectory.getFullPath()).toPortableString();
IPath serializationFilePath = Path.fromOSString(serializationManager.getSerializationFilePath(resourceLocation, serializationKind));
IResource serializationResource = syncDirectory.findMember(serializationFilePath);
if (serializationResource == null && changedResource.getType() == IResource.FOLDER) {
ResourceProxy dataFromCoveringParent = findSerializationDataFromCoveringParent(changedResource, syncDirectory, resourceLocation, serializationFilePath);
if (dataFromCoveringParent != null) {
return dataFromCoveringParent;
}
}
return buildResourceProxy(resourceLocation, serializationResource, syncDirectory, fallbackNodeType, repository);
}
Aggregations