1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 17:35:35 +02:00

[212382] additional "initCommands" slot for ftpListingParsers extension point

This commit is contained in:
Javier Montalvo Orus 2008-03-31 16:59:05 +00:00
parent ac844e3d77
commit a61b832b78
5 changed files with 50 additions and 40 deletions

View file

@ -91,7 +91,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
@ -155,8 +154,6 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
private Map _fCachePreviousFiles = new HashMap();
private static long FTP_STATCACHE_TIMEOUT = 200; //msec
private static final String FTP_COMMAND_SEPARATOR = "|"; //$NON-NLS-1$
private static class FTPBufferedInputStream extends BufferedInputStream {
private FTPClient client;
@ -430,18 +427,11 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
_isBinaryFileType = true;
//Initial commands
String initialCommands = _clientConfigProxy.getInitialCommands();
String[] initialCommands = _clientConfigProxy.getInitialCommands();
if(initialCommands!=null)
{
StringTokenizer stk = new StringTokenizer(initialCommands,FTP_COMMAND_SEPARATOR);
while(stk.hasMoreElements())
{
String command = stk.nextToken();
_ftpClient.sendCommand(command);
}
}
for (int i = 0; i < initialCommands.length; i++) {
_ftpClient.sendCommand(initialCommands[i]);
}
_userHome = _ftpClient.printWorkingDirectory();

View file

@ -28,7 +28,7 @@ public interface IFTPClientConfigProxy {
public String getServerLanguageCode();
public String getShortMonthNames();
public String getServerTimeZoneId();
public String getInitialCommands();
public String[] getInitialCommands();
public FTPClientConfig getFTPClientConfig();

View file

@ -1,10 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.rse.subsystems.files.ftp">
<schema targetNamespace="org.eclipse.rse.subsystems.files.ftp" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<appinfo>
<meta.schema plugin="org.eclipse.rse.subsystems.files.ftp" id="ftpListingParsers" name="FTP Directory Listing Parsers"/>
</appInfo>
</appinfo>
<documentation>
Extension point that allows providing extra parsers for the FTP LIST command output.
Apache commons net provides some APIs and factories to costumize the parser and this extension
@ -42,9 +42,9 @@ The string attributes &lt;code&gt;defaultDateFormatStr&lt;/code&gt; &lt;code&gt;
<documentation>
</documentation>
<appInfo>
<appinfo>
<meta.attribute translatable="true"/>
</appInfo>
</appinfo>
</annotation>
</attribute>
</complexType>
@ -52,6 +52,9 @@ The string attributes &lt;code&gt;defaultDateFormatStr&lt;/code&gt; &lt;code&gt;
<element name="parser">
<complexType>
<sequence minOccurs="0" maxOccurs="unbounded">
<element ref="initCommand"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
@ -64,9 +67,9 @@ The string attributes &lt;code&gt;defaultDateFormatStr&lt;/code&gt; &lt;code&gt;
<documentation>
Name that will be displayed in the FTP Settings dialog
</documentation>
<appInfo>
<appinfo>
<meta.attribute translatable="true"/>
</appInfo>
</appinfo>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
@ -74,9 +77,9 @@ The string attributes &lt;code&gt;defaultDateFormatStr&lt;/code&gt; &lt;code&gt;
<documentation>
Extension of &lt;code&gt;org.apache.commons.net.ftp.Configurable,org.apache.commons.net.ftp.FTPFileEntryParser&lt;/code&gt; implementing the parser for the specific server
</documentation>
<appInfo>
<appinfo>
<meta.attribute kind="java" basedOn="org.apache.commons.net.ftp.Configurable,org.apache.commons.net.ftp.FTPFileEntryParser"/>
</appInfo>
</appinfo>
</annotation>
</attribute>
<attribute name="defaultDateFormatStr" type="string">
@ -163,10 +166,20 @@ If no priority is specified, the default value will be &lt;code&gt;Integer.MAX_V
</documentation>
</annotation>
</attribute>
<attribute name="initCommands" type="string">
</complexType>
</element>
<element name="initCommand">
<annotation>
<documentation>
FTP initialization command to perform after connecting to the remote server, when the server&apos;s system type is detected to match the current listing parser.
</documentation>
</annotation>
<complexType>
<attribute name="cmd" type="string" use="required">
<annotation>
<documentation>
List of FTP commands to be sent after connecting to the remote server. If more than one command is specified, it has to be separated using the character &apos;|&apos;
Command string to execute
</documentation>
</annotation>
</attribute>
@ -174,18 +187,18 @@ If no priority is specified, the default value will be &lt;code&gt;Integer.MAX_V
</element>
<annotation>
<appInfo>
<appinfo>
<meta.section type="since"/>
</appInfo>
</appinfo>
<documentation>
RSE 2.0
</documentation>
</annotation>
<annotation>
<appInfo>
<appinfo>
<meta.section type="examples"/>
</appInfo>
</appinfo>
<documentation>
&lt;!-- Default UNIX parser provided by Apache commons net package --&gt;
&lt;parser
@ -224,27 +237,28 @@ If no priority is specified, the default value will be &lt;code&gt;Integer.MAX_V
</annotation>
<annotation>
<appInfo>
<appinfo>
<meta.section type="apiInfo"/>
</appInfo>
</appinfo>
<documentation>
The provider of a new FTPEntryParser must implement &lt;samp&gt;org.apache.commons.net.ftp.Configurable&lt;/samp&gt; and &lt;samp&gt;org.apache.commons.net.ftp.FTPFileEntryParser&lt;/samp&gt;
</documentation>
</annotation>
<annotation>
<appInfo>
<appinfo>
<meta.section type="implementation"/>
</appInfo>
</appinfo>
<documentation>
Customized VMS and WinNT implementations are supplied in the &lt;code&gt;org.eclipse.rse.subsystems.files.ftp&lt;/code&gt; plug-in.
</documentation>
</annotation>
<annotation>
<appInfo>
<appinfo>
<meta.section type="copyright"/>
</appInfo>
</appinfo>
<documentation>
Copyright (c) 2007, 2008 Symbian Software Ltd. and others. All rights reserved.
This program and the accompanying materials are made available under the terms

View file

@ -69,7 +69,13 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
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$
String initialCommands = ce[i].getAttribute("initCommands"); //$NON-NLS-1$
IConfigurationElement[] initialCommandsSequence = ce[i].getChildren("initCommand"); //$NON-NLS-1$
String[] initialCommands = new String[initialCommandsSequence.length];
for (int j = 0; j < initialCommands.length; j++) {
initialCommands[j] = initialCommandsSequence[j].getAttribute("cmd"); //$NON-NLS-1$
}
FTPClientConfigProxy ftpClientConfigProxy = new FTPClientConfigProxy(id,label,priority,systemTypeRegex,className,declaringBundle,listCommandModifiers,
defaultDateFormatStr,recentDateFormatStr,serverLanguageCode,shortMonthNames,serverTimeZoneId, initialCommands);

View file

@ -31,12 +31,12 @@ public class FTPClientConfigProxy implements IFTPClientConfigProxy{
private String serverLanguageCode;
private String shortMonthNames;
private String serverTimeZoneId;
private String initialCommands;
private String[] initialCommands;
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, String initialCommands)
String defaultDateFormatStr, String recentDateFormatStr, String serverLanguageCode, String shortMonthNames, String serverTimeZoneId, String[] initialCommands)
{
this.id = id;
this.label = label;
@ -113,7 +113,7 @@ public class FTPClientConfigProxy implements IFTPClientConfigProxy{
return ftpClientConfig;
}
public String getInitialCommands() {
public String[] getInitialCommands() {
return initialCommands;
}