// ------------------------------------------------------------------------ // Operation(s) // ------------------------------------------------------------------------ @Override public void run(IProgressMonitor monitor) { try { monitor.worked(1); String root = null; List<TracePackageElement> resultElementList = new ArrayList<>(); SubMonitor subMonitor = SubMonitor.convert(monitor, fProfile.getChildren().length * 2); List<RemoteImportConnectionNodeElement> connectionNodes = fProfile.getConnectionNodeElements(); for (RemoteImportConnectionNodeElement connectionNode : connectionNodes) { RemoteSystemProxy proxy = connectionNode.getRemoteSystemProxy(); // create new element to decouple from input element RemoteImportConnectionNodeElement outputConnectionNode = new RemoteImportConnectionNodeElement( null, connectionNode.getName(), connectionNode.getURI()); resultElementList.add(outputConnectionNode); for (TracePackageElement element : connectionNode.getChildren()) { if (element instanceof RemoteImportTraceGroupElement) { ModalContext.checkCanceled(monitor); RemoteImportTraceGroupElement traceGroup = (RemoteImportTraceGroupElement) element; root = traceGroup.getRootImportPath(); TracePackageElement[] traceElements = traceGroup.getChildren(); fTemplatePatternsToTraceElements = generatePatterns(traceElements); IRemoteFileService fs = proxy.getRemoteConnection().getService(IRemoteFileService.class); if (fs == null) { continue; } final IFileStore remoteFolder = fs.getResource(root); // make sure that remote directory is read and not cached int recursionLevel = 0; // create new element to decouple from input element RemoteImportTraceGroupElement outputTraceGroup = new RemoteImportTraceGroupElement( outputConnectionNode, traceGroup.getRootImportPath()); outputTraceGroup.setRecursive(traceGroup.isRecursive()); generateElementsFromArchive( outputTraceGroup, outputTraceGroup, remoteFolder, recursionLevel, subMonitor.newChild(1)); filterElements(outputTraceGroup); } } } setResultElements(resultElementList.toArray(new TracePackageElement[0])); setStatus(Status.OK_STATUS); } catch (InterruptedException e) { setStatus(Status.CANCEL_STATUS); } catch (Exception e) { setStatus( new Status( IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind( RemoteMessages.RemoteGenerateManifest_GenerateProfileManifestError, fProfile.getText()), e)); } }
public static void remoteFileDownload( ILaunchConfiguration config, ILaunch launch, String localExePath, String remoteExePath, IProgressMonitor monitor) throws CoreException { boolean skipDownload = config.getAttribute( IRemoteConnectionConfigurationConstants.ATTR_SKIP_DOWNLOAD_TO_TARGET, false); if (skipDownload) // Nothing to do. Download is skipped. return; monitor.beginTask(Messages.RemoteRunLaunchDelegate_2, 100); try { IRemoteConnection conn = getCurrentConnection(config); IRemoteFileService fs = conn.getService(IRemoteFileService.class); IFileStore remoteFile = fs.getResource(remoteExePath); IFileSystem localfs = EFS.getLocalFileSystem(); IFileStore localFile = localfs.getStore(new Path(localExePath)); if (!localFile.fetchInfo().exists()) { return; } localFile.copy(remoteFile, EFS.OVERWRITE, monitor); // Need to change the permissions to match the original file // permissions because of a bug in upload Process p = remoteShellExec( config, "", "chmod", "+x " + spaceEscapify(remoteExePath), new SubProgressMonitor(monitor, 5)); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // Wait if necessary for the permission change try { int timeOut = 10; boolean exited = p.waitFor(timeOut, TimeUnit.SECONDS); if (!exited) { Status status = new Status( IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, "Failed to change file permissions in the remote system, path: " + remoteExePath, //$NON-NLS-1$ null); throw new CoreException(status); } } catch (InterruptedException e) { Status status = new Status( IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, "Interrupted while changing file permissions in the remote system, path: " //$NON-NLS-1$ + remoteExePath, e); throw new CoreException(status); } } catch (CoreException e) { abort( Messages.RemoteRunLaunchDelegate_6, e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); } finally { monitor.done(); } }