1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 23:25:26 +02:00

[225747] [dstore] Trying to connect to an "Offline" system throws an NPE

This commit is contained in:
David McKnight 2008-04-25 21:10:57 +00:00
parent 5b60ae1f8b
commit 38b35acc9b
9 changed files with 121 additions and 84 deletions

View file

@ -49,6 +49,7 @@
* David Dykstal (IBM) - [200735][Persistence] Delete a profile that contains a connection and restart, profile is back without connections
* David Dykstal (IBM) - [168976][api] move ISystemNewConnectionWizardPage from core to UI
* Martin Oberhuber (Wind River) - [228774] Improve ElementComparer Performance
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
********************************************************************************/
package org.eclipse.rse.internal.core.model;
@ -2757,7 +2758,13 @@ public class SystemRegistry implements ISystemRegistry
{
ISystemFilterReference ref = (ISystemFilterReference)remoteResource;
ISubSystem ss = ref.getSubSystem();
remoteResource = ss.getTargetForFilter(ref);
if (!ss.isOffline()){
remoteResource = ss.getTargetForFilter(ref);
}
else {
return null;
}
IRemoteObjectIdentifier rid = getRemoteObjectIdentifier(remoteResource);
if (rid == null)
return null;

View file

@ -30,6 +30,7 @@
* David McKnight (IBM) - [222406] Need to be able to override local encoding
* David McKnight (IBM) - [224377] "open with" menu does not have "other" option
* Kevin Doyle (IBM) - [224162] SystemEditableRemoteFile.saveAs does not work because FileServiceSubSytem.upload does invalid check
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
*******************************************************************************/
package org.eclipse.rse.files.ui.resources;
@ -1574,14 +1575,16 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
// get fresh remote file object
remoteFile.markStale(true); // make sure we get the latest remote file (with proper permissions and all)
try
{
remoteFile = subsystem.getRemoteFileObject(remoteFile.getAbsolutePath(), new NullProgressMonitor());
}
catch (Exception e)
{
SystemMessageDialog.displayExceptionMessage(SystemMessageDialog.getDefaultShell(), e);
return;
if (!remoteFile.getParentRemoteFileSubSystem().isOffline()){
try
{
remoteFile = subsystem.getRemoteFileObject(remoteFile.getAbsolutePath(), new NullProgressMonitor());
}
catch (Exception e)
{
SystemMessageDialog.displayExceptionMessage(SystemMessageDialog.getDefaultShell(), e);
return;
}
}
boolean readOnly = !remoteFile.canWrite();
ResourceAttributes attr = file.getResourceAttributes();

View file

@ -21,6 +21,7 @@
* Martin Oberhuber (Wind River) - [199573] Fix potential threading issues in SystemTempFileListener
* David McKnight (IBM) - [205297] Editor upload should not be on main thread
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
*******************************************************************************/
package org.eclipse.rse.files.ui.resources;
@ -611,7 +612,7 @@ public abstract class SystemTempFileListener implements IResourceChangeListener
}
// attempt the remote file synchronization
if (doesHandle(fs))
if (doesHandle(fs) && !fs.isOffline())
{
// see if we're connected
try
@ -632,7 +633,6 @@ public abstract class SystemTempFileListener implements IResourceChangeListener
properties.setDirty(true);
return;
}
doResourceSynchronization(fs, file, uploadPath, monitor);
}
}

View file

@ -50,6 +50,7 @@
* Xuan Chen (IBM) - [223126] [api][breaking] Remove API related to User Actions in RSE Core/UI
* Rupen Mardirossian (IBM) - [210682] Copy collisions will use SystemCopyDialog now instead of renameDialog when there is a copy collision within the same connection
* David McKnight (IBM) - [224377] "open with" menu does not have "other" option
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
*******************************************************************************/
package org.eclipse.rse.internal.files.ui.view;
@ -3285,13 +3286,14 @@ public class SystemViewRemoteFileAdapter
// get updated remoteFile so we get the current remote timestamp
//remoteFile.markStale(true);
IRemoteFileSubSystem subsystem = remoteFile.getParentRemoteFileSubSystem();
try
{
remoteFile = subsystem.getRemoteFileObject(remoteFile.getAbsolutePath(), new NullProgressMonitor());
}
catch (Exception e)
{
if (!subsystem.isOffline()){ // only do this check when online..if offline we assume the temp file is okay
try
{
remoteFile = subsystem.getRemoteFileObject(remoteFile.getAbsolutePath(), new NullProgressMonitor());
}
catch (Exception e)
{
}
}
// get the remote modified stamp

View file

@ -27,6 +27,7 @@
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
* Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading
* Martin Oberhuber (Wind River) - [226574][api] Add ISubSystemConfiguration#supportsEncoding()
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
*******************************************************************************/
package org.eclipse.rse.subsystems.files.core.subsystems;
@ -332,7 +333,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
if (container == null)
return false;
if (container.equals(".")) //$NON-NLS-1$
if (container.equals(".") && !isOffline()) //$NON-NLS-1$
{
try
{

View file

@ -14,10 +14,15 @@
* Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
********************************************************************************/
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
*******************************************************************************/
package org.eclipse.rse.internal.ui.actions;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.IHost;
@ -68,8 +73,8 @@ public class SystemWorkOfflineAction extends SystemBaseAction
*/
public void run()
{
IHost conn = (IHost)getFirstSelection();
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
final IHost conn = (IHost)getFirstSelection();
final ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
if (conn.isOffline())
{
@ -103,17 +108,25 @@ public class SystemWorkOfflineAction extends SystemBaseAction
}
}
// check that everything was disconnedted okay and this is not the local connection
if(sr.isAnySubSystemConnected(conn) && !conn.getSystemType().isLocal())
Job job = new Job("Ensure Disconnected")
{
// backout changes, likely because user cancelled the disconnect
setChecked(false);
sr.setHostOffline(conn, false);
}
public IStatus run(IProgressMonitor monitor){
// check that everything was disconnedted okay and this is not the local connection
if(sr.isAnySubSystemConnected(conn) && !conn.getSystemType().isLocal())
{
// backout changes, likely because user cancelled the disconnect
setChecked(false);
sr.setHostOffline(conn, false);
}
return Status.OK_STATUS;
}
};
job.schedule();
}
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.ui.actions.SystemBaseAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
*/

View file

@ -29,6 +29,7 @@
* David McKnight (IBM) - [199424] restoring memento state asynchronously
* David McKnight (IBM) - [187711] Link with Editor handled by extension
* David Dykstal (IBM) - [226728] NPE during init with clean workspace
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
*******************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -131,7 +132,6 @@ import org.eclipse.ui.part.ISetSelectionTarget;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.views.framelist.FrameList;
/**
* This is the desktop view wrapper of the System View viewer.
*/
@ -1538,68 +1538,72 @@ public class SystemViewPart
{
ss.getCacheManager().setRestoreFromMemento(true);
}
String path = robject.name;
ISystemFilterReference fref = robject.fRef;
try
{
Object actualObject = ss.getObjectWithAbsoluteName(path, monitor);
if (!ss.isOffline()){
String path = robject.name;
ISystemFilterReference fref = robject.fRef;
if (actualObject instanceof IAdaptable)
try
{
// get the adapter
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)actualObject).getAdapter(ISystemViewElementAdapter.class);
Object actualObject = ss.getObjectWithAbsoluteName(path, monitor);
// get the context
ContextObject contextObject = new ContextObject(actualObject, ss, fref);
if (actualObject instanceof IAdaptable)
{
// get the adapter
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)actualObject).getAdapter(ISystemViewElementAdapter.class);
// get the context
ContextObject contextObject = new ContextObject(actualObject, ss, fref);
// get the children
Object[] children = adapter.getChildren(contextObject, monitor);
// get the children
Object[] children = adapter.getChildren(contextObject, monitor);
ShowRestoredRemoteObject showRunnable = new ShowRestoredRemoteObject(actualObject, children);
Display.getDefault().asyncExec(showRunnable);
ShowRestoredRemoteObject showRunnable = new ShowRestoredRemoteObject(actualObject, children);
Display.getDefault().asyncExec(showRunnable);
}
}
catch (Exception e)
{
// unexpected
}
// yantzi: artemis 6.0: reset restore from memento flag
if (ss != null && ss.supportsCaching())
{
ss.getCacheManager().setRestoreFromMemento(false);
}
}
catch (Exception e)
{
// unexpected
}
// yantzi: artemis 6.0: reset restore from memento flag
if (ss != null && ss.supportsCaching())
{
ss.getCacheManager().setRestoreFromMemento(false);
}
}
else if (object instanceof ISystemFilterReference)
{
ISystemFilterReference fref = (ISystemFilterReference)object;
ISubSystem ss = fref.getSubSystem();
if (!ss.isConnected()){
try
if (!ss.isOffline()){
if (!ss.isConnected()){
try
{
ss.connect(monitor, false);
}
catch (Exception e){
return Status.CANCEL_STATUS;
}
}
if (ss.isConnected())
{
ss.connect(monitor, false);
}
catch (Exception e){
return Status.CANCEL_STATUS;
}
// get the adapter
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)object).getAdapter(ISystemViewElementAdapter.class);
// get the context
ContextObject contextObject = new ContextObject(fref, ss, fref);
// get the children
Object[] children = adapter.getChildren(contextObject, monitor);
ShowRestoredRemoteObject showRunnable = new ShowRestoredRemoteObject(fref, children);
Display.getDefault().asyncExec(showRunnable);
}
}
if (ss.isConnected())
{
// get the adapter
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)object).getAdapter(ISystemViewElementAdapter.class);
// get the context
ContextObject contextObject = new ContextObject(fref, ss, fref);
// get the children
Object[] children = adapter.getChildren(contextObject, monitor);
ShowRestoredRemoteObject showRunnable = new ShowRestoredRemoteObject(fref, children);
Display.getDefault().asyncExec(showRunnable);
}
}
}
boolean restoreFromCache = RSEUIPlugin.getDefault().getPreferenceStore().getBoolean(ISystemPreferencesConstants.RESTORE_STATE_FROM_CACHE);

View file

@ -16,6 +16,7 @@
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [189272] exception when canceling ssh connect
* David Dykstal (IBM) - [189483] add notification when canceling password prompting
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
*******************************************************************************/
package org.eclipse.rse.ui.operations;
@ -229,6 +230,9 @@ public class SystemFetchOperation extends JobChangeAdapter implements IRunnableW
{
ss = (SubSystem)_adapter.getSubSystem(_remoteObject);
}
if (ss.isOffline() ){
return;
}
synchronized (ss.getConnectorService())
{
if (!ss.isConnected())

View file

@ -37,6 +37,7 @@
* David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception
* Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading
* Martin Oberhuber (Wind River) - [190231] Prepare API for UI/Non-UI Splitting
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
********************************************************************************/
package org.eclipse.rse.core.subsystems;
@ -1696,14 +1697,16 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider
msg = SubSystemConfiguration.getConnectingMessage(getHostName(), getConnectorService().getPort());
SystemBasePlugin.logInfo(msg);
if (!implicitConnect(true, mon, msg, totalWorkUnits)){
String msgTxt = NLS.bind(CommonMessages.MSG_CONNECT_FAILED, getHostName());
throw new Exception(msgTxt);
}
internalConnect(mon);
if (!isOffline()){
if (!implicitConnect(true, mon, msg, totalWorkUnits)){
String msgTxt = NLS.bind(CommonMessages.MSG_CONNECT_FAILED, getHostName());
throw new Exception(msgTxt);
}
internalConnect(mon);
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
registry.connectedStatusChange(_ss, true, false);
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
registry.connectedStatusChange(_ss, true, false);
}
}
}