diff options
Diffstat (limited to 'rse/plugins/org.eclipse.rse.services/src/org/eclipse')
65 files changed, 0 insertions, 6960 deletions
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/Activator.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/Activator.java deleted file mode 100644 index dc90a277a..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/Activator.java +++ /dev/null @@ -1,206 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Moved from org.eclipse.rse.services - * David McKnight (IBM) - [209704] [api] Ability to override default encoding conversion needed. - *******************************************************************************/ - -package org.eclipse.rse.internal.services; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; - -import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager; -import org.eclipse.rse.services.files.CodePageConverterManager; -import org.eclipse.rse.services.files.IFileServiceCodePageConverter; - -/** - * The main plugin class to be used in the desktop. - */ -public class Activator extends Plugin { - - //The shared instance. - private static Activator plugin; - public static final String PLUGIN_ID="org.eclipse.rse.services"; //$NON-NLS-1$ - - /** - * The constructor. - */ - public Activator() { - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - registerArchiveHandlers(); - registerCodePageConverters(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - plugin = null; - } - - /** - * Returns the shared instance. - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Initializes the Archive Handler Manager, by registering archive \ - * file types with their handlers. - * @author mjberger - */ - protected void registerArchiveHandlers() - { - // Get reference to the plug-in registry - IExtensionRegistry registry = Platform.getExtensionRegistry(); - - // Get configured extenders - IConfigurationElement[] systemTypeExtensions = registry.getConfigurationElementsFor("org.eclipse.rse.services", "archivehandlers"); //$NON-NLS-1$ //$NON-NLS-2$ - - for (int i = 0; i < systemTypeExtensions.length; i++) { - String ext = systemTypeExtensions[i].getAttribute("fileNameExtension"); //$NON-NLS-1$ - if (ext.startsWith(".")) ext = ext.substring(1); //$NON-NLS-1$ - String handlerType = systemTypeExtensions[i].getAttribute("class"); //$NON-NLS-1$ - try - { - // get the name space of the declaring extension - String nameSpace = systemTypeExtensions[i].getDeclaringExtension().getNamespaceIdentifier(); - - // use the name space to get the bundle - Bundle bundle = Platform.getBundle(nameSpace); - - // if the bundle has not been uninstalled, then load the handler referred to in the - // extension, and load it using the bundle - // then register the handler - if (bundle.getState() != Bundle.UNINSTALLED) { - Class handler = bundle.loadClass(handlerType); - ArchiveHandlerManager.getInstance().setRegisteredHandler(ext, handler); - } - } - catch (ClassNotFoundException e) - { - logException(e); - } - } - } - - - - - private void registerCodePageConverters() - { - // retrieve all extension points - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint ep = registry.getExtensionPoint("org.eclipse.rse.services", "codePageConverters"); //$NON-NLS-1$ //$NON-NLS-2$ - if (ep != null){ - IExtension[] extensions = ep.getExtensions(); - - for (int i = 0; i < extensions.length; i++) { - IExtension extension = extensions[i]; - IConfigurationElement[] configElements = extension.getConfigurationElements(); - for (int j = 0; j < configElements.length; j++) { - IConfigurationElement element = configElements[j]; - if (element.getName().equalsIgnoreCase("codePageConverter")) { //$NON-NLS-1$ - try { - Object codePageConverter = element.createExecutableExtension("class"); //$NON-NLS-1$ - if (codePageConverter!=null && codePageConverter instanceof IFileServiceCodePageConverter){ - // only save extension point which implement the correct interface - CodePageConverterManager.registerCodePageConverter((IFileServiceCodePageConverter)codePageConverter); - } - } - catch (CoreException e) { - //shouldn't get here.... - e.printStackTrace(); - } - } - } - } - } - } - - - /** - * Logs an throwable to the log for this plugin. - * @param t the Throwable to be logged. - */ - public void logException(Throwable t) { - ILog log = getLog(); - String id = getBundle().getSymbolicName(); - IStatus status = new Status(IStatus.ERROR, id, 0, "Unexpected exception", t); //$NON-NLS-1$ - log.log(status); - } - - //<tracing code>---------------------------------------------------- - - private static Boolean fTracingOn = null; - public static boolean isTracingOn() { - if (fTracingOn==null) { - String id = plugin.getBundle().getSymbolicName(); - String val = Platform.getDebugOption(id + "/debug"); //$NON-NLS-1$ - if ("true".equals(val)) { //$NON-NLS-1$ - fTracingOn = Boolean.TRUE; - } else { - fTracingOn = Boolean.FALSE; - } - } - return fTracingOn.booleanValue(); - } - public static String getTimestamp() { - try { - DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); //$NON-NLS-1$ - return formatter.format(new Date()); - } catch (Exception e) { - // If there were problems writing out the date, ignore and - // continue since that shouldn't stop us from logging the rest - // of the information - } - return Long.toString(System.currentTimeMillis()); - } - public static void trace(String msg) { - if (isTracingOn()) { - String fullMsg = getTimestamp() + " | " + Thread.currentThread().getName() + " | " + msg; //$NON-NLS-1$ //$NON-NLS-2$ - System.out.println(fullMsg); - System.out.flush(); - } - } - - //</tracing code>--------------------------------------------------- -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/RSEServicesMessages.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/RSEServicesMessages.java deleted file mode 100644 index 837f2561b..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/RSEServicesMessages.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - *******************************************************************************/ -package org.eclipse.rse.internal.services; - -import org.eclipse.osgi.util.NLS; - -public class RSEServicesMessages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.rse.internal.services.messages"; //$NON-NLS-1$ - - private RSEServicesMessages() { - } - - public static String Socket_timeout; - public static String FILEMSG_OPERATION_FAILED; - public static String FILEMSG_OPERATION_FAILED_DETAILS; - - public static String FILEMSG_SECURITY_VIOLATION; - public static String FILEMSG_SECURITY_VIOLATION_DETAILS; - - public static String FILEMSG_FOLDER_NOT_EMPTY; - public static String FILEMSG_FOLDER_NOT_EMPTY_DETAILS; - - - static { - NLS.initializeMessages(BUNDLE_NAME, RSEServicesMessages.class); - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/messages.properties b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/messages.properties deleted file mode 100644 index 8460db2ff..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/messages.properties +++ /dev/null @@ -1,31 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2008 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -# Martin Oberhuber (Wind River) - copy Socket_timeout from team.cvs.core -# David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared -############################################################################### - -# NLS_MESSAGEFORMAT_VAR -# NLS_ENCODING=UTF-8 - -#From org.eclipse.team.internal.ccvs.core/messages.properties -Socket_timeout=A timeout occurred connecting to host {0} - - -FILEMSG_OPERATION_FAILED=Operation failed. File system input or output error -FILEMSG_OPERATION_FAILED_DETAILS=Message reported from file system: {0} - -FILEMSG_SECURITY_VIOLATION=Operation failed. Security violation -FILEMSG_SECURITY_VIOLATION_DETAILS=Message reported from file system: {0} - - -FILEMSG_FOLDER_NOT_EMPTY = Folder is not empty. Cannot delete -FILEMSG_FOLDER_NOT_EMPTY_DETAILS = The operation failed. One possible reason is that the folder is not empty - - diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/CommandPattern.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/CommandPattern.java deleted file mode 100644 index 5bb4c8705..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/CommandPattern.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2001, 2007 IBM Corporation and International Business Machines Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Moved from org.eclipse.rse.services.shells - ********************************************************************************/ - -package org.eclipse.rse.internal.services.shells; - -import java.util.ArrayList; -import java.util.regex.Pattern; - -import org.eclipse.rse.services.shells.ParsedOutput; - -public class CommandPattern -{ - - - private Pattern _pattern; - private ArrayList _outputPatterns; - - public CommandPattern(Pattern theCommandPattern) - { - _pattern = theCommandPattern; - _outputPatterns = new ArrayList(); - } - - public void addOutputPattern(OutputPattern op) - { - _outputPatterns.add(op); - } - - public boolean matchCommand(String theLine) - { - return _pattern.matcher(theLine).matches(); - } - - public ParsedOutput matchLine(String theLine) - { - int patterns = _outputPatterns.size(); - ParsedOutput matchedOutput; - OutputPattern curPattern; - for (int i = 0; i < patterns; i++) - { - curPattern = (OutputPattern) _outputPatterns.get(i); - matchedOutput = curPattern.matchLine(theLine); - if (matchedOutput != null) - return matchedOutput; - } - return null; - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/OutputPattern.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/OutputPattern.java deleted file mode 100644 index b07c0727a..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/OutputPattern.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2001, 2007 IBM Corporation and International Business Machines Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - Moved from org.eclipse.rse.services.shells - ********************************************************************************/ - -package org.eclipse.rse.internal.services.shells; - -import java.util.ArrayList; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.rse.services.shells.ParsedOutput; - -public class OutputPattern -{ - - - private Pattern _pattern; - private String _objType; - private ArrayList _matchOrder; - - public OutputPattern(String objType, String matchOrder, Pattern thePattern) - { - _objType = objType; - _pattern = thePattern; - - _matchOrder = new ArrayList(); - //Here we add a dummy first element to the ArrayList, to mimick how the PatternMatcher stores it's - //matches (starting with group 1). - _matchOrder.add(null); - - int index = 0; - int nextSpace = 0; - //Walk the matchOrder string parsing out words and adding them to _matchOrder...Could use StringTokenizer - //but this seem much simpler. - while ((nextSpace = matchOrder.indexOf(" ", index)) > 0) //$NON-NLS-1$ - { - _matchOrder.add(matchOrder.substring(index, nextSpace).toLowerCase()); - index = nextSpace; - while ((index < matchOrder.length()) && (matchOrder.charAt(index) == ' ')) - index++; - } - _matchOrder.add(matchOrder.substring(index, matchOrder.length()).toLowerCase()); - - } - - public ParsedOutput matchLine(String theLine) - { - Matcher matcher = null; - try - { - matcher = _pattern.matcher(theLine); - if (!matcher.matches()) - return null; - } - catch (StringIndexOutOfBoundsException e) - { - //Getting an exception here, when theLine is an empty line for some patterns..should probably investigate, - //but for now we'll just handle it... - return null; - } - - String fileString = ""; //$NON-NLS-1$ - String lineString = ""; //$NON-NLS-1$ - //Groups start at 1 (group 0 is the entire match). - for (int i = 1; i < _matchOrder.size(); i++) - { - String mStr = (String)_matchOrder.get(i); - if (mStr.equals("file")) //$NON-NLS-1$ - fileString = matcher.group(i); - else if (mStr.equals("line")) //$NON-NLS-1$ - lineString = matcher.group(i); - } - int line = 1; - if (lineString.length() > 0) - { - try - { - line = Integer.parseInt(lineString); - } - catch (NumberFormatException e) - { - } - } - - return new ParsedOutput(_objType, theLine, fileString, line, 1); - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/AbstractTerminalService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/AbstractTerminalService.java deleted file mode 100644 index 3bf580c66..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/AbstractTerminalService.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - *******************************************************************************/ - -package org.eclipse.rse.internal.services.terminals; - -import org.eclipse.rse.services.AbstractService; - -/** - * Abstract base class for clients to create an ITerminalService. - * - * Currently the main value of this class is to protect extenders from API - * breakage as the ITerminalService is evolved in the future. We might, for - * instance, be adding state of the terminal service or capabilities for getting - * environment variables. - * - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as - * part of a work in progress. There is no guarantee that this API will work or - * that it will remain the same. Please do not use this API without consulting - * with the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> - * team. - * </p> - * - * @see ITerminalService - * @since org.eclipse.rse.services 3.0 - */ -public abstract class AbstractTerminalService extends AbstractService implements ITerminalService { - - // empty for now, extenders need to implement the launchTerminal() method - // themselves - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/AbstractTerminalShell.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/AbstractTerminalShell.java deleted file mode 100644 index a6b7d4c73..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/AbstractTerminalShell.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - *******************************************************************************/ - -package org.eclipse.rse.internal.services.terminals; - -import java.io.InputStream; - -import org.eclipse.core.runtime.PlatformObject; - -/** - * Abstract base class for clients to create an ITerminalShell instance. - * - * This abstract base class provides valid default implementations for all - * {@link ITerminalShell} methods where possible. Clients should extend this - * base class rather than implementing ITerminalShell directly, in order to - * remain compatible when the ITerminalShell interface is evolved in the future. - * - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as - * part of a work in progress. There is no guarantee that this API will work or - * that it will remain the same. Please do not use this API without consulting - * with the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> - * team. - * </p> - * - * @since org.eclipse.rse.services 3.0 - */ -public abstract class AbstractTerminalShell extends PlatformObject implements ITerminalShell { - - public String getDefaultEncoding() { - return null; - } - - public String getPtyType() { - return null; - } - - public boolean isLocalEcho() { - return false; - } - - public void setTerminalSize(int newWidth, int newHeight) { - // do nothing - } - - public InputStream getErrorStream() { - return null; - } - - public int exitValue() { - // exit values are not supported by default, but we need to observe the - // API by throwing IllegalThreadStateException - if (isActive()) { - throw new IllegalThreadStateException(); - } - return 0; - } - - /** - * Return the interval (in milliseconds) for polling the {@ink #isActive()} - * method during the {@link #waitFor(long)} method. Subclasses may override - * to return different poll intervals. - * - * The interval may be changed dynamically as appropriate for the current - * state of this shell. That way, wait polling mechanisms such as - * exponential backoff can be implemented. - * - * Or, a concrete implementation that supports a notification mechanism for - * knowing when the shell terminates, can use this to tweak the waitFor() - * method by returning Long.MAX_VALUE here (wait forever), but calling - * {@link #notifyAll()} when the shell is dead. - * - * @return interval (in milliseconds) for polling active state - */ - protected long getWaitForPollInterval() { - return 500L; - } - - /** - * Wait for the shell to terminate. This uses a polling mechanism by - * default, which can be tweaked by overriding - * {@link #getWaitForPollInterval()}. - * - * @see IBaseShell#waitFor(long) - */ - public boolean waitFor(long timeout) throws InterruptedException { - boolean active = isActive(); - if (active) { - long endTime = (timeout <= 0) ? Long.MAX_VALUE : System.currentTimeMillis() + timeout - getWaitForPollInterval(); - do { - synchronized (this) { - wait(getWaitForPollInterval()); - } - active = isActive(); - } while (active && (timeout <= 0 || System.currentTimeMillis() < endTime)); - } - return active; - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/BaseShellDecorator.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/BaseShellDecorator.java deleted file mode 100644 index 3d898d202..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/BaseShellDecorator.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - *******************************************************************************/ - -package org.eclipse.rse.internal.services.terminals; - -import java.io.InputStream; -import java.io.OutputStream; - -import org.eclipse.core.runtime.PlatformObject; - -/** - * Abstract base class for clients to decorate an IBaseShell instance they have - * with additional functionality. - * - * Typically, such additional functionality can be provided either by additional - * knowledge about the underlying system or process, or by analyzing the input - * and output streams for some well-known data that gives such additional - * knowledge. - * - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as - * part of a work in progress. There is no guarantee that this API will work or - * that it will remain the same. Please do not use this API without consulting - * with the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> - * team. - * </p> - * - * @since org.eclipse.rse.services 3.0 - */ -public abstract class BaseShellDecorator extends PlatformObject implements IBaseShell { - - protected final IBaseShell fDelegate; - - public BaseShellDecorator(IBaseShell delegate) { - fDelegate = delegate; - } - - public void exit() { - fDelegate.exit(); - } - - public int exitValue() { - return fDelegate.exitValue(); - } - - public InputStream getErrorStream() { - return fDelegate.getErrorStream(); - } - - public InputStream getInputStream() { - return fDelegate.getInputStream(); - } - - public OutputStream getOutputStream() { - return fDelegate.getOutputStream(); - } - - public boolean isActive() { - return fDelegate.isActive(); - } - - public boolean waitFor(long timeout) throws InterruptedException { - return fDelegate.waitFor(timeout); - } - - public Object getAdapter(Class adapterType) { - // TODO do we want to delegate here or have our own adapter??? - // I think we're most flexible first letting adapt to ourselves, - // and only if not successful then ask the delegate to adapt. - Object adapter = super.getAdapter(adapterType); - if (adapter == null) { - adapter = fDelegate.getAdapter(adapterType); - } - return adapter; - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/IBaseShell.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/IBaseShell.java deleted file mode 100644 index de65abb1b..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/IBaseShell.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - *******************************************************************************/ - -package org.eclipse.rse.internal.services.terminals; - -import java.io.InputStream; -import java.io.OutputStream; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.PlatformObject; - -/** - * A basic shell, representing the connection to some process that may be - * running local or remote. Clients may implement this interface. - * - * Clients implementing this interface are encouraged to extend - * {@link PlatformObject} for providing the {@link #getAdapter(Class)} - * functionality. - * - * A simple implementation of IBaseShell is the {@link ProcessBaseShell}, which - * wraps a Java {@link java.lang.Process} object in the IBaseShell interface to - * provide more convenient access to it through the {{@link #isActive()} and {{@link #waitFor(long)} - * methods, as well as making it adaptable. - * - * The resulting IBaseShell can be decorated by clients with additional - * functionality easily by instantiating their subclassed variant of - * {@link BaseShellDecorator}. - * - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as - * part of a work in progress. There is no guarantee that this API will work or - * that it will remain the same. Please do not use this API without consulting - * with the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> - * team. - * </p> - * - * @see java.lang.Process - * @see ProcessBaseShell - * @see BaseShellDecorator - * @since org.eclipse.rse.services 3.0 - */ -public interface IBaseShell extends IAdaptable { - - /** - * Get a local-to-remote OutputStream connected to the standard input of the - * underlying Process. - * - * Clients must not close the obtained OutputStream themselves, since the - * behavior that this may have on the underlying shell or process is - * undefined. Use {#exit()} instead to terminate the shell if that is - * desired, it will close all relevant Streams. - * - * @return an OutputStream for talking to the underlying process. - */ - public OutputStream getOutputStream(); - - /** - * Get a remote-to-local InputStream connected to the standard output of the - * underlying Process. - * - * Clients must not close the obtained InputStream themselves, since the - * behavior that this may have on the underlying shell or process is - * undefined. Use {#exit()} instead to terminate the shell if that is - * desired, it will close all relevant Streams. - * - * @return an InputStream for reading from the underlying process. - */ - public InputStream getInputStream(); - - /** - * Get a remote-to-local InputStream connected to the standard error output - * of the underlying Process. - * - * Implementations may return <code>null</code> if they do not support - * separate Streams for output and error. - * - * Clients must not close the obtained InputStream themselves, since the - * behavior that this may have on the underlying shell or process is - * undefined. Use {#exit()} instead to terminate the shell if that is - * desired, it will close all relevant Streams. - * - * @return an InputStream for reading error output from the underlying - * process, or <code>null</code> if separate output and error - * streams are not supported. Error output will be merged with the - * Stream obtained from {@link #getInputStream()} in that case. - */ - public InputStream getErrorStream(); - - /** - * Test whether this connection is active. - * - * @return <code>true</code> if the connection is active, i.e. the Process - * underlying this connection is running, and the Streams connected - * to it are not closed. - * @see #exitValue() - */ - public boolean isActive(); - - /** - * Exit this shell. - * - * Implementations are encouraged to try terminating the underlying process - * in a clean way, if they can. Depending on the implementation, this may be - * possible or not. What's guaranteed to happen is that the Streams - * connected with the process are closed so the shell will not be active any - * more. - * - * Execution of this method may run asynchronously in the sense that the - * method performs everything to initiate terminating the shell but then - * returns immediately. Clients may use {@link #waitFor(long)} after calling - * this method to know when the shell is really terminated. At any rate, the - * exit() method returns quickly and guarantees that the shell will be - * terminated as soon as possible, after any required (and possible) cleanup - * is finished. - * - * @see java.lang.Process#destroy() - */ - public void exit(); - - /** - * Return the exit value of the Process connected by this shell. - * - * Depending on the underlying implementation, this call may not be - * supported. Implementations which do not support this must throw an - * IllegalThreadStateException when the shell is still active, or return 0 - * the shell has terminated. - * - * @return the exit value of the Process connected by this shell, provided - * that it has already terminated. By convention, the exit value 0 - * indicates successful completion or the fact that transmission of - * exit values is not supported by an implementation. - * @exception IllegalThreadStateException when the shell is still active. - * @see java.lang.Process#exitValue() - */ - public int exitValue(); - - /** - * Block the calling Thread until this shell is no longer active, or the - * specified timeout has elapsed. If the underlying shell has already - * terminated, this method returns immediately. - * - * When this method returns <code>false</code>, the shell is no longer - * active, so an {@link #exitValue()} may be obtained. - * - * @param timeout the maximum time (in milliseconds) to wait. - * Implementations may return sooner even if the underlying - * Process has not yet terminated, so clients always need to keep - * track of time themselves and need to check the return value. A - * timeout value of zero causes this method to not limit the wait - * time. Negative wait time has undefined behavior. - * @return <code>true</code> if the Shell is still active after waiting - * (e.g. because the timeout has elapsed); <code>false</code> if - * the shell is no longer active. - * @throws InterruptedException if the waiting Thread has been interrupted, - * e.g. because the main application is shutting down. - * @see #isActive() - */ - public boolean waitFor(long timeout) throws InterruptedException; -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/ITerminalService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/ITerminalService.java deleted file mode 100644 index 345f36d69..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/ITerminalService.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - *******************************************************************************/ - -package org.eclipse.rse.internal.services.terminals; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.rse.services.IService; -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; - -/** - * Interface for getting Terminal Connections from a remote side, also known as - * terminal session with Streams. - * - * One ITerminalService instance is typically associated with one particular - * connection to a (potentially remote) system, such that the ITerminalService - * instance can also hold state data about that session, such as connected - * state, login and authentication information, configuration data or - * environment variables. - * - * Each - * {@link #launchTerminal(String, String, String[], String, String, IProgressMonitor)} - * invocation, however, acts as a factory method such that it creates a new - * (remote) process and associated {@link ITerminalShell} connection. - * - * @noimplement This interface is not intended to be implemented by clients. - * Clients must subclass the {@link AbstractTerminalService} class - * rather than implementing this interface directly. - * - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as - * part of a work in progress. There is no guarantee that this API will work or - * that it will remain the same. Please do not use this API without consulting - * with the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> - * team. - * </p> - * - * @since org.eclipse.rse.services 3.0 - * - */ -public interface ITerminalService extends IService { - - /** - * Launch a new terminal connection, also known as shell session with - * Streams. - * - * @param ptyType requested terminal type for the new Terminal. Since not - * all Terminal implementations support specifying the Terminal - * Type, there is no guarantee that a particular setting has any - * effect. Use <code>null</code> to fall back to a default - * terminal type. - * @param encoding Stream encoding to use for sending initial working - * directory and initial commandToRun, and to return on - * {@link ITerminalShell#getDefaultEncoding()} request. Use - * <code>null</code> to fall back to a default encoding. The - * Terminal Service will make efforts to determine a proper - * default encoding on the remote side but this is not guaranteed - * to be correct. - * @param environment Array of environment variable Strings of the form - * "var=text". Since not all terminal implementations support the - * passing of environment variables, there is no guarantee that - * the created shell will actually have the specified environment - * set. Passing <code>null</code> is allowed in order to - * specify that no specific environment needs to be passed. - * @param initialWorkingDirectory initial working directory or empty String - * ("") if not relevant. The remote shell will launch in a - * directory of its own choice in that case (typically a user's - * home directory). - * @param commandToRun initial command to send to the remote side. - * @param monitor Progress Monitor for monitoring and cancellation during - * connection creation. - * @return the terminal connection object. Note that the connection may not - * actually be usable in case the remote side allows opening a - * channel but immediately closes it again. In this case, - * {@link ITerminalShell#getInputStream()} will throw an - * exception or be closed from the very beginning. - * @throws SystemMessageException in case an error occurred or the user - * chose to cancel the operation via the progress monitor. - */ - public ITerminalShell launchTerminal(String ptyType, String encoding, String[] environment, String initialWorkingDirectory, String commandToRun, - IProgressMonitor monitor) throws SystemMessageException; - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/ITerminalShell.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/ITerminalShell.java deleted file mode 100644 index 25eb8ae8e..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/ITerminalShell.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - *******************************************************************************/ - -package org.eclipse.rse.internal.services.terminals; - -import org.eclipse.rse.services.shells.IHostShell; - -/** - * Interface representing a terminal connection through Streams. - * - * Rather than the underlying {@link IBaseShell}, an ITerminalShell connection - * adds methods that describe the presentation of the data transmitted over its - * Streams, as well as methods like {@link #setTerminalSize(int, int)} to change - * the behavior of the presentation of this data. An instance of ITerminalShell - * is typically obtained from an {@link ITerminalService}. - * - * In RSE, a single remote shell instance can only either support the streamed - * ITerminalShell interface or the listener-based {@link IHostShell} interface, - * but not both. Note, though, that with the capabilities that an ITerminalShell - * has, it is always possible to adapt it to an IHostShell; this is typically - * not possible the other way round. We therefore recommend extenders of RSE - * that used to subclass IHostShell to move to the new IBaseShell / - * ITerminalShell APIs eventually, if they can. - * - * @noimplement This interface is not intended to be implemented by clients. - * Clients must subclass the provided {@link AbstractTerminalShell} - * or {@link TerminalShellDecorator} classes rather than - * implementing this interface directly. - * - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as - * part of a work in progress. There is no guarantee that this API will work or - * that it will remain the same. Please do not use this API without consulting - * with the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> - * team. - * </p> - * - * @see IBaseShell - * @see ITerminalService - * @see AbstractTerminalShell - * @see TerminalShellDecorator - * @since org.eclipse.rse.services 3.0 - */ -public interface ITerminalShell extends IBaseShell { - - /** - * Get the Terminal Type that's expected on this connection. - * - * The terminal type may be specified by the client when constructing a - * concrete instance of an ITerminalShell, or a remote side may actually - * expect a particular terminal type to be present. - * - * @return the terminal type expected by the remote side to properly render - * the Streams associated with this Terminal, or <code>null</code> - * if the ITerminalShell does not know what kind of Terminal Type is - * expected. - */ - public String getPtyType(); - - /** - * Return the default encoding that the terminal service had specified when - * creating this terminal connection, or that's known from the remote side - * to be expected. This is not necessarily known or accurate, and may be - * <code>null</code>. - * - * TODO I'm not actually sure if this method is a good idea. Perhaps we - * should use the IAdaptable mechanism for dealing with encodings, since our - * shells basically deal with binary data only. - * - * @return the specified default encoding, or <code>null</code> if - * unknown. - */ - public String getDefaultEncoding(); - - /** - * Notify the remote site that the size of the terminal has changed. There - * is no guarantee that the remote side is actually capable of changing the - * Terminal size. - * - * @param newWidth - * @param newHeight - */ - void setTerminalSize(int newWidth, int newHeight); - - /** - * Test if local echo is needed on this terminal connection. Clients are - * expected to return <code>false</code> if in doubt. - * - * @return <code>true</code> if a local echo is needed. - */ - boolean isLocalEcho(); - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/ProcessBaseShell.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/ProcessBaseShell.java deleted file mode 100644 index 7464167f9..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/ProcessBaseShell.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - *******************************************************************************/ - -package org.eclipse.rse.internal.services.terminals; - -import java.io.InputStream; -import java.io.OutputStream; - -import org.eclipse.core.runtime.PlatformObject; - -/** - * A wrapper for Java {@link Process} objects to give more convenient access to - * them through the {@link IBaseShell} interface. - * - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as - * part of a work in progress. There is no guarantee that this API will work or - * that it will remain the same. Please do not use this API without consulting - * with the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> - * team. - * </p> - * - * @since org.eclipse.rse.services 3.0 - */ -public class ProcessBaseShell extends PlatformObject implements IBaseShell { - - /** - * The underlying Process instance. - */ - protected final Process fProcess; - - /** - * Constructor. - * - * @param p the Process to wrap with this IBaseShell interface. - */ - public ProcessBaseShell(Process p) { - fProcess = p; - } - - /** - * Forcefully terminate the underlying Process through - * {@link Process#destroy()}. Subclasses may want to override this behavior - * by trying to terminate the underlying Process in a cleaner way. - * - * @see IBaseShell#exit() - */ - public void exit() { - fProcess.destroy(); - } - - public int exitValue() { - return fProcess.exitValue(); - } - - public InputStream getErrorStream() { - return fProcess.getErrorStream(); - } - - public InputStream getInputStream() { - return fProcess.getInputStream(); - } - - public OutputStream getOutputStream() { - return fProcess.getOutputStream(); - } - - /** - * Check if the underlying Process is still active. Does not check whether - * the Streams for the Process have been closed by the client, since this - * does not influence the process active state anyways. - * - * @see IBaseShell#isActive() - */ - public boolean isActive() { - try { - fProcess.exitValue(); - } catch (IllegalThreadStateException e) { - return true; - } - return false; - } - - /** - * A Watchdog Thread, to interrupt other Threads after a given time unless a - * specified condition is met. - * - * Sleeps for a given time, and upon wakeup checks if a condition is met. If - * not, the specified Thread is interrupted. - */ - private abstract static class Watchdog extends Thread { - private final Thread fThreadToWatch; - private long fTimeout; - - public Watchdog(Thread threadToWatch, long timeout) { - fThreadToWatch = threadToWatch; - fTimeout = timeout; - } - - protected abstract boolean conditionDone(); - - public void run() { - try { - sleep(fTimeout); - } catch (InterruptedException e) { - /* ignore */ - } finally { - if (!conditionDone()) { - fThreadToWatch.interrupt(); - } - } - } - } - - public boolean waitFor(long timeout) throws InterruptedException { - boolean active = isActive(); - if (active) { - Thread watchdog = null; - if (timeout > 0) { - // TODO Check if using java.util.Timer would be more efficient - // than our own Watchdog - watchdog = new Watchdog(Thread.currentThread(), timeout) { - protected boolean conditionDone() { - return !isActive(); - } - }; - watchdog.start(); - } - try { - fProcess.waitFor(); - } catch (InterruptedException e) { - /* ignore */ - } - if (watchdog != null) { - watchdog.interrupt(); - } - active = isActive(); - } - return active; - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/TerminalShellDecorator.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/TerminalShellDecorator.java deleted file mode 100644 index 492ce473f..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/TerminalShellDecorator.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - *******************************************************************************/ - -package org.eclipse.rse.internal.services.terminals; - -/** - * Abstract base class for clients to decorate an ITerminalShell instance they - * have with additional functionality. - * - * Typically, such additional functionality can be provided either by additional - * knowledge about the underlying system or process, or by analyzing the input - * and output streams for some well-known data that gives such additional - * knowledge. - * - * <p> - * <strong>EXPERIMENTAL</strong>. This class or interface has been added as - * part of a work in progress. There is no guarantee that this API will work or - * that it will remain the same. Please do not use this API without consulting - * with the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> - * team. - * </p> - * - * @since org.eclipse.rse.services 3.0 - */ -public abstract class TerminalShellDecorator extends BaseShellDecorator implements ITerminalShell { - - public TerminalShellDecorator(ITerminalShell delegate) { - super(delegate); - } - - protected ITerminalShell getDelegate() { - return (ITerminalShell) fDelegate; - } - - public String getPtyType() { - return getDelegate().getPtyType(); - } - - public String getDefaultEncoding() { - return getDelegate().getDefaultEncoding(); - } - - public boolean isLocalEcho() { - return getDelegate().isLocalEcho(); - } - - public void setTerminalSize(int newWidth, int newHeight) { - getDelegate().setTerminalSize(newWidth, newHeight); - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/package.html b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/package.html deleted file mode 100644 index 4c2ff8173..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/terminals/package.html +++ /dev/null @@ -1,72 +0,0 @@ -<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> -<html> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> - <meta name="Author" content="Martin Oberhuber (Wind River)"> - <meta name="Copyright" content="Copyright (c) 2008 Wind River Systems, Inc. and others."> - <meta name="License" content="Made available under the terms of the Eclipse Public License v1.0."> - <title>Package-level Javadoc</title> -</head> -<body> -<strong>PROVISIONAL</strong> Application programming interface for the RSE Base Shell and Terminal Services. -<p> -<strong>EXPERIMENTAL</strong>. This class or interface has been added as -part of a work in progress. There is no guarantee that this API will work or -that it will remain the same. Please do not use this API without consulting -with the <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> -team. -</p> -<h2> -Package Specification</h2> -<p> -The RSE Terminal Services packages provides interfaces and basic utility classes -for shell or terminal connections. The classes in this package are especially designed -to be extendable by means of the <b>Decorator</b> pattern as well as the <b>Adapter</b> -pattern: -<ul> -<li><code><a href="IBaseShell.html">IBaseShell</a></code> - is the basic interface for communicating with a (potentially remote) process - through a channel supporting Streams. The Interface is modeled after the - <code><a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Process.html">java.lang.Process</a></code> - class, but provides some nice enhancements such as a timeout for the - <code>waitFor()</code> method, as well as an <code>isActive()</code> - method.</li> -<li><code><a href="ProcessBaseShell.html">ProcessBaseShell</a></code> - is a sample class implementing IBaseShell, that wraps an existing - <code><a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Process.html">java.lang.Process</a></code> - object in the IBaseShell interface for easier consumption.</li> -<li><code><a href="ITerminalShell.html">ITerminalShell</a></code> - extends IBaseShell, adding methods specific to the presentation of the data - transferred from the (remote) process: it provides for getDefaultEncoding(), - getPtyType(), isLocalEcho() as well as setTerminalSize() methods.</li> -<li><code><a href="AbstractTerminalShell.html">AbstractTerminalShell</a></code> - is an abstract base class that implementers of ITerminalShell must extend. - It provides default implementations of all methods where possible, and - ensures that future evolving of the ITerminalShell interface - can be done without breaking binary compatibility with extenders implementing it.</li> -<li><code><a href="BaseShellDecorator.html">BaseShellDecorator</a></code> and - <code><a href="">TerminalShellDecorator</a></code> abstract base - classes should be used when clients want to add functionality by decorating - an existing IBaseShell or ITerminalShell object they have. Again, extending - these not only saves the extender typing default delegation methods, but also - ensures that they remain binary compatible in case the interfaces evolve.</li> -<li><code><a href="ITerminalService.html">ITerminalService</a></code> - is the RSE Service Interface, and currently only - provides one factory method <code>launchTerminal()</code> for creating - a new Terminal Connection. - <code><a href="">AbstractTerminalService</a></code> must be used as base - class by extenders who wish to implement the ITerminalService, in order to ensure - binary compatibility in case the interface evolves - even though - the AbstractTerminalService is currently empty.</li> -</ul> -The classes and interfaces in this package are designed to have only minimal -dependency into Eclipse core APIs, such that Services can eventually be re-used in -environments outside Eclipse. Especially -<code><a href="IBaseShell.html">IBaseShell</a></code>, along with -<code><a href="ProcessBaseShell.html">ProcessBaseShell</a></code> and -<code><a href="BaseShellDecorator.html">BaseShellDecorator</a></code> are usable in -any environment, provided that mock objects are provided for Eclipse -IAdaptable and PlatformObject. -</p> -</body> -</html> diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/AbstractService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/AbstractService.java deleted file mode 100644 index aa86b33dd..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/AbstractService.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - *******************************************************************************/ -package org.eclipse.rse.services; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.PlatformObject; - -/** - * Abstract default implementation of an RSE Service. Clients are expected to - * extend this class. - * - * @see IService - * @since org.eclipse.rse.services 3.0 - */ -public abstract class AbstractService extends PlatformObject implements IService { - - public String getDescription() { - return getName(); - } - - public String getName() { - return this.getClass().getName(); - } - - /** - * Default implementation of initService. Extenders who override this method - * must call <code>super.initService(monitor)</code> as the first call in - * their implementation. - */ - public void initService(IProgressMonitor monitor) { - // Do nothing by default - } - - /** - * Default implementation of uninitService. Extenders who override this - * method must call <code>super.uninitService(monitor)</code> as the last - * call in their implementation. - */ - public void uninitService(IProgressMonitor monitor) { - // Do nothing by default - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/IService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/IService.java deleted file mode 100644 index 0dfd75c7b..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/IService.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc - *******************************************************************************/ - -package org.eclipse.rse.services; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * IService is the base interface for any non-UI service contributions to RSE. - * - * An actual Service is free to perform any operations at all - the only - * commonality between services is that they have a name, can be initialized, - * and are adaptable for future extension. - * - * @noimplement This interface is not intended to be implemented by clients. - * Service implementations must subclass - * {@link AbstractService} rather than implementing this - * interface directly. - */ -public interface IService extends IAdaptable -{ - /** - * Get the name of this Service as a translated, UI-visible String. - * Extenders are expected to override this method. - * - * @return the name of this Service. - */ - public String getName(); - - /** - * Get the description of this Service as a translated, UI-visible String. - * Extenders are expected to override this method. - * - * @return the description of this Service. - */ - public String getDescription(); - - /** - * Initialize this Service to make it ready for operation. This method may - * be long-running, but is not yet expected to open a connection to a - * particular remote system. - * - * Extenders are expected to override this method. - * - * @param monitor A progress monitor to provide progress of long-running - * operation. There is no guarantee that cancellation is actually - * supported by a Service since it would leave the service in a - * potentially inconsistent, partially initialized state. - */ - public void initService(IProgressMonitor monitor); - - /** - * Clean up this Service. This method is called by clients as part of a - * disconnect operation and should clean up any local status that the - * Service might have. - * - * Extenders are expected to override this method. - * - * @param monitor A progress monitor to provide progress of long-running - * operation. There is no guarantee that cancellation is actually - * supported by a Service since it would leave the service in a - * potentially inconsistent, partially initialized state. - */ - public void uninitService(IProgressMonitor monitor); -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/Mutex.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/Mutex.java deleted file mode 100644 index 0e3c1d29c..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/Mutex.java +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Wind River Systems, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - *******************************************************************************/ - -package org.eclipse.rse.services; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.rse.internal.services.Activator; - -/** - * A Mutual Exclusion Lock for Threads that need to access a resource - * in a serialized manner. An Eclipse ProgressMonitor is accepted - * in order to support cancellation when waiting for the Mutex. - * - * Usage Example: - * <code> - * private Mutex fooMutex = new Mutex(); - * boolean doFooSerialized()(IProgressMonitor monitor) { - * if (fooMutex.waitForLock(monitor, 1000)) { - * try { - * return doFoo(); - * } finally { - * fooMutex.release(); - * } - * } - * return false; - * } - * </code> - * - * The Mutex is not reentrant, so when a Thread has locked the - * Mutex it must not try locking it again. - */ -public class Mutex { - - private boolean fLocked = false; - private List fWaitQueue = new LinkedList(); - - /** - * Creates an instance of <tt>Mutex</tt>. - */ - public Mutex() { - } - - /** - * Try to acquire the lock maintained by this mutex. - * - * If the thread needs to wait before it can acquire the mutex, it - * will wait in a first-come-first-serve fashion. In case a progress - * monitor was given, it will be updated and checked for cancel every - * second. - * - * @param monitor Eclipse Progress Monitor. May be <code>null</code>. - * @param timeout Maximum wait time given in milliseconds. - * @return <code>true</code> if the lock was obtained successfully. - */ - public boolean waitForLock(IProgressMonitor monitor, long timeout) { - if (Thread.interrupted()) { - return false; - } - if (monitor!=null && monitor.isCanceled()) { - return false; - } - final Thread myself = Thread.currentThread(); - synchronized(fWaitQueue) { - if (!fLocked) { - //acquire the lock immediately. - fLocked = true; - return true; - } else { - fWaitQueue.add(myself); - Activator.trace("Mutex: added "+myself+", size="+fWaitQueue.size()); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - //need to wait for the lock. - boolean lockAcquired = false; - try { - long start = System.currentTimeMillis(); - long timeLeft = timeout; - long pollTime = (monitor!=null) ? 1000 : timeLeft; - long nextProgressUpdate = start+500; - boolean cancelled = false; - while (timeLeft > 0 && !cancelled && !lockAcquired) { - //is it my turn yet? Check wait queue and wait - synchronized(fWaitQueue) { - if (!fLocked && fWaitQueue.get(0) == myself) { - fWaitQueue.remove(0); - Activator.trace("Mutex: SUCCESS, removed "+myself+", size="+fWaitQueue.size()); //$NON-NLS-1$ //$NON-NLS-2$ - fLocked = true; - lockAcquired = true; - } else { - fWaitQueue.wait(timeLeft > pollTime ? pollTime : timeLeft); - if (!fLocked && fWaitQueue.get(0) == myself) { - fWaitQueue.remove(0); - Activator.trace("Mutex: SUCCESS, removed "+myself+", size="+fWaitQueue.size()); //$NON-NLS-1$ //$NON-NLS-2$ - fLocked = true; - lockAcquired = true; - } - } - } - if (!lockAcquired) { - //Need to continue waiting - Activator.trace("Mutex: wakeup "+myself+" ?"); //$NON-NLS-1$ //$NON-NLS-2$ - long curTime = System.currentTimeMillis(); - timeLeft = start + timeout - curTime; - if (monitor!=null) { - cancelled = monitor.isCanceled(); - if (!cancelled && (curTime > nextProgressUpdate)) { - monitor.worked(1); - nextProgressUpdate+=1000; - } - } - } - } - } catch(InterruptedException e) { - //cancelled waiting -> no lock aquired - } finally { - if (!lockAcquired) { - synchronized(fWaitQueue) { - fWaitQueue.remove(myself); - Activator.trace("Mutex: FAIL, removed "+myself+", size="+fWaitQueue.size()); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - return lockAcquired; - } - - /** - * Release this mutex's lock. - * - * May only be called by the same thread that originally acquired - * the Mutex. - */ - public void release() { - synchronized(fWaitQueue) { - fLocked=false; - if (!fWaitQueue.isEmpty()) { - Object nextOneInQueue = fWaitQueue.get(0); - Activator.trace("Mutex: releasing "+nextOneInQueue); //$NON-NLS-1$ - fWaitQueue.notifyAll(); - } - } - } - - /** - * Return this Mutex's lock status. - * @return <code>true</code> if this mutex is currently acquired by a thread. - */ - public boolean isLocked() { - synchronized(fWaitQueue) { - return fLocked; - } - } - - /** - * Interrupt all threads waiting for the Lock, causing their - * {@link #waitForLock(IProgressMonitor, long)} method to return - * <code>false</code>. - * This should be called if the resource that the Threads are - * contending for, becomes unavailable for some other reason. - */ - public void interruptAll() { - synchronized(fWaitQueue) { - Iterator it = fWaitQueue.iterator(); - while (it.hasNext()) { - Thread aThread = (Thread)it.next(); - aThread.interrupt(); - } - } - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/RemoteUtil.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/RemoteUtil.java deleted file mode 100644 index bc754c9ee..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/RemoteUtil.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Martin Oberhuber (Wind River) - added createSocket() from team.cvs.core/Util - *******************************************************************************/ -package org.eclipse.rse.services; - -import java.io.IOException; -import java.io.InterruptedIOException; -import java.net.Socket; -import java.net.UnknownHostException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.osgi.util.NLS; - -import org.eclipse.rse.internal.services.RSEServicesMessages; - -/** - * Static helper-methods for network access. - */ -public class RemoteUtil { - - //---------------------------------------------------------------------- - // <copied - // plugin: org.eclipse.team.cvs.core - // class: org.eclipse.team.internal.ccvs.core.Policy - // copyright: (c) 2000, 2006 IBM Corporation and others /> - //---------------------------------------------------------------------- - - /** - * Progress Monitor Helper: Checks the passed progress monitor - * and throws an {@link OperationCanceledException} when it is - * cancelled. - * - * @param monitor The ProgressMonitor to be checked - */ - public static void checkCanceled(IProgressMonitor monitor) { - if (monitor.isCanceled()) - throw new OperationCanceledException(); - } - - //</copied> - - //---------------------------------------------------------------------- - // <copied - // plugin: org.eclipse.team.cvs - // class: org.eclipse.team.internal.ccvs.core.util.Util - // copyright: (c) 2000, 2006 IBM Corporation and others /> - //---------------------------------------------------------------------- - - /** - * Helper method that will time out when making a socket connection. - * This is required because there is no way to provide a timeout value - * when creating a socket and in some instances, they don't seem to - * timeout at all. - * @param host inetaddress to connect to - * @param port port to connect to - * @param timeout number of seconds for timeout (default=60) - * @param monitor progress monitor - */ - public static Socket createSocket(final String host, final int port, int timeout, IProgressMonitor monitor) throws UnknownHostException, IOException { - - // Start a thread to open a socket - final Socket[] socket = new Socket[] { null }; - final Exception[] exception = new Exception[] {null }; - final Thread thread = new Thread(new Runnable() { - public void run() { - try { - Socket newSocket = new Socket(host, port); - synchronized (socket) { - if (Thread.interrupted()) { - // we we're either cancelled or timed out so just close the socket - newSocket.close(); - } else { - socket[0] = newSocket; - } - } - } catch (UnknownHostException e) { - exception[0] = e; - } catch (IOException e) { - exception[0] = e; - } - } - }); - thread.start(); - - // Wait the appropriate number of seconds - if (timeout <= 0) timeout = 60; - for (int i = 0; i < timeout; i++) { - try { - // wait for the thread to complete or 1 second, which ever comes first - thread.join(1000); - } catch (InterruptedException e) { - // I think this means the thread was interupted but not necessarily timed out - // so we don't need to do anything - } - synchronized (socket) { - // if the user cancelled, clean up before preempting the operation - if (monitor.isCanceled()) { - if (thread.isAlive()) { - thread.interrupt(); - } - if (socket[0] != null) { - socket[0].close(); - } - // this method will throw the proper exception - checkCanceled(monitor); - } - } - } - // If the thread is still running (i.e. we timed out) signal that it is too late - synchronized (socket) { - if (thread.isAlive()) { - thread.interrupt(); - } - } - if (exception[0] != null) { - if (exception[0] instanceof UnknownHostException) - throw (UnknownHostException)exception[0]; - else - throw (IOException)exception[0]; - } - if (socket[0] == null) { - throw new InterruptedIOException(NLS.bind(RSEServicesMessages.Socket_timeout, new String[] { host })); - } - return socket[0]; - } - - //</copied> - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java deleted file mode 100644 index 43bf48c39..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java +++ /dev/null @@ -1,304 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API - * David McKnight (IBM) - [207178] changing list APIs for file service and subsystems - * David McKnight (IBM) - [162195] new APIs for upload multi and download multi - * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread - * David McKnight (IBM) - [209552] API changes to use multiple and getting rid of deprecated - * David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants - * Martin Oberhuber (Wind River) - [210109] no need to declare IFileService constants in AbstractFileService - * David McKnight (IBM) - [209704] [api] Ability to override default encoding conversion needed. - * Xuan Chen (IBM) - [210555] [regression] NPE when deleting a file on SSH - * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND - * David McKnight (IBM) - [209704] added supportsEncodingConversion() - * David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage() - * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc - * David Dykstal (IBM) - [221211] fix IFileService API for batch operations - * Martin Oberhuber (Wind River) - [221211] Fix progress monitor and cancellation for multi operations - *******************************************************************************/ - -package org.eclipse.rse.services.files; - -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; - -import org.eclipse.rse.services.AbstractService; -import org.eclipse.rse.services.clientserver.SystemEncodingUtil; -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -import org.eclipse.rse.services.clientserver.messages.SystemOperationCancelledException; - - -public abstract class AbstractFileService extends AbstractService implements IFileService -{ - /** - * Perform a single progress tick for default multi-operations, provided - * that a valid progress monitor is passed in: - * <ul> - * <li>Checks the monitor for cancellation and throws - * SystemOperationCancelledException if it is - * <li>Creates a SubMonitor for a single progress tick on the original - * monitor - * </ul> - * - * @param monitor Progress Monitor to use - * @return A valid progress monitor usable for a single work item. Client is - * responsible for calling done() on the subMonitor when done. - * @throws SystemOperationCancelledException in case the user cancelled - * @since 3.0 - */ - protected IProgressMonitor progressTick(IProgressMonitor monitor) throws SystemMessageException { - if (monitor == null) { - return new NullProgressMonitor(); - } - if (monitor.isCanceled()) { - throw new SystemOperationCancelledException(); - } - return new SubProgressMonitor(monitor, 1); - } - - protected abstract IHostFile[] internalFetch(String parentPath, String fileFilter, int fileType, IProgressMonitor monitor) throws SystemMessageException; - - /** - * {@inheritDoc} - * @since 3.0 - */ - public void getFileMultiple(String remoteParents[], String names[], List hostFiles, IProgressMonitor monitor) - throws SystemMessageException - { - if (monitor != null) - monitor.beginTask("", remoteParents.length); //$NON-NLS-1$ - for (int i = 0; i < remoteParents.length; i++) - { - IProgressMonitor subMonitor = progressTick(monitor); - hostFiles.add(getFile(remoteParents[i], names[i], subMonitor)); - subMonitor.done(); - } - } - - /** - * {@inheritDoc} - * @since 3.0 using int fileTYpe - */ - public IHostFile[] list(String remoteParent, String fileFilter, - int fileType, IProgressMonitor monitor) throws SystemMessageException - { - return internalFetch(remoteParent, fileFilter, fileType, monitor); - } - - /** - * {@inheritDoc} - * @since 3.0 - */ - public void listMultiple(String[] remoteParents, - String[] fileFilters, int fileTypes[], List hostFiles, IProgressMonitor monitor) - throws SystemMessageException { - - if (monitor != null) - monitor.beginTask("", remoteParents.length); //$NON-NLS-1$ - for (int i = 0; i < remoteParents.length; i++) - { - IProgressMonitor subMonitor = progressTick(monitor); - IHostFile[] result = list(remoteParents[i], fileFilters[i], fileTypes[i], subMonitor); - for (int j = 0; j < result.length; j++) - { - hostFiles.add(result[j]); - } - subMonitor.done(); - } - - } - - /** - * {@inheritDoc} - * @since 3.0 - */ - public void listMultiple(String[] remoteParents, - String[] fileFilters, int fileType, List hostFiles, IProgressMonitor monitor) - throws SystemMessageException { - - if (monitor != null) - monitor.beginTask("", remoteParents.length); //$NON-NLS-1$ - for (int i = 0; i < remoteParents.length; i++) - { - IProgressMonitor subMonitor = progressTick(monitor); - IHostFile[] result = list(remoteParents[i], fileFilters[i], fileType, subMonitor); - for (int j = 0; j < result.length; j++) - { - hostFiles.add(result[j]); - } - subMonitor.done(); - } - - } - - protected boolean isRightType(int fileType, IHostFile node) - { - switch (fileType) - { - case IFileService.FILE_TYPE_FILES_AND_FOLDERS: - return true; - case IFileService.FILE_TYPE_FILES: - if (node.isFile()) - { - return true; - } - else - { - return false; - } - case IFileService.FILE_TYPE_FOLDERS: - if (node.isDirectory()) - { - return true; - } - else - { - return false; - } - default: - return true; - } - } - - - /** - * {@inheritDoc} - * @since 3.0 returning void - */ - public void deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException - { - if (monitor != null) - monitor.beginTask("", remoteParents.length); //$NON-NLS-1$ - for (int i = 0; i < remoteParents.length; i++) - { - IProgressMonitor subMonitor = progressTick(monitor); - delete(remoteParents[i], fileNames[i], subMonitor); - subMonitor.done(); - } - } - - /** - * {@inheritDoc} Default implementation - just iterate through each file - * @since 3.0 returning void - */ - public void downloadMultiple(String[] remoteParents, String[] remoteFiles, - File[] localFiles, boolean[] isBinaries, String[] hostEncodings, - IProgressMonitor monitor) throws SystemMessageException - { - if (monitor != null) - monitor.beginTask("", remoteParents.length); //$NON-NLS-1$ - for (int i = 0; i < remoteParents.length; i++) - { - IProgressMonitor subMonitor = progressTick(monitor); - String remoteParent = remoteParents[i]; - String remoteFile = remoteFiles[i]; - File localFile = localFiles[i]; - boolean isBinary = isBinaries[i]; - String hostEncoding = hostEncodings[i]; - download(remoteParent, remoteFile, localFile, isBinary, hostEncoding, subMonitor); - subMonitor.done(); - } - } - - /** - * {@inheritDoc} Default implementation - just iterate through each file - * @since 3.0 - */ - public void uploadMultiple(File[] localFiles, String[] remoteParents, - String[] remoteFiles, boolean[] isBinaries, String[] srcEncodings, - String[] hostEncodings, IProgressMonitor monitor) - throws SystemMessageException - { - if (monitor != null) - monitor.beginTask("", remoteParents.length); //$NON-NLS-1$ - for (int i = 0; i < localFiles.length; i++) - { - IProgressMonitor subMonitor = progressTick(monitor); - File localFile = localFiles[i]; - String remoteParent = remoteParents[i]; - String remoteFile = remoteFiles[i]; - - boolean isBinary = isBinaries[i]; - String srcEncoding = srcEncodings[i]; - String hostEncoding = hostEncodings[i]; - upload(localFile, remoteParent, remoteFile, isBinary, srcEncoding, hostEncoding, subMonitor); - monitor.done(); - } - } - - /** - * Returns the local platform encoding by default. Subclasses should override to return the actual remote encoding. - * @see org.eclipse.rse.services.files.IFileService#getEncoding(org.eclipse.core.runtime.IProgressMonitor) - * @since 2.0 - */ - public String getEncoding(IProgressMonitor monitor) throws SystemMessageException { - return SystemEncodingUtil.getInstance().getLocalDefaultEncoding(); - } - - /** - * The default implementation returns <code>null</code>. Clients can override to return an input stream to the file. - * @see org.eclipse.rse.services.files.IFileService#getInputStream(String, String, boolean, IProgressMonitor) - */ - public InputStream getInputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException { - return null; - } - - /** - * Gets the output stream to write/append to a remote file. The default - * implementation returns <code>null</code>. Clients can override to - * return an output stream to the file. - * - * @deprecated use - * {@link #getOutputStream(String, String, int, IProgressMonitor)} - * instead - */ - public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException { - return null; - } - - /** - * Gets the output stream to write/append to a remote file. The default - * implementation returns <code>null</code>. Clients can override to return - * an output stream to the file. - * - * @see org.eclipse.rse.services.files.IFileService#getOutputStream(String, - * String, int, IProgressMonitor) - * @since 3.0 using int options - */ - public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException { - if ((options & IFileService.APPEND) == 0) { - //forward to old deprecated implementation for backward compatibility with old services - boolean isBinary = (options & IFileService.TEXT_MODE) == 0 ? true : false; - return getOutputStream(remoteParent, remoteFile, isBinary, monitor); - } - return null; - } - - /** - * The default implementation returns false. Clients should override this - * method if they make use of IFileServiceCodePageConverter to do conversion - * during download and upload. - * @since 3.0 - */ - public boolean supportsEncodingConversion(){ - return false; - } -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/CodePageConverterManager.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/CodePageConverterManager.java deleted file mode 100644 index 140f9b2aa..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/CodePageConverterManager.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight. - * - * Contributors: - * {Name} (company) - description of contribution. - * David McKnight (IBM) - [209704] [api] Ability to override default encoding conversion needed. - * David McKnight (IBM) - [212229] using default code page converter that isn't null - *******************************************************************************/ -package org.eclipse.rse.services.files; - -import java.util.Vector; - -/** - * Utility class for getting a file service code page converter for a given - * server encoding and file service - * - * @since 3.0 - */ -public class CodePageConverterManager { - - - private static IFileServiceCodePageConverter _defaultCodePageConverter; - protected static Vector _codePageConverters = new Vector(); - - public static void registerCodePageConverter(IFileServiceCodePageConverter converter) - { - _codePageConverters.add(converter); - } - - public static IFileServiceCodePageConverter getDefaultCodePageConverter() - { - if (_defaultCodePageConverter == null){ - _defaultCodePageConverter = new DefaultFileServiceCodePageConverter(); - } - return _defaultCodePageConverter; - } - - /** - * Retrieves the first codepage converter provided via the codePageConverter extension point for the specified - * encoding - * @param serverEncoding The server encoding for which to retrieve a code page converter - * @return A code page converter for the specified encoding, or null if no converter was found for that encoding. - */ - public static IFileServiceCodePageConverter getCodePageConverter(String serverEncoding, IFileService fileService) { - - IFileServiceCodePageConverter matchingCodePageConverter = null; - if (_codePageConverters != null) - { - - //scan through the available converters and return the first valid one for the specified encoding for this - // subsystem implementation - for (int i=0; i<_codePageConverters.size(); i++) { - IFileServiceCodePageConverter codePageConverter = (IFileServiceCodePageConverter)_codePageConverters.elementAt(i); - if (codePageConverter.isServerEncodingSupported(serverEncoding, fileService)) - { - if (matchingCodePageConverter != null){ - int matchingPriority = matchingCodePageConverter.getPriority(serverEncoding, fileService); - int newPriority = codePageConverter.getPriority(serverEncoding, fileService); - if (newPriority < matchingPriority){ - matchingCodePageConverter = codePageConverter; - } - } - else { - matchingCodePageConverter = codePageConverter; - } - } - } - } - - if (matchingCodePageConverter == null) - { - matchingCodePageConverter = getDefaultCodePageConverter(); - } - - - return matchingCodePageConverter; - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/DefaultFileServiceCodePageConverter.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/DefaultFileServiceCodePageConverter.java deleted file mode 100644 index a9b058720..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/DefaultFileServiceCodePageConverter.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2007, 2008 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight. - * - * Contributors: - * David McKnight (IBM) -[209704] [api][dstore] Ability to override default encoding conversion needed. - * David McKnight (IBM) -[220379] [api] Provide a means for contributing custom BIDI encodings - ********************************************************************************/ -package org.eclipse.rse.services.files; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; - -/** - * @since 3.0 - */ -public class DefaultFileServiceCodePageConverter implements - IFileServiceCodePageConverter { - - public byte[] convertClientStringToRemoteBytes(String remotePath, String clientString, - String remoteEncoding, IFileService fs) { - try - { - return clientString.getBytes(remoteEncoding); - } - catch (Exception e) - { - } - return clientString.getBytes(); - } - - public void convertFileFromRemoteEncoding(String remotePath, File file, String remoteEncoding, - String localEncoding, IFileService fs) { - - // read in the file - try - { - int fileLength = (int)file.length(); - FileInputStream inputStream = new FileInputStream(file); - BufferedInputStream bufInputStream = new BufferedInputStream(inputStream, fileLength); - byte[] buffer = new byte[fileLength]; - int bytesRead = bufInputStream.read(buffer, 0, fileLength); - bufInputStream.close(); - inputStream.close(); - - byte[] localBuffer = new String(buffer, 0, bytesRead, remoteEncoding).getBytes(localEncoding); - - FileOutputStream outStream = new FileOutputStream(file); - outStream.write(localBuffer, 0, localBuffer.length); - outStream.close(); - } - catch (Exception e) - { - - } - } - - public boolean isServerEncodingSupported(String remoteEncoding, - IFileService fs) { - return true; - } - - /** - * to make another converter take precedence over this, supply a - * code page converter returning a lower number (i.e. higher priority) - */ - public int getPriority(String remoteEString, IFileService fs){ - return 1000; - } - - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/HostFilePermissions.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/HostFilePermissions.java deleted file mode 100644 index f01dcf35f..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/HostFilePermissions.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2008 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight. - * - * Contributors: - * David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files - ********************************************************************************/ -package org.eclipse.rse.services.files; - -/** - * Default implementation of "Universal" UNIX kind of IHostFilePermissions. - * @since 3.0 - */ -public class HostFilePermissions implements - IHostFilePermissions, Cloneable { - - private int _permissions = 0; - private String _user; - private String _group; - - - /** - * Constructor without any initial values. Users of this need to set fields - * as appropriate - */ - public HostFilePermissions(){ - } - - /** - * Constructor that takes the initial permissions in rwxrwxrwx form - * @param alphaPermissions the initial permissions in alpha form - */ - public HostFilePermissions(String alphaPermissions, String user, String group){ - String accessString = alphaPermissionsToOctal(alphaPermissions); - _permissions = Integer.parseInt(accessString, 8); - _user = user; - _group = group; - } - - /** - * Constructor that takes the initial permissions as a bitmask - * @param initialPermissions the initial permissions bitmask - */ - public HostFilePermissions(int initialPermissions, String user, String group){ - _permissions = initialPermissions; - _user = user; - _group = group; - } - - /** - * Convert permissions in rwxrwxrwx form to octal - * @param userPermissions - * @return - */ - private String alphaPermissionsToOctal(String alphaPermissions) - { - if (alphaPermissions.length() == 10){ // directory bit? - alphaPermissions = alphaPermissions.substring(1); - } - StringBuffer buf = new StringBuffer(); - // permissions - char[] chars = alphaPermissions.toCharArray(); - - int offset = -1; - for (int i = 0; i < 3; i++){ - int value = 0; - - if (chars[++offset] == 'r'){ - value = 4; - } - if (chars[++offset] == 'w'){ - value += 2; - } - if (chars[++offset] == 'x'){ - value += 1; - } - buf.append(value); - } - - return buf.toString(); - } - - public void setPermission(int permission, boolean value) { - if (value) - set(permission); - else - clear(permission); - } - - public boolean getPermission(int permission) { - return isSet(permission); - } - - public int getPermissionBits() { - return _permissions; - } - - public void setPermissionBits(int bits) { - _permissions = bits; - } - - public String toString(){ - return "" + _permissions; //$NON-NLS-1$ - } - - private boolean isSet(long mask) { - return (_permissions & mask) != 0; - } - - private void set(int mask) { - _permissions |= mask; - } - - private void clear(int mask) { - _permissions &= ~mask; - } - - /** - * return permissions in rwxrwxrwx form - */ - public String toAlphaString(){ - StringBuffer buf = new StringBuffer(); - - buf.append(getPermission(IHostFilePermissions.PERM_USER_READ) ? 'r' : '-'); - buf.append(getPermission(IHostFilePermissions.PERM_USER_WRITE) ? 'w' : '-'); - buf.append(getPermission(IHostFilePermissions.PERM_USER_EXECUTE) ? 'x' : '-'); - buf.append(getPermission(IHostFilePermissions.PERM_GROUP_READ) ? 'r' : '-'); - buf.append(getPermission(IHostFilePermissions.PERM_GROUP_WRITE) ? 'w' : '-'); - buf.append(getPermission(IHostFilePermissions.PERM_GROUP_EXECUTE) ? 'x' : '-'); - buf.append(getPermission(IHostFilePermissions.PERM_OTHER_READ) ? 'r' : '-'); - buf.append(getPermission(IHostFilePermissions.PERM_OTHER_WRITE) ? 'w' : '-'); - buf.append(getPermission(IHostFilePermissions.PERM_OTHER_EXECUTE) ? 'x' : '-'); - return buf.toString(); - } - - public String getGroupOwner() { - return _group; - } - - public String getUserOwner() { - return _user; - } - - public void setGroupOwner(String group) { - _group = group; - } - - public void setUserOwner(String user) { - _user = user; - } - - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFilePermissionsService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFilePermissionsService.java deleted file mode 100644 index 16ed0846c..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFilePermissionsService.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2008 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight. - * - * Contributors: - * David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files - ********************************************************************************/ -package org.eclipse.rse.services.files; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; - -/** - * Service used to get and set the permissions of a file. The - * {@link #getCapabilities(IHostFile)} method must be implemented to tell - * clients what kinds of permission services are actually available on a - * concrete implementation. - * - * @since 3.0 - */ -public interface IFilePermissionsService { - - public static int FS_CAN_GET_OWNER = 1 << 0; - public static int FS_CAN_GET_GROUP = 1 << 1; - public static int FS_CAN_GET_PERMISSIONS = 1 << 2; - public static int FS_CAN_SET_OWNER = 1 << 3; - public static int FS_CAN_SET_GROUP = 1 << 4; - public static int FS_CAN_SET_PERMISSIONS = 1 << 5; - - public static final int FS_CAN_GET_ALL = FS_CAN_GET_OWNER | FS_CAN_GET_GROUP | FS_CAN_GET_PERMISSIONS; - public static final int FS_CAN_SET_ALL = FS_CAN_SET_OWNER | FS_CAN_SET_GROUP | FS_CAN_SET_PERMISSIONS; - - - /** - * Gets the permissions for a file including the user and group owner - * - * @param file the remote file - * @param monitor the monitor for this potentially long running operation - * @return the host file permissions - * @throws SystemMessageException if an error occurs. - * Typically this would be one of those in the RemoteFileException family. - */ - public IHostFilePermissions getFilePermissions(IHostFile file, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Sets the permissions for a file including the user and group owner as specified in the permissions - * - * @param file the remote file - * @param permissions the new permissions for this file - * @param monitor the monitor for this potentially long running operation - * @throws SystemMessageException if an error occurs. - * Typically this would be one of those in the RemoteFileException family. - */ - public void setFilePermissions(IHostFile file, IHostFilePermissions permissions, IProgressMonitor monitor) throws SystemMessageException; - - - /** - * Returns the capabilities of this file permissions service for the corresponding file. If - * null is specified, this returns the general capabilities of this service. - * - * @param file the remote file - * @return the capabilities of this service against this file - */ - public int getCapabilities(IHostFile file); - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java deleted file mode 100644 index 4a79fa3cc..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java +++ /dev/null @@ -1,638 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API - * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem - * Martin Oberhuber (Wind River) - [199548] Avoid touching files on setReadOnly() if unnecessary - * Martin Oberhuber (Wind River) - [204710] Update Javadoc to mention that getUserHome() may return null - * David McKnight (IBM) - [207178] changing list APIs for file service and subsystems - * David McKnight (IBM) - [162195] new APIs for upload multi and download multi - * David McKnight (IBM) - [209552] API changes to use multiple and getting rid of deprecated - * David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants - * Kevin Doyle (IBM) - [208778] new API getOutputSteam for getting an output stream in append mode - * David McKnight (IBM) - [209704] added supportsEncodingConversion() - * Martin Oberhuber (Wind River) - [cleanup] Fix API since tags - * David Dykstal (IBM) - [221211] clarifying javadoc on batch operations - * David Dykstal (IBM) - [221211] fix IFileService API for batch operations - * Radoslav Gerganov (ProSyst) - [230919] IFileService.delete() should not return a boolean - * Martin Oberhuber (Wind River) - [234026] Clarify IFileService#createFolder() Javadocs - *******************************************************************************/ - -package org.eclipse.rse.services.files; - -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.rse.services.IService; -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; - -/** - * A IFileService is an abstraction of a file service that runs over some sort - * of connection. It can be shared among multiple instances of a subsystem. At - * some point this file service layer may become official API but for now it is - * experimental. Each subsystem is currently responsible for layering an - * abstraction over whatever it wants to construct as a service. - * <p> - * This is a very bare bones definition. A real definition would probably have - * changed terminology, use URI's rather than Strings, and have much more robust - * error handling. - * </p> - * <p> - * Implementers of this interface will have to either be instantiated, - * initialized, or somehow derive a connection as part of its state. - * </p> - * @noimplement This interface is not intended to be implemented by clients. - * File service implementations must subclass - * {@link AbstractFileService} rather than implementing this - * interface directly. - */ -public interface IFileService extends IService -{ - /** - * Query constant (bit mask value 1) which indicates that a query should be - * on files. The filter(s) passed into the list methods will produce a - * subset of files matching the filter(s). - * - * This constant is passed into the IFileService list calls. Implementors of - * IFileService make use of this to determine what to query and what to - * return from the query. - * - * @see IFileService#list(String,String,int,IProgressMonitor) - * @see IFileService#listMultiple(String[],String[],int,List,IProgressMonitor) - * @see IFileService#listMultiple(String[],String[],int[],List,IProgressMonitor) - * - * @since org.eclipse.rse.services 3.0 - */ - public static final int FILE_TYPE_FILES = 0x1; - - /** - * Query constant (bit mask value 2) which indicates that a query should be - * on folders. The filter(s) passed into the list methods will produce a - * subset of folders matching the filter(s). - * - * This constant is passed into the IFileService list calls. Implementors of - * IFileService make use of this to determine what to query and what to - * return from the query. - * - * @see IFileService#list(String,String,int,IProgressMonitor) - * @see IFileService#listMultiple(String[],String[],int,List,IProgressMonitor) - * @see IFileService#listMultiple(String[],String[],int[],List,IProgressMonitor) - * - * @since org.eclipse.rse.services 3.0 - */ - public static final int FILE_TYPE_FOLDERS = 0x2; - - /** - * Query constant (bit mask value 0) which indicates that a query should - * produce folders and files. The filter(s) passed into the list methods - * will produce a subset of files matching the filter(s) and all the - * folders. Note that only files are filtered and all folders are returned - * when this is used. - * - * This constant is passed into the IFileService list calls. Implementors of - * IFileService make use of this to determine what to query and what to - * return from the query. - * - * @see IFileService#list(String,String,int,IProgressMonitor) - * @see IFileService#listMultiple(String[],String[],int,List,IProgressMonitor) - * @see IFileService#listMultiple(String[],String[],int[],List,IProgressMonitor) - * - * @since org.eclipse.rse.services 3.0 - */ - public static final int FILE_TYPE_FILES_AND_FOLDERS = 0x0; - - /** - * Options constant (value 1 <<0) for specifying a stream that will - * append data to a file. - * - * @see IFileService#getOutputStream(String, String, int, IProgressMonitor) - * - * @since org.eclipse.rse.services 3.0 - */ - public static final int APPEND = 1 << 0; - - /** - * Options constant (value 2 <<0) for specifying that a file is Text - * instead of the default Binary. - * - * In Text mode, encoding conversions and line end conversions can be - * performed on the stream. - * - * @see IFileService#getOutputStream(String, String, int, IProgressMonitor) - * - * @since org.eclipse.rse.services 3.0 - */ - public static final int TEXT_MODE = 2 << 0; - - /** - * Options constant (value 0) to indicate that no bit options are set. - * - * @since org.eclipse.rse.services 3.0 - */ - public static final int NONE = 0; - - /** - * Copy a file to the remote file system. The remote target is denoted by a - * string representing the parent and a string representing the file. - * @param stream input stream to transfer - * @param remoteParent - a string designating the parent folder of the target for this file. - * @param remoteFile - a string designating the name of the file to be written on the remote system. - * @param isBinary - indicates whether the file is text or binary - * @param hostEncoding - the tgt encoding of the file (if text) - * @param monitor the monitor for this potentially long running operation - * @throws SystemMessageException if an error occurs. - * Typically this would be one of those in the RemoteFileException family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void upload(InputStream stream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Copy a file to the remote file system. The remote target is denoted by a - * string representing the parent and a string representing the file. - * @param localFile - a real file in the local file system. - * @param remoteParent - a string designating the parent folder of the target for this file. - * @param remoteFile - a string designating the name of the file to be written on the remote system. - * @param isBinary - indicates whether the file is text or binary - * @param srcEncoding - the src encoding of the file (if text) - * @param hostEncoding - the tgt encoding of the file (if text) - * @param monitor the monitor for this potentially long running operation - * @throws SystemMessageException if an error occurs. - * Typically this would be one of those in the - * {@link RemoteFileException} family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException; - - - /** - * Copy files to the remote file system. The remote target is denoted by - * strings representing the parents and strings representing the files. - * <p> - * If an error occurs during the upload of a file, this operation stops on that file and a {@link SystemMessageException} is thrown. - * Files uploaded before that file will remain uploaded. Files in the list after that file will not be uploaded. - * The file on which the error occurs will not be uploaded. - * @param localFiles - real files in the local file system. - * @param remoteParents - strings designating the parent folders of the target for the files. - * @param remoteFiles - strings designating the names of the files to be written on the remote system. - * @param isBinary - indicates whether the files are text or binary - * @param srcEncodings - the src encodings of the files (if text) - * @param hostEncodings - the tgt encodings of the files (if text) - * @param monitor the monitor for this potentially long running operation - * @throws SystemMessageException if an error occurs. - * Typically this would be one of those in the - * {@link RemoteFileException} family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void uploadMultiple(File[] localFiles, String[] remoteParents, String[] remoteFiles, boolean[] isBinary, String[] srcEncodings, String[] hostEncodings, IProgressMonitor monitor) throws SystemMessageException; - - - /** - * Copy a file from the remote file system to the local system. - * @param remoteParent - a String designating the remote parent. - * @param remoteFile - a String designating the remote file residing in the parents. - * @param localFile - The file that is to be written. If the file exists it is - * overwritten. - * @param isBinary - indicates whether the file is text on binary - * @param hostEncoding - the encoding on the host (if text) - * @param monitor the monitor for this potentially long running operation - * @throws SystemMessageException if an error occurs. - * Typically this would be one of those in the - * {@link RemoteFileException} family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Copy files from the remote file system to the local system. - * <p> - * If an error occurs during the download of a file, this operation stops on that file and a {@link SystemMessageException} is thrown. - * Files downloaded before that file will remain downloaded. Files in the list after that file will not be downloaded. - * The file on which the error occurs will not be downloaded. - * - * @param remoteParents - string designating the remote parents. - * @param remoteFiles - Strings designating the remote files residing in the - * parents. - * @param localFiles - The files that are to be written. If the files exists - * they are overwritten. - * @param isBinary - indicates whether the files are text on binary - * @param hostEncodings - the encodings on the host (if text) - * @param monitor the monitor for this potentially long running operation - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the {@link RemoteFileException} family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void downloadMultiple(String[] remoteParents, String[] remoteFiles, File[] localFiles, boolean[] isBinary, String[] hostEncodings, IProgressMonitor monitor) throws SystemMessageException; - - - - /** - * Get an abstract remote file handle for a specified path. - * - * @param remoteParent the name of the parent directory on the remote file - * system from which to retrieve the file. - * @param name the name of the file to be retrieved. - * @param monitor the monitor for this potentially long running operation - * @return the host file given the parent path and file name. Must not - * return <code>null</code>, non-existing files should be - * reported with an IHostFile object where - * {@link IHostFile#exists()} returns <code>false</code>. - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - */ - public IHostFile getFile(String remoteParent, String name, IProgressMonitor monitor) throws SystemMessageException; - - - /** - * List the contents of a remote folder. - * - * @param remoteParent - the name of the parent directory on the remote file - * system from which to retrieve the child list. - * @param fileFilter - a string that can be used to filter the children. - * Only those files matching the filter make it into the list. - * The interface does not dictate where the filtering occurs. - * @param fileType - indicates whether to query files, folders, both or some - * other type - * @param monitor the monitor for this potentially long running operation - * @return the list of host files. - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - * - * @since org.eclipse.rse.services 3.0 - */ - public IHostFile[] list(String remoteParent, String fileFilter, int fileType, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Get multiple abstract remote file handles for an array of specified - * paths. - * <p> - * If an error occurs during the retrieval an item, this operation stops on that item and a {@link SystemMessageException} is thrown. - * Items retrieved before that item will be returned. Items to be retrieved after that item will not be retrieved. - * The items on which the error occurs will not be retrieved. - * - * @param remoteParents - the list of remote parents - * @param names - the list of file names - * @param hostFiles a list to which the retrieved {@link IHostFile} objects will be appended - * @param monitor the monitor for this potentially long running operation - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void getFileMultiple(String remoteParents[], String names[], List hostFiles, IProgressMonitor monitor) throws SystemMessageException; - - /** - * List the contents of multiple remote folders. - * <p> - * If an error occurs during the retrieval of the contents of a folder, this operation stops on that folder and a {@link SystemMessageException} is thrown. - * Items retrieved before that folder will be returned. Items in folders after that folder will not be retrieved. - * The items in the folder on which the error occurs will not be returned. - * - * @param remoteParents - the names of the parent directories on the remote - * file system from which to retrieve the collective child list. - * @param fileFilters - a set of strings that can be used to filter the - * children. Only those files matching the filter corresponding - * to it's remoteParent make it into the list. The interface does - * not dictate where the filtering occurs. For each remoteParent, - * there must be a corresponding fileFilter. - * @param fileTypes - indicates whether to query files, folders, both or - * some other type. For each remoteParent, there must be a - * corresponding fileType. For the default list of available file - * types see <code>IFileServiceContants</code> - * @param hostFiles a list to which the found {@link IHostFile} objects will be appended - * @param monitor the monitor for this potentially long running operation - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void listMultiple(String[] remoteParents, String[] fileFilters, int[] fileTypes, List hostFiles, IProgressMonitor monitor) throws SystemMessageException; - - /** - * List the contents of multiple remote folders. - * <p> - * If an error occurs during the retrieval of the contents of a folder, this operation stops on that folder and a {@link SystemMessageException} is thrown. - * Items retrieved before that folder will be returned. Items in folders after that folder will not be retrieved. - * The items in the folder on which the error occurs will not be returned. - * - * @param remoteParents - the names of the parent directories on the remote - * file system from which to retrieve the collective child list. - * @param fileFilters - a set of strings that can be used to filter the - * children. Only those files matching the filter corresponding - * to it's remoteParent make it into the list. The interface does - * not dictate where the filtering occurs. For each remoteParent, - * there must be a corresponding fileFilter. - * @param fileType - indicates whether to query files, folders, both or some - * other type. All results will be of the specified type. For the - * default list of available file types see - * <code>IFileServiceContants</code> - * @param hostFiles a list to which the found {@link IHostFile} objects will be appended - * @param monitor the monitor for this potentially long running operation - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void listMultiple(String[] remoteParents, String[] fileFilters, int fileType, List hostFiles, IProgressMonitor monitor) throws SystemMessageException; - - - /** - * Get abstract remote file handles for the known remote file system roots. - * - * @param monitor the monitor for this potentially long running operation - * Return the list of roots for this system - * @return the list of host files. - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - */ - public IHostFile[] getRoots(IProgressMonitor monitor) throws SystemMessageException; - - /** - * Return the user's home directory on this connection. - * - * The resulting IHostFile object is just a handle, so there is no guarantee - * that it refers to an existing file. - * - * This method may also return <code>null</code> if the home directory could - * not be determined (for instance, because the connection is not yet connected). - * In this case, clients are encouraged to query the home directory again once - * the connection is connected. - * - * @return A handle to the current user's home directory, or <code>null</code> - * if the home directory could not be determined. - */ - public IHostFile getUserHome(); - - /** - * Create a file on the host. - * - * @param remoteParent the parent directory - * @param fileName the name of the new file - * @param monitor the monitor for this potentially long running operation - * @return the newly created file - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - */ - public IHostFile createFile(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Create a folder on the host. - * - * Implementations are free to create missing parent folders or fail with a - * SystemMessageException if the parent folder does not yet exist. In - * general, creating missing parent folders is recommended if it doesn't - * require additional client-server round trips. Therefore the "Local" and - * "DStore" services do create missing parent folders. - * - * @param remoteParent the parent directory - * @param folderName the name of the new folder - * @param monitor the progress monitor - * @return the newly created folder - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - */ - public IHostFile createFolder(String remoteParent, String folderName, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Delete a file or folder on the host. - * - * @param remoteParent the folder containing the file to delete - * @param fileName the name of the file or folder to delete - * @param monitor the progress monitor - * @throws SystemMessageException if an error occurs or the user canceled - * the operation. SystemElementNotFoundException is thrown if the remote - * file doesn't exist. - * - * @since org.eclipse.rse.services 3.0 - */ - public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Delete a set of files or folders on the host. Should throw an exception - * if some files and folders were deleted and others were not due to an - * exception during the operation. Without an exception thrown in such - * cases, views may not be refreshed correctly to account for deleted - * resources. - * <p> - * If an error occurs during the deletion of an item, this operation stops on that item and a {@link SystemMessageException} is thrown. - * Items deleted before that item will remain deleted. Items specified after that item will not be deleted. - * The item on which the error occurs will not be deleted. - * - * @param remoteParents the array of folders containing the files to delete - * @param fileNames the names of the files or folders to delete - * @param monitor the progress monitor - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Rename a file or folder on the host. - * - * @param remoteParent the folder containing the file to rename - * @param oldName the old name of the file or folder to rename - * @param newName the new name for the file - * @param monitor the progress monitor - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Rename a file or folder on the host. - * - * @param remoteParent the folder containing the file to rename - * @param oldName the old name of the file or folder to rename - * @param newName the new name for the file - * @param oldFile the file to update with the change - * @param monitor the progress monitor - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Move the file or folder specified to a different remote path. - * - * @param srcParent the folder containing the file or folder to move - * @param srcName the new of the file or folder to move - * @param tgtParent the destination folder for the move - * @param tgtName the name of the moved file or folder - * @param monitor the progress monitor - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Copy the file or folder to the specified destination. - * - * @param srcParent the folder containing the file or folder to copy - * @param srcName the new of the file or folder to copy - * @param tgtParent the destination folder for the copy - * @param tgtName the name of the copied file or folder - * @param monitor the progress monitor - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Copy a set of files or folders to the specified destination. - * <p> - * If an error occurs during the copy of an item, this operation stops on that item and a {@link SystemMessageException} is thrown. - * Items copied before that item will remain copied. Items copied after that item will not be copied. - * The item on which the error occurs will not be copied. - * - * @param srcParents the folders containing each file or folder to copy - * @param srcNames the names of the files or folders to copy - * @param tgtParent the destination folder for the copy - * @param monitor the progress monitor - * @throws SystemMessageException if an error occurs. Typically this would - * be one of those in the RemoteFileException family. - * - * @since org.eclipse.rse.services 3.0 - */ - public void copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Indicates whether the file system is case sensitive. - * - * @return true if the file system has case sensitive file names - */ - public boolean isCaseSensitive(); - - /** - * Set the last modified stamp of the file or folder with the specified - * timestamp. - * - * Note that the precision to which the underlying file system supports last - * modified times may vary. Therefore, even if this method successfully sets - * the timestamp, there is no guarantee that the - * {@link IHostFile#getModifiedDate()} method after a following - * {@link #getFile(String, String, IProgressMonitor)} call returns exactly - * the same timestamp. - * - * @param parent the parent path of the file to set - * @param name the name of the file to set - * @param timestamp the new timestamp in milliseconds from January 1, 1970, - * 00:00:00 UTC. - * @param monitor the progress monitor - * @see IHostFile#getModifiedDate() - * - * @since org.eclipse.rse.services 3.0 - */ - public void setLastModified(String parent, String name, long timestamp, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Set the read-only permission of the specified file or folder. - * - * @param parent the parent path of the file to set - * @param name the name of the file to set - * @param readOnly indicates whether to make the file read-only or - * read-write - * @param monitor the progress monitor - * - * @since org.eclipse.rse.services 3.0 - */ - public void setReadOnly(String parent, String name, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Gets the remote encoding. - * @param monitor the progress monitor. - * @return the encoding. - * @throws SystemMessageException if an error occurs. - * @since 2.0 - */ - public String getEncoding(IProgressMonitor monitor) throws SystemMessageException; - - /** - * Get the input stream to access the contents a remote file. Clients should - * close the input stream when done. - * - * @param remoteParent the absolute path of the parent. - * @param remoteFile the name of the remote file. - * @param isBinary <code>true</code> if the file is a binary file, - * <code>false</code> otherwise. - * @param monitor the progress monitor. - * @return the input stream to access the contents of the remote file. - * @throws SystemMessageException if an error occurs. - * @since org.eclipse.rse.services 2.0 - */ - public InputStream getInputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Get the output stream to write to a remote file. Clients should close the - * output stream when done. - * - * @param remoteParent the absolute path of the parent. - * @param remoteFile the name of the remote file. - * @param isBinary <code>true</code> if the file is a binary file, - * <code>false</code> otherwise. - * @param monitor the progress monitor. - * @return the input stream to access the contents of the remote file. - * @throws SystemMessageException if an error occurs. - * @since org.eclipse.rse.services 2.0 - * @deprecated Use - * {@link #getOutputStream(String, String, int, IProgressMonitor)} - * instead - */ - public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Get the output stream to write/append to a remote file. Clients should - * close the output stream when done. - * - * @param remoteParent the absolute path of the parent. - * @param remoteFile the name of the remote file. - * @param options bit wise or of option constants. Valid constants are - * {@link IFileService#APPEND}, {@link IFileService#TEXT_MODE}, - * and {@link IFileService#NONE} - * @param monitor the progress monitor. - * @return the input stream to access the contents of the remote file. - * @throws SystemMessageException if an error occurs. - * @since org.eclipse.rse.services 3.0 - */ - public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Indicates whether this file service supports code page conversion using - * the IFileServiceCodePageConverter mechanism. Certain extensions, such as - * property pages for encoding conversion can determine whether or not to - * display or enable themselves based on result of this call. - * - * @return whether this service supports encoding conversion - * - * @since org.eclipse.rse.services 3.0 - */ - public boolean supportsEncodingConversion(); -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileServiceCodePageConverter.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileServiceCodePageConverter.java deleted file mode 100644 index 6f6abd7fa..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileServiceCodePageConverter.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2007, 2008 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight. - * - * Contributors: - * David McKnight (IBM) -[209704] [api] Ability to override default encoding conversion needed. - * David McKnight (IBM) -[220379] [api] Provide a means for contributing custom BIDI encodings - ********************************************************************************/ - -package org.eclipse.rse.services.files; - -import java.io.File; - - -/** - * This interface is used by the extension point - * It allows overriding the Universal File Subsystem translation of files, and results in - * binary transfer, with calls to the implementor to handle code page conversion. - * @since org.eclipse.rse.services 3.0 - */ -public interface IFileServiceCodePageConverter { - - /** - * Converts a client string to remote bytes, for use when uploading in binary mode. - * @param remotePath the path of the remote file - * @param clientString the client string to convert - * @param remoteEncoding The remote encoding for the desired server bytes - * @param fs The file service to apply conversion to. - * Can be used to determine implementation specific settings to the converter - * @return The bytes to upload to the server - */ - public byte [] convertClientStringToRemoteBytes(String remotePath, String clientString, String remoteEncoding, IFileService fs); - - /** - * Converts the specified file (which was downloaded from the server in binary mode) from server encoding bytes, to local encoding - * @param remotePath the path of the remote file - * @param file The file to convert - * @param localEncoding The remote encoding of the file - * @param fs The file service to apply conversion to. - * Can be used to determine implementation specific settings to the converter - */ - public void convertFileFromRemoteEncoding(String remotePath, File file, String remoteEncoding, String localEncoding, IFileService fs); - - /** - * Indicates whether or not the specified server encoding and subsystem implementation is supported by this code page converter - * @param remoteEncoding The remote encoding from the server to check - * @param fs The file service to apply conversion to. - * Can be used to determine implementation specific settings to the converter - * @return True if this code page converter can convert the specified encoding, false otherwise - */ - public boolean isServerEncodingSupported(String remoteEncoding, IFileService fs); - - /** - * Indicates the priority of this code page converter if more than one code page converter - * handle a particular encoding. The lower the number, the higher the priority. - * @return priority - */ - public int getPriority(String remoteEncoding, IFileService fs); - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IHostFile.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IHostFile.java deleted file mode 100644 index 210daef0b..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IHostFile.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.services.files; - -/** - * Objects that conform to this interface are delivered by the file services to their clients. - * These objects are meant to represent objects that are files or file-like objects on a - * remote system. These would include files, folders, directories, archives and the like. - * <p> - * These objects are typically "handle" objects and can be created even though their corresponding - * remote resources do not exist - in this case, the {@link #exists()} method will return - * <code>false</code>. - * <p> - * @see IFileService - */ -public interface IHostFile { - /** - * Gets the simple name of the file object on the remote system. - * - * @return The name of the file object on the remote system devoid of any qualifying path - * information. - */ - public String getName(); - - /** - * Gets the absolute path name of the parent object of this object on the remote file system. - * - * @return The fully qualified path of any parent object for this file. This would typically be the - * string representation of the absolute path as interpreted by the remote file system. Returns - * <code>null</code> if {@link #isRoot()} is true. - */ - public String getParentPath(); - - /** - * Gets the fully qualified path to this object in the remote file system. - * - * The name is constructed as it would be used on the remote file system. - * This string can be interpreted and used by its file service to locate - * this object on the remote file system beginning at the file system root. - * - * @return a String representing the path name. Never returns <code>null</code>. - */ - public String getAbsolutePath(); - - /** - * Determines if the file system object is hidden on the remote file system. - * - * @return true if and only if the file on the remote system has a "hidden" attribute or a naming - * convention that would normal indicate that it was hidden when listing the contents of its parent - * on that file system. It is up to the file services to conform to the correct notion of "hidden" for - * the remote systems they support. - */ - public boolean isHidden(); - - /** - * Determines if the file system object is a directory on the remote file system. - * - * @return true if and only if the object on the remote system is a directory. That is, it contains - * entries that can be interpreted as other IHostFile objects. A return value of true does not - * necessarily imply that isFile() returns false. - */ - public boolean isDirectory(); - - /** - * Determines if the file system object is a "root" directory on the remote file system. - * - * @return true if and only if the object on the remote system is a directory whose simple name and - * absolute path name are the same. - */ - public boolean isRoot(); - - /** - * Determines if the file system object is a file on the remote file system. - * - * @return true if and only if the object on the remote system can be considered to have "contents" that - * have the potential to be read and written as a byte or character stream. A return value of true - * does not necessarily imply that {@link #isDirectory()} returns false. - */ - public boolean isFile(); - - /** - * Determines if the file system object is "writeable" on the remote file system. - * - * @return true if and only if the object on the remote system is a file that can be written. This could - * mean that there is write permission granted to this user or perhaps a "writable" attribute is set for the - * file. It is up to the file services to conform to the correct notion of "writable" for the remote - * systems they support. For directory objects this should return true if the child objects may be added - * to or removed from the directory. - */ - public boolean canWrite(); - - /** - * Determines if the file system object is "readable" on the remote file system. - * - * @return true if and only if the object on the remote system is a file that can be read. This could - * mean that there is read permission granted to this user or perhaps a "readable" attribute is set for the - * file. It is up to the file services to conform to the correct notion of "readable" for the remote - * systems they support. For directory objects this should return true if the user can determine the children - * of the directory. - */ - public boolean canRead(); - - /** - * Determines if the file system object exists on the remote file system. - * - * @return true if and only if the remote object represented by this object exists - * in the remote file system. Symbolic links on a UNIX file system exist even if - * the target they point to does not exist. - */ - public boolean exists(); - - /** - * Determines if the file system object represents an archive on the remote file system. - * - * @return true if and only if the remote object is a file that can be "extracted" to contain other files. - * Examples would be tar and zip files. It is up to the file services to conform to the correct notion of - * "archive" for the remote systems they support. If a file service creates an object with - * this attribute as true then the file service must be able to extract the contents of the archive. - */ - public boolean isArchive(); - - /** - * Gets the size of the file system object on the remote file system in bytes if isFile() is true. - * If the storage unit on the remote system is not bytes then the file service creating this must - * convert the remote value to bytes. - * - * @return the size in bytes of the file if {@link #isFile()} is true, 0L otherwise. - */ - public long getSize(); - - /** - * Gets a timestamp representing the date and time of last modification to the file. - * - * @return the timestamp as obtained from the remote file system. - * The timestamp represents the time the file was modified in milliseconds from January 1, 1970, 00:00:00 UTC. - * Note that even so, comparison of timestamps between systems should be avoided since clock resolution and - * accuracy vary widely from system to system. - * It may be necessary to convert from the timestamp of a remote file system to this format. - */ - public long getModifiedDate(); - - /** - * Renames this abstract file handle. - * - * This does not physically rename the corresponding file on the - * remote system, it merely updates internal bookkeeping for a - * rename operation that needs to be performed separately through - * an instance of @see IFileService. - * - * Therefore, this method cannot fail and no return value is given. - * - * @param newAbsolutePath The new path on the remote file system that - * this file will be renamed to. - */ - public void renameTo(String newAbsolutePath); - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IHostFilePermissions.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IHostFilePermissions.java deleted file mode 100644 index 7c3ffb751..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IHostFilePermissions.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2008 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight. - * - * Contributors: - * David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files - ********************************************************************************/ -package org.eclipse.rse.services.files; - - -/** - * Interface for file permission and ownership support in RSE - * IFileService. An implementation of an IHostFilePermissions - * object is expected to be a data storage for permission and - * ownership information. - * @since 3.0 - */ -public interface IHostFilePermissions { - - /** - * Permission constant indicating that - * the user can read this file - */ - public static final int PERM_USER_READ = 1 << 8; - - /** - * Permission constant indicating that - * the user can write to this file - */ - public static final int PERM_USER_WRITE = 1 << 7; - - /** - * Permission constant indicating that - * the user can execute this file - */ - public static final int PERM_USER_EXECUTE = 1 << 6; - - /** - * Permission constant indicating that - * the group can read this file - */ - public static final int PERM_GROUP_READ = 1 << 5; - - /** - * Permission constant indicating that - * the group can write to this file - * - */ - public static final int PERM_GROUP_WRITE = 1 << 4; - - /** - * Permission constant indicating that - * the group can execute this file - * - */ - public static final int PERM_GROUP_EXECUTE = 1 << 3; - - /** - * Permission constant indicating that - * other users can read this file - * - */ - public static final int PERM_OTHER_READ = 1 << 2; - - /** - * Permission constant indicating that - * other users can write to this file - * - */ - public static final int PERM_OTHER_WRITE = 1 << 1; - - /** - * Permission constant indicating that - * other users can execute to this file - * - */ - public static final int PERM_OTHER_EXECUTE = 1 << 0; - - - // support masks - public static final int PERM_ANY_READ = PERM_USER_READ | PERM_GROUP_READ | PERM_OTHER_READ; - public static final int PERM_ANY_WRITE = PERM_USER_WRITE | PERM_GROUP_WRITE | PERM_OTHER_WRITE; - public static final int PERM_ANY_EXECUTE = PERM_USER_EXECUTE | PERM_GROUP_EXECUTE | PERM_OTHER_EXECUTE; - - /** - * Set or reset all the permission bits from the given bitmask. - * - * @param bitmask the permission(s) bits to modify - * @param value whether to turn on off of the permission(s) - * - * Example: setPermission(PERM_USER_WRITE | PERM_GROUP_WRITE, true); - */ - public void setPermission(int bitmask, boolean value); - - /** - * Test if any of the permission bits from the bitmask are set. - * - * @param bitmask the permission(s) to check for - * @return true if one of the permission bits is set - * - * Example: getPermission(PERM_USER_WRITE | PERM_GROUP_WRITE) - */ - public boolean getPermission(int bitmask); - - /** - * Get the set of permission bits. - * - * @return set of permission bits - */ - public int getPermissionBits(); - - /** - * Set the permission bits - * @param bits the set of permission bits - */ - public void setPermissionBits(int bits); - - - /** - * return permissions in rwxrwxrwx form - */ - public String toAlphaString(); - - /** - * returns the user owner of the file - * @return the user owner - */ - public String getUserOwner(); - - /** - * returns the group owner of the file - * @return the group owner - */ - public String getGroupOwner(); - - /** - * Sets the user owner attribute - * @param user the user owner attribute - */ - public void setUserOwner(String user); - - /** - * Sets the group owner attribute - * @param group the group owner attribute - */ - public void setGroupOwner(String group); - - /** - * Creates and returns a copy of this object, as specified - * by the {@link Object#clone()} contract. - * - * Each implementer of the IHostFilePermission API must properly implement - * this method and implement the {@link Cloneable} interface. - * @return the cloned object - * @throws CloneNotSupportedException if an instance cannot be cloned for - * any reason, e.g. because its state contains complex objects that - * cannot be cloned. - * @see Object#clone() - */ - public Object clone() throws CloneNotSupportedException; -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IHostFilePermissionsContainer.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IHostFilePermissionsContainer.java deleted file mode 100644 index 30bb91b96..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IHostFilePermissionsContainer.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2008 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ -package org.eclipse.rse.services.files; - -/** - * A container of permissions. Implementations of IHostFile that support - * IHostFilePermissions should implement this too - * @since 3.0 - */ -public interface IHostFilePermissionsContainer { - - /** - * Returns the host file permissions (including user and group) for this file - * @return the host file permissions - */ - public IHostFilePermissions getPermissions(); - - /** - * TODO remove this API - here for now because we want to prevent duplicate - * query jobs from being triggered from SystemViewRemoteFileAdapter.getPropertyValue() - * - * Sets the permissions attributes for this file. Right now, using this - * to set a dummy "Pending" set of permissions from UI when doing asynchronous queries - * from property sheet or table view - */ - public void setPermissions(IHostFilePermissions permissions); - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/PendingHostFilePermissions.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/PendingHostFilePermissions.java deleted file mode 100644 index 12de1d1a0..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/PendingHostFilePermissions.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2008 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ -package org.eclipse.rse.services.files; - -/** - * A dummy HostFilePermissions node that can be used for deferred - * query of permissions. Clients who want to read permissions but - * see this pending node need to wait until the real permissions - * get available. - * - * @since 3.0 - */ -public class PendingHostFilePermissions extends HostFilePermissions { - - public PendingHostFilePermissions() - { - super(0, "Pending", "Pending"); //$NON-NLS-2$ - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFileCancelledException.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFileCancelledException.java deleted file mode 100644 index 49c44ab50..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFileCancelledException.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [216351] Improve cancellation of SystemFetchOperation for files - * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - * Martin Oberhuber (Wind River) - [226374] [api] Need default SystemMessageException specialisations - *******************************************************************************/ - -package org.eclipse.rse.services.files; - -import org.eclipse.rse.services.clientserver.messages.SystemOperationCancelledException; - -/** - * Exception thrown when attempting a file operation and the user cancelled it - * before it could be completed. Used to extend RemoteFileException before 3.0 - * - * @deprecated use SystemOperationCancelledException - * @since 3.0 - */ -public class RemoteFileCancelledException extends SystemOperationCancelledException { - - /** - * A serialVersionUID is recommended for all serializable classes. This - * trait is inherited from Throwable. This should be updated if there is a - * schema change for this class. - */ - private static final long serialVersionUID = 1L; - - /** - * Constructor - */ - public RemoteFileCancelledException() { - super(); - } -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFileException.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFileException.java deleted file mode 100644 index 94ff44ee3..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFileException.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [226374] [api] Need default SystemMessageException specialisations - *******************************************************************************/ - -package org.eclipse.rse.services.files; -import java.util.ResourceBundle; - -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemRemoteMessageException; - - -/** - * Base class for remote file system exceptions. - * <p> - * All remote file exceptions are guaranteed to have a translated message - * retrievable via getMessage(), to make it easy to display to the user. - * <p> - * All child exceptions potentially contain an embedded exception that is the - * original exception from the remote system. - * <p> - * Use {#link getRemoteException()} to retrieve that wrapped exception, if any. - * Extends SystemRemoteMessageException since 3.0 - * - * @since 3.0 - */ -public class RemoteFileException extends SystemRemoteMessageException -{ - /** - * A serialVersionUID is recommended for all serializable classes. - * This trait is inherited from Throwable. - * This should be updated if there is a schema change for this class. - */ - private static final long serialVersionUID = 1L; - - /** - * Constructor for RemoteFileException with an error message for getMessage() to return. - * @param bundle The ResourceBundle containing the error message - * @param key The key to retrieve the message - */ - public RemoteFileException(ResourceBundle bundle, String key) - { - this(getString(bundle,key), null); - } - /** - * Constructor for RemoteFileException with an error message for getMessage() to return. - * @param msg The fully resolved message - */ - public RemoteFileException(String msg) - { - this(msg, null); - } - /** - * Constructor for RemoteFileException with an error message for getMessage() to return, - * and a wrapped exception to contain. It is accessed via getRemoteException(). - * @param bundle The ResourceBundle containing the error message - * @param key The key to retrieve the message - * @param remoteException The exception to contain within this exception - */ - public RemoteFileException(ResourceBundle bundle, String key, Exception remoteException) - { - this(getString(bundle,key), remoteException); - } - /** - * Constructor for RemoteFileException with an error message for getMessage() to return. - * and a wrapped exception to contain. It is accessed via getRemoteException(). - * @param msg The fully resolved message - * @param remoteException The exception to contain within this exception - */ - public RemoteFileException(String msg, Exception remoteException) - { - super(msg, remoteException); - } - - /** - * Constructor for RemoteFileException with an error message for getMessage() to return. - * @param msg The fully resolved message - */ - public RemoteFileException(SystemMessage msg) - { - this(msg, null); - } - /** - * Constructor for RemoteFileException with an error message for getMessage() to return. - * and a wrapped exception to contain. It is accessed via getRemoteException(). - * @param msg The fully resolved message - * @param remoteException The exception to contain within this exception - */ - public RemoteFileException(SystemMessage msg, Exception remoteException) - { - super(msg, remoteException); - } - - private static String getString(ResourceBundle bundle, String key) - { - String msg = null; - try { msg = bundle.getString(key); } catch (Exception exc) {} - if (msg == null) - msg = "Message with key " + key + " not found"; //$NON-NLS-1$ //$NON-NLS-2$ - return msg; - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFileIOException.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFileIOException.java deleted file mode 100644 index 00d963465..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFileIOException.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - *******************************************************************************/ - -package org.eclipse.rse.services.files; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.osgi.util.NLS; - -import org.eclipse.rse.internal.services.Activator; -import org.eclipse.rse.internal.services.RSEServicesMessages; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; - -/** - * Exception thrown when attempting an operation and it fails for IO reasons, such as - * the file is read-only. - * <p> - * The original remote system's io message is always embedded and retrievable - * via getRemoteException(). - */ -public class RemoteFileIOException extends RemoteFileException { - - /** - * A serialVersionUID is recommended for all serializable classes. - * This trait is inherited from Throwable. - * This should be updated if there is a schema change for this class. - */ - private static final long serialVersionUID = 1L; - private static SystemMessage myMessage = null; - - /** - * Constructor for RemoteFileIOException - * @param remoteException the initial cause of this exception - */ - public RemoteFileIOException(Exception remoteException) { - super(getMyMessage(Activator.PLUGIN_ID, remoteException), remoteException); - - } - - /** - * Constructor for RemoteFileIOException that also takes a pluginId - * - * @param pluginId a plugin ID - * @param remoteException the initial cause of this exception - * @since 3.0 - */ - public RemoteFileIOException(String pluginId, Exception remoteException) { - super(getMyMessage(pluginId, remoteException), remoteException); - - } - - private static SystemMessage getMyMessage(String pluginId, Exception remoteException) { - - String secondLevel = remoteException.getMessage(); - if (secondLevel == null) { - secondLevel = remoteException.getClass().getName(); - } - - String msgTxt = RSEServicesMessages.FILEMSG_OPERATION_FAILED; - String msgDetails = NLS.bind(RSEServicesMessages.FILEMSG_OPERATION_FAILED_DETAILS, secondLevel); - - myMessage = new SimpleSystemMessage(pluginId, - "RSEF1002", //$NON-NLS-1$ - IStatus.ERROR, msgTxt, msgDetails); - - return myMessage; - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFileSecurityException.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFileSecurityException.java deleted file mode 100644 index 0b44e86e5..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFileSecurityException.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - * Martin Oberhuber (Wind River) - [226374] [api] Need default SystemMessageException specialisations - *******************************************************************************/ - -package org.eclipse.rse.services.files; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.osgi.util.NLS; - -import org.eclipse.rse.internal.services.Activator; -import org.eclipse.rse.internal.services.RSEServicesMessages; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; - -/** - * Exception thrown when attempting an operation and it fails for security - * reasons. The original remote system's security message is always embedded and - * retrievable via getRemoteException(). - * - * @deprecated Use SystemRemoteSecurityException - */ -public class RemoteFileSecurityException extends RemoteFileException { - - /** - * A serialVersionUID is recommended for all serializable classes. - * This trait is inherited from Throwable. - * This should be updated if there is a schema change for this class. - */ - private static final long serialVersionUID = 1L; - private static SystemMessage myMessage = null; - - /** - * Constructor - * @param remoteException the original cause of this exception. - */ - public RemoteFileSecurityException(Exception remoteException) { - super(getMyMessage(remoteException), remoteException); - - } - - private static SystemMessage getMyMessage(Exception remoteException) { - if (myMessage == null) { - String secondLevel = remoteException.getMessage(); - if (secondLevel == null) { - secondLevel = remoteException.getClass().getName(); - } - - String msgTxt = RSEServicesMessages.FILEMSG_SECURITY_VIOLATION; - String msgDetails = NLS.bind(RSEServicesMessages.FILEMSG_SECURITY_VIOLATION_DETAILS, secondLevel); - - myMessage = new SimpleSystemMessage(Activator.PLUGIN_ID, - "RSEF1001", //$NON-NLS-1$ - IStatus.ERROR, msgTxt, msgDetails); - } - return myMessage; - } -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFolderNotEmptyException.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFolderNotEmptyException.java deleted file mode 100644 index 7aaf7b2e6..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/RemoteFolderNotEmptyException.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared - *******************************************************************************/ - -package org.eclipse.rse.services.files; - -import org.eclipse.core.runtime.IStatus; - -import org.eclipse.rse.internal.services.Activator; -import org.eclipse.rse.internal.services.RSEServicesMessages; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; - -/** - * Exception thrown when attempting to delete a folder, and the folder is not empty. - */ -public class RemoteFolderNotEmptyException extends RemoteFileException { - - /** - * A serialVersionUID is recommended for all serializable classes. - * This trait is inherited from Throwable. - * This should be updated if there is a schema change for this class. - */ - private static final long serialVersionUID = 1L; - private static SystemMessage myMessage = null; - - /** - * Constructor for RemoteFolderNotEmptyException when there is no remote exception to wrap - */ - public RemoteFolderNotEmptyException() { - this(null); - } - - /** - * Constructor for RemoteFolderNotEmptyException when there is a remote exception to wrap - * @param remoteException the exception that caused this one to be constructed. - */ - public RemoteFolderNotEmptyException(Exception remoteException) { - super(getMyMessage(), remoteException); - } - - - private static SystemMessage getMyMessage() { - if (myMessage == null) { - String msgTxt = RSEServicesMessages.FILEMSG_FOLDER_NOT_EMPTY; - String msgDetails = RSEServicesMessages.FILEMSG_FOLDER_NOT_EMPTY_DETAILS; - myMessage = new SimpleSystemMessage(Activator.PLUGIN_ID, - "RSEF1003", //$NON-NLS-1$ - IStatus.ERROR, msgTxt, msgDetails); - } - return myMessage; - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/package.html b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/package.html deleted file mode 100644 index f2afc79f6..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/package.html +++ /dev/null @@ -1,32 +0,0 @@ -<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> -<html> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> - <meta name="Author" content="Martin Oberhuber (Wind River)"> - <meta name="Copyright" content="Copyright (c) 2008 Wind River Systems, Inc. and others."> - <meta name="License" content="Made available under the terms of the Eclipse Public License v1.0."> - <title>Package-level Javadoc</title> -</head> -<body> -Application programming interface for the RSE Services Layer. -<h2> -Package Specification</h2> -<p> -The RSE Services layer provides interfaces and basic utility classes -for remote operations. There is no restriction whatsoever about the -kind of those operations, and actually there isn't even a need for -remote systems to be involved. The Services defined here provide -basic functionality for RSE to operate on. -</p><p> -The RSE Services layer is designed to have only minimal dependency into -Eclipse core APIs, such that Services can eventually be re-used in -environments outside Eclipse. This can be done today by providing a library -with mock objects for the few Eclipse interfaces that Services currently use: -<code>IAdaptable</code>, <code>IProgressMonitor</code>, -<code>IStatus</code>, <code>NLS</code>, <code>PlatformObject</code> -and few others related to the Eclipse Extension Registry, which are only -used in the Activator and can thus be replaced easily by a different -mechanisms for providing extensions. -</p> -</body> -</html> diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/processes/AbstractHostProcess.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/processes/AbstractHostProcess.java deleted file mode 100644 index 161db8910..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/processes/AbstractHostProcess.java +++ /dev/null @@ -1,300 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.services.processes; - -import org.eclipse.rse.services.clientserver.IServiceConstants; -import org.eclipse.rse.services.clientserver.processes.IHostProcess; -import org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteConstants; - -public class AbstractHostProcess implements IHostProcess -{ - protected Object[] _properties = new Object[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_COUNT+1]; - - /** - * create a new AbstractHostProcess with the default property set - */ - public AbstractHostProcess() - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_EXENAME] = " "; //$NON-NLS-1$ - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_GID] = new Long(-1); - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_PID] = new Long(-1); - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_PPID] = new Long(-1); - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_STATUS] = new String(" "); //$NON-NLS-1$ - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_TGID] = new Long(-1); - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_TRACERPID] = new Long(-1); - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_UID] = new Long(-1); - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_USERNAME] = " "; //$NON-NLS-1$ - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_VMSIZE] = new Long(-1); - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_VMRSS] = new Long(-1); - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_COUNT] = " "; //set the label //$NON-NLS-1$ - } - - /** - * create a new AbstractHostProcess with initial Attributes. - * This is equivalent to constructing the object, then calling - * setAllProperties(initialAttributes). - * @param initialAttributes String of initial attributes - * @see #setAllProperties(String) - */ - public AbstractHostProcess(String initialAttributes) - { - setAllProperties(initialAttributes); - } - - protected Long getLongAttribute(String value, long dflt) - { - long result; - try - { - result = Long.parseLong(value); - } - catch (NumberFormatException e) - { - return new Long(dflt); - } - return new Long(result); - } - - protected Integer getIntAttribute(String value, int dflt) - { - int result; - try - { - result = Integer.parseInt(value); - } - catch (NumberFormatException e) - { - return new Integer(dflt); - } - return new Integer(result); - } - - public void setPid(String pid) - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_PID] = getLongAttribute(pid, -1); - } - - public void setPPid(String ppid) - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_PPID] = getLongAttribute(ppid, -1); - - } - - public void setName(String name) - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_EXENAME] = name; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.clientserver.processes.IHostProcess#getLabel() - */ - public String getLabel() - { - return (String) _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_COUNT]; - } - - public void setLabel(String label) - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_COUNT] = label; - } - - public void setState(String state) - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_STATUS] = state; - } - - public void setTgid(String tgid) - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_TGID] = getLongAttribute(tgid, -1); - } - - public void setTracerPid(String tracerpid) - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_TRACERPID] = getLongAttribute(tracerpid, -1); - } - - public void setUid(String uid) - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_UID] = getLongAttribute(uid, -1); - } - - public void setUsername(String username) - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_USERNAME] = username; - } - - public void setGid(String gid) - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_GID] = getLongAttribute(gid, -1); - } - - public void setVmSizeInKB(String size) - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_VMSIZE] = getLongAttribute(size, 0); - } - - public void setVmRSSInKB(String size) - { - _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_VMRSS] = getLongAttribute(size, 0); - } - - /** - * This method allows to set all attributes at once with your own string - * passed as a parameter, as long as the string is in the same format as - * outlined below (pass in null to use the DataElement's string). - * <p> The string contains properties of the object in the following order, - * separated by {@link IServiceConstants#TOKEN_SEPARATOR}: - * <ul> - * <li>Process Id (pid) - long - * <li>Executable name - String - * <li>Status - char - * <li>Tgid - long - * <li>Process Parent id (ppid) - long - * <li>Tracer pid - long - * <li>User id (uid) - long - * <li>Username - String - * <li>Group id (gid) - long - * <li>VM Size - long - * <li>VM RSS - long - * </ul> - * @param allProperties Property String as defined above - */ - public void setAllProperties(String allProperties) - { - String s = allProperties; - - if (s != null && s.length() > 0) - { - String[] str = s.split("\\"+IServiceConstants.TOKEN_SEPARATOR); //$NON-NLS-1$ - int numOfExpectedTokens = ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_COUNT; - int tokens = str.length; - if (tokens == numOfExpectedTokens) - { - try - { - setPid(str[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_PID]); - - setName(str[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_EXENAME]); - - setTgid(str[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_TGID]); - - setPPid(str[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_PPID]); - - setTracerPid(str[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_TRACERPID]); - - setUid(str[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_UID]); - - setUsername(str[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_USERNAME]); - - setGid(str[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_GID]); - - setVmSizeInKB(str[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_VMSIZE]); - - setVmRSSInKB(str[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_VMRSS]); - - setState(str[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_STATUS]); - - setLabel(getName()); - - } - catch (ArrayIndexOutOfBoundsException e) - { - // SystemPlugin.logError("Error in AbstractHostProcess.getAttributes(). Attributes in unexpected format. Attributes = " + s); - } - } - } - } - - public long getPid() - { - return ((Long)_properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_PID]).longValue(); - } - - public long getPPid() - { - return ((Long)_properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_PPID]).longValue(); - } - - public String getName() - { - return (String) _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_EXENAME]; - } - - public String getState() - { - return (String) _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_STATUS]; - } - - public long getTgid() - { - return ((Long)_properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_TGID]).longValue(); - } - - public long getTracerPid() - { - return ((Long)_properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_TRACERPID]).longValue(); - } - - public long getUid() - { - return ((Long)_properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_UID]).intValue(); - } - - public String getUsername() - { - return (String) _properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_USERNAME]; - } - - public long getGid() - { - return ((Long)_properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_GID]).intValue(); - } - - public boolean isRoot() - { - return (getPPid() == 0); - } - - public long getVmSizeInKB() - { - return ((Long)_properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_VMSIZE]).longValue(); - } - - public long getVmRSSInKB() - { - return ((Long)_properties[ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_INDEX_VMRSS]).longValue(); - } - - /** - * Return all the properties of this data structure in one string. - * Properties are separated by {@link IServiceConstants#TOKEN_SEPARATOR}. - * @see #setAllProperties(String) - * @return String of Properties - */ - public String getAllProperties() - { - String properties = ""; //$NON-NLS-1$ - for (int i = 0; i < ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_COUNT; i++) - { - properties = properties + _properties[i].toString(); - if (i != ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_COUNT - 1) - properties = properties + IServiceConstants.TOKEN_SEPARATOR; - } - return properties; - } -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/processes/AbstractProcessService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/processes/AbstractProcessService.java deleted file mode 100644 index b73c72a90..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/processes/AbstractProcessService.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006, 2008 IBM Corporation and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API - * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc - ********************************************************************************/ - -package org.eclipse.rse.services.processes; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.rse.services.AbstractService; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -import org.eclipse.rse.services.clientserver.processes.HostProcessFilterImpl; -import org.eclipse.rse.services.clientserver.processes.IHostProcess; -import org.eclipse.rse.services.clientserver.processes.IHostProcessFilter; - -/** - * Abstract base class for RSE Process Service. - */ -public abstract class AbstractProcessService extends AbstractService implements IProcessService -{ - public IHostProcess[] listAllProcesses(String exeNameFilter, String userNameFilter, String stateFilter, IProgressMonitor monitor) throws SystemMessageException - { - HostProcessFilterImpl rpfs = new HostProcessFilterImpl(); - rpfs.setName(exeNameFilter); - rpfs.setUsername(userNameFilter); - rpfs.setSpecificState(stateFilter); - return listAllProcesses(rpfs, monitor); - } - - public IHostProcess[] listAllProcesses(IProgressMonitor monitor) throws SystemMessageException - { - HostProcessFilterImpl rpfs = new HostProcessFilterImpl(); - return listAllProcesses(rpfs, monitor); - } - - /** - * Return a single IHostProcess object for the 'init' process with pid 1. - * - * @param monitor Progress monitor - * @return Array with 1 element, the IHostProcess object for the root - * process - * @throws SystemMessageException in case anything goes wrong - * @see org.eclipse.rse.services.processes.IProcessService#listRootProcesses(org.eclipse.core.runtime.IProgressMonitor) - */ - public IHostProcess[] listRootProcesses(IProgressMonitor monitor) throws SystemMessageException - { - IHostProcess[] roots = new IHostProcess[1]; - roots[0] = getProcess(1, monitor); - return roots; - } - - public IHostProcess[] listChildProcesses(long parentPID, IProgressMonitor monitor) throws SystemMessageException - { - String pPidString = "" + parentPID; //$NON-NLS-1$ - HostProcessFilterImpl rpfs = new HostProcessFilterImpl(); - rpfs.setPpid(pPidString); - - return listAllProcesses(rpfs, monitor); - } - - public IHostProcess[] listChildProcesses(long parentPID, IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException - { - String pPidString = "" + parentPID; //$NON-NLS-1$ - filter.setPpid(pPidString); - - return listAllProcesses(filter, monitor); - } - - public IHostProcess getParentProcess(long pid, IProgressMonitor monitor) throws SystemMessageException - { - return getProcess(getProcess(pid, monitor).getPPid(), monitor); - } - - public IHostProcess getProcess(long pid, IProgressMonitor monitor) throws SystemMessageException - { - String pidString = "" + pid; //$NON-NLS-1$ - HostProcessFilterImpl rpfs = new HostProcessFilterImpl(); - rpfs.setPid(pidString); - - IHostProcess[] results = listAllProcesses(rpfs, monitor); - if ((results == null) || (results.length == 0)) return null; - else return results[0]; - } - - /** - * @deprecated This method was removed from IProcessService in RSE 3.0, and - * implementers are not expected to return anything useful. Use - * {@link SimpleSystemMessage} to create system messages - * instead. - */ - public SystemMessage getMessage(String messageID) - { - return null; - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/processes/IProcessService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/processes/IProcessService.java deleted file mode 100644 index e58ff7fe2..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/processes/IProcessService.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006, 2008 IBM Corporation and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API - * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc - ********************************************************************************/ - -package org.eclipse.rse.services.processes; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.rse.services.IService; -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -import org.eclipse.rse.services.clientserver.processes.IHostProcess; -import org.eclipse.rse.services.clientserver.processes.IHostProcessFilter; - -/** - * An IProcessService is an abstraction of a process service that runs over some - * sort of connection. It can be shared among multiple instances of a subsystem. - * Each subsystem is currently responsible for layering an abstraction over - * whatever it wants to construct as a service. - * <p> - * Implementers of this interface will have to either be instantiated, - * initialized, or somehow derive a connection as part of its state. - * - * @noimplement This interface is not intended to be implemented by clients. - * Process service implementations must subclass - * {@link AbstractProcessService} rather than implementing this - * interface directly. - */ -public interface IProcessService extends IService -{ - /** - * Return a list of all processes on the remote system. - * - * @param monitor A progress monitor to which progress will be reported - * @return List of all processes - * @throws SystemMessageException in case anything goes wrong - */ - public IHostProcess[] listAllProcesses(IProgressMonitor monitor) throws SystemMessageException; - - /** - * Return a filtered list of all processes on the remote system. - * - * @param filter An object to filter results by - * @param monitor A progress monitor to which progress will be reported - * @return Filtered list of processes - * @throws SystemMessageException in case anything goes wrong - */ - public IHostProcess[] listAllProcesses(IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Return a filtered list of all processes on the remote system. - * - * @param exeNameFilter The executable name to filter results by, or null if - * no exeName filtering - * @param userNameFilter The user name to filter results by, or null if no - * userName filtering - * @param stateFilter The state code to filter results by, or null if no - * state filtering - * @param monitor A progress monitor to which progress will be reported - * @return Filtered list of processes - * @throws SystemMessageException in case anything goes wrong - */ - public IHostProcess[] listAllProcesses(String exeNameFilter, String userNameFilter, String stateFilter, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Returns root processes on the remote system - * - * @param monitor A progress monitor to which progress will be reported - * @return List of root processes - * @throws SystemMessageException in case anything goes wrong - */ - public IHostProcess[] listRootProcesses(IProgressMonitor monitor) throws SystemMessageException; - - /** - * Return a list of all remote child processes of the given parent process - * on the remote system - * - * @param parentPID The ID of the parent process whose children are to be - * listed - * @param monitor A progress monitor to which progress will be reported - * @return List of child processes - * @throws SystemMessageException in case anything goes wrong - */ - public IHostProcess[] listChildProcesses(long parentPID, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Return a filtered list of remote child processes of the given parent - * process on the remote system - * - * @param parentPID The ID of the parent process whose children are to be - * listed - * @param filter A filter to narrow results by - * @param monitor A progress monitor to which progress will be reported - * @return Filtered list of child processes - * @throws SystemMessageException in case anything goes wrong - */ - public IHostProcess[] listChildProcesses(long parentPID, IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Given a process, return its parent process object. - * - * @param pid the ID of the process to return parent of. - * @param monitor A progress monitor to which progress will be reported - * @return The parent process - * @throws SystemMessageException in case anything goes wrong - */ - public IHostProcess getParentProcess(long pid, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Given a pid, return an IHostProcess object for it. - * - * @param pid The process ID of the desired process - * @param monitor A progress monitor to which progress will be reported - * @return IHostProcess object for the given pid - * @throws SystemMessageException in case anything goes wrong - */ - public IHostProcess getProcess(long pid, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Kills a process. - * - * @param pid the ID of the process to be killed. - * @param signal the signal to send to the process - * @param monitor A progress monitor to which progress will be reported - * @return <code>false</code> if the given process doesn't exist, else - * <code>true</code>. Throws an exception if anything fails. - * @throws SystemMessageException in case anything goes wrong - */ - public boolean kill(long pid, String signal, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Returns a list of the types of signals that can be sent to - * a process on the remote system. - * @return the signal types, or null if there are none, or they cannot be found. - */ - public String[] getSignalTypes(); -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchResult.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchResult.java deleted file mode 100644 index 862dd9c6f..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchResult.java +++ /dev/null @@ -1,252 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.search; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.rse.services.clientserver.SystemSearchString; -import org.eclipse.rse.services.files.IHostFile; - - -/** - * The RemoteSearchResultImpl class is an implementation of IRemoteSearchResult. - * It is used for storing information about a particular search result. - */ -public class AbstractSearchResult implements IAdaptable, IHostSearchResult -{ - - - private String _text; - private int _line = 0; - private int _index = -1; - - private Object _parent; - private SystemSearchString _matchingSearchString; - private IHostSearchResultConfiguration _configuration; - - private List _matches; - - protected class RemoteSearchResultMatch - { - - private int _startOffset = -1; - private int _endOffset = -1; - - private RemoteSearchResultMatch(int startOffset, int endOffset) { - this._startOffset = startOffset; - this._endOffset = endOffset; - } - } - - /** - * Constructor to create a result. - * @param parent container of the result. - * @param searchString the search string for which the result was produced. - */ - public AbstractSearchResult(IHostSearchResultConfiguration configuration, Object parent, SystemSearchString searchString) - { - _parent = parent; - _matchingSearchString = searchString; - _matches = new ArrayList(); - _configuration = configuration; - } - - - - /** - * Sets the displayable text for the search result. - * @param text the displayable text. - */ - public void setText(String text) { - _text = text; - } - - /** - * Sets the associated line number for the result. - * @param line the line number. - */ - public void setLine(int line) { - _line = line; - } - - /** - * Sets the index of the search result in the context of its parent. - * @param index the index. - */ - public void setIndex(int index) { - _index = index; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResult#getText() - */ - public String getText() { - return _text; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResult#getLine() - */ - public int getLine() { - return _line; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResult#getIndex() - */ - public int getIndex() { - return _index; - } - - /** - * Gets the absolute path of the file for which the result was found. - * @return the absolute path of the file. - */ - public String getAbsolutePath() { - - if (_parent instanceof IHostFile) { - return ((IHostFile)_parent).getAbsolutePath(); - } - else { - return null; - } - } - - /** - * Gets the containing object for the search result. - * @return the containing parent. - */ - public Object getParent() { - return _parent; - } - - public void setParent(Object parent) - { - _parent = parent; - } - - /** - * Gets the associated adapter for this search result. - * @param adapterType the adapter type. - */ - public Object getAdapter(Class adapterType) { - return Platform.getAdapterManager().getAdapter(this, adapterType); - } - - /** - * Returns children of the search result, if applicable. - * @return <code>null</code> for this implementation. - */ - public Object[] getChildren() { - return null; - } - - /** - * Indicates whether this search result has children - * @return <code>false</code> since there are no children. - */ - public boolean hasChildren() { - return false; - } - - /** - * Gets the displayable label for this output. Calls getText(). - * @return the label. - */ - public String getLabel() { - return getText(); - } - - /** - * Gets the search string that this result matches. - * @return the search string. - */ - public SystemSearchString getMatchingSearchString() { - return _matchingSearchString; - } - - /** - * Add a match to the result. A match comprises a char start offset and a char end offset, both - * relative to the beginning of the file. The matches are added in order. - * @param startOffset the char start offset, from the beginning of the file. - * @param endOffset the char end offset, from the beginning of the file. - */ - public void addMatch(int startOffset, int endOffset) { - _matches.add(new RemoteSearchResultMatch(startOffset, endOffset)); - } - - /** - * Gets the number of matches in this line. - * @return the number of matches. - */ - public int numOfMatches() { - return _matches.size(); - } - - /** - * Gets the char start offset for the given match index. - * @param matchIndex the match index. For example, to get the start offset for the first match, specify 0. - * @return the char start offset, or -1 if there is no match corresponding to the given index. - */ - public int getCharStart(int matchIndex) { - RemoteSearchResultMatch match = (RemoteSearchResultMatch)(_matches.get(matchIndex)); - - if (match != null) { - return match._startOffset; - } - else { - return -1; - } - } - - /** - * Gets the char end offset for the given match index. - * @param matchIndex the match index. For example, to get the end offset for the first match, specify 0. - * @return the char end offset, or -1 if there is no match corresponding to the given index. - */ - public int getCharEnd(int matchIndex) { - RemoteSearchResultMatch match = (RemoteSearchResultMatch)(_matches.get(matchIndex)); - - if (match != null) { - return match._endOffset; - } - else { - return -1; - } - } - - /** - * @return the char start offset of the first match. - */ - public int getCharEnd() { - return getCharEnd(0); - } - - /** - * @return the char end offset of the first match. - */ - public int getCharStart() { - return getCharStart(0); - } - - public IHostSearchResultConfiguration getConfiguration() - { - return _configuration; - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchResultConfiguration.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchResultConfiguration.java deleted file mode 100644 index 0407bcdf9..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchResultConfiguration.java +++ /dev/null @@ -1,224 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.services.search; - -import java.util.HashMap; -import java.util.Map; -import java.util.Vector; - -import org.eclipse.rse.services.clientserver.SystemSearchString; - - -/** - * This class represents a search result configuration. A configuration - * consists of a search target and a search string, and belongs to a search - * result set. Once a search has been started via a subsystem, the results - * are stored in the configuration itself. The status of the search can also be queried from - * the configuration. - */ -public abstract class AbstractSearchResultConfiguration implements IHostSearchResultConfiguration -{ - - protected IHostSearchResultSet parentResultSet; - protected Object searchTarget; - protected SystemSearchString searchString; - protected Vector results; - protected Map _containedResults; - protected int status; - protected ISearchService _searchService; - protected ISearchHandler _searchHandler; - - - /** - * Constructor for a result set configuration. Sets status to <code>RUNNING</code>. - * @param resultSet the parent result set. - * @param searchObject the target of the search. - * @param string the search string. - */ - public AbstractSearchResultConfiguration(IHostSearchResultSet resultSet, Object searchObject, SystemSearchString string, ISearchService searchService) - { - results = new Vector(); - setParentResultSet(resultSet); - setSearchTarget(searchObject); - setSearchString(string); - setStatus(IHostSearchConstants.RUNNING); - _searchService = searchService; - _containedResults = new HashMap(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#setParentResultSet(org.eclipse.rse.services.search.IHostSearchResultSet) - */ - public void setParentResultSet(IHostSearchResultSet resultSet) - { - this.parentResultSet = resultSet; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#getParentResultSet() - */ - public IHostSearchResultSet getParentResultSet() { - return parentResultSet; - } - - public ISearchService getSearchService() - { - return _searchService; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#setSearchTarget(java.lang.Object) - */ - public void setSearchTarget(Object searchObject) { - this.searchTarget = searchObject; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#getSearchTarget() - */ - public Object getSearchTarget() { - return searchTarget; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#setSearchString(org.eclipse.rse.services.clientserver.SystemSearchString) - */ - public void setSearchString(SystemSearchString string) { - this.searchString = string; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#getSearchString() - */ - public SystemSearchString getSearchString() - { - return searchString; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#addResult(java.lang.Object) - */ - public void addResult(Object result) - { - results.add(result); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#removeResult(java.lang.Object) - */ - public void removeResult(Object result) - { - results.remove(result); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#removeAndAddResult(java.lang.Object, java.lang.Object) - */ - public void removeAndAddResult(Object oldResult, Object newResult) - { - results.remove(oldResult); - results.add(newResult); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#getResults() - */ - public Object[] getResults() - { - return results.toArray(); - } - - public IHostSearchResult[] getContainedResults(Object resultContainer) - { - return (IHostSearchResult[])_containedResults.get(resultContainer); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#getResultsSize() - */ - public int getResultsSize() - { - return results.size(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#removeResults() - */ - public void removeResults() - { - results.removeAllElements(); - _containedResults.clear(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#setStatus(int) - */ - public void setStatus(int status) { - this.status = status; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#getStatus() - */ - public int getStatus() { - return status; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#cancel() - */ - public void cancel() { - - // if not running, return - if (getStatus() != IHostSearchConstants.RUNNING) { - return; - } - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultConfiguration#dispose() - */ - public void dispose() { - - // cancel search first - cancel(); - - // remove results - removeResults(); - } - - public void addResults(Object container, IHostSearchResult[] results) - { - _containedResults.put(container, results); - } - - public void setSearchHandler(ISearchHandler searchHandler) - { - _searchHandler = searchHandler; - } - - - /** - * Gets the search handler. - * @return the search handler. - */ - public ISearchHandler getSearchHandler() - { - return _searchHandler; - } -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchService.java deleted file mode 100644 index 509f13d8a..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchService.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006, 2008 IBM Corporation and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API - * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc - ********************************************************************************/ - -package org.eclipse.rse.services.search; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.rse.services.AbstractService; -import org.eclipse.rse.services.files.IFileService; - -/** - * Abstract base class for RSE Search Service. A useful implementation should - * ensure that only minimal data transfer is required between the remote system - * and the local client. - */ -public abstract class AbstractSearchService extends AbstractService implements ISearchService -{ - protected Map _searches; - - public AbstractSearchService() - { - _searches = new HashMap(); - } - - public final void search(IHostSearchResultConfiguration searchConfig, IFileService fileService, IProgressMonitor monitor) - { - ISearchHandler handler = internalSearch(searchConfig, fileService, monitor); - _searches.put(searchConfig, handler); - } - - - public final void cancelSearch(IHostSearchResultConfiguration searchConfig, IProgressMonitor monitor) - { - ISearchHandler handler = (ISearchHandler)_searches.get(searchConfig); - handler.cancel(monitor); - } - - - protected abstract ISearchHandler internalSearch(IHostSearchResultConfiguration searchConfig, IFileService fileService, IProgressMonitor monitor); -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/HostSearchResultSet.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/HostSearchResultSet.java deleted file mode 100644 index 720817526..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/HostSearchResultSet.java +++ /dev/null @@ -1,287 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc - *******************************************************************************/ - -package org.eclipse.rse.services.search; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.PlatformObject; - - -/** - * A remote search result set represents a page in the Remote Search view. - * A search result set contains multiple search configurations and their results. - * This allows it to contain results from multiple connections, filters, and folders - * (from different systems). - */ -public class HostSearchResultSet extends PlatformObject implements IHostSearchResultSet, IAdaptable -{ - - protected Vector configurations; - protected String name; - - /** - * Constructor to create a result set. - */ - public HostSearchResultSet() { - configurations = new Vector(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#setName(java.lang.String) - */ - public void setName(String name) { - this.name = name; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#getName() - */ - public String getName() { - return name; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#addSearchConfiguration(org.eclipse.rse.services.search.IHostSearchResultConfiguration) - */ - public void addSearchConfiguration(IHostSearchResultConfiguration config) { - configurations.add(config); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#removeSearchConfiguration(org.eclipse.rse.services.search.IHostSearchResultConfiguration) - */ - public void removeSearchConfiguration(IHostSearchResultConfiguration config) { - configurations.remove(config); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#getSearchConfigurations() - */ - public Iterator getSearchConfigurations() { - return configurations.iterator(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#addResult(org.eclipse.rse.services.search.IHostSearchResultConfiguration, java.lang.Object) - */ - public void addResult(IHostSearchResultConfiguration config, Object result) { - config.addResult(result); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#removeResult(org.eclipse.rse.services.search.IHostSearchResultConfiguration, java.lang.Object) - */ - public void removeResult(IHostSearchResultConfiguration config, Object result) { - config.removeResult(result); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#getResultsForConfiguration(org.eclipse.rse.services.search.IHostSearchResultConfiguration) - */ - public Object[] getResultsForConfiguration(IHostSearchResultConfiguration config) { - return config.getResults(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#getAllResults() - */ - public Object[] getAllResults() { - - List list = new ArrayList(); - - Iterator iter = getSearchConfigurations(); - - while (iter.hasNext()) - { - IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next(); - - list.addAll(Arrays.asList(config.getResults())); - } - - return list.toArray(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#removeAllResults() - */ - public void removeAllResults() { - - Iterator iter = getSearchConfigurations(); - - while (iter.hasNext()) { - IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next(); - config.removeResults(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#getNumOfResults() - */ - public int getNumOfResults() { - - int resultSize = 0; - - Iterator iter = getSearchConfigurations(); - - while (iter.hasNext()) { - IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next(); - resultSize += config.getResultsSize(); - } - - return resultSize; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#cancel() - */ - public void cancel() { - - // cancel each config that is running - Iterator iter = getSearchConfigurations(); - - while (iter.hasNext()) { - IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next(); - - if (config.getStatus() == IHostSearchConstants.RUNNING) { - config.cancel(); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#removeResult(java.lang.Object) - */ - public void removeResult(Object result) { - Iterator iter = getSearchConfigurations(); - - while (iter.hasNext()) { - IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next(); - config.removeResult(result); - } - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#removeAndAddResult(java.lang.Object, java.lang.Object) - */ - public void removeAndAddResult(Object oldResult, Object newResult) { - Iterator iter = getSearchConfigurations(); - - while (iter.hasNext()) { - IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next(); - config.removeAndAddResult(oldResult, newResult); - } - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#dispose() - */ - public void dispose() { - - // first cancel all configs that are still running - cancel(); - - // now dispose each configuration - Iterator iter = getSearchConfigurations(); - - while (iter.hasNext()) { - IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next(); - config.dispose(); - } - - // remove all the configurations - configurations.removeAllElements(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#isCancelled() - */ - public boolean isCancelled() { - Iterator iter = getSearchConfigurations(); - - while (iter.hasNext()) { - IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next(); - - // if a config is not cancelled, the search is not cancelled - if (config.getStatus() != IHostSearchConstants.CANCELLED) { - return false; - } - } - - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#isFinished() - */ - public boolean isFinished() { - Iterator iter = getSearchConfigurations(); - - while (iter.hasNext()) { - IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next(); - - // if a config is not finished, the search is not finished - if (config.getStatus() != IHostSearchConstants.FINISHED) { - return false; - } - } - - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#isRunning() - */ - public boolean isRunning() { - Iterator iter = getSearchConfigurations(); - - while (iter.hasNext()) { - IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next(); - - // if a config is running, the search is running - if (config.getStatus() == IHostSearchConstants.RUNNING) { - return true; - } - } - - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.search.IHostSearchResultSet#isDisconnected() - */ - public boolean isDisconnected() { - Iterator iter = getSearchConfigurations(); - - while (iter.hasNext()) { - IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next(); - - // if a config is not disconnected, the search is not disconnected - if (config.getStatus() != IHostSearchConstants.DISCONNECTED) { - return false; - } - } - - return true; - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchConstants.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchConstants.java deleted file mode 100644 index d3e1b8a77..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchConstants.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006, 2008 IBM Corporation and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [cleanup] Add API "since" tags - ********************************************************************************/ - -package org.eclipse.rse.services.search; - -public interface IHostSearchConstants { - - /** - * Status indicating configuration is still running, 0. - */ - public static final int RUNNING = 0; - - /** - * Status indicating configuration has finished, 1. - */ - public static final int FINISHED = 1; - - /** - * Status indicating configuration has been cancelled, 2. - */ - public static final int CANCELLED = 2; - - /** - * Status indicating configuration has been disconnected, 3. - */ - public static final int DISCONNECTED = 3; -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchResult.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchResult.java deleted file mode 100644 index 617ba7104..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchResult.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.services.search; - -import org.eclipse.rse.services.clientserver.SystemSearchString; - - -public interface IHostSearchResult -{ - public static final String SEARCH_RESULT_DELIMITER = ":SEARCH"; //$NON-NLS-1$ - public static final String SEARCH_RESULT_OPEN_DELIMITER = "<"; //$NON-NLS-1$ - public static final String SEARCH_RESULT_CLOSE_DELIMITER = ">"; //$NON-NLS-1$ - public static final String SEARCH_RESULT_INDEX_DELIMITER = ":"; //$NON-NLS-1$ - - public void setParent(Object parent); - - public Object getParent(); - - - public int getLine(); - - /** - * Gets the search string that this result matches. - * @return the search string. - */ - public SystemSearchString getMatchingSearchString(); - - /** - * Gets the path to the file that this output references if it references any. It may return null if - * no such association exists. This may be used to jump to an editor from a view which displays - * this - * - * @return the path of the referenced file if there is one - */ - public String getAbsolutePath(); - - /** - * Gets the text to display for a search result. - * @return the text. - */ - public String getText(); - - /** - * Gets the index of this search result in the context of its parent. - * @return the index. - */ - public int getIndex(); - - - /** - * Add a match to the result. A match comprises a char start offset and a char end offset, both - * relative to the beginning of the file. The matches are added in order. - * @param startOffset the char start offset, from the beginning of the file. - * @param endOffset the char end offset, from the beginning of the file. - */ - public void addMatch(int startOffset, int endOffset); - - /** - * Gets the number of matches in this line. - * @return the number of matches. - */ - public int numOfMatches(); - - /** - * Gets the char start offset for the given match index. - * @param matchIndex the match index. For example, to get the start offset for the first match, specify 0. - * @return the char start offset. - */ - public int getCharStart(int matchIndex); - - /** - * Gets the char end offset for the given match index. - * @param matchIndex the match index. For example, to get the end offset for the first match, specify 0. - * @return the char end offset. - */ - public int getCharEnd(int matchIndex); - - - public IHostSearchResultConfiguration getConfiguration(); -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchResultConfiguration.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchResultConfiguration.java deleted file mode 100644 index ee2cc8582..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchResultConfiguration.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.services.search; - -import org.eclipse.rse.services.clientserver.SystemSearchString; - -/** - * An interface representing a search result configuration. - */ -public interface IHostSearchResultConfiguration { - - /** - * Sets the parent result set. - * @param resultSet the parent result set. - */ - public void setParentResultSet(IHostSearchResultSet resultSet); - - /** - * Gets the parent result set. - * @return the parent result set. - */ - public IHostSearchResultSet getParentResultSet(); - - /** - * Gets the results contained within the resultContainer - * @param resultContainer - * @return the results - */ - public IHostSearchResult[] getContainedResults(Object resultContainer); - - /** - * Sets the object to be searched. - * @param searchObject the object to be searched. - */ - public void setSearchTarget(Object searchObject); - - /** - * Gets the object to be searched. - * @return the object to be searched. - */ - public Object getSearchTarget(); - - /** - * Sets the search string. - * @param string the search string. - */ - public void setSearchString(SystemSearchString string); - - /** - * Gets the search string. - * @return string the search string. - */ - public SystemSearchString getSearchString(); - - /** - * Adds a search result. - * @param result a search result. - */ - public void addResult(Object result); - - /** - * Adds a set of search results along their associated container - * @param container - * @param results - */ - public void addResults(Object container, IHostSearchResult[] results); - - /** - * Removes a search result. - * @param result a search result. - */ - public void removeResult(Object result); - - /** - * Removes the old result and adds a new result. - * @param oldResult the old result. - * @param newResult the new result. - */ - public void removeAndAddResult(Object oldResult, Object newResult); - - /** - * Gets search results. - * @return search results. - */ - public Object[] getResults(); - - /** - * Gets the size of the results. - * @return the size of the results. - */ - public int getResultsSize(); - - /** - * Removes all search results. - */ - public void removeResults(); - - /** - * Sets the status of the search. One of <code>RUNNING</code>, <code>FINISHED</code>, - * <code>CANCELLED</code>, or <code>DISCONNECTED</code>. - * @param status the status. - */ - public void setStatus(int status); - - /** - * Gets the status of the search. One of <code>RUNNING</code>, <code>FINISHED</code>, - * <code>CANCELLED</code>, or <code>DISCONNECTED</code>. - * @return the status of the search. - */ - public int getStatus(); - - /** - * Cancels the search if it is running. - */ - public void cancel(); - - /** - * Cancels the search and then removes the search results. Implementors should call <code>super</code> first. - */ - public void dispose(); - - /** - * Sets the search handler - * @param handler - */ - public void setSearchHandler(ISearchHandler handler); -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchResultConfigurationFactory.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchResultConfigurationFactory.java deleted file mode 100644 index baf0d9d82..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchResultConfigurationFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.search; - -import org.eclipse.rse.services.clientserver.SystemSearchString; - -public interface IHostSearchResultConfigurationFactory -{ - public IHostSearchResultConfiguration createSearchConfiguration(IHostSearchResultSet resultSet, Object searchTarget, SystemSearchString searchString); -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchResultSet.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchResultSet.java deleted file mode 100644 index dad13692f..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/IHostSearchResultSet.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.search; - -import java.util.Iterator; - -/** - * A remote search result set represents a page in the Remote Search view. - * A search result set contains multiple search configurations and their results. - * This allows it to contain results from multiple connections, filters, and folders - * (from different systems). - */ -public interface IHostSearchResultSet { - - /** - * Sets the name of the search. - * @param name the name of the search. - */ - public void setName(String name); - - /** - * Gets the name of the search that is being run. - * @return the name of the search. - */ - public String getName(); - - /** - * Add a search configuration. - * @param config a search configuration. - */ - public void addSearchConfiguration(IHostSearchResultConfiguration config); - - /** - * Removes a search configuration. - * @param config a search configuration. - */ - public void removeSearchConfiguration(IHostSearchResultConfiguration config); - - /** - * Returns an iterator over search configurations. - * @return an iterator over search configurations. - */ - public Iterator getSearchConfigurations(); - - /** - * Add a result for a search configuration. - * @param config a search configuration that was previously added. - * @param result a search result. - */ - public void addResult(IHostSearchResultConfiguration config, Object result); - - /** - * Removes a result from a search configuration. - * @param config a search configuration that was previously added. - * @param result a search result. - */ - public void removeResult(IHostSearchResultConfiguration config, Object result); - - /** - * Removes a result from all search configurations where it exists. - * @param result a search result. - */ - public void removeResult(Object result); - - /** - * Removes the old result from configurations where it is found, and - * add the new result to those configurations. - * @param oldResult the old result. - * @param newResult the new result. - */ - public void removeAndAddResult(Object oldResult, Object newResult); - - /** - * Returns the results of a particular search configuration. - * @param config a search configuration. - * @return the results for the given search configuration. - */ - public Object[] getResultsForConfiguration(IHostSearchResultConfiguration config); - - /** - * Returns all results of the search. - * @return all results of the search. - */ - public Object[] getAllResults(); - - /** - * Removes all results of the search. - */ - public void removeAllResults(); - - /** - * Gets the number of results. - * @return the number of results. - */ - public int getNumOfResults(); - - /** - * Cancels the search. Cancel those configurations that are still running. - */ - public void cancel(); - - /** - * Removes all configurations. First cancels the search, then calls the <code>dispose</code> method of - * the configurations before removing them. - */ - public void dispose(); - - /** - * Returns whether search is running. A search is running if any of the configurations is running. - * @return <code>true</code> if the search is running, <code>false</code> otherwise. - */ - public boolean isRunning(); - - /** - * Returns whether the search is cancelled. A search is cancelled if all of the configurations are - * cancelled. - * @return <code>true</code> if the search is cancelled, <code>false</code> otherwise. - */ - public boolean isCancelled(); - - /** - * Returns whether the search is finished. A search is finished if all the configurations are finished. - * @return <code>true</code> if the search is finished, <code>false</code> otherwise. - */ - public boolean isFinished(); - - /** - * Returns whether the search is disconnected. A search is disconnected if all the configurations are - * disconnected. - * @return <code>true</code> if the search is disconnected, <code>false</code> otherwise. - */ - public boolean isDisconnected(); -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/ISearchHandler.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/ISearchHandler.java deleted file mode 100644 index 1fc97b5ae..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/ISearchHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.search; - -import org.eclipse.core.runtime.IProgressMonitor; - -public interface ISearchHandler -{ - public void search(IProgressMonitor monitor); - public void cancel(IProgressMonitor monitor); -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/ISearchService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/ISearchService.java deleted file mode 100644 index db46e3d4f..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/ISearchService.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006, 2008 IBM Corporation and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API - * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc - ********************************************************************************/ - -package org.eclipse.rse.services.search; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.rse.services.files.IFileService; - -/** - * RSE Search Service Interface. - * - * @noimplement This interface is not intended to be implemented by clients. - * Search service implementations must subclass - * {@link AbstractSearchService} rather than implementing this - * interface directly. - */ -public interface ISearchService -{ - public void search(IHostSearchResultConfiguration searchConfig, IFileService fileService, IProgressMonitor monitor); - public void cancelSearch(IHostSearchResultConfiguration searchConfig, IProgressMonitor monitor); - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java deleted file mode 100644 index 0ac8e3f75..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.shells; - - -public abstract class AbstractHostShell implements IHostShell -{ - - public void addOutputListener(IHostShellOutputListener listener) - { - IHostShellOutputReader outReader = getStandardOutputReader(); - if (outReader != null) - { - outReader.addOutputListener(listener); - } - IHostShellOutputReader errReader = getStandardErrorReader(); - if (errReader != null) - { - errReader.addOutputListener(listener); - } - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShellOutputReader.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShellOutputReader.java deleted file mode 100644 index 9cb68ec59..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShellOutputReader.java +++ /dev/null @@ -1,196 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [197848] Fix shell terminated state when remote dies - * Martin Oberhuber (Wind River) - [217429] Make registering multiple output listeners thread-safe - *******************************************************************************/ - -package org.eclipse.rse.services.shells; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public abstract class AbstractHostShellOutputReader extends Thread implements IHostShellOutputReader -{ - protected List _listeners; - protected int _waitIncrement = 2; - protected boolean _keepRunning = true; - - protected List _linesOfOutput; - protected int _consumerOffset; - protected IHostShell _hostShell; - protected boolean _isErrorReader = false; - - - protected long _timeOfLastEvent = 0; - protected int _sizeAtLastEvent = 0; - - public AbstractHostShellOutputReader(IHostShell hostShell, boolean isErrorReader) - { - _hostShell = hostShell; - _listeners = Collections.synchronizedList(new ArrayList()); - _linesOfOutput = new ArrayList(); - _consumerOffset = 0; - _isErrorReader = isErrorReader; - _timeOfLastEvent = System.currentTimeMillis(); - } - - public boolean isErrorReader() - { - return _isErrorReader; - } - - public IHostShell getHostShell() - { - return _hostShell; - } - - public void setWaitTime(int value) - { - _waitIncrement = value; - } - - public int getWaitTime() - { - return _waitIncrement; - } - - - public void handle() - { - IHostOutput line = internalReadLine(); - - if (line != null) - { - addLine(line); - } - - else - { - finish(); - _keepRunning = false; - } - - } - - protected void addLine(IHostOutput line) - { - _linesOfOutput.add(line); - int sizenow = _linesOfOutput.size(); - int deltaSize = sizenow - _sizeAtLastEvent; - - long timenow = System.currentTimeMillis(); - //if ((timenow - _timeOfLastEvent) > 10 || deltaSize > 2) - { - - - // notify listeners - HostShellChangeEvent event = new HostShellChangeEvent(_hostShell, this, _sizeAtLastEvent, deltaSize); - fireOutputChanged(event); - _timeOfLastEvent = timenow; - _sizeAtLastEvent = sizenow; - } - } - - /** @since 3.0 */ - protected final synchronized void startIfNotAlive() { - if (!isAlive()) { - start(); - } - } - - public IHostOutput readLine() - { - if (!isAlive()) - { - internalReadLine(); - startIfNotAlive(); - } - return (IHostOutput)_linesOfOutput.get(_consumerOffset++); - } - - public IHostOutput readLine(int lineNumber) - { - return (IHostOutput)_linesOfOutput.get(lineNumber); - } - - - - public void setLineOffset(int lineNumber) - { - _consumerOffset = lineNumber; - } - public void addOutputListener(IHostShellOutputListener listener) - { - _listeners.add(listener); - startIfNotAlive(); - } - - public void fireOutputChanged(IHostShellChangeEvent event) - { - for (int i = 0; i < _listeners.size(); i++) - { - IHostShellOutputListener listener = (IHostShellOutputListener)_listeners.get(i); - listener.shellOutputChanged(event); - } - if (!_keepRunning) - dispose(); - } - - public void dispose() - { - _listeners.clear(); - } - - public boolean isFinished() - { - return !_keepRunning; - } - - public void finish() - { - if (_keepRunning) - { - _waitIncrement = 0; - //dispose(); - } - } - - public void run() - { - while (_keepRunning) - { - try - { - Thread.sleep(_waitIncrement); - Thread.yield(); - handle(); - } - catch (InterruptedException e) - { - finish(); - _keepRunning = false; - } - } - if (!isErrorReader()) { - //Bug 197848: Fire empty event as notification that we are done - HostShellChangeEvent event = new HostShellChangeEvent(_hostShell, this, 0, 0); - fireOutputChanged(event); - } - } - - protected abstract IHostOutput internalReadLine(); - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractShellService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractShellService.java deleted file mode 100644 index 8d4f5ef7b..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractShellService.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - * Martin Oberhuber (Wind River) - [226301][api] IShellService should throw SystemMessageException on error - *******************************************************************************/ - -package org.eclipse.rse.services.shells; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.rse.services.AbstractService; -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; - -/** - * Abstract base class for RSE Shell Service implementations. - * - * @since org.eclipse.rse.services 3.0 - */ -public abstract class AbstractShellService extends AbstractService implements IShellService { - - private static final String[] EMPTY_ARRAY = new String[0]; - - /** - * Return an empty host environment. Extenders should override this method - * if they are able to return environment on the remote side. If they do not - * implement this feature, they must not override this method. - * - * @see IShellService#getHostEnvironment() - */ - public String[] getHostEnvironment() throws SystemMessageException { - // not implemented by default - // TODO SSH https://bugs.eclipse.org/bugs/show_bug.cgi?id=162018 - return EMPTY_ARRAY; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.shells.IShellService#launchShell(java.lang.String, java.lang.String[], org.eclipse.core.runtime.IProgressMonitor) - */ - public IHostShell launchShell(String initialWorkingDirectory, String[] environment, IProgressMonitor monitor) throws SystemMessageException { - return launchShell(initialWorkingDirectory, null, environment, monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.services.shells.IShellService#runCommand(java.lang.String, java.lang.String, java.lang.String[], org.eclipse.core.runtime.IProgressMonitor) - */ - public IHostShell runCommand(String initialWorkingDirectory, String command, String[] environment, IProgressMonitor monitor) throws SystemMessageException { - return runCommand(initialWorkingDirectory, command, null, environment, monitor); - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/HostShellChangeEvent.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/HostShellChangeEvent.java deleted file mode 100644 index 18775d953..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/HostShellChangeEvent.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.shells; - -public class HostShellChangeEvent implements IHostShellChangeEvent -{ - protected IHostShell _hostShell; - protected IHostShellOutputReader _reader; - protected int _offset; - protected int _range; - - public HostShellChangeEvent(IHostShell shell, IHostShellOutputReader reader, int offset, int range) - { - _hostShell = shell; - _reader = reader; - _offset = offset; - _range = range; - } - - public IHostShell getHostShell() - { - return _hostShell; - } - - public IHostShellOutputReader getReader() - { - return _reader; - } - - public IHostOutput[] getLines() - { - IHostOutput[] lines = new IHostOutput[_range]; - int r = 0; - int size = _offset + _range ; - for (int i= _offset; i < size; i++) - { - lines[r] = _reader.readLine(i); - r++; - } - return lines; - } - - public IHostOutput[] getLineObjects() - { - return getLines(); - } - - public boolean isError() - { - return _reader.isErrorReader(); - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/HostShellOutputStream.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/HostShellOutputStream.java deleted file mode 100644 index f0bc76658..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/HostShellOutputStream.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 PalmSource, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ewa Matejska (PalmSource) - * Martin Oberhuber (Wind River) - moved from org.eclipse.rse.remotecdt (bug 161777) - * Martin Oberhuber (Wind River) - improved Javadoc - *******************************************************************************/ - -package org.eclipse.rse.services.shells; - -import java.io.IOException; -import java.io.OutputStream; - - -/** - * An adapter between the OutputStream and the IHostShell objects. - * @author Ewa Matejska - * @see IHostShell - * @see java.io.OutputStream - */ -public class HostShellOutputStream extends OutputStream { - - private IHostShell hostShell; - - /** - * Constructor. - * @param hostShell An instance of the IHostShell class. - * The output will be sent to this instance. - */ - public HostShellOutputStream(IHostShell hostShell) { - this.hostShell = hostShell; - } - - /** - * Writes one byte to the shell. - * @see java.io.OutputStream#write(byte[]) - */ - public void write(byte[] b) { - if(hostShell != null && b != null) - hostShell.writeToShell(new String(b)); - } - - /** - * Writes multiple bytes to the shell. - * @see java.io.OutputStream#write(byte[], int, int) - */ - public void write(byte[] b, int off, int len) { - if(hostShell != null && b != null) - hostShell.writeToShell(new String(b, off, len)); - } - - /** - * Writes one character to the shell. - * @see java.io.OutputStream#write(int) - */ - public void write(int b) throws IOException { - char[] array = { (char) b }; - if(hostShell != null) - hostShell.writeToShell(new String(array)); - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/HostShellProcessAdapter.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/HostShellProcessAdapter.java deleted file mode 100644 index e728e464f..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/HostShellProcessAdapter.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 PalmSource, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ewa Matejska (PalmSource) - initial version - * Martin Oberhuber (Wind River) - adapt to IHostOutput API (bug 161773, 158312) - * Martin Oberhuber (Wind River) - moved from org.eclipse.rse.remotecdt (bug 161777) - * Martin Oberhuber (Wind River) - renamed from HostShellAdapter (bug 161777) - * Martin Oberhuber (Wind River) - improved Javadoc - *******************************************************************************/ - -package org.eclipse.rse.services.shells; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; - - -/** - * This class represents a host shell process. It does not - * represent one process running in the shell. This means - * that the output of multiple shell commands will be returned - * until the shell exits. - * - * @author Ewa Matejska - */ -public class HostShellProcessAdapter extends Process implements -IHostShellOutputListener { - - private IHostShell hostShell; - private PipedInputStream inputStream = null; - private PipedInputStream errorStream = null; - private HostShellOutputStream outputStream = null; - - private PipedOutputStream hostShellInput = null; - private PipedOutputStream hostShellError = null; - - /** - * Constructor. - * @param hostShell An instance of the IHostShell class. - * @throws java.io.IOException - */ - public HostShellProcessAdapter(IHostShell hostShell) throws java.io.IOException { - this.hostShell = hostShell; - hostShellInput = new PipedOutputStream(); - hostShellError = new PipedOutputStream(); - inputStream = new PipedInputStream(hostShellInput); - errorStream = new PipedInputStream(hostShellError); - outputStream = new HostShellOutputStream(hostShell); - this.hostShell.getStandardOutputReader().addOutputListener(this); - this.hostShell.getStandardErrorReader().addOutputListener(this); - } - - /** - * Exits the shell. - * @see java.lang.Process#destroy() - */ - public synchronized void destroy() { - hostShell.exit(); - notifyAll(); - try { - hostShellInput.close(); - hostShellError.close(); - inputStream.close(); - errorStream.close(); - outputStream.close(); - } catch (IOException e) { - //FIXME IOException when closing one of the streams will leave others open - // Ignore - } - } - - /** - * There is no relevant exit value to return when the shell exits. - * This always returns 0. - */ - public synchronized int exitValue() { - if(hostShell.isActive()) - throw new IllegalThreadStateException(); - // No way to tell what the exit value was. - // TODO it would be possible to get the exit value - // when the remote process is started like this: - // sh -c 'remotecmd ; echo "-->RSETAG<-- $?\"' - // Then the output steram could be examined for -->RSETAG<-- to get the exit value. - return 0; - } - - /** - * Returns the error stream of the shell. - * @see java.lang.Process#getErrorStream() - */ - public InputStream getErrorStream() { - return errorStream; - } - - /** - * Returns the input stream for the shell. - * @see java.lang.Process#getInputStream() - */ - public InputStream getInputStream() { - return inputStream; - } - - /** - * Returns the output stream for the shell. - * @see java.lang.Process#getOutputStream() - */ - public OutputStream getOutputStream() { - return outputStream; - } - - /** - * Waits for the shell to exit. - * @see java.lang.Process#waitFor() - */ - public synchronized int waitFor() throws InterruptedException { - - while(hostShell.isActive()) { - try { - wait(1000); - } catch (InterruptedException e) { - // ignore because we're polling to see if shell is still active. - } - } - - try { - // Wait a second to try to get some more output from the target shell before closing. - wait(1000); - // Allow for the data from the stream to be read if it's available - if (inputStream.available() != 0 || errorStream.available() != 0) - throw new InterruptedException(); - - hostShellInput.close(); - hostShellError.close(); - inputStream.close(); - errorStream.close(); - outputStream.close(); - } catch (IOException e) { - // Ignore - } - return 0; - } - - /** - * Process an RSE Shell event, by writing the lines of text contained - * in the event into the adapter's streams. - * @see org.eclipse.rse.services.shells.IHostShellOutputListener#shellOutputChanged(org.eclipse.rse.services.shells.IHostShellChangeEvent) - */ - public void shellOutputChanged(IHostShellChangeEvent event) { - IHostOutput[] input = event.getLines(); - OutputStream outputStream = event.isError() ? hostShellError : hostShellInput; - try { - for(int i = 0; i < input.length; i++) { - outputStream.write(input[i].getString().getBytes()); - outputStream.write('\n'); - outputStream.flush(); - } - } catch(IOException e) { - // Ignore - } - } - -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostOutput.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostOutput.java deleted file mode 100644 index 2cc4126d3..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostOutput.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed the initial implementation: - * David McKnight. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.shells; - -public interface IHostOutput -{ - public String getString(); -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShell.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShell.java deleted file mode 100644 index 8139cfcb5..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShell.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.shells; - - -public interface IHostShell -{ - public boolean isActive(); - public void writeToShell(String command); - - public void addOutputListener(IHostShellOutputListener listener); - - public IHostShellOutputReader getStandardOutputReader(); - public IHostShellOutputReader getStandardErrorReader(); - - public void exit(); - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShellChangeEvent.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShellChangeEvent.java deleted file mode 100644 index 68be8f284..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShellChangeEvent.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.shells; - -public interface IHostShellChangeEvent -{ - public IHostShell getHostShell(); - public IHostShellOutputReader getReader(); - public IHostOutput[] getLines(); - public boolean isError(); -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShellOutputListener.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShellOutputListener.java deleted file mode 100644 index 2eba910ab..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShellOutputListener.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.shells; - -public interface IHostShellOutputListener -{ - public void shellOutputChanged(IHostShellChangeEvent event); -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShellOutputNotifier.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShellOutputNotifier.java deleted file mode 100644 index da7273e44..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShellOutputNotifier.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.shells; - -public interface IHostShellOutputNotifier -{ - public void fireOutputChanged(IHostShellChangeEvent event); - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShellOutputReader.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShellOutputReader.java deleted file mode 100644 index 103c31ff2..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IHostShellOutputReader.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.shells; - -public interface IHostShellOutputReader extends IHostShellOutputNotifier -{ - public IHostOutput readLine(); - public IHostOutput readLine(int index); - public void addOutputListener(IHostShellOutputListener listener); - public boolean isErrorReader(); - public void finish(); -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IShellService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IShellService.java deleted file mode 100644 index 19b99e926..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IShellService.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006, 2008 IBM Corporation and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API - * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc - * Martin Oberhuber (Wind River) - [226301][api] IShellService should throw SystemMessageException on error - ********************************************************************************/ - -package org.eclipse.rse.services.shells; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.rse.services.IService; -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; - -/** - * IShellService is an abstraction for running shells and shell commands. - * - * @noimplement This interface is not intended to be implemented by clients. - * Search service implementations must subclass - * {@link AbstractShellService} rather than implementing this - * interface directly. - */ -public interface IShellService extends IService -{ - /** - * Launch a new shell in the specified directory with a default encoding. - * - * This is a convenience method, passing <code>null</code> as encoding - * into {@link #launchShell(String, String, String[], IProgressMonitor)}. - * - * @throws SystemMessageException in case an error occurred or the user - * chose to cancel the operation via the progress monitor. - */ - public IHostShell launchShell(String initialWorkingDirectory, String[] environment, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Launch a new shell in the specified directory. - * - * @param initialWorkingDirectory initial working directory or empty String - * ("") if not relevant. The remote shell will launch in a - * directory of its own choice in that case (typically a user's - * home directory). - * @param encoding Stream encoding to use, or <code>null</code> to fall - * back to a default encoding. The Shell Service will make - * efforts to determine a proper default encoding on the remote - * side but this is not guaranteed to be correct. - * @param environment Array of environment variable Strings of the form - * "var=text". Since not all shell implementations support the - * passing of environment variables, there is no guarantee that - * the created shell will actually have the specified environment - * set. - * @param monitor Progress Monitor for monitoring and cancellation - * @return the shell object. Note that the shell may not actually be usable - * in case the remote side allows opening a channel but immediately - * closes it again. In this case, {@link IHostShell#isActive()} - * returns <code>false</code> on the created Shell object. - * @throws SystemMessageException in case an error occurred or the user - * chose to cancel the operation via the progress monitor. - */ - public IHostShell launchShell(String initialWorkingDirectory, String encoding, String[] environment, IProgressMonitor monitor) throws SystemMessageException; - - /** - * - * Run a single command in it's own shell with a default encoding. - * - * This is a convenience method, passing <code>null</code> as encoding - * into - * {@link #runCommand(String, String, String, String[], IProgressMonitor)}. - * - * @throws SystemMessageException in case an error occurred or the user - * chose to cancel the operation via the progress monitor. - */ - public IHostShell runCommand(String initialWorkingDirectory, String command, String[] environment, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Run a single command in it's own shell. - * - * This method is similar to - * {@link #launchShell(String, String, String[], IProgressMonitor)} but - * immediately executes a specified command rather than just opening a - * shell. There is no guarantee that after the host shell will accept any - * subsequent commands after the initial command has been executed; there - * is, however, also no guarantee that the host shell will terminate the - * connection automatically. Clients need to call {@link IHostShell#exit()} - * in case the shell remains active after the initial command is completed. - * - * @param initialWorkingDirectory initial working directory or empty String - * ("") if not relevant. The remote command will launch in a - * directory of its own choice in that case (typically a user's - * home directory). - * @param command initial command to send to the remote side. - * @param encoding Stream encoding to use, or <code>null</code> to fall - * back to a default encoding. The Shell Service will make - * efforts to determine a proper default encoding on the remote - * side but this is not guaranteed to be correct. - * @param environment Array of environment variable Strings of the form - * "var=text". Since not all shell implementations support the - * passing of environment variables, there is no guarantee that - * the created shell will actually have the specified environment - * set. - * @param monitor Progress Monitor for monitoring and cancellation - * @return the shell object for getting output and error streams. Note that - * the shell may not actually be usable in case an error occurred on - * the remote side, such as the command not being executable. In - * this case, {@link IHostShell#isActive()} returns - * <code>false</code> on the created Shell object. - * @throws SystemMessageException in case an error occurred or the user - * chose to cancel the operation via the progress monitor. - */ - public IHostShell runCommand(String initialWorkingDirectory, String command, String encoding, String[] environment, IProgressMonitor monitor) throws SystemMessageException; - - /** - * Return an array of environment variables that describe the environment on - * the remote system. Each String returned is of the format "var=text": - * Everything up to the first equals sign is the name of the given - * environment variable, everything after the equals sign is its contents. - * - * @return Array of environment variable Strings of the form "var=text" if - * supported by a shell service implementation. Should return an - * empty array in case environment variable retrieval is not - * supported on a particular shell service implementation. - * @throws SystemMessageException in case an error occurred or the user - * chose to cancel the operation via the progress monitor. - */ - public String[] getHostEnvironment() throws SystemMessageException; -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/ParsedOutput.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/ParsedOutput.java deleted file mode 100644 index 82e37851b..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/ParsedOutput.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.services.shells; - -//This is just a convenience object for storing information parsed out of a line of output. -public class ParsedOutput -{ - - - public String type; - public String text; - public String file; - public int line; - public int col; - - public ParsedOutput (String theType, String theText, String theFile, int theLine, int theColumn) - { - type = theType; - text = theText; - file = theFile; - line = theLine; - col = theColumn; - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/Patterns.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/Patterns.java deleted file mode 100644 index aa0c58ba7..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/Patterns.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ -package org.eclipse.rse.services.shells; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.ArrayList; -import java.util.regex.Pattern; - -import org.eclipse.rse.internal.services.Activator; -import org.eclipse.rse.internal.services.shells.CommandPattern; -import org.eclipse.rse.internal.services.shells.OutputPattern; - -import org.osgi.framework.Bundle; - -public class Patterns { - private ArrayList _theCommands; - private String _currentCommand; - - public Patterns() { - _theCommands = new ArrayList(); - parsePatterns(); - } - - private void parsePatterns() { - Bundle bundle = Activator.getDefault().getBundle(); - URL patterns = bundle.getEntry("/patterns.dat"); //$NON-NLS-1$ - if (patterns != null) { - try { - InputStream in = patterns.openStream(); - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - _theCommands.clear(); - String curLine; - CommandPattern curCommand = null; - while ((curLine = reader.readLine()) != null) { - curLine = curLine.trim(); - // Skip the current line if it is empty or starts with a # - if ((curLine.length() == 0) || (curLine.charAt(0) == '#')) { - continue; - } - // Check if this line is the start of a new command section - if (curLine.startsWith("command")) { //$NON-NLS-1$ - int colon = curLine.indexOf(":"); //$NON-NLS-1$ - // Check that there is something after the colon - if (colon == (curLine.length() - 1)) { - continue; - } - Pattern thePattern = Pattern.compile(curLine.substring(colon + 1, curLine.length()).trim()); - curCommand = new CommandPattern(thePattern); - _theCommands.add(curCommand); - } - // If we get here, the line must be an output pattern - else { - int firstSpace = curLine.indexOf(" "); //$NON-NLS-1$ - int patternWord = curLine.indexOf("pattern"); //$NON-NLS-1$ - int firstEquals = curLine.indexOf("="); //$NON-NLS-1$ - if ((firstEquals == -1) || (firstEquals == (curLine.length() - 1))) { - continue; - } - String objType = curLine.substring(0, firstSpace); - String matchOrder = curLine.substring(firstSpace + 1, patternWord).trim(); - String patternString = curLine.substring(firstEquals + 1, curLine.length()); - Pattern thePattern = Pattern.compile(patternString.trim()); - if (curCommand != null) { - curCommand.addOutputPattern(new OutputPattern(objType, matchOrder, thePattern)); - } - } - } - in.close(); - } catch (IOException e) { - Activator.getDefault().logException(e); - } - } - } - - public void refresh(String theCommand) { - _currentCommand = theCommand; - parsePatterns(); - } - - public void update(String theCommand) { - _currentCommand = theCommand; - } - - public ParsedOutput matchLine(String theLine) { - CommandPattern curCommand; - ParsedOutput matchedOutput = null; - int commands = _theCommands.size(); - if (_currentCommand != null) - { - - for (int i = 0; i < commands; i++) - { - curCommand = (CommandPattern) _theCommands.get(i); - if (curCommand.matchCommand(_currentCommand)) - { - matchedOutput = curCommand.matchLine(theLine); - } - if (matchedOutput != null) - { - return matchedOutput; - } - } - } - return null; - } -} diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/SimpleHostOutput.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/SimpleHostOutput.java deleted file mode 100644 index c95791008..000000000 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/SimpleHostOutput.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed the initial implementation: - * David McKnight. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ -package org.eclipse.rse.services.shells; - -public class SimpleHostOutput implements IHostOutput -{ - private String _line; - public SimpleHostOutput(String line) - { - _line = line; - } - - public String getString() - { - return _line; - } - - public String toString() - { - return _line; - } -} |