mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-09 10:05:24 +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();
|
String systemName = _ftpClient.getSystemName();
|
||||||
|
|
||||||
_ftpClient.setParserFactory(_entryParserFactory);
|
_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(_clientConfigProxy!=null)
|
||||||
|
|
||||||
if(config!=null)
|
|
||||||
{
|
{
|
||||||
_ftpClient.configure(config);
|
_ftpClient.configure(_clientConfigProxy.getFTPClientConfig());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -304,9 +303,6 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
_ftpClient.configure(new FTPClientConfig(FTPClientConfig.SYST_UNIX));
|
_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()
|
// Initial active/passive mode. This action will be refreshed later using setDataConnectionMode()
|
||||||
if(_ftpPropertySet.getPropertyValue("passive").equalsIgnoreCase("true")) //$NON-NLS-1$ //$NON-NLS-2$
|
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;
|
package org.eclipse.rse.internal.services.files.ftp.parser;
|
||||||
|
|
||||||
import org.apache.commons.net.ftp.FTPClientConfig;
|
|
||||||
import org.apache.commons.net.ftp.parser.FTPFileEntryParserFactory;
|
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
|
* @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
|
* Returns an array of strings containing the id
|
||||||
* @return a String[] containing the name attribute of the extension points
|
* @return a String[] containing the name attribute of the extension points
|
||||||
*/
|
*/
|
||||||
public String[] getKeySet();
|
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;
|
package org.eclipse.rse.internal.services.files.ftp.parser;
|
||||||
|
|
||||||
|
import org.apache.commons.net.ftp.FTPClientConfig;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
public interface IFTPClientConfigProxy {
|
public interface IFTPClientConfigProxy {
|
||||||
|
@ -27,4 +28,6 @@ public interface IFTPClientConfigProxy {
|
||||||
public String getShortMonthNames();
|
public String getShortMonthNames();
|
||||||
public String getServerTimeZoneId();
|
public String getServerTimeZoneId();
|
||||||
|
|
||||||
|
public FTPClientConfig getFTPClientConfig();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,6 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
private static FTPClientConfigFactory factory = null;
|
private static FTPClientConfigFactory factory = null;
|
||||||
|
|
||||||
private Hashtable ftpConfigProxyById = new Hashtable();
|
private Hashtable ftpConfigProxyById = new Hashtable();
|
||||||
|
|
||||||
private Hashtable ftpConfigs = new Hashtable();
|
|
||||||
private Hashtable ftpParsers = 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$
|
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)
|
* (non-Javadoc)
|
||||||
* @see org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory#getFTPClientConfig(java.lang.String)
|
* @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$
|
if(parser.equals("AUTO")) //$NON-NLS-1$
|
||||||
{
|
{
|
||||||
|
@ -143,37 +141,31 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
config.setServerTimeZoneId(foundProxy.getServerTimeZoneId());
|
config.setServerTimeZoneId(foundProxy.getServerTimeZoneId());
|
||||||
|
|
||||||
//not necessary storing in the hashtable, as discovered will not be reused
|
//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))
|
if(ftpConfigProxyById.containsKey(parser))
|
||||||
{
|
|
||||||
//restore parser from hashtable
|
|
||||||
ftpClientConfig = (FTPClientConfig)ftpConfigs.get(parser);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
//restore parser from the proxy hashtable
|
||||||
|
foundFTPClientConfigProxy = (FTPClientConfigProxy)ftpConfigProxyById.get(parser);
|
||||||
|
|
||||||
Enumeration ftpConfigProxyEnum = ftpConfigProxyById.elements();
|
//activate if necessary
|
||||||
|
if(foundFTPClientConfigProxy.getFTPClientConfig()==null)
|
||||||
while(ftpConfigProxyEnum.hasMoreElements())
|
|
||||||
{
|
|
||||||
FTPClientConfigProxy proxy = (FTPClientConfigProxy)ftpConfigProxyEnum.nextElement();
|
|
||||||
|
|
||||||
if(proxy.getId().equals(parser))
|
|
||||||
{
|
{
|
||||||
FTPClientConfig config = null;
|
FTPClientConfig config = null;
|
||||||
|
|
||||||
if(!ftpParsers.containsKey(proxy.getClassName()))
|
if(!ftpParsers.containsKey(foundFTPClientConfigProxy.getClassName()))
|
||||||
{
|
{
|
||||||
FTPFileEntryParser entryParser = null;
|
FTPFileEntryParser entryParser = null;
|
||||||
try {
|
try {
|
||||||
entryParser = (FTPFileEntryParser)proxy.getDeclaringBundle().loadClass(proxy.getClassName()).newInstance();
|
entryParser = (FTPFileEntryParser)foundFTPClientConfigProxy.getDeclaringBundle().loadClass(foundFTPClientConfigProxy.getClassName()).newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
|
@ -181,30 +173,25 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
ftpParsers.put(proxy.getClassName(), entryParser);
|
ftpParsers.put(foundFTPClientConfigProxy.getClassName(), entryParser);
|
||||||
}
|
}
|
||||||
|
|
||||||
config = new FTPClientConfig(proxy.getClassName());
|
config = new FTPClientConfig(foundFTPClientConfigProxy.getClassName());
|
||||||
|
|
||||||
//not necessary checking for null, as null is valid input
|
//not necessary checking for null, as null is valid input
|
||||||
config.setDefaultDateFormatStr(proxy.getDefaultDateFormatStr());
|
config.setDefaultDateFormatStr(foundFTPClientConfigProxy.getDefaultDateFormatStr());
|
||||||
config.setRecentDateFormatStr(proxy.getRecentDateFormatStr());
|
config.setRecentDateFormatStr(foundFTPClientConfigProxy.getRecentDateFormatStr());
|
||||||
config.setServerLanguageCode(proxy.getServerLanguageCode());
|
config.setServerLanguageCode(foundFTPClientConfigProxy.getServerLanguageCode());
|
||||||
config.setShortMonthNames(proxy.getShortMonthNames());
|
config.setShortMonthNames(foundFTPClientConfigProxy.getShortMonthNames());
|
||||||
config.setServerTimeZoneId(proxy.getServerTimeZoneId());
|
config.setServerTimeZoneId(foundFTPClientConfigProxy.getServerTimeZoneId());
|
||||||
|
|
||||||
ftpConfigs.put(parser, config);
|
foundFTPClientConfigProxy.setFTPClientConfig(config);
|
||||||
ftpClientConfig = (FTPClientConfig)ftpConfigs.get(parser);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
return foundFTPClientConfigProxy;
|
||||||
return ftpClientConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -223,7 +210,7 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
public FTPFileEntryParser createFileEntryParser(String key) throws ParserInitializationException {
|
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
|
// but in case the execution flow gets modified it's worth checking and populating it if required
|
||||||
//
|
//
|
||||||
if(!ftpParsers.containsKey(key))
|
if(!ftpParsers.containsKey(key))
|
||||||
|
@ -258,13 +245,4 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (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;
|
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.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigProxy;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
|
@ -30,6 +31,8 @@ public class FTPClientConfigProxy implements IFTPClientConfigProxy{
|
||||||
private String shortMonthNames;
|
private String shortMonthNames;
|
||||||
private String serverTimeZoneId;
|
private String serverTimeZoneId;
|
||||||
|
|
||||||
|
private FTPClientConfig ftpClientConfig;
|
||||||
|
|
||||||
public FTPClientConfigProxy(String id, String label, String priority, String systemTypeRegex, String className, Bundle declaringBundle, String listCommandModifiers,
|
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)
|
String defaultDateFormatStr, String recentDateFormatStr, String serverLanguageCode, String shortMonthNames, String serverTimeZoneId)
|
||||||
{
|
{
|
||||||
|
@ -101,4 +104,12 @@ public class FTPClientConfigProxy implements IFTPClientConfigProxy{
|
||||||
public String getServerTimeZoneId() {
|
public String getServerTimeZoneId() {
|
||||||
return serverTimeZoneId;
|
return serverTimeZoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FTPClientConfig getFTPClientConfig() {
|
||||||
|
return ftpClientConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFTPClientConfig(FTPClientConfig ftpClientConfig) {
|
||||||
|
this.ftpClientConfig=ftpClientConfig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue