### Eclipse Workspace Patch 1.0 #P org.eclipse.rse.services.dstore Index: src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java,v retrieving revision 1.20 diff -u -r1.20 DStoreFileService.java --- src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java 4 Oct 2007 13:49:44 -0000 1.20 +++ src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java 24 Oct 2007 13:56:15 -0000 @@ -19,7 +19,8 @@ * 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 "/" + * Xuan Chen (IBM) - [190824] Incorrect result for DStore#getSeparator() function when parent is "/" + * David McKnight (IBM) - [207095] check for null datastore ********************************************************************************/ package org.eclipse.rse.internal.services.dstore.files; @@ -105,6 +106,7 @@ super.uninitService(monitor); _fileElementMap.clear(); _dstoreFileMap.clear(); + _uploadLogElement = null; } public String getName() @@ -149,7 +151,10 @@ protected String getDataStoreRoot() { - return getDataStore().getAttribute(DataStoreAttributes.A_LOCAL_PATH); + DataStore ds = getDataStore(); + if (ds != null) + return ds.getAttribute(DataStoreAttributes.A_LOCAL_PATH); + return null; } @@ -172,28 +177,46 @@ protected void setDataStoreRoot(String root) { - getDataStore().setAttribute(DataStoreAttributes.A_LOCAL_PATH, root); + DataStore ds = getDataStore(); + if (ds != null) + ds.setAttribute(DataStoreAttributes.A_LOCAL_PATH, root); } protected DataElement findUploadLog() { DataElement minerInfo = getMinerElement(); - if (_uploadLogElement == null || _uploadLogElement.getDataStore() != getDataStore()) + DataStore ds = getDataStore(); + if (_uploadLogElement == null || _uploadLogElement.getDataStore() != ds) { - _uploadLogElement = getDataStore().find(minerInfo, DE.A_NAME, "universal.uploadlog", 2); //$NON-NLS-1$ + if (ds != null) + { + _uploadLogElement = ds.find(minerInfo, DE.A_NAME, "universal.uploadlog", 2); //$NON-NLS-1$ + } + else + { + return null; + } } return _uploadLogElement; } protected DataElement getAttributes(String fileNameFilter, boolean showHidden) { - DataElement attributes = getDataStore().createTransientObject(_filterAttributes); - String version = IServiceConstants.VERSION_1; - StringBuffer buffer = new StringBuffer(); - String filter = ((fileNameFilter == null) ? "*" : fileNameFilter); //$NON-NLS-1$ - buffer.append(version).append(IServiceConstants.TOKEN_SEPARATOR).append(filter).append(IServiceConstants.TOKEN_SEPARATOR).append(showHidden); - attributes.setAttribute(DE.A_SOURCE, buffer.toString()); - return attributes; + DataStore ds = getDataStore(); + if (ds != null) + { + DataElement attributes = ds.createTransientObject(_filterAttributes); + String version = IServiceConstants.VERSION_1; + StringBuffer buffer = new StringBuffer(); + String filter = ((fileNameFilter == null) ? "*" : fileNameFilter); //$NON-NLS-1$ + buffer.append(version).append(IServiceConstants.TOKEN_SEPARATOR).append(filter).append(IServiceConstants.TOKEN_SEPARATOR).append(showHidden); + attributes.setAttribute(DE.A_SOURCE, buffer.toString()); + return attributes; + } + else + { + return null; + } } @@ -776,10 +799,17 @@ buf.append(name); de = getElementFor(buf.toString()); } - dsQueryCommand(de, IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT, monitor); - //getFile call should also need to convert this DataElement into a HostFile using - //convertToHostFile() call. This way, this DataElement will be put into _fileMap. - return convertToHostFile(de); + + // with 207095, it's possible to get here unconnected such that there is no element + if (de != null) { + dsQueryCommand(de, IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT, monitor); + //getFile call should also need to convert this DataElement into a HostFile using + //convertToHostFile() call. This way, this DataElement will be put into _fileMap. + return convertToHostFile(de); + } + else { + return null; + } } /** @@ -1284,6 +1314,12 @@ waitForInitialize(null); } + DataStore ds = getDataStore(); + + // 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); @@ -1295,7 +1331,7 @@ if (element == null || element.isDeleted()) { DataElement universaltemp = getMinerElement(); - element = getDataStore().createObject(universaltemp, IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR, normalizedPath, normalizedPath, "", false); //$NON-NLS-1$ + element = ds.createObject(universaltemp, IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR, normalizedPath, normalizedPath, "", false); //$NON-NLS-1$ } return element; } @@ -1314,8 +1350,11 @@ protected IHostFile[] fetch(String remoteParent, String fileFilter, String queryType, IProgressMonitor monitor) { DataStore ds = getDataStore(); - - + if (ds == null) + { + return new IHostFile[0]; + } + // create filter descriptor DataElement deObj = getElementFor(remoteParent); if (deObj == null) @@ -1343,15 +1382,16 @@ String remotePath = parent + getSeparator(parent) + name; DataElement de = getElementFor(remotePath); DataStore ds = de.getDataStore(); - - - DataElement setCmd = getCommandDescriptor(de, IUniversalDataStoreConstants.C_SET_LASTMODIFIED); - if (setCmd != null) + if (ds != null) { - // first modify the source attribute to temporarily be the date field - de.setAttribute(DE.A_SOURCE, timestamp + ""); //$NON-NLS-1$ - ds.command(setCmd, de, true); - return true; + DataElement setCmd = getCommandDescriptor(de, IUniversalDataStoreConstants.C_SET_LASTMODIFIED); + if (setCmd != null) + { + // first modify the source attribute to temporarily be the date field + de.setAttribute(DE.A_SOURCE, timestamp + ""); //$NON-NLS-1$ + ds.command(setCmd, de, true); + return true; + } } return false; @@ -1363,23 +1403,24 @@ String remotePath = parent + getSeparator(parent) + name; DataElement de = getElementFor(remotePath); DataStore ds = de.getDataStore(); - - - DataElement setCmd = getCommandDescriptor(de, IUniversalDataStoreConstants.C_SET_READONLY); - if (setCmd != null) + if (ds != null) { - String flag = readOnly ? "true" : "false"; //$NON-NLS-1$ //$NON-NLS-2$ - de.setAttribute(DE.A_SOURCE, flag); - DataElement status = ds.command(setCmd, de, true); - try - { - getStatusMonitor(ds).waitForUpdate(status); - } - catch (Exception e) + DataElement setCmd = getCommandDescriptor(de, IUniversalDataStoreConstants.C_SET_READONLY); + if (setCmd != null) { + String flag = readOnly ? "true" : "false"; //$NON-NLS-1$ //$NON-NLS-2$ + de.setAttribute(DE.A_SOURCE, flag); + DataElement status = ds.command(setCmd, de, true); + try + { + getStatusMonitor(ds).waitForUpdate(status); + } + catch (Exception e) + { + } + return true; } - return true; } return false; } @@ -1394,20 +1435,22 @@ 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 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); + DataElement status = ds.command(queryCmd, encodingElement, true); - try { - getStatusMonitor(ds).waitForUpdate(status); - } - catch (Exception e) { - } + try { + getStatusMonitor(ds).waitForUpdate(status); + } + catch (Exception e) { + } - remoteEncoding = encodingElement.getValue(); + remoteEncoding = encodingElement.getValue(); + } } return remoteEncoding; Index: src/org/eclipse/rse/services/dstore/AbstractDStoreService.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/AbstractDStoreService.java,v retrieving revision 1.12 diff -u -r1.12 AbstractDStoreService.java --- src/org/eclipse/rse/services/dstore/AbstractDStoreService.java 9 Jul 2007 17:59:40 -0000 1.12 +++ src/org/eclipse/rse/services/dstore/AbstractDStoreService.java 24 Oct 2007 13:56:15 -0000 @@ -13,6 +13,7 @@ * 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) - [207095] check for null datastore ********************************************************************************/ package org.eclipse.rse.services.dstore; @@ -72,17 +73,26 @@ protected DataElement getMinerElement(String id) { - return getDataStore().findMinerInformation(id); + DataStore ds = getDataStore(); + if (ds != null) + { + return ds.findMinerInformation(id); + } + else + { + return null; + } } protected DataElement[] dsQueryCommand(DataElement subject, ArrayList args, String command, IProgressMonitor monitor) { // query roots DataElement queryCmd = getCommandDescriptor(subject, command); + DataStore ds = getDataStore(); - if (queryCmd != null) + if (queryCmd != null && ds != null) { - DataElement status = getDataStore().command(queryCmd, args, subject, true); + DataElement status = ds.command(queryCmd, args, subject, true); try { DStoreStatusMonitor smon = getStatusMonitor(getDataStore()); @@ -118,10 +128,11 @@ { // query roots DataElement queryCmd = getCommandDescriptor(subject, command); + DataStore ds = getDataStore(); - if (queryCmd != null) + if (queryCmd != null && ds != null) { - DataElement status = getDataStore().command(queryCmd, args, subject, true); + DataElement status = ds.command(queryCmd, args, subject, true); try { DStoreStatusMonitor smon = getStatusMonitor(getDataStore()); @@ -147,10 +158,9 @@ { // query roots DataElement queryCmd = getCommandDescriptor(subject, command); - - if (queryCmd != null) + DataStore ds = getDataStore(); + if (queryCmd != null && ds != null) { - DataStore ds = getDataStore(); DataElement status = ds.command(queryCmd, subject, true); try { @@ -181,11 +191,11 @@ protected DataElement dsStatusCommand(DataElement subject, String command, IProgressMonitor monitor) { // query roots - DataElement queryCmd = getCommandDescriptor(subject, command); - - if (queryCmd != null) - { - DataStore ds = getDataStore(); + DataElement queryCmd = getCommandDescriptor(subject, command); + DataStore ds = getDataStore(); + + if (queryCmd != null && ds != null) + { DataElement status = ds.command(queryCmd, subject, true); try { @@ -214,20 +224,29 @@ DataElement cmd = (DataElement)_cmdDescriptorMap.get(command); if (cmd == null || ds != cmd.getDataStore()) { - cmd = getDataStore().localDescriptorQuery(subject.getDescriptor(), command); - _cmdDescriptorMap.put(command, cmd); + if (ds != null) + { + cmd = ds.localDescriptorQuery(subject.getDescriptor(), command); + _cmdDescriptorMap.put(command, cmd); + } } return cmd; } public int getServerVersion() { - return getDataStore().getServerVersion(); + DataStore ds = getDataStore(); + if (ds != null) + return ds.getServerVersion(); + return 0; } public int getServerMinor() { - return getDataStore().getServerMinor(); + DataStore ds = getDataStore(); + if (ds != null) + return ds.getServerMinor(); + return 0; } protected void checkHostJVM() @@ -261,8 +280,12 @@ { if (_initializeStatus != null) { - DStoreStatusMonitor smon = getStatusMonitor(getDataStore()); - return smon.determineStatusDone(_initializeStatus); + DataStore ds = getDataStore(); + if (ds != null) + { + DStoreStatusMonitor smon = getStatusMonitor(ds); + return smon.determineStatusDone(_initializeStatus); + } } return false; } @@ -271,24 +294,28 @@ { if (_initializeStatus != null) { - DStoreStatusMonitor smon = getStatusMonitor(getDataStore()); - try - { - smon.waitForUpdate(_initializeStatus, monitor, 100); - } - catch (InterruptedException e) + DataStore ds = getDataStore(); + if (ds != null) { - // cancel monitor if it's still not canceled - if (monitor != null && !monitor.isCanceled()) + DStoreStatusMonitor smon = getStatusMonitor(getDataStore()); + try { - monitor.setCanceled(true); + smon.waitForUpdate(_initializeStatus, monitor, 100); } + 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 - } + //InterruptedException is used to report user cancellation, so no need to log + //This should be reviewed (use OperationCanceledException) with bug #190750 + } - getMinerElement(); + getMinerElement(); + } } } #P org.eclipse.rse.subsystems.files.core Index: src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java,v retrieving revision 1.42 diff -u -r1.42 FileServiceSubSystem.java --- src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java 13 Sep 2007 13:49:44 -0000 1.42 +++ src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java 24 Oct 2007 13:56:17 -0000 @@ -19,6 +19,7 @@ * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem * Javier Montalvo Orus (Symbian) - [199773] Default file transfer mode is ignored for some file types + * David McKnight (IBM) - [207095] Implicit connect on getRemoteFileObject *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.servicesubsystem; @@ -127,11 +128,15 @@ * an unqualified file or folder name and its parent folder object. * @param parent Folder containing the folder or file * @param folderOrFileName Un-qualified folder or file name + * @param monitor the progress monitor * @return an IRemoteFile object for the file. * @see IRemoteFile */ public IRemoteFile getRemoteFileObject(IRemoteFile parent, String folderOrFileName, IProgressMonitor monitor) throws SystemMessageException { + // for bug 207095, implicit connect if the connection is not connected + checkIsConnected(); + String fullPath = parent.getAbsolutePath() + getSeparator() + folderOrFileName; IRemoteFile file = getCachedRemoteFile(fullPath); if (file != null && !file.isStale()) @@ -147,11 +152,13 @@ * Constructs and returns an IRemoteFile object given a fully-qualified * file or folder name. * @param folderOrFileName Fully qualified folder or file name + * @param monitor the progress monitor * @return The constructed IRemoteFile * @see IRemoteFile */ public IRemoteFile getRemoteFileObject(String folderOrFileName, IProgressMonitor monitor) throws SystemMessageException { + String fofName = folderOrFileName; if (folderOrFileName.length() > 1) { @@ -162,12 +169,14 @@ return file; } + // for bug 207095, implicit connect if the connection is not connected + checkIsConnected(); + if (fofName.endsWith(ArchiveHandlerManager.VIRTUAL_SEPARATOR)) { fofName = fofName.substring(0, fofName.length() - ArchiveHandlerManager.VIRTUAL_SEPARATOR.length()); - } - - + } + int j = fofName.indexOf(ArchiveHandlerManager.VIRTUAL_SEPARATOR); if (j == -1) { @@ -184,7 +193,14 @@ } if (fofName.equals(".")) { //$NON-NLS-1$ - return getUserHome(); + IRemoteFile userHome = getUserHome(); + if (userHome == null){ + + // with 207095, it's possible that we could be trying to get user home when not connected + SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_ERROR_UNEXPECTED); + throw new SystemMessageException(msg); + } + return userHome; } String sep = PathUtility.getSeparator(folderOrFileName); @@ -262,16 +278,21 @@ return root; } IHostFile userHome = getFileService().getUserHome(); + // with 207095, it's possible that user is not connected, and that userHome is null + if (userHome == null) { + return null; + } + IRemoteFile parent = null; if (!userHome.getParentPath().equals(".")) //$NON-NLS-1$ { - try - { - //parent = getRemoteFileObject(userHome.getParentPath()); - } - catch (Exception e) - { - } + try + { + //parent = getRemoteFileObject(userHome.getParentPath()); + } + catch (Exception e) + { + } } root = getHostFileToRemoteFileAdapter().convertToRemoteFile(this, getDefaultContext(), parent, userHome); cacheRemoteFile(root, "."); //$NON-NLS-1$