From e3b82f8326a94a59373d16bc3000bc0cf9eca4a8 Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Wed, 9 Apr 2008 19:28:07 +0000 Subject: [PATCH] [Bug 226262] [api][breaking] RSE IService should be IAdaptable --- .../daytime/service/DaytimeService.java | 33 +- .../dstore/files/DStoreFileService.java | 699 +++++++++--------- .../processes/DStoreProcessService.java | 116 +-- .../dstore/shells/DStoreShellService.java | 57 +- .../dstore/AbstractDStoreService.java | 154 ++-- .../services/files/ftp/FTPService.java | 9 +- .../local/files/LocalFileService.java | 10 +- .../local/processes/LocalProcessService.java | 45 +- .../local/shells/LocalShellService.java | 51 +- .../services/ssh/files/SftpFileService.java | 3 + .../services/ssh/shell/SshHostShell.java | 30 +- .../services/ssh/shell/SshShellService.java | 42 +- .../telnet/shell/TelnetShellService.java | 50 +- .../org.eclipse.core.resources.prefs | 3 + .../eclipse/rse/services/AbstractService.java | 51 ++ .../org/eclipse/rse/services/IService.java | 62 +- .../services/files/AbstractFileService.java | 55 +- .../src/org/eclipse/rse/services/package.html | 32 + .../processes/AbstractProcessService.java | 50 +- .../services/processes/IProcessService.java | 101 ++- .../search/AbstractSearchService.java | 32 +- .../services/search/HostSearchResultSet.java | 100 ++- .../rse/services/search/ISearchService.java | 22 +- .../services/shells/AbstractShellService.java | 45 ++ .../rse/services/shells/IShellService.java | 123 ++- .../shell/linux/LinuxShellProcessService.java | 33 +- .../wince/files/WinCEFileService.java | 55 +- 27 files changed, 1116 insertions(+), 947 deletions(-) create mode 100644 rse/plugins/org.eclipse.rse.services/.settings/org.eclipse.core.resources.prefs create mode 100644 rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/AbstractService.java create mode 100644 rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/package.html create mode 100644 rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractShellService.java diff --git a/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/service/DaytimeService.java b/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/service/DaytimeService.java index 707ceb22b25..491c47b3601 100644 --- a/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/service/DaytimeService.java +++ b/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/service/DaytimeService.java @@ -1,13 +1,14 @@ /******************************************************************************* - * 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 + * Copyright (c) 2006, 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) - [216252] use SimpleSystemMessage instead of getMessage() + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable *******************************************************************************/ package org.eclipse.rse.examples.daytime.service; @@ -18,17 +19,16 @@ import java.io.InputStreamReader; import java.net.Socket; import java.net.UnknownHostException; -import org.eclipse.core.runtime.IProgressMonitor; - import org.eclipse.rse.examples.daytime.DaytimeResources; +import org.eclipse.rse.services.AbstractService; /** * The DaytimeService implements the UI-less protocol for accessing the * daytime TCP service on a remote host. Other implementations of the * same interface might use other methods for retrieving the time of day. */ -public class DaytimeService implements IDaytimeService { - +public class DaytimeService extends AbstractService implements IDaytimeService { + private String fHostname; public DaytimeService() { @@ -43,11 +43,6 @@ public class DaytimeService implements IDaytimeService { return DaytimeResources.Daytime_Service_Description; } - public void initService(IProgressMonitor monitor) { - //nothing to do - } - - public void setHostName(String hostname) { fHostname = hostname; } @@ -61,8 +56,4 @@ public class DaytimeService implements IDaytimeService { return result; } - public void uninitService(IProgressMonitor monitor) { - //nothing to do - } - } diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java index a04ff297206..ae0431c704d 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java @@ -7,21 +7,21 @@ * * 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, + * 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: * Kevin Doyle (IBM) - Fix 183870 - Display File Exists Error * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * Xuan Chen (IBM) - [189681] [dstore][linux] Refresh Folder in My Home messes up Refresh in Root * Kushal Munir (IBM) - [189352] Replace with appropriate line end character on upload - * David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout + * David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout * David McKnight (IBM) - [196035] Wrapper SystemMessageExceptions for createFile and createFolder with RemoteFileSecurityException * Kevin Doyle (IBM) - [191548] Deleting Read-Only directory removes it from view and displays no error * Xuan Chen (IBM) - [202670] [Supertransfer] After doing a copy to a directory that contains folders some folders name's display "deleted" - * Xuan Chen (IBM) - [190824] Incorrect result for DStore#getSeparator() function when parent is "/" - * David McKnight (IBM) - [207095] check for null datastore + * Xuan Chen (IBM) - [190824] Incorrect result for DStore#getSeparator() function when parent is "/" + * David McKnight (IBM) - [207095] check for null datastore * 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) - [209423] Fix for null pointer - filter attributes need unique ids @@ -40,6 +40,7 @@ * Radoslav Gerganov (ProSyst) - [216195] [dstore] Saving empty file fails * David McKnight (IBM) - [220379] [api] Provide a means for contributing custom BIDI encodings * David McKnight (IBM) - [225573] [dstore] client not falling back to single operation when missing batch descriptors (due to old server) + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable *******************************************************************************/ package org.eclipse.rse.internal.services.dstore.files; @@ -104,15 +105,15 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer protected org.eclipse.dstore.core.model.DataElement _uploadLogElement = null; protected Map _fileElementMap; protected Map _dstoreFileMap; - + private int _bufferUploadSize = IUniversalDataStoreConstants.BUFFER_SIZE; private int _bufferDownloadSize = IUniversalDataStoreConstants.BUFFER_SIZE; protected ISystemFileTypes _fileTypeRegistry; private String remoteEncoding; - + protected boolean unixStyle = false; - + private static String[] _filterAttributes = { "attributes", //$NON-NLS-1$ "filter", //$NON-NLS-1$ @@ -122,7 +123,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer "", //$NON-NLS-1$ DataStoreResources.FALSE, "2"}; //$NON-NLS-1$ - + public DStoreFileService(IDataStoreProvider dataStoreProvider, ISystemFileTypes fileTypeRegistry) { super(dataStoreProvider); @@ -130,57 +131,55 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer _dstoreFileMap = new HashMap(); _fileTypeRegistry = fileTypeRegistry; } - + public void uninitService(IProgressMonitor monitor) { - super.uninitService(monitor); _fileElementMap.clear(); _dstoreFileMap.clear(); _uploadLogElement = null; + super.uninitService(monitor); } - - public String getName() { return ServiceResources.DStore_File_Service_Label; } - + public String getDescription() { return ServiceResources.DStore_File_Service_Description; } - + public void setBufferUploadSize(int size) { _bufferUploadSize = size; } - + public void setBufferDownloadSize(int size) { _bufferDownloadSize = size; } - + protected int getBufferUploadSize() { return _bufferUploadSize; } - + protected int getBufferDownloadSize() { return _bufferDownloadSize; } - + protected String getMinerId() { return IUniversalDataStoreConstants.UNIVERSAL_FILESYSTEM_MINER_ID; } - + protected String getByteStreamHandlerId() { return UniversalByteStreamHandler.class.getName(); } - + protected String getDataStoreRoot() { DataStore ds = getDataStore(); @@ -188,7 +187,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer return ds.getAttribute(DataStoreAttributes.A_LOCAL_PATH); return null; } - + protected String prepareForDownload(String localPath) { @@ -213,7 +212,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer if (ds != null) ds.setAttribute(DataStoreAttributes.A_LOCAL_PATH, root); } - + protected DataElement findUploadLog() { DataElement minerInfo = getMinerElement(); @@ -231,8 +230,8 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } return _uploadLogElement; } - - + + protected DataElement getAttributes(String fileNameFilter, boolean showHidden) { @@ -241,7 +240,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { String[] clonedAttributes = (String[])_filterAttributes.clone(); clonedAttributes[DE.A_ID] = fileNameFilter; - + DataElement attributes = ds.createTransientObject(clonedAttributes); String version = IServiceConstants.VERSION_1; StringBuffer buffer = new StringBuffer(); @@ -256,17 +255,17 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } } - + public boolean upload(InputStream inputStream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) { BufferedInputStream bufInputStream = null; - - boolean isCancelled = false; - + + boolean isCancelled = false; + try - { + { String byteStreamHandlerId = getByteStreamHandlerId(); String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile; @@ -280,7 +279,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer // ds.getDomainNotifier().addDomainListener(listener); int buffer_size = getBufferUploadSize(); - + // read in the file bufInputStream = new BufferedInputStream(inputStream, buffer_size); @@ -290,62 +289,62 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer int available = bufInputStream.available(); - + // line separator of local machine String localLineSep = System.getProperty("line.separator"); //$NON-NLS-1$ - + // line separator of remote machine String targetLineSep = "\n"; //$NON-NLS-1$ - + if (!unixStyle) { targetLineSep = "\r\n"; //$NON-NLS-1$ } - + int localLineSepLength = localLineSep.length(); - + long totalSent = 0; // upload bytes while available while (available > 0 && !isCancelled) { - - + + numToRead = (available < buffer_size) ? available : buffer_size; int bytesRead = bufInputStream.read(buffer, 0, numToRead); if (bytesRead == -1) break; - + totalSent += bytesRead; - if (!isBinary && hostEncoding != null) + if (!isBinary && hostEncoding != null) { String tempStr = new String(buffer, 0, bytesRead); - - // if the line end characters of the local and remote machines are different, we need to replace them + + // if the line end characters of the local and remote machines are different, we need to replace them if (!localLineSep.equals(targetLineSep)) { int index = tempStr.indexOf(localLineSep); - + StringBuffer buf = new StringBuffer(); - + boolean lineEndFound = false; int lastIndex = 0; - + while (index != -1) { buf = buf.append(tempStr.substring(lastIndex, index)); buf = buf.append(targetLineSep); - + if (!lineEndFound) { lineEndFound = true; } - + lastIndex = index+localLineSepLength; - + index = tempStr.indexOf(localLineSep, lastIndex); } - + if (lineEndFound) { buf = buf.append(tempStr.substring(lastIndex)); tempStr = buf.toString(); @@ -354,7 +353,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer convBytes = tempStr.getBytes(hostEncoding); - + // append subsequent segments getDataStore().replaceAppendFile(remotePath, convBytes, convBytes.length, true, byteStreamHandlerId); } @@ -362,9 +361,9 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { // append subsequent segments getDataStore().replaceAppendFile(remotePath, buffer, bytesRead, true, byteStreamHandlerId); - } - - + } + + if (monitor != null) { @@ -431,46 +430,46 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } } - + return true; } - + public boolean upload(File file, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) { FileInputStream inputStream = null; BufferedInputStream bufInputStream = null; - + boolean isCancelled = false; boolean transferSuccessful = false; long totalBytes = file.length(); - + try - { + { String byteStreamHandlerId = getByteStreamHandlerId(); String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile; // create an empty file and append data to it later // this handles the case of uploading empty files as well getDataStore().replaceFile(remotePath, new byte[] {}, 0, isBinary, byteStreamHandlerId); - + if (monitor != null) { monitor.setTaskName(file.getName()); //subMonitor = new SubProgressMonitor(monitor, (int)totalBytes); } - + // DataElement uploadLog = findUploadLog(); findUploadLog(); // listener = new FileTransferStatusListener(remotePath, shell, monitor, getConnectorService(), ds, uploadLog); // ds.getDomainNotifier().addDomainListener(listener); int buffer_size = getBufferUploadSize(); - + // read in the file inputStream = new FileInputStream(file); bufInputStream = new BufferedInputStream(inputStream, buffer_size); @@ -482,70 +481,70 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer int available = bufInputStream.available(); long totalSent = 0; - + // line separator of local machine String localLineSep = System.getProperty("line.separator"); //$NON-NLS-1$ - + // line separator of remote machine String targetLineSep = "\n"; //$NON-NLS-1$ - + if (!unixStyle) { targetLineSep = "\r\n"; //$NON-NLS-1$ } - + int localLineSepLength = localLineSep.length(); - + IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(hostEncoding, this); // upload bytes while available while (available > 0 && !isCancelled) { - + numToRead = (available < buffer_size) ? available : buffer_size; int bytesRead = bufInputStream.read(buffer, 0, numToRead); if (bytesRead == -1) break; - + totalSent += bytesRead; - if (!isBinary && srcEncoding != null && hostEncoding != null) + if (!isBinary && srcEncoding != null && hostEncoding != null) { String tempStr = new String(buffer, 0, bytesRead, srcEncoding); - - // if the line end characters of the local and remote machines are different, we need to replace them + + // if the line end characters of the local and remote machines are different, we need to replace them if (!localLineSep.equals(targetLineSep)) { int index = tempStr.indexOf(localLineSep); - + StringBuffer buf = new StringBuffer(); - + boolean lineEndFound = false; int lastIndex = 0; - + while (index != -1) { buf = buf.append(tempStr.substring(lastIndex, index)); buf = buf.append(targetLineSep); - + if (!lineEndFound) { lineEndFound = true; } - + lastIndex = index+localLineSepLength; - + index = tempStr.indexOf(localLineSep, lastIndex); } - + if (lineEndFound) { buf = buf.append(tempStr.substring(lastIndex)); tempStr = buf.toString(); } } - + convBytes = codePageConverter.convertClientStringToRemoteBytes(remotePath, tempStr, hostEncoding, this); - + // append subsequent segments getDataStore().replaceAppendFile(remotePath, convBytes, convBytes.length, true, byteStreamHandlerId); } @@ -553,9 +552,9 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { // append subsequent segments getDataStore().replaceAppendFile(remotePath, buffer, bytesRead, true, byteStreamHandlerId); - } - - + } + + if (/*display != null &&*/ monitor != null) { double percent = (totalSent * 1.0) / totalBytes; @@ -563,11 +562,11 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer String str = MessageFormat.format( ServiceResources.DStore_Service_Percent_Complete_Message, new Object[] { - new Long(totalSent / IUniversalDataStoreConstants.KB_IN_BYTES), + new Long(totalSent / IUniversalDataStoreConstants.KB_IN_BYTES), new Long(totalBytes / IUniversalDataStoreConstants.KB_IN_BYTES), new Double(percent) }); - monitor.subTask(str); + monitor.subTask(str); isCancelled = monitor.isCanceled(); } @@ -633,7 +632,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { if (transferSuccessful) { - + // try // { @@ -644,9 +643,9 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer // { // UniversalSystemPlugin.logError(CLASSNAME + " InterruptedException while waiting for command", e); // } - + } - + //ds.getDomainNotifier().removeDomainListener(listener); // if (listener.uploadHasFailed()) @@ -655,7 +654,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer // } } } - + return true; } @@ -665,18 +664,18 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { DataStore ds = getDataStore(); DataElement universaltemp = getMinerElement(); - - //int mode = isBinary ? IUniversalDataStoreConstants.BINARY_MODE : IUniversalDataStoreConstants.TEXT_MODE; + + //int mode = isBinary ? IUniversalDataStoreConstants.BINARY_MODE : IUniversalDataStoreConstants.TEXT_MODE; int mode = IUniversalDataStoreConstants.BINARY_MODE; - + if (!makeSureLocalExists(localFile)) { return false; } - + String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile; - + DataElement de = getElementFor(remotePath); if (de.getType().equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR)) { @@ -689,11 +688,11 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { monitor.beginTask(remotePath, (int)fileLength); } - - - DataElement remoteElement = ds.createObject(universaltemp, de.getType(), remotePath, String.valueOf(mode)); + + + DataElement remoteElement = ds.createObject(universaltemp, de.getType(), remotePath, String.valueOf(mode)); DataElement localElement = ds.createObject(universaltemp, de.getType(), localFile.getAbsolutePath(), encoding); - + DataElement bufferSizeElement = ds.createObject(universaltemp, "buffer_size", "" + getBufferDownloadSize(), ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ DataElement queryCmd = getCommandDescriptor(de,IUniversalDataStoreConstants.C_DOWNLOAD_FILE); @@ -701,9 +700,9 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer argList.add(remoteElement); argList.add(localElement); argList.add(bufferSizeElement); - + DataElement subject = ds.createObject(universaltemp, de.getType(), remotePath, String.valueOf(mode)); - + DataElement status = ds.command(queryCmd, argList, subject); if (status == null) { @@ -725,7 +724,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { monitor.setCanceled(true); } - + //InterruptedException is used to report user cancellation, so no need to log //This should be reviewed (use OperationCanceledException) with bug #190750 } @@ -746,13 +745,13 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer lastLocalBytes= localBytes; Thread.sleep(100); localBytes = localFile.length(); - + } catch (Exception e) - { + { } } - + List resultList = remoteElement.getNestedData(); DataElement resultChild = null; @@ -762,26 +761,26 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer resultChild = (DataElement) resultList.get(i); if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_SUCCESS_TYPE)) - { - if (!isBinary){ // do standard conversion if this is text! + { + if (!isBinary){ // do standard conversion if this is text! String localEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$ IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(encoding, this); - + codePageConverter.convertFileFromRemoteEncoding(remotePath, localFile, encoding, localEncoding, this); } - - - + + + return true; } else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_FILE_NOT_FOUND_EXCEPTION)) { localFile.delete(); - + String msgTxt = ServiceResources.FILEMSG_SECURITY_ERROR; String msgDetails = NLS.bind(ServiceResources.FILEMSG_SECURITY_ERROR_DETAILS, IUniversalDataStoreConstants.DOWNLOAD_RESULT_FILE_NOT_FOUND_EXCEPTION); - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_SECURITY_ERROR, IStatus.ERROR, msgTxt, msgDetails); throw new SystemMessageException(msg); @@ -794,14 +793,14 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer //UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error reading file " + remotePath, e); //throw new RemoteFileIOException(e); } - + else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_IO_EXCEPTION)) { localFile.delete(); - + String msgTxt = ServiceResources.FILEMSG_SECURITY_ERROR; String msgDetails = NLS.bind(ServiceResources.FILEMSG_SECURITY_ERROR_DETAILS, IUniversalDataStoreConstants.DOWNLOAD_RESULT_IO_EXCEPTION); - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_SECURITY_ERROR, IStatus.ERROR, msgTxt, msgDetails); @@ -839,30 +838,30 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } return true; } - + /** * Default implementation - just iterate through each file */ public boolean downloadMultiple(String[] remoteParents, String[] remoteFiles, File[] localFiles, boolean[] isBinaries, String[] hostEncodings, - IProgressMonitor monitor) throws SystemMessageException - { + IProgressMonitor monitor) throws SystemMessageException + { boolean result = true; - - + + List downloadListeners = new ArrayList(); List remoteElements = new ArrayList(); - + DataStore ds = getDataStore(); DataElement universaltemp = getMinerElement(); - + // get the subjects String[] paths = getPathsFor(remoteParents, remoteFiles); DataElement[] des = getElementsFor(paths); - + DataElement queryCmd = null; DataElement bufferSizeElement = null; - + // if any elements are unresolved, do a query on them List unresolved = new ArrayList(); for (int d = 0; d < des.length; d++) @@ -884,64 +883,64 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer parents[u] = de.getValue(); names[u] = de.getName(); } - + // I think the de should be reused since getElement should find it? - getFileMultiple(parents, names, monitor); + getFileMultiple(parents, names, monitor); } - - + + // kick off all downloads for (int i = 0; i < des.length && result == true; i++) { int mode = IUniversalDataStoreConstants.BINARY_MODE; DataElement de = des[i]; String remotePath = paths[i]; - + File localFile = localFiles[i]; String hostEncoding = hostEncodings[i]; - + if (!makeSureLocalExists(localFile)) { return false; } - + long fileLength = DStoreHostFile.getFileLength(de.getSource()); if (monitor != null) { monitor.beginTask(remotePath, (int)fileLength); } - - DataElement remoteElement = ds.createObject(universaltemp, de.getType(), remotePath, String.valueOf(mode)); + + DataElement remoteElement = ds.createObject(universaltemp, de.getType(), remotePath, String.valueOf(mode)); DataElement localElement = ds.createObject(universaltemp, de.getType(), localFile.getAbsolutePath(), hostEncoding); - + // only do this once if (bufferSizeElement == null) - bufferSizeElement = ds.createObject(universaltemp, "buffer_size", "" + getBufferDownloadSize(), ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + bufferSizeElement = ds.createObject(universaltemp, "buffer_size", "" + getBufferDownloadSize(), ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + // only do this once if (queryCmd == null) queryCmd = getCommandDescriptor(de,IUniversalDataStoreConstants.C_DOWNLOAD_FILE); - + ArrayList argList = new ArrayList(); argList.add(remoteElement); argList.add(localElement); argList.add(bufferSizeElement); - + DataElement subject = ds.createObject(universaltemp, de.getType(), remotePath, String.valueOf(mode)); - + DataElement status = ds.command(queryCmd, argList, subject); if (status == null) { System.out.println("no download descriptor for "+remoteElement); //$NON-NLS-1$ return false; } - + DownloadListener dlistener = new DownloadListener(status, localFile, remotePath, fileLength, monitor); downloadListeners.add(dlistener); remoteElements.add(remoteElement); } - + // all downloads have been started // now wait for each to complete for (int j = 0; j < downloadListeners.size(); j++) @@ -962,7 +961,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { monitor.setCanceled(true); } - + //InterruptedException is used to report user cancellation, so no need to log //This should be reviewed (use OperationCanceledException) with bug #190750 } @@ -985,13 +984,13 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer lastLocalBytes= localBytes; Thread.sleep(100); localBytes = localFile.length(); - + } catch (Exception e) - { + { } } - + DataElement remoteElement = (DataElement)remoteElements.get(j); List resultList = remoteElement.getNestedData(); DataElement resultChild = null; @@ -1000,28 +999,28 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { for (int i = 0; i < resultList.size(); i++) { - + resultChild = (DataElement) resultList.get(i); - + if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_SUCCESS_TYPE)) { // do standard conversion if this is text! - if (!isBinaries[i]){ // do standard conversion if this is text! + if (!isBinaries[i]){ // do standard conversion if this is text! String localEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$ IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(hostEncodings[i], this); codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[i], localEncoding, this); } - + result = true; } else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_FILE_NOT_FOUND_EXCEPTION)) { localFile.delete(); - + String msgTxt = ServiceResources.FILEMSG_SECURITY_ERROR; String msgDetails = NLS.bind(ServiceResources.FILEMSG_SECURITY_ERROR_DETAILS, IUniversalDataStoreConstants.DOWNLOAD_RESULT_FILE_NOT_FOUND_EXCEPTION); - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_SECURITY_ERROR, IStatus.ERROR, msgTxt, msgDetails); throw new SystemMessageException(msg); @@ -1035,13 +1034,13 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer //throw new RemoteFileIOException(e); result = false; } - + else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_IO_EXCEPTION)) { localFile.delete(); String msgTxt = ServiceResources.FILEMSG_SECURITY_ERROR; String msgDetails = NLS.bind(ServiceResources.FILEMSG_SECURITY_ERROR_DETAILS, IUniversalDataStoreConstants.DOWNLOAD_RESULT_IO_EXCEPTION); - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_SECURITY_ERROR, IStatus.ERROR, msgTxt, msgDetails); throw new SystemMessageException(msg); @@ -1054,11 +1053,11 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer result = false; } } - + if (monitor != null) { //monitor.done(); - } + } } } return result; @@ -1070,7 +1069,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer public boolean uploadMultiple(File[] localFiles, String[] remoteParents, String[] remoteFiles, boolean[] isBinaries, String[] srcEncodings, String[] hostEncodings, IProgressMonitor monitor) - throws SystemMessageException + throws SystemMessageException { boolean result = true; for (int i = 0; i < localFiles.length && result == true; i++) @@ -1078,7 +1077,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer File localFile = localFiles[i]; String remoteParent = remoteParents[i]; String remoteFile = remoteFiles[i]; - + boolean isBinary = isBinaries[i]; String srcEncoding = srcEncodings[i]; String hostEncoding = hostEncodings[i]; @@ -1086,7 +1085,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } return result; } - + private DataElement getSubjectFor(String remoteParent, String name) { DataElement de = null; @@ -1106,7 +1105,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } return de; } - + private DataElement[] getSubjectsFor(String[] remoteParents, String[] names) { List subjects = new ArrayList(); @@ -1117,12 +1116,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } return (DataElement[])subjects.toArray(new DataElement[subjects.size()]); } - + public IHostFile getFile(String remoteParent, String name, IProgressMonitor monitor) { DataElement de = getSubjectFor(remoteParent, name); - - // with 207095, it's possible to get here unconnected such that there is no element + + // with 207095, it's possible to get here unconnected such that there is no element if (de != null) { dsQueryCommand(de, null, IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT, monitor); //getFile call should also need to convert this DataElement into a HostFile using @@ -1133,22 +1132,22 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer return null; } } - + /** * Mass query of individual files */ - public IHostFile[] getFileMultiple(String remoteParents[], String names[], IProgressMonitor monitor) + public IHostFile[] getFileMultiple(String remoteParents[], String names[], IProgressMonitor monitor) throws SystemMessageException { DataElement[] subjects = getSubjectsFor(remoteParents, names); - + // construct default array of commands String[] queryStrings = new String[remoteParents.length]; for (int i = 0; i < queryStrings.length; i++) { queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT; } - + dsQueryCommandMulti(subjects, null, queryStrings, monitor); return convertToHostFiles(subjects, "*"); //$NON-NLS-1$ @@ -1163,9 +1162,9 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer protected String getSeparator(String parentPath) { if (parentPath == null || parentPath.length() < 1) return "/"; //$NON-NLS-1$ - if (parentPath.length() == 1) + if (parentPath.length() == 1) { - //deal with the case where parentPath has only one character here + //deal with the case where parentPath has only one character here //since the code below assumes parentPath has at least two characters. if (parentPath.charAt(0) == '/') { @@ -1173,7 +1172,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } else { - //If only one character, but not '/', just return "/" as default. But this should not happen. + //If only one character, but not '/', just return "/" as default. But this should not happen. return "/"; //$NON-NLS-1$ } } @@ -1202,7 +1201,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer else return "/"; //$NON-NLS-1$ else return "/"; //unrecognized path //$NON-NLS-1$ } - + protected IHostFile convertToHostFile(DataElement element) { String type = element.getType(); @@ -1211,10 +1210,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer type.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR)) { file = new DStoreVirtualHostFile(element); - } + } else { - file = new DStoreHostFile(element); + file = new DStoreHostFile(element); } String path = file.getAbsolutePath(); _fileElementMap.put(path, element); @@ -1235,7 +1234,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { DataElement element = elements[i]; if (element != null && !element.isDeleted() && element.getType() != null) - { + { String type = element.getType(); // filter files if (type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR) || type.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR)) @@ -1253,7 +1252,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } return (IHostFile[]) results.toArray(new IHostFile[results.size()]); } - + public IHostFile getUserHome() @@ -1265,91 +1264,91 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { String remotePath = remoteParent + getSeparator(remoteParent) + fileName; DataElement de = getElementFor(remotePath); - - + + DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_CREATE_FILE, monitor); if (status == null) return null; - + if (null != monitor && monitor.isCanceled()) { - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ICommonMessageIds.MSG_OPERATION_CANCELED, IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED); //This operation has been canceled by the user. - throw new SystemMessageException(msg); + throw new SystemMessageException(msg); } - - if (FileSystemMessageUtil.getSourceMessage(status).equals(IServiceConstants.SUCCESS)) + + if (FileSystemMessageUtil.getSourceMessage(status).equals(IServiceConstants.SUCCESS)) return new DStoreHostFile(de); else if (FileSystemMessageUtil.getSourceMessage(status).equals(IServiceConstants.FAILED_WITH_EXIST)) - { + { String msgTxt = ServiceResources.FILEMSG_CREATE_FILE_FAILED_EXIST; String msgDetails = NLS.bind(ServiceResources.FILEMSG_CREATE_FILE_FAILED_EXIST_DETAILS, remotePath); - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_CREATE_FILE_FAILED_EXIST, IStatus.ERROR, msgTxt, msgDetails); - throw new SystemMessageException(msg); + throw new SystemMessageException(msg); } else - { + { // for 196035 - throwing security exception instead of message exception String msgTxt = ServiceResources.FILEMSG_CREATE_FILE_FAILED; String msgDetails = ServiceResources.FILEMSG_CREATE_FILE_FAILED_DETAILS; - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_CREATE_FILE_FAILED, IStatus.ERROR, msgTxt, msgDetails); - - - Exception e= new SystemMessageException(msg); + + + Exception e= new SystemMessageException(msg); RemoteFileSecurityException messageException = new RemoteFileSecurityException(e); throw messageException; - } + } } public IHostFile createFolder(String remoteParent, String folderName, IProgressMonitor monitor) throws SystemMessageException { String remotePath = remoteParent + getSeparator(remoteParent) + folderName; DataElement de = getElementFor(remotePath); - + DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_CREATE_FOLDER, monitor); if (status == null) return null; - + if (null != monitor && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, ICommonMessageIds.MSG_OPERATION_CANCELED, - IStatus.CANCEL, - CommonMessages.MSG_OPERATION_CANCELED)); + IStatus.CANCEL, + CommonMessages.MSG_OPERATION_CANCELED)); } - - if (FileSystemMessageUtil.getSourceMessage(status).equals(IServiceConstants.SUCCESS)) + + if (FileSystemMessageUtil.getSourceMessage(status).equals(IServiceConstants.SUCCESS)) return new DStoreHostFile(de); else if(FileSystemMessageUtil.getSourceMessage(status).equals(IServiceConstants.FAILED_WITH_EXIST)) { String msgTxt = ServiceResources.FILEMSG_CREATE_FOLDER_FAILED_EXIST; String msgDetails = NLS.bind(ServiceResources.FILEMSG_CREATE_FOLDER_FAILED_EXIST_DETAILS, remotePath); - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_CREATE_FOLDER_FAILED_EXIST, IStatus.ERROR, msgTxt, msgDetails); - throw new SystemMessageException(msg); + throw new SystemMessageException(msg); } else { String msgTxt = ServiceResources.FILEMSG_CREATE_FILE_FAILED; String msgDetails = NLS.bind(ServiceResources.FILEMSG_CREATE_FILE_FAILED_DETAILS, remotePath); - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_CREATE_FILE_FAILED, IStatus.ERROR, msgTxt, msgDetails); // for 196035 - throwing security exception instead of message exception - Exception e= new SystemMessageException(msg); + Exception e= new SystemMessageException(msg); RemoteFileSecurityException messageException = new RemoteFileSecurityException(e); throw messageException; - //throw new SystemMessageException(getMessage("RSEF1304").makeSubstitution(remotePath)); //$NON-NLS-1$ - } + //throw new SystemMessageException(getMessage("RSEF1304").makeSubstitution(remotePath)); //$NON-NLS-1$ + } } @@ -1362,9 +1361,9 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer if (null != monitor && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, ICommonMessageIds.MSG_OPERATION_CANCELED, - IStatus.CANCEL, + IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED)); } String sourceMsg = FileSystemMessageUtil.getSourceMessage(status); @@ -1375,18 +1374,18 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } else { String msgTxt = NLS.bind(ServiceResources.FILEMSG_DELETE_FILE_FAILED, FileSystemMessageUtil.getSourceLocation(status)); String msgDetails = ServiceResources.FILEMSG_DELETE_FILE_FAILED_DETAILS; - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_DELETE_FILE_FAILED, IStatus.ERROR, msgTxt, msgDetails); - - throw new SystemMessageException(msg); + + throw new SystemMessageException(msg); } } - + public boolean deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException { if (remoteParents.length == 1) return delete(remoteParents[0], fileNames[0], monitor); - + ArrayList dataElements = new ArrayList(remoteParents.length); for (int i = 0; i < remoteParents.length; i++) { @@ -1394,16 +1393,16 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer DataElement de = getElementFor(remotePath); if (de != null) dataElements.add(de); } - + DataElement status = dsStatusCommand((DataElement) dataElements.get(0), dataElements, IUniversalDataStoreConstants.C_DELETE_BATCH, monitor); if (status != null) { if (null != monitor && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, ICommonMessageIds.MSG_OPERATION_CANCELED, - IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED)); + IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED)); } String sourceMsg = FileSystemMessageUtil.getSourceMessage(status); // When running a server older than 2.0.1 success is not set for directories, so we must @@ -1413,11 +1412,11 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } else { String msgTxt = NLS.bind(ServiceResources.FILEMSG_DELETE_FILE_FAILED, FileSystemMessageUtil.getSourceLocation(status)); String msgDetails = ServiceResources.FILEMSG_DELETE_FILE_FAILED_DETAILS; - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_DELETE_FILE_FAILED, IStatus.ERROR, msgTxt, msgDetails); - - throw new SystemMessageException(msg); + + throw new SystemMessageException(msg); } } else { @@ -1426,10 +1425,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer for (int i = 0; i < remoteParents.length && result; i++){ String parent = remoteParents[i]; String name = fileNames[i]; - result = delete(parent, name, monitor); + result = delete(parent, name, monitor); } return result; - + } } @@ -1447,14 +1446,14 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer oldPath = remoteParent + getSeparator(remoteParent) + oldName; newPath = remoteParent + getSeparator(remoteParent) + newName; } - + DataElement de = getElementFor(oldPath); - - + + // new servers use the full path de.setAttribute(DE.A_SOURCE, newPath); - - + + DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_RENAME, monitor); if (status != null && status.getAttribute(DE.A_SOURCE).equals("failed")) @@ -1463,40 +1462,40 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer // had the rename expecting the full path in the A_SOURCE attribute itself // prior to that, we constructed the target file name from the value and the source // I must have missed that while reviewing - + // this is our attempt at recovering, but doing the operation with the old // format. Old servers only used the name for the source attribute on C_RENAME de.setAttribute(DE.A_SOURCE, newName); - + // trying again status = dsStatusCommand(de, IUniversalDataStoreConstants.C_RENAME, monitor); } - - - + + + if (status == null) return false; if (null != monitor && monitor.isCanceled()) { - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ICommonMessageIds.MSG_OPERATION_CANCELED, IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED); //This operation has been canceled by the user. throw new SystemMessageException(msg); } - if (FileSystemMessageUtil.getSourceMessage(status).equals(IServiceConstants.SUCCESS)) + if (FileSystemMessageUtil.getSourceMessage(status).equals(IServiceConstants.SUCCESS)) return true; else { String msgTxt = NLS.bind(ServiceResources.FILEMSG_RENAME_FILE_FAILED, FileSystemMessageUtil.getSourceLocation(status)); String msgDetails = ServiceResources.FILEMSG_RENAME_FILE_FAILED_DETAILS; - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_RENAME_FILE_FAILED, IStatus.ERROR, msgTxt, msgDetails); - - throw new SystemMessageException(msg); - } + + throw new SystemMessageException(msg); + } } - + public boolean rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) throws SystemMessageException { boolean retVal = rename(remoteParent, oldName, newName, monitor); @@ -1508,7 +1507,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer protected boolean moveByCopy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException { boolean movedOk = false; - + if (copy(srcParent, srcName, tgtParent, tgtName, monitor)) { try @@ -1529,10 +1528,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer throw exc; } } - + return movedOk; } - + public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException { String src = srcParent + getSeparator(srcParent) + srcName; @@ -1563,16 +1562,16 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } /* - // handle special characters in source and target strings + // handle special characters in source and target strings StringBuffer srcBuf = new StringBuffer(src); StringBuffer tgtBuf = new StringBuffer(tgt); - + for (int i = 0; i < srcBuf.length(); i++) { char c = srcBuf.charAt(i); - + boolean isSpecialChar = isSpecialChar(c); - + if (isSpecialChar) { srcBuf.insert(i, "\\"); @@ -1583,9 +1582,9 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer for (int i = 0; i < tgtBuf.length(); i++) { char c = tgtBuf.charAt(i); - + boolean isSpecialChar = isSpecialChar(c); - + if (isSpecialChar) { tgtBuf.insert(i, "\\"); @@ -1623,7 +1622,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer done = cmdSubSystem.runRemoteCommand(runFile, command); runFile.getParentRemoteFile().markStale(true); runFile.markStale(true); - + } catch (InterruptedException e) { @@ -1637,7 +1636,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer */ } - + /** * Checks whether the given character is a special character in the shell. A special character is * '$', '`', '"' and '\'. @@ -1645,7 +1644,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer * @return true if the character is a special character, false otherwise. */ protected boolean isSpecialChar(char c) { - + if ((c == '$') || (c == '`') || (c == '"') || (c == '\\')) { return true; } @@ -1659,15 +1658,15 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer DataStore ds = getDataStore(); String srcRemotePath = srcParent + getSeparator(srcParent) + srcName; DataElement srcDE = getElementFor(srcRemotePath); - + DataElement tgtDE = getElementFor(tgtParent); if (tgtDE.getType().equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR)) { dsQueryCommand(tgtDE, IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT, monitor); } - + DataElement cpCmd = getCommandDescriptor(tgtDE, IUniversalDataStoreConstants.C_COPY); - + if (cpCmd != null) { ArrayList args = new ArrayList(); @@ -1675,21 +1674,21 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer DataElement nameObj = ds.createObject(null, "name", tgtName); //$NON-NLS-1$ args.add(nameObj); DataElement status = ds.command(cpCmd, args, tgtDE, true); - + try { getStatusMonitor(ds).waitForUpdate(status, monitor); - + if (status.getAttribute(DE.A_SOURCE).equals(IServiceConstants.FAILED)) { String msgTxt = NLS.bind(ServiceResources.FILEMSG_COPY_FILE_FAILED, srcName); String msgDetails = ServiceResources.FILEMSG_COPY_FILE_FAILED_DETAILS; - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_COPY_FILE_FAILED, IStatus.ERROR, msgTxt, msgDetails); - - throw new SystemMessageException(msg); + + throw new SystemMessageException(msg); } } catch (InterruptedException e) @@ -1697,9 +1696,9 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer if (monitor != null && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, ICommonMessageIds.MSG_OPERATION_CANCELED, - IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED)); + IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED)); } // cancel monitor if it's still not canceled if (monitor != null && !monitor.isCanceled()) @@ -1715,12 +1714,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer public boolean copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException { DataStore ds = getDataStore(); - + DataElement tgtDE = getElementFor(tgtParent); if (tgtDE.getType().equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR)) { // get the property queried object - dsQueryCommand(tgtDE, IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT, monitor); + dsQueryCommand(tgtDE, IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT, monitor); } DataElement cpCmd = getCommandDescriptor(tgtDE, IUniversalDataStoreConstants.C_COPY_BATCH); @@ -1738,16 +1737,16 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer try { getStatusMonitor(ds).waitForUpdate(status, monitor); - + if (status.getAttribute(DE.A_SOURCE).equals(IServiceConstants.FAILED)) { - + String msgTxt = NLS.bind(ServiceResources.FILEMSG_COPY_FILE_FAILED, srcNames[0]); String msgDetails = ServiceResources.FILEMSG_COPY_FILE_FAILED_DETAILS; - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IDStoreMessageIds.FILEMSG_COPY_FILE_FAILED, IStatus.ERROR, msgTxt, msgDetails); - - throw new SystemMessageException(msg); + + throw new SystemMessageException(msg); } } catch (InterruptedException e) @@ -1755,16 +1754,16 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer if (monitor != null && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, ICommonMessageIds.MSG_OPERATION_CANCELED, - IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED)); + IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED)); } // cancel monitor if it's still not canceled if (monitor != null && !monitor.isCanceled()) { monitor.setCanceled(true); } - + //InterruptedException is used to report user cancellation, so no need to log //This should be reviewed (use OperationCanceledException) with bug #190750 } @@ -1776,17 +1775,17 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer for (int i = 0; i < srcParents.length && result; i++){ String parent = srcParents[i]; String name = srcNames[i]; - result = copy(parent, name, tgtParent, name, monitor); + result = copy(parent, name, tgtParent, name, monitor); } return result; - + } } - + public IHostFile[] getRoots(IProgressMonitor monitor) { if (!isInitialized()) @@ -1795,14 +1794,14 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } DataStore ds = getDataStore(); DataElement universaltemp = getMinerElement(); - + // create filter descriptor DataElement deObj = ds.createObject(universaltemp, IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR, "", "", "", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ DataElement[] results = dsQueryCommand(deObj, IUniversalDataStoreConstants.C_QUERY_ROOTS, monitor); - + return convertToHostFiles(results, "*"); //$NON-NLS-1$ } - + private String getQueryString(int fileType) { String queryString = null; @@ -1811,19 +1810,19 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer case IFileService.FILE_TYPE_FILES: queryString = IUniversalDataStoreConstants.C_QUERY_VIEW_FILES; break; - + case IFileService.FILE_TYPE_FOLDERS: queryString = IUniversalDataStoreConstants.C_QUERY_VIEW_FOLDERS; break; - + case IFileService.FILE_TYPE_FILES_AND_FOLDERS: - default: + default: queryString = IUniversalDataStoreConstants.C_QUERY_VIEW_ALL; break; } return queryString; } - + private String[] getQueryStrings(int[] fileTypes) { String[] queryStrings = new String[fileTypes.length]; @@ -1834,13 +1833,13 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer case IFileService.FILE_TYPE_FILES: queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_VIEW_FILES; break; - + case IFileService.FILE_TYPE_FOLDERS: queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_VIEW_FOLDERS; break; - + case IFileService.FILE_TYPE_FILES_AND_FOLDERS: - default: + default: queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_VIEW_ALL; break; } @@ -1850,26 +1849,26 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer public IHostFile[] list(String remoteParent, String fileFilter, int fileType, IProgressMonitor monitor) { - String queryString = getQueryString(fileType); + String queryString = getQueryString(fileType); return fetch(remoteParent, fileFilter, queryString, monitor); } - + public IHostFile[] listMultiple(String[] remoteParents, String[] fileFilters, int[] fileTypes, IProgressMonitor monitor) - throws SystemMessageException + throws SystemMessageException { String[] queryStrings = getQueryStrings(fileTypes); return fetchMulti(remoteParents, fileFilters, queryStrings, monitor); } - + public IHostFile[] listMultiple(String[] remoteParents, String[] fileFilters, int fileType, IProgressMonitor monitor) - throws SystemMessageException + throws SystemMessageException { String queryString = getQueryString(fileType); - + // create array of the same query string String[] queryStrings = new String[remoteParents.length]; for (int i = 0; i < remoteParents.length; i++) @@ -1879,7 +1878,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer return fetchMulti(remoteParents, fileFilters, queryStrings, monitor); } - + protected String[] getPathsFor(String[] remoteParents, String[] remoteFiles) { String[] results = new String[remoteParents.length]; @@ -1892,37 +1891,37 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { sep = getSeparator(remoteParent); } - + results[i] = remoteParent + sep + remoteFile; } return results; } - + protected DataElement[] getElementsFor(String[] paths) { DataElement[] results = new DataElement[paths.length]; for (int i = 0; i < paths.length; i++) { - results[i] = getElementFor(paths[i]); + results[i] = getElementFor(paths[i]); } return results; } - + protected DataElement getElementFor(String path) { if (!isInitialized()) { waitForInitialize(null); } - + DataStore ds = getDataStore(); - - // with 207095, it's possible to get here when disconnected and no dstore + + // with 207095, it's possible to get here when disconnected and no dstore if (ds == null){ return null; } - + String normalizedPath = PathUtility.normalizeUnknown(path); DataElement element = (DataElement)_fileElementMap.get(normalizedPath); if (element != null && element.isDeleted()) @@ -1937,8 +1936,8 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } return element; } - - + + /** * Get a dstore IHostFile object for the given absolute path, provided * that the file object has been accessed before and is available in our @@ -1950,7 +1949,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { return (IHostFile)_dstoreFileMap.get(path); } - + protected IHostFile[] fetch(String remoteParent, String fileFilter, String queryType, IProgressMonitor monitor) { DataStore ds = getDataStore(); @@ -1958,7 +1957,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { return new IHostFile[0]; } - + // create filter descriptor DataElement deObj = getElementFor(remoteParent); if (deObj == null) @@ -1966,18 +1965,18 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer DataElement universaltemp = getMinerElement(); ds.createObject(universaltemp, IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR, remoteParent, remoteParent, "", false); //$NON-NLS-1$ } - + DataElement attributes = getAttributes(fileFilter, true); ArrayList args = new ArrayList(1); args.add(attributes); - - DataElement[] results = dsQueryCommand(deObj, args, queryType, monitor); + + DataElement[] results = dsQueryCommand(deObj, args, queryType, monitor); return convertToHostFiles(results, fileFilter); } - + /** * Fetch multiple results (for different parents an filters - * + * * @param remoteParents the parents to query * @param fileFilters the filters for each parent to query * @param queryTypes the type of queries (for each parent) - files, folders, both, etc @@ -1991,10 +1990,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { return new IHostFile[0]; } - + ArrayList[] argses = new ArrayList[remoteParents.length]; DataElement subjects[] = new DataElement[remoteParents.length]; - + for (int i = 0; i < remoteParents.length; i++) { // create filter descriptor @@ -2005,14 +2004,14 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer deObj = ds.createObject(universaltemp, IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR, remoteParents[i], remoteParents[i], "", false); //$NON-NLS-1$ } subjects[i] = deObj; - + DataElement attributes = getAttributes(fileFilters[i], true); ArrayList args = new ArrayList(1); args.add(attributes); argses[i] = args; } - - List consolidatedResults = dsQueryCommandMulti(subjects, argses, queryTypes, monitor); + + List consolidatedResults = dsQueryCommandMulti(subjects, argses, queryTypes, monitor); List convertedResults = new ArrayList(); for (int r = 0; r < consolidatedResults.size(); r++) { @@ -2022,7 +2021,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer convertedResults.add(results[c]); } } - + return (IHostFile[])convertedResults.toArray(new IHostFile[consolidatedResults.size()]); } @@ -2032,7 +2031,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } public boolean setLastModified(String parent, String name, - long timestamp, IProgressMonitor monitor) throws SystemMessageException + long timestamp, IProgressMonitor monitor) throws SystemMessageException { String remotePath = parent + getSeparator(parent) + name; DataElement de = getElementFor(remotePath); @@ -2048,12 +2047,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer return true; } } - + return false; } public boolean setReadOnly(String parent, String name, - boolean readOnly, IProgressMonitor monitor) throws SystemMessageException + boolean readOnly, IProgressMonitor monitor) throws SystemMessageException { String remotePath = parent + getSeparator(parent) + name; DataElement de = getElementFor(remotePath); @@ -2072,7 +2071,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } catch (Exception e) { - + } return true; } @@ -2086,14 +2085,14 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer * @since 2.0 */ public String getEncoding(IProgressMonitor monitor) throws SystemMessageException { - + if (remoteEncoding == null) { - + DataStore ds = getDataStore(); if (ds != null) { DataElement encodingElement = ds.createObject(null, IUniversalDataStoreConstants.UNIVERSAL_TEMP_DESCRIPTOR, ""); //$NON-NLS-1$ - + DataElement queryCmd = ds.localDescriptorQuery(encodingElement.getDescriptor(),IUniversalDataStoreConstants.C_SYSTEM_ENCODING); DataElement status = ds.command(queryCmd, encodingElement, true); @@ -2103,7 +2102,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } catch (Exception e) { } - + remoteEncoding = encodingElement.getValue(); } } @@ -2114,7 +2113,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer /* (non-Javadoc) * @see org.eclipse.rse.services.files.IFileService#getInputStream(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, boolean) */ - public InputStream getInputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException + public InputStream getInputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException { String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile; int mode; @@ -2138,7 +2137,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer int options = isBinary ? IFileService.NONE : IFileService.TEXT_MODE; return getOutputStream(remoteParent, remoteFile, options, monitor); } - + public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException { String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile; @@ -2152,11 +2151,11 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer { mode = IUniversalDataStoreConstants.TEXT_MODE; } - + DStoreOutputStream outputStream = new DStoreOutputStream(getDataStore(), remotePath, getEncoding(monitor), mode, unixStyle, options); return outputStream; } - + /** * Sets whether this is a Unix-style file system or a Windows-style file system. The * default is Windows if this is not called. The creator of this class should call this to set the type of the file system. @@ -2165,12 +2164,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer public void setIsUnixStyle(boolean isUnixStyle) { this.unixStyle = isUnixStyle; } - + public boolean supportsEncodingConversion(){ return true; } - + public IHostFilePermissions getFilePermissions(IHostFile rfile, IProgressMonitor monitor) throws SystemMessageException { DStoreHostFile file = (DStoreHostFile)rfile; @@ -2183,41 +2182,41 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer file.setPermissions(result); } */ - + DataElement remoteFile = file.getDataElement(); - + DataElement status = dsStatusCommand(remoteFile, IUniversalDataStoreConstants.C_QUERY_FILE_PERMISSIONS, monitor); - if (status != null) { + if (status != null) { int permissionsInt = 0; - + // access string in the form || - String permissionsStr = status.getSource(); - + String permissionsStr = status.getSource(); + if (permissionsStr != null && permissionsStr.length() > 0) { String[] permAttributes = permissionsStr.split("\\"+IServiceConstants.TOKEN_SEPARATOR); //$NON-NLS-1$ - + // permissions bits String accessString = permAttributes[0]; try - { + { int accessInt = Integer.parseInt(accessString, 8); - permissionsInt = accessInt; // leave permissions in decimal + permissionsInt = accessInt; // leave permissions in decimal } - catch (Exception e){ + catch (Exception e){ } - + // user String user = permAttributes[1]; - + // group String group = permAttributes[2]; - + result = new HostFilePermissions(permissionsInt, user, group); file.setPermissions(result); } } } - + return result; } @@ -2225,17 +2224,17 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer IHostFilePermissions permissions, IProgressMonitor monitor) throws SystemMessageException { DataElement remoteFile = ((DStoreHostFile)file).getDataElement(); - + ArrayList args = new ArrayList(); int bits = permissions.getPermissionBits(); String permissionsInOctal = Integer.toOctalString(bits); // from decimal to octal String user = permissions.getUserOwner(); String group = permissions.getGroupOwner(); - + String permissionsStr = permissionsInOctal + '|' + user + '|' + group; DataElement newPermissionsElement = getDataStore().createObject(null, "permissions", permissionsStr); //$NON-NLS-1$ args.add(newPermissionsElement); - + DataElement status = dsStatusCommand(remoteFile, args, IUniversalDataStoreConstants.C_SET_FILE_PERMISSIONS, monitor); if (status != null) { @@ -2243,8 +2242,8 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer if (file instanceof IHostFilePermissionsContainer){ ((IHostFilePermissionsContainer)file).setPermissions(permissions); // set to use new permissions } - - } + + } } public int getCapabilities(IHostFile file) { @@ -2258,11 +2257,11 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer return capabilities; } else { - + DataElement remoteFile = ((DStoreHostFile)file).getDataElement(); - DataElement getCmd = getCommandDescriptor(remoteFile, IUniversalDataStoreConstants.C_QUERY_FILE_PERMISSIONS); + DataElement getCmd = getCommandDescriptor(remoteFile, IUniversalDataStoreConstants.C_QUERY_FILE_PERMISSIONS); DataElement setCmd = getCommandDescriptor(remoteFile, IUniversalDataStoreConstants.C_SET_FILE_PERMISSIONS); - + if (getCmd != null){ capabilities = capabilities | IFilePermissionsService.FS_CAN_GET_ALL; } @@ -2273,6 +2272,6 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer return capabilities; } - - + + } diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/processes/DStoreProcessService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/processes/DStoreProcessService.java index 7af07f28981..ac04a63cb18 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/processes/DStoreProcessService.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/processes/DStoreProcessService.java @@ -1,20 +1,21 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * 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 + * 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, + * 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) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout + * David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout * David McKnight (IBM) - [159092] For to use correct process miner id * David McKnight (IBM) - [196624] dstore miner IDs should be String constants rather than dynamic lookup + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc ********************************************************************************/ package org.eclipse.rse.internal.services.dstore.processes; @@ -37,10 +38,9 @@ import org.eclipse.rse.services.clientserver.processes.IHostProcessFilter; import org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteConstants; import org.eclipse.rse.services.dstore.util.DStoreStatusMonitor; import org.eclipse.rse.services.processes.AbstractProcessService; -import org.eclipse.rse.services.processes.IProcessService; - -public class DStoreProcessService extends AbstractProcessService implements IProcessService +public class DStoreProcessService extends AbstractProcessService +// TODO implements IDStoreService ? { protected IDataStoreProvider _provider; protected DataElement _minerElement = null; @@ -48,23 +48,23 @@ public class DStoreProcessService extends AbstractProcessService implements IPro protected DataElement _procMinerStatus; protected String[] _statusTypes; protected String _userName; - + public DStoreProcessService(IDataStoreProvider provider) { _provider = provider; } - + public String getName() { return ServiceResources.DStore_Process_Service_Label; } - + public String getDescription() { return ServiceResources.DStore_Process_Service_Description; } - - public IHostProcess[] listAllProcesses(IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException + + public IHostProcess[] listAllProcesses(IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException { if (!isInitialized()) { @@ -74,12 +74,12 @@ public class DStoreProcessService extends AbstractProcessService implements IPro DataStore ds = getDataStore(); DataElement universaltemp = getMinerElement(); - + // create filter descriptor DataElement deObj; deObj = ds.find(universaltemp, DE.A_NAME, IUniversalProcessDataStoreConstants.UNIVERSAL_PROCESS_ROOT, 1); if (deObj == null) deObj = ds.createObject(universaltemp, IUniversalProcessDataStoreConstants.UNIVERSAL_PROCESS_FILTER, IUniversalProcessDataStoreConstants.UNIVERSAL_PROCESS_ROOT, "", "", false); //$NON-NLS-1$ //$NON-NLS-2$ - deObj.setAttribute(DE.A_SOURCE, filter.toString()); + deObj.setAttribute(DE.A_SOURCE, filter.toString()); // query DataElement queryCmd = ds.localDescriptorQuery(deObj.getDescriptor(), IUniversalProcessDataStoreConstants.C_PROCESS_FILTER_QUERY_ALL); @@ -102,13 +102,13 @@ public class DStoreProcessService extends AbstractProcessService implements IPro if (nested != null) { Object[] results = nested.toArray(); - + String message = status.getAttribute(DE.A_VALUE); if (!message.equals(ISystemProcessRemoteConstants.PROCESS_MINER_SUCCESS)) { throw new SystemMessageException(getMessage("RSEPG1301")); //$NON-NLS-1$ } - + // convert objects to remote files String userName = getRemoteUserName(); if (userName != null && filter.getUsername().equals("${user.id}")) //$NON-NLS-1$ @@ -123,7 +123,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro return processes; } - + /** * Helper method to convert DataElement objects to IRemoteClientProcess objects. */ @@ -131,7 +131,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro { if (objs == null) return null; - + ArrayList list = new ArrayList(objs.length); for (int idx = 0; idx < objs.length; idx++) @@ -141,9 +141,9 @@ public class DStoreProcessService extends AbstractProcessService implements IPro { if (processFilter == null || processFilter.allows(de.getValue())) { - DStoreHostProcess newProcess = new DStoreHostProcess(de); + DStoreHostProcess newProcess = new DStoreHostProcess(de); list.add(newProcess); - } + } } } @@ -156,7 +156,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro return processes; } - + /** * Helper method to return the DataStore object needed by comm layer. */ @@ -164,18 +164,18 @@ public class DStoreProcessService extends AbstractProcessService implements IPro { return _provider.getDataStore(); } - + protected DataElement getMinerElement() { if (_minerElement == null || _minerElement.getDataStore() != getDataStore()) { _minerElement = getDataStore() - .findMinerInformation(IUniversalDataStoreConstants.UNIVERSAL_PROCESS_MINER_ID); + .findMinerInformation(IUniversalDataStoreConstants.UNIVERSAL_PROCESS_MINER_ID); } return _minerElement; } - + public DStoreStatusMonitor getStatusMonitor(DataStore dataStore) { if (_statusMonitor == null || _statusMonitor.getDataStore() != dataStore) @@ -185,31 +185,31 @@ public class DStoreProcessService extends AbstractProcessService implements IPro return _statusMonitor; } - public boolean kill(long PID, String signal, IProgressMonitor monitor) throws SystemMessageException + public boolean kill(long PID, String signal, IProgressMonitor monitor) throws SystemMessageException { try { DataStore ds = getDataStore(); - + // run kill command on host DStoreHostProcess process = (DStoreHostProcess) getProcess(PID, monitor); - + // if there is no process, simply return true if (process == null) { return true; } - + DataElement deObj = (DataElement) process.getObject(); DataElement killCmd = ds.localDescriptorQuery(deObj.getDescriptor(), IUniversalProcessDataStoreConstants.C_PROCESS_KILL); deObj.setAttribute(DE.A_SOURCE, signal); - + if (killCmd != null) { DataElement status = ds.command(killCmd, deObj, true); - + DStoreStatusMonitor smon = getStatusMonitor(getDataStore()); smon.waitForUpdate(status); - + // get results String message = status.getAttribute(DE.A_VALUE); if (message.equals(ISystemProcessRemoteConstants.PROCESS_MINER_SUCCESS)) return true; @@ -229,10 +229,10 @@ public class DStoreProcessService extends AbstractProcessService implements IPro { throw new SystemMessageException(getMessage("RSEG1067")); //$NON-NLS-1$ } - return false; + return false; } - - public String[] getSignalTypes() + + public String[] getSignalTypes() { if (_statusTypes != null) { @@ -244,7 +244,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro } return _statusTypes; } - + /** * Returns a list of the types of signals that can be sent to * a process on the remote system. @@ -266,7 +266,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro return null; } } - + protected DataElement getSignalTypesMinerElement() { return getDataStore().find(_minerElement, DE.A_NAME, "universal.killinfo"); //$NON-NLS-1$ @@ -274,17 +274,19 @@ public class DStoreProcessService extends AbstractProcessService implements IPro public void initService(IProgressMonitor monitor) { + super.initService(monitor); initMiner(monitor); } - + public void uninitService(IProgressMonitor monitor) { _minerElement = null; _procMinerStatus = null; _minerElement = null; _statusMonitor = null; + super.uninitService(monitor); } - + public boolean isInitialized() { if (_procMinerStatus != null) @@ -294,7 +296,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro } return false; } - + protected void waitForInitialize(IProgressMonitor monitor) { if (_procMinerStatus!= null) @@ -311,14 +313,14 @@ public class DStoreProcessService extends AbstractProcessService implements IPro { monitor.setCanceled(true); } - + //InterruptedException is used to report user cancellation, so no need to log //This should be reviewed (use OperationCanceledException) with bug #190750 } getMinerElement(); } } - + protected void initMiner(IProgressMonitor monitor) @@ -328,30 +330,30 @@ public class DStoreProcessService extends AbstractProcessService implements IPro { if (getServerVersion() >= 8) { - String minerId = getMinerId(); + String minerId = getMinerId(); String message = SystemMessage.sub(ServiceResources.DStore_Service_ProgMon_Initializing_Message, "&1", minerId); //$NON-NLS-1$ monitor.beginTask(message, IProgressMonitor.UNKNOWN); DataStore ds = getDataStore(); if (_minerElement == null || _minerElement.getDataStore() != ds) - { + { if (ds != null && _procMinerStatus == null) - { - _procMinerStatus = ds.activateMiner(minerId); - - } + { + _procMinerStatus = ds.activateMiner(minerId); + + } } } } monitor.done(); } - + /** * Get the username used to connect to the remote machine */ public String getRemoteUserName() { if (_userName == null) - { + { DataStore ds = getDataStore(); DataElement encodingElement = ds.createObject(null, IUniversalProcessDataStoreConstants.UNIVERSAL_PROCESS_TEMP, ""); //$NON-NLS-1$ @@ -364,29 +366,29 @@ public class DStoreProcessService extends AbstractProcessService implements IPro monitor.waitForUpdate(status); } catch (Exception e) - { + { } _userName = encodingElement.getValue(); } return _userName; } - + protected String getMinerId() { return IUniversalDataStoreConstants.UNIVERSAL_PROCESS_MINER_ID; } - + public int getServerVersion() { return getDataStore().getServerVersion(); } - + public int getServerMinor() { return getDataStore().getServerMinor(); } - + protected String getProcessMinerId() { return IUniversalDataStoreConstants.UNIVERSAL_PROCESS_MINER_ID; diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellService.java index 1c02e90b4d3..e39f08848b1 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellService.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellService.java @@ -7,15 +7,16 @@ * * 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, + * 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) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout - * David McKnight (IBM) - [196624] dstore miner IDs should be String constants rather than dynamic lookup + * David McKnight (IBM) - [196624] dstore miner IDs should be String constants rather than dynamic lookup * David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage() + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc *******************************************************************************/ package org.eclipse.rse.internal.services.dstore.shells; @@ -41,24 +42,24 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS protected String[] _envVars; protected DataElement _envMinerElement; protected DataElement _envMinerStatus; - + public DStoreShellService(IDataStoreProvider dataStoreProvider) { super(dataStoreProvider); } - - + + public String getName() { return ServiceResources.DStore_Shell_Service_Label; } - + public String getDescription() { return ServiceResources.DStore_Shell_Service_Description; } - - + + public IHostShell launchShell(String initialWorkingDirectory, String[] environment, IProgressMonitor monitor) { if (!isInitialized()) @@ -120,7 +121,7 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS } return _envVars; } - + protected String getMinerId() { return IUniversalDataStoreConstants.UNIVERSAL_COMMAND_MINER_ID; @@ -130,8 +131,8 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS { return IUniversalDataStoreConstants.UNIVERSAL_ENVIRONMENT_MINER_ID; } - - + + public boolean isInitialized() { if (_initializeStatus != null) @@ -141,7 +142,7 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS } return false; } - + protected void waitForInitialize(IProgressMonitor monitor) { if (_envMinerStatus!= null) @@ -158,7 +159,7 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS { monitor.setCanceled(true); } - + //InterruptedException is used to report user cancellation, so no need to log //This should be reviewed (use OperationCanceledException) with bug #190750 } @@ -166,28 +167,28 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS } super.waitForInitialize(monitor); } - + public void uninitService(IProgressMonitor monitor) { - super.uninitService(monitor); _envMinerElement = null; - _envMinerStatus = null; + _envMinerStatus = null; + super.uninitService(monitor); } - + protected void initMiner(IProgressMonitor monitor) { // init env miner first if (getServerVersion() >= 8) { - String minerId = getEnvSystemMinerId(); + String minerId = getEnvSystemMinerId(); String message = SystemMessage.sub(ServiceResources.DStore_Service_ProgMon_Initializing_Message, "&1", minerId); //$NON-NLS-1$ monitor.beginTask(message, IProgressMonitor.UNKNOWN); DataStore ds = getDataStore(); if (_envMinerElement == null || _envMinerElement.getDataStore() != ds) - { + { if (ds != null && _envMinerStatus == null) - { + { _envMinerStatus = ds.activateMiner(minerId); /* DStoreStatusMonitor smon = getStatusMonitor(ds); @@ -199,15 +200,15 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS { e.printStackTrace(); } - + getMinerElement(getEnvSystemMinerId()); */ - - - } + + + } } super.initMiner(monitor); - } + } } - + } diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/AbstractDStoreService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/AbstractDStoreService.java index 30055da7cc9..a28f2946fc0 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/AbstractDStoreService.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/AbstractDStoreService.java @@ -7,16 +7,17 @@ * * 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, + * 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][refactoring] Move IProgressMonitor last in public base classes - * David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout + * David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout * David McKnight (IBM) - [207095] check for null datastore * David McKnight (IBM) - [209593] [api] check for existing query to avoid duplicates * David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage() + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable *******************************************************************************/ package org.eclipse.rse.services.dstore; @@ -31,23 +32,24 @@ import org.eclipse.dstore.core.model.DataElement; import org.eclipse.dstore.core.model.DataStore; import org.eclipse.dstore.core.model.IDataStoreProvider; import org.eclipse.rse.internal.services.dstore.ServiceResources; +import org.eclipse.rse.services.AbstractService; import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.dstore.util.DStoreStatusMonitor; -public abstract class AbstractDStoreService implements IDStoreService +public abstract class AbstractDStoreService extends AbstractService implements IDStoreService { protected IDataStoreProvider _dataStoreProvider; protected DataElement _minerElement; protected DStoreStatusMonitor _statusMonitor; protected Map _cmdDescriptorMap; protected DataElement _initializeStatus; - + public AbstractDStoreService(IDataStoreProvider dataStoreProvider) { _dataStoreProvider = dataStoreProvider; _cmdDescriptorMap = new HashMap(); } - + public DStoreStatusMonitor getStatusMonitor(DataStore dataStore) { if (_statusMonitor == null || _statusMonitor.getDataStore() != dataStore) @@ -56,12 +58,12 @@ public abstract class AbstractDStoreService implements IDStoreService } return _statusMonitor; } - + public DataStore getDataStore() { return _dataStoreProvider.getDataStore(); } - + protected DataElement getMinerElement() { if (_minerElement == null || _minerElement.getDataStore() != getDataStore()) @@ -70,20 +72,20 @@ public abstract class AbstractDStoreService implements IDStoreService } return _minerElement; } - + protected DataElement getMinerElement(String id) - { + { DataStore ds = getDataStore(); if (ds != null) { - return ds.findMinerInformation(id); + return ds.findMinerInformation(id); } else { return null; } } - + protected DataElement[] dsQueryCommand(DataElement subject, String command, IProgressMonitor monitor) { return dsQueryCommand(subject, null, command, monitor); @@ -103,7 +105,7 @@ public abstract class AbstractDStoreService implements IDStoreService DataElement queryCmd = getCommandDescriptor(subject, command); DataStore ds = getDataStore(); DStoreStatusMonitor smonitor = getStatusMonitor(ds); - + if (queryCmd != null && ds != null) { // check if there already is an active command for this query @@ -119,7 +121,7 @@ public abstract class AbstractDStoreService implements IDStoreService try { smonitor.waitForUpdate(status, monitor); - + int resultSize = subject.getNestedSize(); checkHostJVM(); @@ -131,26 +133,26 @@ public abstract class AbstractDStoreService implements IDStoreService } } catch (InterruptedException e) - { + { // cancel monitor if it's still not canceled if (monitor != null && !monitor.isCanceled()) { monitor.setCanceled(true); } - + //InterruptedException is used to report user cancellation, so no need to log //This should be reviewed (use OperationCanceledException) with bug #190750 - } + } } return new DataElement[0]; } - + protected List dsQueryCommandMulti(DataElement[] subjects, String[] commands, IProgressMonitor monitor) { return dsQueryCommandMulti(subjects, null, commands, monitor); } - + /** * Query multiple subjects in one shot * @param subjects the subjects to query @@ -162,20 +164,20 @@ public abstract class AbstractDStoreService implements IDStoreService protected List dsQueryCommandMulti(DataElement[] subjects, ArrayList[] argses, String[] commands, IProgressMonitor monitor) { List statuses = new ArrayList(); - DataStore ds = getDataStore(); + DataStore ds = getDataStore(); DStoreStatusMonitor smonitor = getStatusMonitor(ds); - - + + for (int i = 0; i < subjects.length && !monitor.isCanceled(); i++) { DataElement subject = subjects[i]; - + DataElement queryCmd = getCommandDescriptor(subject, commands[i]); if (queryCmd != null && ds != null) - { + { // check if there already is an active command for this query DataElement status = smonitor.getCommandStatus(queryCmd, subject); - + if (status == null){ if (argses != null){ status = ds.command(queryCmd, argses[i], subject, true); @@ -184,65 +186,65 @@ public abstract class AbstractDStoreService implements IDStoreService status = ds.command(queryCmd, subject, true); } } - statuses.add(status); + statuses.add(status); } } List consolidatedResults = new ArrayList(); - + // wait for each command to complete for (int i = 0; i < statuses.size() && !monitor.isCanceled(); i++) { DataElement status = (DataElement)statuses.get(i); DataElement deObj = subjects[i]; - + try { - smonitor.waitForUpdate(status, monitor); - + smonitor.waitForUpdate(status, monitor); + if (!monitor.isCanceled() && smonitor.determineStatusDone(status)) { List nested = deObj.getNestedData(); if (nested != null) { consolidatedResults.add(nested.toArray(new DataElement[nested.size()])); - } + } } } catch (InterruptedException e) - { + { // cancel monitor if it's still not canceled if (monitor != null && !monitor.isCanceled()) { monitor.setCanceled(true); } - + //InterruptedException is used to report user cancellation, so no need to log //This should be reviewed (use OperationCanceledException) with bug #190750 - } + } } - + return consolidatedResults; } - - - - - + + + + + protected DataElement dsStatusCommand(DataElement subject, ArrayList args, String command, IProgressMonitor monitor) { DataStore ds = getDataStore(); DStoreStatusMonitor smonitor = getStatusMonitor(ds); DataElement queryCmd = getCommandDescriptor(subject, command); - + if (queryCmd != null && ds != null) { // check if there already is an active command for this query DataElement status = smonitor.getCommandStatus(queryCmd, subject); - - if (status == null){ + + if (status == null){ status = ds.command(queryCmd, args, subject, true); } try @@ -250,35 +252,35 @@ public abstract class AbstractDStoreService implements IDStoreService smonitor.waitForUpdate(status, monitor); } catch (InterruptedException e) - { + { // cancel monitor if it's still not canceled if (monitor != null && !monitor.isCanceled()) { monitor.setCanceled(true); } - + //InterruptedException is used to report user cancellation, so no need to log //This should be reviewed (use OperationCanceledException) with bug #190750 - } + } return status; } return null; } - - + + protected DataElement dsStatusCommand(DataElement subject, String command, IProgressMonitor monitor) { DataStore ds = getDataStore(); DStoreStatusMonitor smonitor = getStatusMonitor(ds); - DataElement queryCmd = getCommandDescriptor(subject, command); - + DataElement queryCmd = getCommandDescriptor(subject, command); + if (queryCmd != null && ds != null) - { + { // check if there already is an active command for this query DataElement status = smonitor.getCommandStatus(queryCmd, subject); - - if (status == null){ + + if (status == null){ status = ds.command(queryCmd, subject, true); } try @@ -286,13 +288,13 @@ public abstract class AbstractDStoreService implements IDStoreService smonitor.waitForUpdate(status, monitor); } catch (InterruptedException e) - { + { // cancel monitor if it's still not canceled if (monitor != null && !monitor.isCanceled()) { monitor.setCanceled(true); } - + //InterruptedException is used to report user cancellation, so no need to log //This should be reviewed (use OperationCanceledException) with bug #190750 @@ -301,7 +303,7 @@ public abstract class AbstractDStoreService implements IDStoreService } return null; } - + protected DataElement getCommandDescriptor(DataElement subject, String command) { DataStore ds = getDataStore(); @@ -316,7 +318,7 @@ public abstract class AbstractDStoreService implements IDStoreService } return cmd; } - + public int getServerVersion() { DataStore ds = getDataStore(); @@ -324,7 +326,7 @@ public abstract class AbstractDStoreService implements IDStoreService return ds.getServerVersion(); return 0; } - + public int getServerMinor() { DataStore ds = getDataStore(); @@ -332,25 +334,25 @@ public abstract class AbstractDStoreService implements IDStoreService return ds.getServerMinor(); return 0; } - + protected void checkHostJVM() { /* DataElement status = getDataStore().queryHostJVM(); String source = status.getSource(); String[] tokens = source.split(","); - + long freeMem = Long.parseLong(tokens[0]); long totalMem = Long.parseLong(tokens[1]); int numElements = Integer.parseInt(tokens[3]); - + System.out.println("Host JVM Stats:"); System.out.println("\tfreeMem="+freeMem); System.out.println("\ttotalMem="+totalMem); - + System.out.println("\tnumber of elements="+numElements); - + String[] lastCreated = tokens[4].split(";"); System.out.println("\tlast created:"); for (int i = 0; i < lastCreated.length; i++) @@ -359,7 +361,7 @@ public abstract class AbstractDStoreService implements IDStoreService } */ } - + public boolean isInitialized() { if (_initializeStatus != null) @@ -373,7 +375,7 @@ public abstract class AbstractDStoreService implements IDStoreService } return false; } - + protected void waitForInitialize(IProgressMonitor monitor) { if (_initializeStatus != null) @@ -393,27 +395,29 @@ public abstract class AbstractDStoreService implements IDStoreService { monitor.setCanceled(true); } - + //InterruptedException is used to report user cancellation, so no need to log //This should be reviewed (use OperationCanceledException) with bug #190750 } - + getMinerElement(); } } } - + public void initService(IProgressMonitor monitor) { + super.initService(monitor); initMiner(monitor); } - + public void uninitService(IProgressMonitor monitor) { _initializeStatus = null; _cmdDescriptorMap.clear(); _minerElement = null; _statusMonitor = null; + super.uninitService(monitor); } protected void initMiner(IProgressMonitor monitor) @@ -428,9 +432,9 @@ public abstract class AbstractDStoreService implements IDStoreService monitor.beginTask(message, IProgressMonitor.UNKNOWN); DataStore ds = getDataStore(); if (_minerElement == null || _minerElement.getDataStore() != ds) - { + { if (ds != null && _initializeStatus == null) - { + { _initializeStatus = ds.activateMiner(minerId); /* DStoreStatusMonitor smon = getStatusMonitor(ds); @@ -442,16 +446,16 @@ public abstract class AbstractDStoreService implements IDStoreService { e.printStackTrace(); } - + getMinerElement(); */ - } + } } } } monitor.done(); } - + protected abstract String getMinerId(); } diff --git a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java index 20c356b0ed0..387fe31d4c7 100644 --- a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java +++ b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java @@ -72,6 +72,7 @@ * 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 * Javier Montalvo Orus (Symbian) - [212382] additional "initCommands" slot for ftpListingParsers extension point + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable ********************************************************************************/ package org.eclipse.rse.internal.services.files.ftp; @@ -1382,14 +1383,6 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil return hasSucceeded; } - public void initService(IProgressMonitor monitor) - { - } - - public void uninitService(IProgressMonitor monitor) - { - } - public boolean isCaseSensitive() { //TODO find out whether remote is case sensitive or not diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java index fd6ffa419df..892234852c3 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java @@ -35,6 +35,7 @@ * David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage() * David McKnight (IBM) - [220241] JJ: IRemoteFileSubSystem.list() on the Local file subsystem does not return correct results * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable *******************************************************************************/ package org.eclipse.rse.internal.services.local.files; @@ -1545,15 +1546,6 @@ public class LocalFileService extends AbstractFileService implements ILocalServi return (rc == 0); } - public void initService(IProgressMonitor monitor) - { - - } - - public void uninitService(IProgressMonitor monitor) - { - } - public boolean isCaseSensitive() { return !isWindows(); diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/processes/LocalProcessService.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/processes/LocalProcessService.java index e057bbad910..6a104569f65 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/processes/LocalProcessService.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/processes/LocalProcessService.java @@ -7,13 +7,14 @@ * * 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, + * 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 * Kevin Doyle (IBM) - [199871] LocalProcessService needs to implement getMessage() + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc *******************************************************************************/ package org.eclipse.rse.internal.services.local.processes; @@ -32,30 +33,29 @@ import org.eclipse.rse.services.clientserver.processes.IHostProcessFilter; import org.eclipse.rse.services.clientserver.processes.handlers.ProcessHandler; import org.eclipse.rse.services.clientserver.processes.handlers.ProcessHandlerManager; import org.eclipse.rse.services.processes.AbstractProcessService; -import org.eclipse.rse.services.processes.IProcessService; -public class LocalProcessService extends AbstractProcessService implements ILocalService, IProcessService -{ +public class LocalProcessService extends AbstractProcessService implements ILocalService +{ protected String[] _statusTypes; protected ProcessHandler handler; - + public LocalProcessService() { handler = ProcessHandlerManager.getInstance().getNewProcessHandler(); } - - + + public String getName() { return LocalServiceResources.Local_Process_Service_Name; } - + public String getDescription() { return LocalServiceResources.Local_Process_Service_Description; } - - public IHostProcess[] listAllProcesses(IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException + + public IHostProcess[] listAllProcesses(IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException { IHostProcess[] processes = null; @@ -72,18 +72,18 @@ public class LocalProcessService extends AbstractProcessService implements ILoca return processes; } - public boolean kill(long PID, String signal, IProgressMonitor monitor) throws SystemMessageException + public boolean kill(long PID, String signal, IProgressMonitor monitor) throws SystemMessageException { IHostProcess process = null; try { process = getProcess(PID, monitor); - + // if there is no process, simply return true if (process == null) { return true; } - + handler.kill(process, signal); return true; } @@ -97,14 +97,14 @@ public class LocalProcessService extends AbstractProcessService implements ILoca if (process != null) name += process.getName(); String pid = ""; //$NON-NLS-1$ if (process != null) pid += process.getPid(); - + SystemMessage msg = getMessage("RSEPG1300"); //$NON-NLS-1$ msg.makeSubstitution(name + " (" + pid + ")", e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ throw new SystemMessageException(msg); } } - public String[] getSignalTypes() + public String[] getSignalTypes() { if (_statusTypes != null) { @@ -116,7 +116,7 @@ public class LocalProcessService extends AbstractProcessService implements ILoca } return _statusTypes; } - + /** * Returns a list of the signal types supported by the 'kill' command on this system * @return a list of the signal types or null if there are none or there is an error in @@ -152,13 +152,4 @@ public class LocalProcessService extends AbstractProcessService implements ILoca } } - public void initService(IProgressMonitor monitor) - { - - } - - public void uninitService(IProgressMonitor monitor) - { - } - } diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/LocalShellService.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/LocalShellService.java index 72985a05f2c..0d2bee285ce 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/LocalShellService.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/shells/LocalShellService.java @@ -1,17 +1,18 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * 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 + * 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, + * 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 ********************************************************************************/ package org.eclipse.rse.internal.services.local.shells; @@ -25,34 +26,27 @@ import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.rse.internal.services.local.ILocalService; import org.eclipse.rse.internal.services.local.LocalServiceResources; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; +import org.eclipse.rse.services.shells.AbstractShellService; import org.eclipse.rse.services.shells.IHostShell; -import org.eclipse.rse.services.shells.IShellService; -public class LocalShellService implements IShellService, ILocalService +public class LocalShellService extends AbstractShellService implements ILocalService { private static final String SHELL_INVOCATION = ">"; //$NON-NLS-1$ private String[] _envVars; - + public LocalShellService() { } - + public String getName() { return LocalServiceResources.Local_Shell_Service_Name; } - + public String getDescription() { return LocalServiceResources.Local_Shell_Service_Description; } - - public IHostShell launchShell(String initialWorkingDirectory, String[] environment, IProgressMonitor monitor) - { - String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$ - return launchShell(initialWorkingDirectory, defaultEncoding, environment, monitor); - } public IHostShell launchShell(String initialWorkingDirectory, String encoding, String[] environment, IProgressMonitor monitor) { @@ -61,12 +55,6 @@ public class LocalShellService implements IShellService, ILocalService return hostShell; } - public IHostShell runCommand(String initialWorkingDirectory, String command, String[] environment, IProgressMonitor monitor) - { - String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$ - return runCommand(initialWorkingDirectory, command, defaultEncoding, environment, monitor); - } - public IHostShell runCommand(String initialWorkingDirectory, String command, String encoding, String[] environment, IProgressMonitor monitor) { LocalHostShell hostShell = new LocalHostShell(initialWorkingDirectory,command, encoding, environment); @@ -81,7 +69,7 @@ public class LocalShellService implements IShellService, ILocalService List envVars = new ArrayList(); String[] envCommand = new String[3]; - //If we're on windows, change the envCommand. + //If we're on windows, change the envCommand. if (System.getProperty("os.name").toLowerCase().startsWith("win")) //$NON-NLS-1$ //$NON-NLS-2$ { envCommand[0] = "cmd"; //$NON-NLS-1$ @@ -132,17 +120,4 @@ public class LocalShellService implements IShellService, ILocalService return _envVars; } - public void initService(IProgressMonitor monitor) - { - - } - - public void uninitService(IProgressMonitor monitor) - { - - } - public SystemMessage getMessage(String messageID) - { - return null; - } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java index 18bdc82a589..67100fab129 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java +++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java @@ -24,6 +24,7 @@ * Martin Oberhuber (Wind River) - [216343] immediate link targets and canonical paths for Sftp * 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 * Martin Oberhuber (Wind River) - [224799] Fix JSch encoding problems with Arabic filenames + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable *******************************************************************************/ package org.eclipse.rse.internal.services.ssh.files; @@ -1068,6 +1069,7 @@ public class SftpFileService extends AbstractFileService implements ISshService, public void initService(IProgressMonitor monitor) { Activator.trace("SftpFileService.initService"); //$NON-NLS-1$ + super.initService(monitor); try { connect(); @@ -1080,6 +1082,7 @@ public class SftpFileService extends AbstractFileService implements ISshService, public void uninitService(IProgressMonitor monitor) { Activator.trace("SftpFileService.uninitService"); //$NON-NLS-1$ disconnect(); + super.uninitService(monitor); } public boolean isCaseSensitive() { diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/shell/SshHostShell.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/shell/SshHostShell.java index 3f5c1fb5658..1032f553a3f 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/shell/SshHostShell.java +++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/shell/SshHostShell.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * 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 @@ -7,15 +7,16 @@ * * 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, + * 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) - Adapted from LocalHostShell. * David McKnight (IBM) - [191599] Use the remote encoding specified in the host property page * David McKnight (IBM) - [196301] Check that the remote encoding isn't null before using it * Martin Oberhuber (Wind River) - [204744] Honor encoding in SSH command input field + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable *******************************************************************************/ package org.eclipse.rse.internal.services.ssh.shell; @@ -53,7 +54,7 @@ public class SshHostShell extends AbstractHostShell implements IHostShell { private SshShellOutputReader fStdoutHandler; private SshShellOutputReader fStderrHandler; private SshShellWriterThread fShellWriter; - + public SshHostShell(ISshSessionProvider sessionProvider, String initialWorkingDirectory, String commandToRun, String encoding, String[] environment) { try { fSessionProvider = sessionProvider; @@ -66,7 +67,7 @@ public class SshHostShell extends AbstractHostShell implements IHostShell { //if(commandToRun!=null && !commandToRun.equals(SHELL_INVOCATION) & (fChannel instanceof ChannelShell)) { // ((ChannelShell)fChannel).setPty(false); //} - + //Try to set the user environment. On most sshd configurations, this will //not work since in sshd_config, PermitUserEnvironment and AcceptEnv //settings are disabled. Still, it's worth a try. @@ -91,6 +92,9 @@ public class SshHostShell extends AbstractHostShell implements IHostShell { } else { + // default encoding - same as + // System.getProperty("file.encoding") + // TODO should try to determine remote encoding if possible fStdoutHandler = new SshShellOutputReader(this, new BufferedReader(new InputStreamReader(fChannel.getInputStream())), false); } fStderrHandler = new SshShellOutputReader(this, null,true); @@ -106,10 +110,10 @@ public class SshHostShell extends AbstractHostShell implements IHostShell { fShellWriter = new SshShellWriterThread(outputWriter); } fChannel.connect(); - if (initialWorkingDirectory!=null && initialWorkingDirectory.length()>0 + if (initialWorkingDirectory!=null && initialWorkingDirectory.length()>0 && !initialWorkingDirectory.equals(".") //$NON-NLS-1$ && !initialWorkingDirectory.equals("Command Shell") //$NON-NLS-1$ //FIXME workaround for bug 153047 - ) { + ) { writeToShell("cd "+PathUtility.enQuoteUnix(initialWorkingDirectory)); //$NON-NLS-1$ } else if (SHELL_INVOCATION.equals(commandToRun)) { writeToShell(getPromptCommand()); @@ -135,9 +139,9 @@ public class SshHostShell extends AbstractHostShell implements IHostShell { } /** - * Connect to remote system and launch Threads for the - * shell as needed. - * @param monitor + * Connect to remote system and launch Threads for the shell as needed. + * + * @param monitor progress monitor for long-running operation */ protected void start(IProgressMonitor monitor) { @@ -162,11 +166,11 @@ public class SshHostShell extends AbstractHostShell implements IHostShell { } private static final Pattern cdCommands = Pattern.compile("\\A\\s*(cd|chdir|ls)\\b"); //$NON-NLS-1$ - + public String getPromptCommand() { return "echo $PWD'>'"; //$NON-NLS-1$ } - + public void writeToShell(String command) { if (isActive()) { if ("#break".equals(command)) { //$NON-NLS-1$ diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/shell/SshShellService.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/shell/SshShellService.java index 64580e33980..08471e83d59 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/shell/SshShellService.java +++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/shell/SshShellService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * 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 @@ -7,13 +7,14 @@ * * 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, + * 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) - Adapted from LocalShellService. * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable *******************************************************************************/ package org.eclipse.rse.internal.services.ssh.shell; @@ -23,29 +24,21 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.rse.internal.services.ssh.ISshService; import org.eclipse.rse.internal.services.ssh.ISshSessionProvider; import org.eclipse.rse.internal.services.ssh.SshServiceResources; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; +import org.eclipse.rse.services.shells.AbstractShellService; import org.eclipse.rse.services.shells.IHostShell; -import org.eclipse.rse.services.shells.IShellService; /** * A Shell Services for ssh. * Adapted from LocalShellService. */ -public class SshShellService implements ISshService, IShellService { +public class SshShellService extends AbstractShellService implements ISshService { private ISshSessionProvider fSessionProvider; - + public SshShellService(ISshSessionProvider sessionProvider) { fSessionProvider = sessionProvider; } - //TODO abstract base class should handle default encodings - public IHostShell launchShell(String initialWorkingDirectory, - String[] environment, IProgressMonitor monitor) { - String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$ - return launchShell(initialWorkingDirectory, defaultEncoding, environment, monitor); - } - public IHostShell launchShell(String initialWorkingDirectory, String encoding, String[] environment, IProgressMonitor monitor) { @@ -53,13 +46,6 @@ public class SshShellService implements ISshService, IShellService { return hostShell; } - //TODO abstract base class should handle default encodings - public IHostShell runCommand(String initialWorkingDirectory, - String command, String[] environment, IProgressMonitor monitor) { - String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$ - return runCommand(initialWorkingDirectory, command, defaultEncoding, environment, monitor); - } - public IHostShell runCommand(String initialWorkingDirectory, String command, String encoding, String[] environment, IProgressMonitor monitor) { @@ -80,16 +66,4 @@ public class SshShellService implements ISshService, IShellService { return SshServiceResources.SshShellService_Description; } - public void initService(IProgressMonitor monitor) { - // nothing to do - } - - public void uninitService(IProgressMonitor monitor) { - // nothing to do - } - - public SystemMessage getMessage(String messageID) { - return null; - } - } diff --git a/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellService.java b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellService.java index 8a4ca016ef9..d9b20a60018 100644 --- a/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellService.java +++ b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * 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 @@ -7,13 +7,14 @@ * * 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, + * 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) - Adapted from LocalShellService. * Sheldon D'souza (Celunite) - Adapted from SshShellService. + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable *******************************************************************************/ package org.eclipse.rse.internal.services.telnet.shell; @@ -21,46 +22,32 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.rse.internal.services.telnet.ITelnetService; import org.eclipse.rse.internal.services.telnet.ITelnetSessionProvider; import org.eclipse.rse.internal.services.telnet.TelnetServiceResources; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; +import org.eclipse.rse.services.shells.AbstractShellService; import org.eclipse.rse.services.shells.IHostShell; -import org.eclipse.rse.services.shells.IShellService; -public class TelnetShellService implements ITelnetService, IShellService { +public class TelnetShellService extends AbstractShellService implements ITelnetService { - private ITelnetSessionProvider fTelnetSessionProvider; - + public TelnetShellService( ITelnetSessionProvider sessionProvider) { this.fTelnetSessionProvider = sessionProvider; } - + public String[] getHostEnvironment() { return new String[0]; } - public IHostShell launchShell(String initialWorkingDirectory, - String[] environment, IProgressMonitor monitor) { - String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$ - return launchShell(initialWorkingDirectory, defaultEncoding, environment, monitor); - } - public IHostShell launchShell(String initialWorkingDirectory, String encoding, String[] environment, IProgressMonitor monitor) { - TelnetHostShell hostShell = new TelnetHostShell(fTelnetSessionProvider, initialWorkingDirectory, TelnetHostShell.SHELL_INVOCATION, encoding, environment); + TelnetHostShell hostShell = new TelnetHostShell(fTelnetSessionProvider, initialWorkingDirectory, TelnetHostShell.SHELL_INVOCATION, encoding, environment); return hostShell; } - public IHostShell runCommand(String initialWorkingDirectory, - String command, String[] environment, IProgressMonitor monitor) { - String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$ - return runCommand(initialWorkingDirectory, command, defaultEncoding, environment, monitor); - } - public IHostShell runCommand(String initialWorkingDirectory, String command, String encoding, String[] environment, IProgressMonitor monitor) { - TelnetHostShell hostShell = new TelnetHostShell(fTelnetSessionProvider, initialWorkingDirectory, TelnetHostShell.SHELL_INVOCATION, encoding, environment); + TelnetHostShell hostShell = new TelnetHostShell(fTelnetSessionProvider, initialWorkingDirectory, TelnetHostShell.SHELL_INVOCATION, encoding, environment); return hostShell; } @@ -68,23 +55,8 @@ public class TelnetShellService implements ITelnetService, IShellService { return TelnetServiceResources.TelnetShellService_Description; } - public SystemMessage getMessage(String messageID) { - // TODO Auto-generated method stub - return null; - } - public String getName() { return TelnetServiceResources.TelnetShellService_Name; } - public void initService(IProgressMonitor monitor) { - // TODO Auto-generated method stub - - } - - public void uninitService(IProgressMonitor monitor) { - // TODO Auto-generated method stub - - } - } diff --git a/rse/plugins/org.eclipse.rse.services/.settings/org.eclipse.core.resources.prefs b/rse/plugins/org.eclipse.rse.services/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..670884a4dba --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Wed Apr 09 15:34:43 CEST 2008 +eclipse.preferences.version=1 +encoding/=ISO-8859-1 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 new file mode 100644 index 00000000000..d004bc59c0a --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/AbstractService.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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.core 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 super.initService(monitor) 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 super.uninitService(monitor) 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 index d000941f91c..0dfd75c7b47 100644 --- 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 @@ -7,22 +7,74 @@ * * 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, + * 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. + * 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; -public interface IService +/** + * 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/files/AbstractFileService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java index 52e652bd5dd..2510aa50702 100644 --- 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 @@ -7,10 +7,10 @@ * * 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, + * 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 @@ -24,6 +24,7 @@ * 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 *******************************************************************************/ package org.eclipse.rse.services.files; @@ -36,15 +37,16 @@ import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.rse.services.AbstractService; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -public abstract class AbstractFileService implements IFileService +public abstract class AbstractFileService extends AbstractService implements IFileService { - + protected abstract IHostFile[] internalFetch(String parentPath, String fileFilter, int fileType, IProgressMonitor monitor) throws SystemMessageException; - - public IHostFile[] getFileMultiple(String remoteParents[], String names[], IProgressMonitor monitor) + + public IHostFile[] getFileMultiple(String remoteParents[], String names[], IProgressMonitor monitor) throws SystemMessageException { List results = new ArrayList(); @@ -55,12 +57,12 @@ public abstract class AbstractFileService implements IFileService return (IHostFile[])results.toArray(new IHostFile[results.size()]); } - public IHostFile[] list(String remoteParent, String fileFilter, + public IHostFile[] list(String remoteParent, String fileFilter, int fileType, IProgressMonitor monitor) throws SystemMessageException { return internalFetch(remoteParent, fileFilter, fileType, monitor); } - + public IHostFile[] listMultiple(String[] remoteParents, String[] fileFilters, int fileTypes[], IProgressMonitor monitor) throws SystemMessageException { @@ -74,7 +76,7 @@ public abstract class AbstractFileService implements IFileService files.add(result[j]); } } - + return (IHostFile[])files.toArray(new IHostFile[files.size()]); } @@ -91,10 +93,10 @@ public abstract class AbstractFileService implements IFileService files.add(result[j]); } } - + return (IHostFile[])files.toArray(new IHostFile[files.size()]); } - + protected boolean isRightType(int fileType, IHostFile node) { switch (fileType) @@ -104,12 +106,12 @@ public abstract class AbstractFileService implements IFileService case IFileService.FILE_TYPE_FILES: if (node.isFile()) { - return true; + return true; } else { return false; - } + } case IFileService.FILE_TYPE_FOLDERS: if (node.isDirectory()) { @@ -121,7 +123,7 @@ public abstract class AbstractFileService implements IFileService } default: return true; - } + } } @@ -140,7 +142,7 @@ public abstract class AbstractFileService implements IFileService */ public boolean downloadMultiple(String[] remoteParents, String[] remoteFiles, File[] localFiles, boolean[] isBinaries, String[] hostEncodings, - IProgressMonitor monitor) throws SystemMessageException + IProgressMonitor monitor) throws SystemMessageException { boolean result = true; for (int i = 0; i < remoteParents.length && result == true; i++) @@ -161,7 +163,7 @@ public abstract class AbstractFileService implements IFileService public boolean uploadMultiple(File[] localFiles, String[] remoteParents, String[] remoteFiles, boolean[] isBinaries, String[] srcEncodings, String[] hostEncodings, IProgressMonitor monitor) - throws SystemMessageException + throws SystemMessageException { boolean result = true; for (int i = 0; i < localFiles.length && result == true; i++) @@ -169,7 +171,7 @@ public abstract class AbstractFileService implements IFileService File localFile = localFiles[i]; String remoteParent = remoteParents[i]; String remoteFile = remoteFiles[i]; - + boolean isBinary = isBinaries[i]; String srcEncoding = srcEncodings[i]; String hostEncoding = hostEncodings[i]; @@ -177,7 +179,7 @@ public abstract class AbstractFileService implements IFileService } return result; } - + /** * 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) @@ -196,15 +198,18 @@ public abstract class AbstractFileService implements IFileService } /** - * Gets the output stream to write/append to a remote file. - * The default implementation returns null. - * Clients can override to return an output stream to the file. - * @deprecated + * Gets the output stream to write/append to a remote file. The default + * implementation returns null. 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 null. @@ -219,7 +224,7 @@ public abstract class AbstractFileService implements IFileService } 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. 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 new file mode 100644 index 00000000000..f2afc79f665 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/package.html @@ -0,0 +1,32 @@ + + + + + + + + Package-level Javadoc + + +Application programming interface for the RSE Services Layer. +

+Package Specification

+

+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. +

+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: +IAdaptable, IProgressMonitor, +IStatus, NLS, PlatformObject +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. +

+ + 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 index 60a354015a2..cb81e02584c 100644 --- 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 @@ -1,31 +1,37 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * 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 + * 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, + * 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.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; -public abstract class AbstractProcessService implements IProcessService +/** + * 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 + public IHostProcess[] listAllProcesses(String exeNameFilter, String userNameFilter, String stateFilter, IProgressMonitor monitor) throws SystemMessageException { HostProcessFilterImpl rpfs = new HostProcessFilterImpl(); rpfs.setName(exeNameFilter); @@ -34,7 +40,7 @@ public abstract class AbstractProcessService implements IProcessService return listAllProcesses(rpfs, monitor); } - public IHostProcess[] listAllProcesses(IProgressMonitor monitor) throws SystemMessageException + public IHostProcess[] listAllProcesses(IProgressMonitor monitor) throws SystemMessageException { HostProcessFilterImpl rpfs = new HostProcessFilterImpl(); return listAllProcesses(rpfs, monitor); @@ -42,51 +48,53 @@ public abstract class AbstractProcessService implements IProcessService /** * 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 + * @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 + 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 + 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 + + 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 + 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 + 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]; } - + public SystemMessage getMessage(String messageID) { return null; 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 index 2c538855933..e58ff7fe200 100644 --- 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 @@ -1,121 +1,144 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * 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 + * 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, + * 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. + * 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. *

- * Implementers of this interface will have to either be instantiated, initialized, or - * somehow derive a connection as part of its state. + * 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 + * @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 + * @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 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 + * @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 + * @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 + * 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 + * @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 + * 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 + * @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 + * @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 + * @return IHostProcess object for the given pid + * @throws SystemMessageException in case anything goes wrong */ - public IHostProcess getProcess(long pid, IProgressMonitor monitor) throws SystemMessageException; - + public IHostProcess getProcess(long pid, IProgressMonitor monitor) throws SystemMessageException; + /** - * Kills a process. + * 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 false if the given process doesn't exist, else true. - * Throws an exception if anything fails. - * @throws SystemMessageException + * @return false if the given process doesn't exist, else + * true. Throws an exception if anything fails. + * @throws SystemMessageException in case anything goes wrong */ - public boolean kill(long pid, String signal, IProgressMonitor monitor) throws SystemMessageException; + public boolean kill(long pid, String signal, IProgressMonitor monitor) throws SystemMessageException; /** * Returns a list of the types of signals that can be sent to 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 index 486bf42816b..509f13d8ab7 100644 --- 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 @@ -1,17 +1,18 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * 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 + * 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, + * 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; @@ -20,26 +21,31 @@ 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; - - -public abstract class AbstractSearchService implements ISearchService +/** + * 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); 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 index 70754b9d0bf..8a734215993 100644 --- 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 @@ -7,12 +7,12 @@ * * 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, + * 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. + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc *******************************************************************************/ package org.eclipse.rse.services.search; @@ -24,18 +24,18 @@ import java.util.List; import java.util.Vector; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; +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 + * This allows it to contain results from multiple connections, filters, and folders * (from different systems). */ -public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable +public class HostSearchResultSet extends PlatformObject implements IHostSearchResultSet, IAdaptable { - + protected Vector configurations; protected String name; @@ -106,48 +106,48 @@ public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable * @see org.eclipse.rse.services.search.IHostSearchResultSet#getAllResults() */ public Object[] getAllResults() { - + List list = new ArrayList(); - + Iterator iter = getSearchConfigurations(); - - while (iter.hasNext()) + + while (iter.hasNext()) { IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next(); - - list.addAll(Arrays.asList(config.getResults())); + + 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; } @@ -155,13 +155,13 @@ public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable * @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(); } @@ -173,60 +173,60 @@ public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable */ 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.CANCELED) { return false; } } - + return true; } @@ -235,16 +235,16 @@ public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable */ 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; } @@ -253,16 +253,16 @@ public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable */ 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; } @@ -271,23 +271,17 @@ public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable */ 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; } - - /** - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - return Platform.getAdapterManager().getAdapter(this, adapter); - } + } 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 index cd43259db68..db46e3d4fc4 100644 --- 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 @@ -1,24 +1,34 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * 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 + * 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, + * 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); 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 new file mode 100644 index 00000000000..256c2515e0b --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractShellService.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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.shells; + +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.rse.services.AbstractService; + +/** + * Abstract base class for RSE Shell Service implementations. + */ +public abstract class AbstractShellService extends AbstractService implements IShellService { + + /* (non-Javadoc) + * @see org.eclipse.rse.services.shells.IShellService#getHostEnvironment() + */ + public String[] getHostEnvironment() { + // not implemented by default + return null; + } + + /* (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) { + 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) { + return runCommand(initialWorkingDirectory, command, null, environment, monitor); + } + +} 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 index e2b6b5b76f9..28bb4a62823 100644 --- 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 @@ -1,77 +1,122 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * 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 + * 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, + * 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.shells; import org.eclipse.core.runtime.IProgressMonitor; + import org.eclipse.rse.services.IService; /** - * IShellService is an abstraction for running shells and - * shell commands + * 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 - * @param initialWorkingDirectory - * @param environment Array of environment variable Strings of the form "var=text" - * @param monitor - * @return the shell object + * Launch a new shell in the specified directory with a default encoding. + * + * This is a convenience method, passing null as encoding + * into {@link #launchShell(String, String, String[], IProgressMonitor)}. */ public IHostShell launchShell(String initialWorkingDirectory, String[] environment, IProgressMonitor monitor); - + /** - * Launch a new shell in the specified directory - * @param initialWorkingDirectory - * @param encoding - * @param environment Array of environment variable Strings of the form "var=text" - * @param monitor - * @return the shell object + * Launch a new shell in the specified directory. + * + * @param initialWorkingDirectory initial working directory or + * null 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 null 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 an error occurred or the operation was canceled. In this + * case, {@link IHostShell#isActive()} returns false + * on the created Shell object. */ public IHostShell launchShell(String initialWorkingDirectory, String encoding, String[] environment, IProgressMonitor monitor); /** - * Run a command in it's own shell - * @param initialWorkingDirectory - * @param command - * @param environment Array of environment variable Strings of the form "var=text" - * @param monitor - * @return the shell object for getting output and error streams + * + * Run a single command in it's own shell with a default encoding. + * + * This is a convenience method, passing null as encoding + * into + * {@link #runCommand(String, String, String, String[], IProgressMonitor)}. */ public IHostShell runCommand(String initialWorkingDirectory, String command, String[] environment, IProgressMonitor monitor); - + /** - * Run a command in it's own shell - * @param initialWorkingDirectory - * @param command - * @param encoding - * @param environment Array of environment variable Strings of the form "var=text" - * @param monitor - * @return the shell object for getting output and error streams + * 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 + * null 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 null 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 or + * the operation was canceled. In this case, + * {@link IHostShell#isActive()} returns false on the + * created Shell object. */ public IHostShell runCommand(String initialWorkingDirectory, String command, String encoding, String[] environment, IProgressMonitor monitor); /** - * Return an array of environment variables that describe the environment on the host. - * 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" + * 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. May return + * null in case environment variable retrieval is not + * supported on a particular shell service implementation. */ public String[] getHostEnvironment(); } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/internal/subsystems/processes/shell/linux/LinuxShellProcessService.java b/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/internal/subsystems/processes/shell/linux/LinuxShellProcessService.java index b7212dfadd8..9e9716c180e 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/internal/subsystems/processes/shell/linux/LinuxShellProcessService.java +++ b/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/internal/subsystems/processes/shell/linux/LinuxShellProcessService.java @@ -1,15 +1,16 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 MontaVista Software, 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: + * Copyright (c) 2006, 2008 MontaVista Software, 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: * Yu-Fen Kuo (MontaVista) - initial API and implementation - * Martin Oberhuber (Wind River) - [refactor] "shell" instead of "ssh" everywhere + * Martin Oberhuber (Wind River) - [refactor] "shell" instead of "ssh" everywhere * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * David McKnight (IBM) - [175308] Need to use a job to wait for shell to exit + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc *******************************************************************************/ package org.eclipse.rse.internal.subsystems.processes.shell.linux; @@ -36,7 +37,7 @@ import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShell /** * class to fetch remote linux target's process info - * + * */ public class LinuxShellProcessService extends AbstractProcessService { @@ -54,7 +55,7 @@ public class LinuxShellProcessService extends AbstractProcessService { /** * constructor - * + * * @param host the connection to work on */ public LinuxShellProcessService(final IHost host) { @@ -167,11 +168,11 @@ public class LinuxShellProcessService extends AbstractProcessService { } catch (IOException e) { Activator.log(e); } - + // Wait for remote process to exit. WaiterJob waiter = new WaiterJob(p); waiter.schedule(); - + return (IHostProcess[]) hostProcessList .toArray(new IHostProcess[hostProcessList.size()]); } @@ -185,14 +186,12 @@ public class LinuxShellProcessService extends AbstractProcessService { } public void initService(final IProgressMonitor monitor) { + super.initService(monitor); linuxProcessHelper = new LinuxProcessHelper(); // initialize username /uid hashmap before getting any process linuxProcessHelper.populateUsernames(host); } - public void uninitService(final IProgressMonitor monitor) { - } - private boolean progressWorked(final IProgressMonitor monitor, final int work) { boolean cancelRequested = false; @@ -207,7 +206,7 @@ public class LinuxShellProcessService extends AbstractProcessService { * Returns a list of the signal types supported by the 'kill' command on * this system. Signal Types will be used in the Kill dialog for user to * choose which signal they want to use for killing a process. - * + * * @return a list of the signal types or null if there are none or there is * an error in executing the kill command. */ @@ -253,7 +252,7 @@ public class LinuxShellProcessService extends AbstractProcessService { } catch (IOException e) { Activator.log(e); } - + // Wait for remote process to exit. WaiterJob waiter = new WaiterJob(p); waiter.schedule(); diff --git a/wince/org.eclipse.rse.subsystems.wince/src/org/eclipse/rse/internal/services/wince/files/WinCEFileService.java b/wince/org.eclipse.rse.subsystems.wince/src/org/eclipse/rse/internal/services/wince/files/WinCEFileService.java index ce2c533e88f..8a90b973d52 100644 --- a/wince/org.eclipse.rse.subsystems.wince/src/org/eclipse/rse/internal/services/wince/files/WinCEFileService.java +++ b/wince/org.eclipse.rse.subsystems.wince/src/org/eclipse/rse/internal/services/wince/files/WinCEFileService.java @@ -7,6 +7,7 @@ * * Contributors: * Radoslav Gerganov - derived from SftpFileService and LocalFileService + * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable *******************************************************************************/ package org.eclipse.rse.internal.services.wince.files; @@ -41,11 +42,11 @@ import org.eclipse.tm.rapi.RapiFindData; public class WinCEFileService extends AbstractFileService implements IWinCEService { IRapiSessionProvider sessionProvider; - + public WinCEFileService(IRapiSessionProvider sessionProvider) { this.sessionProvider = sessionProvider; } - + String concat(String parentDir, String fileName) { String result = parentDir; if (!result.endsWith("\\")) { //$NON-NLS-1$ @@ -54,7 +55,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi result += fileName; return result; } - + protected IHostFile[] internalFetch(String parentPath, String fileFilter, int fileType, IProgressMonitor monitor) throws SystemMessageException { if (fileFilter == null) { @@ -71,7 +72,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi try { IRapiSession session = sessionProvider.getSession(); RapiFindData[] foundFiles = session.findAllFiles(concat(parentPath,"*"), //$NON-NLS-1$ - Rapi.FAF_NAME | Rapi.FAF_ATTRIBUTES | Rapi.FAF_LASTWRITE_TIME | + Rapi.FAF_NAME | Rapi.FAF_ATTRIBUTES | Rapi.FAF_LASTWRITE_TIME | Rapi.FAF_SIZE_HIGH | Rapi.FAF_SIZE_LOW); for (int i = 0 ; i < foundFiles.length ; i++) { String fileName = foundFiles[i].fileName; @@ -104,11 +105,11 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi } return (attr & Rapi.FILE_ATTRIBUTE_DIRECTORY) != 0; } - + private boolean exist(IRapiSession session, String fileName) { return session.getFileAttributes(fileName) != -1; } - + public boolean copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException { String srcFullPath = concat(srcParent, srcName); @@ -158,7 +159,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi String fullPath = concat(remoteParent, fileName); IRapiSession session = sessionProvider.getSession(); try { - int handle = session.createFile(fullPath, Rapi.GENERIC_WRITE, Rapi.FILE_SHARE_READ, + int handle = session.createFile(fullPath, Rapi.GENERIC_WRITE, Rapi.FILE_SHARE_READ, Rapi.CREATE_ALWAYS, Rapi.FILE_ATTRIBUTE_NORMAL); session.closeHandle(handle); RapiFindData findData = new RapiFindData(); @@ -203,14 +204,14 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi } } catch (RapiException e) { //FIXME error handling - throw new RemoteFileException(e.getMessage()); + throw new RemoteFileException(e.getMessage()); } return true; } public boolean download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException { - + if (!localFile.exists()) { File localParentFile = localFile.getParentFile(); if (!localParentFile.exists()) { @@ -222,7 +223,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi int handle = Rapi.INVALID_HANDLE_VALUE; BufferedOutputStream bos = null; try { - handle = session.createFile(fullPath, Rapi.GENERIC_READ, + handle = session.createFile(fullPath, Rapi.GENERIC_READ, Rapi.FILE_SHARE_READ, Rapi.OPEN_EXISTING, Rapi.FILE_ATTRIBUTE_NORMAL); bos = new BufferedOutputStream(new FileOutputStream(localFile)); // don't increase the buffer size! the native functions sometimes fail with large buffers, 4K always work @@ -288,14 +289,14 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi return false; } - public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, + public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException { boolean ok = copy(srcParent, srcName, tgtParent, tgtName, monitor); ok = ok && delete(srcParent, srcName, monitor); return ok; } - public boolean rename(String remoteParent, String oldName, String newName, + public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException { String oldFullPath = concat(remoteParent, oldName); String newFullPath = concat(remoteParent, newName); @@ -309,7 +310,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi return true; } - public boolean rename(String remoteParent, String oldName, String newName, IHostFile oldFile, + public boolean rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) throws SystemMessageException { boolean retVal = rename(remoteParent, oldName, newName, monitor); String newFullPath = concat(remoteParent, newName); @@ -332,7 +333,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi String fullPath = concat(remoteParent, remoteFile); int handle = Rapi.INVALID_HANDLE_VALUE; try { - handle = session.createFile(fullPath, Rapi.GENERIC_WRITE, + handle = session.createFile(fullPath, Rapi.GENERIC_WRITE, Rapi.FILE_SHARE_READ, Rapi.CREATE_ALWAYS, Rapi.FILE_ATTRIBUTE_NORMAL); // don't increase the buffer size! the native functions sometimes fail with large buffers, 4K always work byte[] buffer = new byte[4 * 1024]; @@ -366,7 +367,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi return true; } - public boolean upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, + public boolean upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException { FileInputStream fis = null; try { @@ -384,7 +385,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi String fullPath = concat(remoteParent, remoteFile); IRapiSession session = sessionProvider.getSession(); try { - int handle = session.createFile(fullPath, Rapi.GENERIC_READ, + int handle = session.createFile(fullPath, Rapi.GENERIC_READ, Rapi.FILE_SHARE_READ, Rapi.OPEN_EXISTING, Rapi.FILE_ATTRIBUTE_NORMAL); return new BufferedInputStream(new WinCEInputStream(session, handle)); } catch (RapiException e) { @@ -404,7 +405,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi } else { cd = Rapi.OPEN_EXISTING; } - int handle = session.createFile(fullPath, Rapi.GENERIC_WRITE, + int handle = session.createFile(fullPath, Rapi.GENERIC_WRITE, Rapi.FILE_SHARE_READ, cd, Rapi.FILE_ATTRIBUTE_NORMAL); return new BufferedOutputStream(new WinCEOutputStream(session, handle)); } catch (RapiException e) { @@ -421,22 +422,16 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi return Messages.WinCEFileService_1; } - public void initService(IProgressMonitor monitor) { - } - - public void uninitService(IProgressMonitor monitor) { - } - private static class WinCEInputStream extends InputStream { private int handle; private IRapiSession session; - + public WinCEInputStream(IRapiSession session, int handle) { this.handle = handle; this.session = session; } - + public int read() throws IOException { byte[] b = new byte[1]; try { @@ -462,19 +457,19 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi throw new IOException(e.getMessage()); } } - + } - + private static class WinCEOutputStream extends OutputStream { private int handle; private IRapiSession session; - + public WinCEOutputStream(IRapiSession session, int handle) { this.session = session; this.handle = handle; } - + public void write(int b) throws IOException { try { session.writeFile(handle, new byte[] {(byte)b}); @@ -490,7 +485,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi throw new IOException(e.getMessage()); } } - + public void close() throws IOException { try { session.closeHandle(handle);