mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 04:55:22 +02:00
[207095] check for null datastore
This commit is contained in:
parent
40315bf19f
commit
1e7454b343
2 changed files with 153 additions and 83 deletions
|
@ -20,6 +20,7 @@
|
|||
* 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
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.dstore.files;
|
||||
|
@ -105,6 +106,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
super.uninitService(monitor);
|
||||
_fileElementMap.clear();
|
||||
_dstoreFileMap.clear();
|
||||
_uploadLogElement = null;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
|
@ -149,7 +151,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
|
||||
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,22 +177,35 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
|
||||
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);
|
||||
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$
|
||||
|
@ -195,6 +213,11 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
attributes.setAttribute(DE.A_SOURCE, buffer.toString());
|
||||
return attributes;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -776,11 +799,18 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
buf.append(name);
|
||||
de = getElementFor(buf.toString());
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns what the next part of the path should be, given the current
|
||||
|
@ -1284,6 +1314,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
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 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
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,7 +1350,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
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);
|
||||
|
@ -1343,8 +1382,8 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
String remotePath = parent + getSeparator(parent) + name;
|
||||
DataElement de = getElementFor(remotePath);
|
||||
DataStore ds = de.getDataStore();
|
||||
|
||||
|
||||
if (ds != null)
|
||||
{
|
||||
DataElement setCmd = getCommandDescriptor(de, IUniversalDataStoreConstants.C_SET_LASTMODIFIED);
|
||||
if (setCmd != null)
|
||||
{
|
||||
|
@ -1353,6 +1392,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
ds.command(setCmd, de, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1363,8 +1403,8 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
String remotePath = parent + getSeparator(parent) + name;
|
||||
DataElement de = getElementFor(remotePath);
|
||||
DataStore ds = de.getDataStore();
|
||||
|
||||
|
||||
if (ds != null)
|
||||
{
|
||||
DataElement setCmd = getCommandDescriptor(de, IUniversalDataStoreConstants.C_SET_READONLY);
|
||||
if (setCmd != null)
|
||||
{
|
||||
|
@ -1381,6 +1421,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1394,7 +1435,8 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
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);
|
||||
|
@ -1409,6 +1451,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
|
||||
remoteEncoding = encodingElement.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return remoteEncoding;
|
||||
}
|
||||
|
|
|
@ -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 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
|
||||
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 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
{
|
||||
// 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 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
{
|
||||
// query roots
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
|
||||
if (queryCmd != null)
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
if (queryCmd != null && ds != null)
|
||||
{
|
||||
DataElement status = ds.command(queryCmd, subject, true);
|
||||
try
|
||||
{
|
||||
|
@ -182,10 +192,10 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
{
|
||||
// query roots
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
|
||||
if (queryCmd != null)
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
|
||||
if (queryCmd != null && ds != null)
|
||||
{
|
||||
DataElement status = ds.command(queryCmd, subject, true);
|
||||
try
|
||||
{
|
||||
|
@ -214,20 +224,29 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
DataElement cmd = (DataElement)_cmdDescriptorMap.get(command);
|
||||
if (cmd == null || ds != cmd.getDataStore())
|
||||
{
|
||||
cmd = getDataStore().localDescriptorQuery(subject.getDescriptor(), command);
|
||||
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,15 +280,22 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
{
|
||||
if (_initializeStatus != null)
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
DataStore ds = getDataStore();
|
||||
if (ds != null)
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(ds);
|
||||
return smon.determineStatusDone(_initializeStatus);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void waitForInitialize(IProgressMonitor monitor)
|
||||
{
|
||||
if (_initializeStatus != null)
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
if (ds != null)
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
try
|
||||
|
@ -291,6 +317,7 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
getMinerElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void initService(IProgressMonitor monitor)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue