mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 23:25:26 +02:00
listCommandModifiers available through parser autodetection.
FTPClientConfigFactory.getClientConfig returns an instance of FTPClientConfigProxy, encapsulating the FTPClientConfig
This commit is contained in:
parent
f140318733
commit
f704975e20
5 changed files with 58 additions and 79 deletions
|
@ -291,12 +291,11 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
|||
String systemName = _ftpClient.getSystemName();
|
||||
|
||||
_ftpClient.setParserFactory(_entryParserFactory);
|
||||
_clientConfigProxy = _entryParserFactory.getFTPClientConfig(_ftpPropertySet.getPropertyValue("parser"),systemName); //$NON-NLS-1$
|
||||
|
||||
FTPClientConfig config = _entryParserFactory.getFTPClientConfig(_ftpPropertySet.getPropertyValue("parser"),systemName); //$NON-NLS-1$
|
||||
|
||||
if(config!=null)
|
||||
if(_clientConfigProxy!=null)
|
||||
{
|
||||
_ftpClient.configure(config);
|
||||
_ftpClient.configure(_clientConfigProxy.getFTPClientConfig());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -304,9 +303,6 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
|||
_ftpClient.configure(new FTPClientConfig(FTPClientConfig.SYST_UNIX));
|
||||
}
|
||||
|
||||
//FTPClientConfigProxy object with information of the extended LIST command, or null
|
||||
_clientConfigProxy = _entryParserFactory.getFTPClientConfigProxy(_ftpPropertySet.getPropertyValue("parser")); //$NON-NLS-1$
|
||||
|
||||
// Initial active/passive mode. This action will be refreshed later using setDataConnectionMode()
|
||||
if(_ftpPropertySet.getPropertyValue("passive").equalsIgnoreCase("true")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
{
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
package org.eclipse.rse.internal.services.files.ftp.parser;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPClientConfig;
|
||||
import org.apache.commons.net.ftp.parser.FTPFileEntryParserFactory;
|
||||
|
||||
|
||||
|
@ -19,23 +18,15 @@ public interface IFTPClientConfigFactory extends FTPFileEntryParserFactory {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param parser Parser selected from the FTP Settings. This setting is "AUTO" by default, performing a parser discovery
|
||||
* @param parserId Parser id selected from the FTP Settings. This setting is "AUTO" by default, performing a parser discovery
|
||||
* @param systemName String returned by the host from the FTP SYST command, describing the host
|
||||
* @return FTPClientConfig instance created from the attributes passed in the extension point
|
||||
* @return IFTPClientConfigProxy instance created from the attributes passed in the extension point
|
||||
*/
|
||||
public FTPClientConfig getFTPClientConfig(String parser, String systemName);
|
||||
public IFTPClientConfigProxy getFTPClientConfig(String parserId, String systemName);
|
||||
|
||||
/**
|
||||
* Returns an array of strings containing the id
|
||||
* @return a String[] containing the name attribute of the extension points
|
||||
*/
|
||||
public String[] getKeySet();
|
||||
|
||||
/**
|
||||
* Returns the IFTPClientConfigProxy that matches the given id
|
||||
* @param id of the FTPClientConfigProxy
|
||||
* @return The IFTPClientConfigProxy or null if not found
|
||||
*/
|
||||
public IFTPClientConfigProxy getFTPClientConfigProxy(String id);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
package org.eclipse.rse.internal.services.files.ftp.parser;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPClientConfig;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
public interface IFTPClientConfigProxy {
|
||||
|
@ -27,4 +28,6 @@ public interface IFTPClientConfigProxy {
|
|||
public String getShortMonthNames();
|
||||
public String getServerTimeZoneId();
|
||||
|
||||
public FTPClientConfig getFTPClientConfig();
|
||||
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
|||
private static FTPClientConfigFactory factory = null;
|
||||
|
||||
private Hashtable ftpConfigProxyById = new Hashtable();
|
||||
|
||||
private Hashtable ftpConfigs = new Hashtable();
|
||||
private Hashtable ftpParsers = new Hashtable();
|
||||
private IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.subsystems.files.ftp","ftpFileEntryParsers"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
|
@ -81,10 +79,10 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
|||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory#getFTPClientConfig(java.lang.String)
|
||||
*/
|
||||
public FTPClientConfig getFTPClientConfig(String parser, String systemName)
|
||||
public IFTPClientConfigProxy getFTPClientConfig(String parser, String systemName)
|
||||
{
|
||||
|
||||
FTPClientConfig ftpClientConfig = null;
|
||||
FTPClientConfigProxy foundFTPClientConfigProxy = null;
|
||||
|
||||
if(parser.equals("AUTO")) //$NON-NLS-1$
|
||||
{
|
||||
|
@ -143,68 +141,57 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
|||
config.setServerTimeZoneId(foundProxy.getServerTimeZoneId());
|
||||
|
||||
//not necessary storing in the hashtable, as discovered will not be reused
|
||||
ftpClientConfig = config;
|
||||
foundProxy.setFTPClientConfig(config);
|
||||
|
||||
foundFTPClientConfigProxy = foundProxy;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(ftpClientConfig==null)
|
||||
if(foundFTPClientConfigProxy==null)
|
||||
{
|
||||
if(ftpConfigs.containsKey(parser))
|
||||
{
|
||||
//restore parser from hashtable
|
||||
ftpClientConfig = (FTPClientConfig)ftpConfigs.get(parser);
|
||||
}
|
||||
else
|
||||
if(ftpConfigProxyById.containsKey(parser))
|
||||
{
|
||||
//restore parser from the proxy hashtable
|
||||
foundFTPClientConfigProxy = (FTPClientConfigProxy)ftpConfigProxyById.get(parser);
|
||||
|
||||
Enumeration ftpConfigProxyEnum = ftpConfigProxyById.elements();
|
||||
|
||||
while(ftpConfigProxyEnum.hasMoreElements())
|
||||
//activate if necessary
|
||||
if(foundFTPClientConfigProxy.getFTPClientConfig()==null)
|
||||
{
|
||||
FTPClientConfigProxy proxy = (FTPClientConfigProxy)ftpConfigProxyEnum.nextElement();
|
||||
FTPClientConfig config = null;
|
||||
|
||||
if(proxy.getId().equals(parser))
|
||||
if(!ftpParsers.containsKey(foundFTPClientConfigProxy.getClassName()))
|
||||
{
|
||||
FTPClientConfig config = null;
|
||||
|
||||
if(!ftpParsers.containsKey(proxy.getClassName()))
|
||||
{
|
||||
FTPFileEntryParser entryParser = null;
|
||||
try {
|
||||
entryParser = (FTPFileEntryParser)proxy.getDeclaringBundle().loadClass(proxy.getClassName()).newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ftpParsers.put(proxy.getClassName(), entryParser);
|
||||
FTPFileEntryParser entryParser = null;
|
||||
try {
|
||||
entryParser = (FTPFileEntryParser)foundFTPClientConfigProxy.getDeclaringBundle().loadClass(foundFTPClientConfigProxy.getClassName()).newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
config = new FTPClientConfig(proxy.getClassName());
|
||||
|
||||
//not necessary checking for null, as null is valid input
|
||||
config.setDefaultDateFormatStr(proxy.getDefaultDateFormatStr());
|
||||
config.setRecentDateFormatStr(proxy.getRecentDateFormatStr());
|
||||
config.setServerLanguageCode(proxy.getServerLanguageCode());
|
||||
config.setShortMonthNames(proxy.getShortMonthNames());
|
||||
config.setServerTimeZoneId(proxy.getServerTimeZoneId());
|
||||
|
||||
ftpConfigs.put(parser, config);
|
||||
ftpClientConfig = (FTPClientConfig)ftpConfigs.get(parser);
|
||||
|
||||
break;
|
||||
|
||||
ftpParsers.put(foundFTPClientConfigProxy.getClassName(), entryParser);
|
||||
}
|
||||
|
||||
config = new FTPClientConfig(foundFTPClientConfigProxy.getClassName());
|
||||
|
||||
//not necessary checking for null, as null is valid input
|
||||
config.setDefaultDateFormatStr(foundFTPClientConfigProxy.getDefaultDateFormatStr());
|
||||
config.setRecentDateFormatStr(foundFTPClientConfigProxy.getRecentDateFormatStr());
|
||||
config.setServerLanguageCode(foundFTPClientConfigProxy.getServerLanguageCode());
|
||||
config.setShortMonthNames(foundFTPClientConfigProxy.getShortMonthNames());
|
||||
config.setServerTimeZoneId(foundFTPClientConfigProxy.getServerTimeZoneId());
|
||||
|
||||
foundFTPClientConfigProxy.setFTPClientConfig(config);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ftpClientConfig;
|
||||
return foundFTPClientConfigProxy;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -223,7 +210,7 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
|||
public FTPFileEntryParser createFileEntryParser(String key) throws ParserInitializationException {
|
||||
|
||||
//
|
||||
// the hashtable "ftpParsers" will be populated previously by getFTPClientConfig()
|
||||
// the hashtable "ftpFileEntryParser" will be populated previously by getFTPClientConfig()
|
||||
// but in case the execution flow gets modified it's worth checking and populating it if required
|
||||
//
|
||||
if(!ftpParsers.containsKey(key))
|
||||
|
@ -257,14 +244,5 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
|||
return createFileEntryParser(key);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory#getFTPClientConfigProxy(java.lang.String)
|
||||
*/
|
||||
public IFTPClientConfigProxy getFTPClientConfigProxy(String id)
|
||||
{
|
||||
return (IFTPClientConfigProxy)ftpConfigProxyById.get(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
package org.eclipse.rse.internal.subsystems.files.ftp.parser;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPClientConfig;
|
||||
import org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigProxy;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
|
@ -30,6 +31,8 @@ public class FTPClientConfigProxy implements IFTPClientConfigProxy{
|
|||
private String shortMonthNames;
|
||||
private String serverTimeZoneId;
|
||||
|
||||
private FTPClientConfig ftpClientConfig;
|
||||
|
||||
public FTPClientConfigProxy(String id, String label, String priority, String systemTypeRegex, String className, Bundle declaringBundle, String listCommandModifiers,
|
||||
String defaultDateFormatStr, String recentDateFormatStr, String serverLanguageCode, String shortMonthNames, String serverTimeZoneId)
|
||||
{
|
||||
|
@ -101,4 +104,12 @@ public class FTPClientConfigProxy implements IFTPClientConfigProxy{
|
|||
public String getServerTimeZoneId() {
|
||||
return serverTimeZoneId;
|
||||
}
|
||||
|
||||
public FTPClientConfig getFTPClientConfig() {
|
||||
return ftpClientConfig;
|
||||
}
|
||||
|
||||
public void setFTPClientConfig(FTPClientConfig ftpClientConfig) {
|
||||
this.ftpClientConfig=ftpClientConfig;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue