mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-20 06:35:50 +02:00
added FTPClientConfigProxy, parsers listed by ID and custom LIST parameter
This commit is contained in:
parent
6b12e6b899
commit
8d0d5ea796
8 changed files with 292 additions and 128 deletions
|
@ -65,6 +65,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.rse.core.model.IPropertySet;
|
import org.eclipse.rse.core.model.IPropertySet;
|
||||||
import org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory;
|
import org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory;
|
||||||
|
import org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigProxy;
|
||||||
import org.eclipse.rse.services.Mutex;
|
import org.eclipse.rse.services.Mutex;
|
||||||
import org.eclipse.rse.services.clientserver.FileTypeMatcher;
|
import org.eclipse.rse.services.clientserver.FileTypeMatcher;
|
||||||
import org.eclipse.rse.services.clientserver.IMatcher;
|
import org.eclipse.rse.services.clientserver.IMatcher;
|
||||||
|
@ -97,7 +98,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
private boolean _isBinaryFileType = true;
|
private boolean _isBinaryFileType = true;
|
||||||
private boolean _isPassiveDataConnectionMode = false;
|
private boolean _isPassiveDataConnectionMode = false;
|
||||||
private IFTPClientConfigFactory _entryParserFactory;
|
private IFTPClientConfigFactory _entryParserFactory;
|
||||||
|
private IFTPClientConfigProxy _clientConfigProxy;
|
||||||
|
|
||||||
private class FTPBufferedInputStream extends BufferedInputStream {
|
private class FTPBufferedInputStream extends BufferedInputStream {
|
||||||
|
|
||||||
|
@ -303,7 +304,9 @@ 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$
|
||||||
{
|
{
|
||||||
|
@ -980,7 +983,19 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
_ftpFiles = _ftpClient.listFiles();
|
|
||||||
|
_ftpFiles = null;
|
||||||
|
|
||||||
|
if(_clientConfigProxy!=null)
|
||||||
|
{
|
||||||
|
_ftpFiles = _ftpClient.listFiles(_clientConfigProxy.getListCommandModifiers());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ftpFiles = _ftpClient.listFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
_exception = e;
|
_exception = e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.files.ftp.parser;
|
package org.eclipse.rse.internal.services.files.ftp.parser;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.commons.net.ftp.FTPClientConfig;
|
import org.apache.commons.net.ftp.FTPClientConfig;
|
||||||
import org.apache.commons.net.ftp.parser.FTPFileEntryParserFactory;
|
import org.apache.commons.net.ftp.parser.FTPFileEntryParserFactory;
|
||||||
|
|
||||||
|
@ -28,9 +26,16 @@ public interface IFTPClientConfigFactory extends FTPFileEntryParserFactory {
|
||||||
public FTPClientConfig getFTPClientConfig(String parser, String systemName);
|
public FTPClientConfig getFTPClientConfig(String parser, String systemName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Set of key names
|
* Returns an array of strings containing the id
|
||||||
* @return a Set containing the name attribute of the extension points
|
* @return a String[] containing the name attribute of the extension points
|
||||||
*/
|
*/
|
||||||
public Set 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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Ltd. All rights reserved.
|
||||||
|
* This program and the accompanying materials are made available under the terms
|
||||||
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Javier Montalvo Orus (Symbian) - initial API and implementation
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.rse.internal.services.files.ftp.parser;
|
||||||
|
|
||||||
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
|
public interface IFTPClientConfigProxy {
|
||||||
|
|
||||||
|
public String getId();
|
||||||
|
public String getLabel();
|
||||||
|
public int getPriority();
|
||||||
|
public String getSystemTypeRegex();
|
||||||
|
public String getClassName();
|
||||||
|
public Bundle getDeclaringBundle();
|
||||||
|
public String getListCommandModifiers();
|
||||||
|
public String getDefaultDateFormatStr();
|
||||||
|
public String getRecentDateFormatStr();
|
||||||
|
public String getServerLanguageCode();
|
||||||
|
public String getShortMonthNames();
|
||||||
|
public String getServerTimeZoneId();
|
||||||
|
|
||||||
|
}
|
|
@ -51,42 +51,42 @@ Javier Montalvo Orus (Symbian) - improved autodetection of FTPListingParser
|
||||||
<extension point="org.eclipse.rse.subsystems.files.ftp.ftpFileEntryParser">
|
<extension point="org.eclipse.rse.subsystems.files.ftp.ftpFileEntryParser">
|
||||||
<parser
|
<parser
|
||||||
class="org.apache.commons.net.ftp.parser.UnixFTPEntryParser"
|
class="org.apache.commons.net.ftp.parser.UnixFTPEntryParser"
|
||||||
ftpSystemTypes=".*[Uu][Nn][Ii][Xx].*"
|
|
||||||
id="org.eclipse.rse.ftp.parser.Unix"
|
id="org.eclipse.rse.ftp.parser.Unix"
|
||||||
label="%FTPParser.UNIX"
|
label="%FTPParser.UNIX"
|
||||||
priority="100">
|
priority="100"
|
||||||
|
systemTypeRegex=".*[Uu][Nn][Ii][Xx].*">
|
||||||
</parser>
|
</parser>
|
||||||
<parser
|
<parser
|
||||||
class="org.apache.commons.net.ftp.parser.MVSFTPEntryParser"
|
class="org.apache.commons.net.ftp.parser.MVSFTPEntryParser"
|
||||||
ftpSystemTypes=".*[Mm][Vv][Ss].*"
|
systemTypeRegex=".*[Mm][Vv][Ss].*"
|
||||||
id="org.eclipse.rse.ftp.parser.MVS"
|
id="org.eclipse.rse.ftp.parser.MVS"
|
||||||
label="%FTPParser.MVS"
|
label="%FTPParser.MVS"
|
||||||
priority="100">
|
priority="100">
|
||||||
</parser>
|
</parser>
|
||||||
<parser
|
<parser
|
||||||
class="org.eclipse.rse.internal.subsystems.files.ftp.parser.RSENTFTPEntryParser"
|
class="org.eclipse.rse.internal.subsystems.files.ftp.parser.RSENTFTPEntryParser"
|
||||||
ftpSystemTypes=".*[Ww][Ii][Nn][Dd][Oo][Ww][Ss].*"
|
systemTypeRegex=".*[Ww][Ii][Nn][Dd][Oo][Ww][Ss].*"
|
||||||
id="org.eclipse.rse.ftp.parser.WinNT"
|
id="org.eclipse.rse.ftp.parser.WinNT"
|
||||||
label="%FTPParser.WinNT"
|
label="%FTPParser.WinNT"
|
||||||
priority="100">
|
priority="100">
|
||||||
</parser>
|
</parser>
|
||||||
<parser
|
<parser
|
||||||
class="org.apache.commons.net.ftp.parser.OS2FTPEntryParser"
|
class="org.apache.commons.net.ftp.parser.OS2FTPEntryParser"
|
||||||
ftpSystemTypes=".*[Oo][Ss]/2.*"
|
systemTypeRegex=".*[Oo][Ss]/2.*"
|
||||||
id="org.eclipse.rse.ftp.parser.OS2"
|
id="org.eclipse.rse.ftp.parser.OS2"
|
||||||
label="%FTPParser.OS2"
|
label="%FTPParser.OS2"
|
||||||
priority="100">
|
priority="100">
|
||||||
</parser>
|
</parser>
|
||||||
<parser
|
<parser
|
||||||
class="org.apache.commons.net.ftp.parser.OS400FTPEntryParser"
|
class="org.apache.commons.net.ftp.parser.OS400FTPEntryParser"
|
||||||
ftpSystemTypes=".*[Oo][Ss]/400.*"
|
systemTypeRegex=".*[Oo][Ss]/400.*"
|
||||||
id="org.eclipse.rse.ftp.parser.OS400"
|
id="org.eclipse.rse.ftp.parser.OS400"
|
||||||
label="%FTPParser.OS400"
|
label="%FTPParser.OS400"
|
||||||
priority="100">
|
priority="100">
|
||||||
</parser>
|
</parser>
|
||||||
<parser
|
<parser
|
||||||
class="org.eclipse.rse.internal.subsystems.files.ftp.parser.RSEVMSFTPEntryParser"
|
class="org.eclipse.rse.internal.subsystems.files.ftp.parser.RSEVMSFTPEntryParser"
|
||||||
ftpSystemTypes=".*[Vv][Mm][Ss].*"
|
systemTypeRegex=".*[Vv][Mm][Ss].*"
|
||||||
id="org.eclipse.rse.ftp.parser.VMS"
|
id="org.eclipse.rse.ftp.parser.VMS"
|
||||||
label="%FTPParser.VMS"
|
label="%FTPParser.VMS"
|
||||||
priority="100">
|
priority="100">
|
||||||
|
|
|
@ -139,7 +139,7 @@ only 8-bit ASCII characters are known to be supported. For example, a set of mo
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="ftpSystemTypes" type="string">
|
<attribute name="systemTypeRegex" type="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
Regular expression used to match with the string returned by the FTP SYST command to autodetect the parser if not specified by the user
|
Regular expression used to match with the string returned by the FTP SYST command to autodetect the parser if not specified by the user
|
||||||
|
@ -149,7 +149,16 @@ only 8-bit ASCII characters are known to be supported. For example, a set of mo
|
||||||
<attribute name="priority" type="string">
|
<attribute name="priority" type="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
Priority used if more than one extension matches the regular expression given by ftpSystemTypes.
|
Priority used if more than one extension matches the regular expression given by the <code>ftpSystemTypes</code> attribute. Integer values are allowed.
|
||||||
|
In case of more than one parser with a matching regular expression, the parser with lower priority number will be used.
|
||||||
|
If no priority is specified, the default value will be <code>Integer.MAX_VALUE</code>.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="listCommandModifiers" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Modifiers of the FTP "LIST" command. As an example if the LIST command has to be "LIST -l", the contents of this optional field has to be "-l"
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
|
|
@ -23,7 +23,6 @@ package org.eclipse.rse.internal.subsystems.files.ftp.connectorservice;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.rse.core.model.IHost;
|
import org.eclipse.rse.core.model.IHost;
|
||||||
|
@ -61,10 +60,11 @@ public class FTPConnectorService extends StandardConnectorService
|
||||||
_propertySet.addProperty("passive","false",PropertyType.getEnumPropertyType(new String[]{"true","false"})); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
_propertySet.addProperty("passive","false",PropertyType.getEnumPropertyType(new String[]{"true","false"})); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
|
||||||
// FTP List parser
|
// FTP List parser
|
||||||
Set keys = FTPClientConfigFactory.getParserFactory().getKeySet();
|
String[] keys = FTPClientConfigFactory.getParserFactory().getKeySet();
|
||||||
String[] keysArray = new String[keys.size()+1];
|
String[] keysArray = new String[keys.length+1];
|
||||||
|
|
||||||
|
System.arraycopy(keys, 0, keysArray, 0, keys.length);
|
||||||
|
|
||||||
keys.toArray(keysArray);
|
|
||||||
keysArray[keysArray.length-1]="AUTO"; //$NON-NLS-1$
|
keysArray[keysArray.length-1]="AUTO"; //$NON-NLS-1$
|
||||||
|
|
||||||
Arrays.sort(keysArray);
|
Arrays.sort(keysArray);
|
||||||
|
|
|
@ -11,25 +11,26 @@
|
||||||
|
|
||||||
package org.eclipse.rse.internal.subsystems.files.ftp.parser;
|
package org.eclipse.rse.internal.subsystems.files.ftp.parser;
|
||||||
|
|
||||||
|
import java.util.Enumeration;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.apache.commons.net.ftp.FTPClientConfig;
|
import org.apache.commons.net.ftp.FTPClientConfig;
|
||||||
import org.apache.commons.net.ftp.FTPFileEntryParser;
|
import org.apache.commons.net.ftp.FTPFileEntryParser;
|
||||||
import org.apache.commons.net.ftp.parser.ParserInitializationException;
|
import org.apache.commons.net.ftp.parser.ParserInitializationException;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory;
|
import org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory;
|
||||||
|
import org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigProxy;
|
||||||
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
|
|
||||||
private static FTPClientConfigFactory factory = null;
|
private static FTPClientConfigFactory factory = null;
|
||||||
|
|
||||||
private Set keySet = new TreeSet();
|
private Hashtable ftpConfigProxyById = new Hashtable();
|
||||||
|
|
||||||
private Hashtable ftpConfig = new Hashtable();
|
private Hashtable ftpConfig = new Hashtable();
|
||||||
private Hashtable ftpFileEntryParser = new Hashtable();
|
private Hashtable ftpFileEntryParser = new Hashtable();
|
||||||
private IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.subsystems.files.ftp","ftpFileEntryParser"); //$NON-NLS-1$ //$NON-NLS-2$
|
private IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.subsystems.files.ftp","ftpFileEntryParser"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -53,8 +54,26 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
IConfigurationElement[] ce = ep.getConfigurationElements();
|
IConfigurationElement[] ce = ep.getConfigurationElements();
|
||||||
for (int i = 0; i < ce.length; i++) {
|
for (int i = 0; i < ce.length; i++) {
|
||||||
|
|
||||||
String label = ce[i].getAttribute("label"); //$NON-NLS-1$
|
String id = ce[i].getAttribute("id"); //$NON-NLS-1$
|
||||||
keySet.add(label);
|
String label = ce[i].getAttribute("label"); //$NON-NLS-1$
|
||||||
|
String priority = ce[i].getAttribute("priority"); //$NON-NLS-1$
|
||||||
|
String systemTypeRegex = ce[i].getAttribute("systemTypeRegex"); //$NON-NLS-1$
|
||||||
|
String className = ce[i].getAttribute("class"); //$NON-NLS-1$
|
||||||
|
Bundle declaringBundle = Platform.getBundle(ce[i].getContributor().getName());
|
||||||
|
|
||||||
|
String listCommandModifiers = ce[i].getAttribute("listCommandModifiers"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
String defaultDateFormatStr = ce[i].getAttribute("defaultDateFormatStr"); //$NON-NLS-1$
|
||||||
|
String recentDateFormatStr = ce[i].getAttribute("recentDateFormatStr"); //$NON-NLS-1$
|
||||||
|
String serverLanguageCode = ce[i].getAttribute("serverLanguageCode"); //$NON-NLS-1$
|
||||||
|
String shortMonthNames = ce[i].getAttribute("shortMonthNames"); //$NON-NLS-1$
|
||||||
|
String serverTimeZoneId = ce[i].getAttribute("serverTimeZoneId"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
FTPClientConfigProxy ftpClientConfigProxy = new FTPClientConfigProxy(id,label,priority,systemTypeRegex,className,declaringBundle,listCommandModifiers,
|
||||||
|
defaultDateFormatStr,recentDateFormatStr,serverLanguageCode,shortMonthNames,serverTimeZoneId);
|
||||||
|
|
||||||
|
ftpConfigProxyById.put(id, ftpClientConfigProxy);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,73 +88,59 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
|
|
||||||
if(parser.equals("AUTO")) //$NON-NLS-1$
|
if(parser.equals("AUTO")) //$NON-NLS-1$
|
||||||
{
|
{
|
||||||
int priorityInt = Integer.MAX_VALUE;
|
int previousPriority = Integer.MAX_VALUE;
|
||||||
int previousPriorityInt = Integer.MAX_VALUE;
|
FTPClientConfigProxy foundProxy = null;
|
||||||
IConfigurationElement selectedCofiguration = null;
|
|
||||||
|
|
||||||
IConfigurationElement[] ce = ep.getConfigurationElements();
|
Enumeration ftpConfigProxyEnum = ftpConfigProxyById.elements();
|
||||||
for (int i = 0; i < ce.length; i++)
|
|
||||||
|
while(ftpConfigProxyEnum.hasMoreElements())
|
||||||
{
|
{
|
||||||
String ftpSystemTypes = ce[i].getAttribute("ftpSystemTypes"); //$NON-NLS-1$
|
FTPClientConfigProxy proxy = (FTPClientConfigProxy)ftpConfigProxyEnum.nextElement();
|
||||||
if(ftpSystemTypes!=null)
|
|
||||||
|
if(proxy.getSystemTypeRegex()!=null)
|
||||||
{
|
{
|
||||||
Pattern ftpSystemTypesRegex = Pattern.compile(ftpSystemTypes);
|
Pattern ftpSystemTypesRegex = Pattern.compile(proxy.getSystemTypeRegex());
|
||||||
if(ftpSystemTypesRegex.matcher(systemName).matches())
|
if(ftpSystemTypesRegex.matcher(systemName).matches())
|
||||||
{
|
{
|
||||||
//try to get priority otherwise assigning Integer.MAX_VALUE
|
int priority = proxy.getPriority();
|
||||||
String priority = ce[i].getAttribute("priority"); //$NON-NLS-1$
|
|
||||||
if(priority!=null)
|
|
||||||
{
|
|
||||||
priorityInt = Integer.parseInt(priority);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
priorityInt = Integer.MAX_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(priorityInt < previousPriorityInt)
|
if(priority < previousPriority)
|
||||||
{
|
{
|
||||||
selectedCofiguration = ce[i];
|
foundProxy = proxy;
|
||||||
previousPriorityInt = priorityInt;
|
previousPriority = priority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//process the selected IConfigurationElement
|
//process the selected proxy
|
||||||
if(selectedCofiguration != null)
|
if(foundProxy != null)
|
||||||
{
|
{
|
||||||
FTPClientConfig config = null;
|
FTPClientConfig config = null;
|
||||||
|
|
||||||
//populate tables
|
if(!ftpFileEntryParser.containsKey(foundProxy.getClassName()))
|
||||||
String clas = selectedCofiguration.getAttribute("class"); //$NON-NLS-1$
|
|
||||||
|
|
||||||
if(!ftpFileEntryParser.containsKey(clas))
|
|
||||||
{
|
{
|
||||||
FTPFileEntryParser entryParser=null;
|
FTPFileEntryParser entryParser = null;
|
||||||
try {
|
try {
|
||||||
entryParser = (FTPFileEntryParser)selectedCofiguration.createExecutableExtension("class"); //$NON-NLS-1$
|
entryParser = (FTPFileEntryParser)foundProxy.getDeclaringBundle().loadClass(foundProxy.getClassName()).newInstance();
|
||||||
} catch (CoreException e) {
|
} catch (InstantiationException e) {
|
||||||
throw new ParserInitializationException(e.getMessage());
|
e.printStackTrace();
|
||||||
}
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
ftpFileEntryParser.put(clas, entryParser);
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
ftpFileEntryParser.put(foundProxy.getClassName(), entryParser);
|
||||||
}
|
}
|
||||||
|
|
||||||
String defaultDateFormatStr = selectedCofiguration.getAttribute("defaultDateFormatStr"); //$NON-NLS-1$
|
config = new FTPClientConfig(foundProxy.getClassName());
|
||||||
String recentDateFormatStr = selectedCofiguration.getAttribute("recentDateFormatStr"); //$NON-NLS-1$
|
|
||||||
String serverLanguageCode = selectedCofiguration.getAttribute("serverLanguageCode"); //$NON-NLS-1$
|
|
||||||
String shortMonthNames = selectedCofiguration.getAttribute("shortMonthNames"); //$NON-NLS-1$
|
|
||||||
String serverTimeZoneId = selectedCofiguration.getAttribute("serverTimeZoneId"); //$NON-NLS-1$
|
|
||||||
|
|
||||||
config = new FTPClientConfig(clas);
|
|
||||||
|
|
||||||
//not necessary checking for null, as null is valid input
|
//not necessary checking for null, as null is valid input
|
||||||
config.setDefaultDateFormatStr(defaultDateFormatStr);
|
config.setDefaultDateFormatStr(foundProxy.getDefaultDateFormatStr());
|
||||||
config.setRecentDateFormatStr(recentDateFormatStr);
|
config.setRecentDateFormatStr(foundProxy.getRecentDateFormatStr());
|
||||||
config.setServerLanguageCode(serverLanguageCode);
|
config.setServerLanguageCode(foundProxy.getServerLanguageCode());
|
||||||
config.setShortMonthNames(shortMonthNames);
|
config.setShortMonthNames(foundProxy.getShortMonthNames());
|
||||||
config.setServerTimeZoneId(serverTimeZoneId);
|
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;
|
ftpClientConfig = config;
|
||||||
|
@ -153,46 +158,42 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IConfigurationElement[] ce = ep.getConfigurationElements();
|
|
||||||
for (int i = 0; i < ce.length; i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
String label = ce[i].getAttribute("label"); //$NON-NLS-1$
|
Enumeration ftpConfigProxyEnum = ftpConfigProxyById.elements();
|
||||||
|
|
||||||
|
while(ftpConfigProxyEnum.hasMoreElements())
|
||||||
|
{
|
||||||
|
FTPClientConfigProxy proxy = (FTPClientConfigProxy)ftpConfigProxyEnum.nextElement();
|
||||||
|
|
||||||
if(label.equals(parser))
|
if(proxy.getId().equals(parser))
|
||||||
{
|
{
|
||||||
|
|
||||||
FTPClientConfig config = null;
|
FTPClientConfig config = null;
|
||||||
|
|
||||||
//populate tables
|
if(!ftpFileEntryParser.containsKey(proxy.getClassName()))
|
||||||
String clas = ce[i].getAttribute("class"); //$NON-NLS-1$
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
ftpFileEntryParser.put(proxy.getClassName(), entryParser);
|
||||||
|
}
|
||||||
|
|
||||||
FTPFileEntryParser entryParser=null;
|
config = new FTPClientConfig(proxy.getClassName());
|
||||||
try {
|
|
||||||
entryParser = (FTPFileEntryParser)ce[i].createExecutableExtension("class"); //$NON-NLS-1$
|
|
||||||
} catch (CoreException e) {
|
|
||||||
throw new ParserInitializationException(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
ftpFileEntryParser.put(clas, entryParser);
|
|
||||||
|
|
||||||
String defaultDateFormatStr = ce[i].getAttribute("defaultDateFormatStr"); //$NON-NLS-1$
|
|
||||||
String recentDateFormatStr = ce[i].getAttribute("recentDateFormatStr"); //$NON-NLS-1$
|
|
||||||
String serverLanguageCode = ce[i].getAttribute("serverLanguageCode"); //$NON-NLS-1$
|
|
||||||
String shortMonthNames = ce[i].getAttribute("shortMonthNames"); //$NON-NLS-1$
|
|
||||||
String serverTimeZoneId = ce[i].getAttribute("serverTimeZoneId"); //$NON-NLS-1$
|
|
||||||
|
|
||||||
config = new FTPClientConfig(clas);
|
|
||||||
|
|
||||||
//not necessary checking for null, as null is valid input
|
//not necessary checking for null, as null is valid input
|
||||||
config.setDefaultDateFormatStr(defaultDateFormatStr);
|
config.setDefaultDateFormatStr(proxy.getDefaultDateFormatStr());
|
||||||
config.setRecentDateFormatStr(recentDateFormatStr);
|
config.setRecentDateFormatStr(proxy.getRecentDateFormatStr());
|
||||||
config.setServerLanguageCode(serverLanguageCode);
|
config.setServerLanguageCode(proxy.getServerLanguageCode());
|
||||||
config.setShortMonthNames(shortMonthNames);
|
config.setShortMonthNames(proxy.getShortMonthNames());
|
||||||
config.setServerTimeZoneId(serverTimeZoneId);
|
config.setServerTimeZoneId(proxy.getServerTimeZoneId());
|
||||||
|
|
||||||
ftpConfig.put(label, config);
|
|
||||||
|
|
||||||
|
ftpConfig.put(parser, config);
|
||||||
ftpClientConfig = (FTPClientConfig)ftpConfig.get(parser);
|
ftpClientConfig = (FTPClientConfig)ftpConfig.get(parser);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -200,7 +201,6 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -211,9 +211,9 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory#getKeySet()
|
* @see org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory#getKeySet()
|
||||||
*/
|
*/
|
||||||
public Set getKeySet()
|
public String[] getKeySet()
|
||||||
{
|
{
|
||||||
return keySet;
|
return (String[])ftpConfigProxyById.keySet().toArray(new String[ftpConfigProxyById.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -228,27 +228,19 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
//
|
//
|
||||||
if(!ftpFileEntryParser.containsKey(key))
|
if(!ftpFileEntryParser.containsKey(key))
|
||||||
{
|
{
|
||||||
IConfigurationElement[] ce = ep.getConfigurationElements();
|
FTPClientConfigProxy proxy = (FTPClientConfigProxy)ftpConfigProxyById.get(key);
|
||||||
for (int i = 0; i < ce.length; i++)
|
|
||||||
{
|
FTPFileEntryParser entryParser = null;
|
||||||
|
try {
|
||||||
String label = ce[i].getAttribute("label"); //$NON-NLS-1$
|
entryParser = (FTPFileEntryParser)proxy.getDeclaringBundle().loadClass(proxy.getClassName()).newInstance();
|
||||||
|
} catch (InstantiationException e) {
|
||||||
if(label.equals(key))
|
e.printStackTrace();
|
||||||
{
|
} catch (IllegalAccessException e) {
|
||||||
//populate tables
|
e.printStackTrace();
|
||||||
String clas = ce[i].getAttribute("class"); //$NON-NLS-1$
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
FTPFileEntryParser entryParser=null;
|
}
|
||||||
try {
|
ftpFileEntryParser.put(proxy.getClassName(), entryParser);
|
||||||
entryParser = (FTPFileEntryParser)ce[i].createExecutableExtension("class"); //$NON-NLS-1$
|
|
||||||
} catch (CoreException e) {
|
|
||||||
throw new ParserInitializationException(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
ftpFileEntryParser.put(clas, entryParser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,4 +258,13 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Ltd. All rights reserved.
|
||||||
|
* This program and the accompanying materials are made available under the terms
|
||||||
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Javier Montalvo Orus (Symbian) - initial API and implementation
|
||||||
|
* Javier Montalvo Orus (Symbian) - improved autodetection of FTPListingParser
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.rse.internal.subsystems.files.ftp.parser;
|
||||||
|
|
||||||
|
import org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigProxy;
|
||||||
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
|
public class FTPClientConfigProxy implements IFTPClientConfigProxy{
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String label;
|
||||||
|
private int priority = Integer.MAX_VALUE;
|
||||||
|
private String systemTypeRegex;
|
||||||
|
private String className;
|
||||||
|
private Bundle declaringBundle;
|
||||||
|
private String listCommandModifiers;
|
||||||
|
|
||||||
|
private String defaultDateFormatStr;
|
||||||
|
private String recentDateFormatStr;
|
||||||
|
private String serverLanguageCode;
|
||||||
|
private String shortMonthNames;
|
||||||
|
private String serverTimeZoneId;
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
this.label = label;
|
||||||
|
|
||||||
|
try{
|
||||||
|
this.priority = Integer.parseInt(priority);
|
||||||
|
}catch(NumberFormatException e){}
|
||||||
|
|
||||||
|
this.systemTypeRegex = systemTypeRegex;
|
||||||
|
this.className = className;
|
||||||
|
this.listCommandModifiers = listCommandModifiers;
|
||||||
|
|
||||||
|
this.declaringBundle = declaringBundle;
|
||||||
|
|
||||||
|
this.defaultDateFormatStr = defaultDateFormatStr;
|
||||||
|
this.recentDateFormatStr = recentDateFormatStr;
|
||||||
|
this.serverLanguageCode = serverLanguageCode;
|
||||||
|
this.shortMonthNames = shortMonthNames;
|
||||||
|
this.serverTimeZoneId = serverTimeZoneId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSystemTypeRegex() {
|
||||||
|
return systemTypeRegex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClassName() {
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bundle getDeclaringBundle() {
|
||||||
|
return declaringBundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getListCommandModifiers() {
|
||||||
|
return listCommandModifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultDateFormatStr() {
|
||||||
|
return defaultDateFormatStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRecentDateFormatStr() {
|
||||||
|
return recentDateFormatStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerLanguageCode() {
|
||||||
|
return serverLanguageCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShortMonthNames() {
|
||||||
|
return shortMonthNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerTimeZoneId() {
|
||||||
|
return serverTimeZoneId;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue