mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 23:25:26 +02:00
[176216] FTP sould provide API to allow clients register their own FTPListingParser
This commit is contained in:
parent
7f53460969
commit
4c1cb55a12
10 changed files with 192 additions and 66 deletions
|
@ -1,42 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (c) 2006, 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
|
||||
-->
|
||||
<?eclipse version="3.1"?>
|
||||
<plugin>
|
||||
<extension-point id="ftpFileEntryParser" name="ftpFileEntryParser" schema="schema/ftpFileEntryParser.exsd"/>
|
||||
|
||||
<extension point="org.eclipse.rse.services.files.ftp.ftpFileEntryParser">
|
||||
<parser
|
||||
class="org.apache.commons.net.ftp.parser.UnixFTPEntryParser"
|
||||
name="UNIX">
|
||||
</parser>
|
||||
<parser
|
||||
class="org.apache.commons.net.ftp.parser.MVSFTPEntryParser"
|
||||
name="MVS">
|
||||
</parser>
|
||||
<parser
|
||||
class="org.eclipse.rse.internal.services.files.ftp.parser.RSENTFTPEntryParser"
|
||||
name="WinNT">
|
||||
</parser>
|
||||
<parser
|
||||
class="org.apache.commons.net.ftp.parser.OS2FTPEntryParser"
|
||||
name="OS2">
|
||||
</parser>
|
||||
<parser
|
||||
class="org.apache.commons.net.ftp.parser.OS400FTPEntryParser"
|
||||
name="OS400">
|
||||
</parser>
|
||||
<parser
|
||||
class="org.eclipse.rse.internal.services.files.ftp.parser.RSEVMSFTPEntryParser"
|
||||
name="VMS">
|
||||
</parser>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
|
@ -62,7 +62,7 @@ import org.apache.commons.net.ftp.FTPReply;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.rse.core.model.IPropertySet;
|
||||
import org.eclipse.rse.internal.services.files.ftp.parser.FTPClientConfigFactory;
|
||||
import org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory;
|
||||
import org.eclipse.rse.services.Mutex;
|
||||
import org.eclipse.rse.services.clientserver.FileTypeMatcher;
|
||||
import org.eclipse.rse.services.clientserver.IMatcher;
|
||||
|
@ -95,6 +95,8 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
|||
|
||||
private boolean _isBinaryFileType = true;
|
||||
private boolean _isPassiveDataConnectionMode = false;
|
||||
private IFTPClientConfigFactory _entryParserFactory;
|
||||
|
||||
|
||||
private class FTPBufferedInputStream extends BufferedInputStream {
|
||||
|
||||
|
@ -224,6 +226,11 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
|||
{
|
||||
_ftpLoggingOutputStream = ftpLoggingOutputStream;
|
||||
}
|
||||
|
||||
public void setFTPClientConfigFactory(IFTPClientConfigFactory entryParserFactory)
|
||||
{
|
||||
_entryParserFactory = entryParserFactory;
|
||||
}
|
||||
|
||||
public void connect() throws Exception
|
||||
{
|
||||
|
@ -283,8 +290,10 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
|||
|
||||
if(!_parser.equalsIgnoreCase("AUTO")) //$NON-NLS-1$
|
||||
{
|
||||
_ftpClient.setParserFactory(FTPClientConfigFactory.getParserFactory());
|
||||
_ftpClient.configure(FTPClientConfigFactory.getParserFactory().getFTPClientConfig(_parser));
|
||||
|
||||
_ftpClient.setParserFactory(_entryParserFactory);
|
||||
_ftpClient.configure(_entryParserFactory.getFTPClientConfig(_parser));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -299,8 +308,8 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
|||
//FTPClientConfig.SYST_NT = "WINDOWS"
|
||||
if(systemName.startsWith(FTPClientConfig.SYST_NT))
|
||||
{
|
||||
_ftpClient.setParserFactory(FTPClientConfigFactory.getParserFactory());
|
||||
_ftpClient.configure(FTPClientConfigFactory.getParserFactory().getFTPClientConfig("WinNT")); //$NON-NLS-1$
|
||||
_ftpClient.setParserFactory(_entryParserFactory);
|
||||
_ftpClient.configure(_entryParserFactory.getFTPClientConfig("WinNT")); //$NON-NLS-1$
|
||||
}else
|
||||
//FTPClientConfig.SYST_MVS = "MVS"
|
||||
if(systemName.startsWith(FTPClientConfig.SYST_MVS))
|
||||
|
@ -320,8 +329,8 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
|||
//FTPClientConfig.SYST_VMS = "VMS"
|
||||
if(systemName.startsWith(FTPClientConfig.SYST_VMS))
|
||||
{
|
||||
_ftpClient.setParserFactory(FTPClientConfigFactory.getParserFactory());
|
||||
_ftpClient.configure(FTPClientConfigFactory.getParserFactory().getFTPClientConfig("VMS_improved")); //$NON-NLS-1$
|
||||
_ftpClient.setParserFactory(_entryParserFactory);
|
||||
_ftpClient.configure(_entryParserFactory.getFTPClientConfig("VMS")); //$NON-NLS-1$
|
||||
}else
|
||||
//Default UNIX-like parsing
|
||||
//FTPClientConfig.SYST_UNIX = "UNIX"
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
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.parser.FTPFileEntryParserFactory;
|
||||
|
||||
|
||||
public interface IFTPClientConfigFactory extends FTPFileEntryParserFactory {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key name attribute of the extension point to be returned
|
||||
* @return FTPClientConfig instance created from the attributes passed in the extension point
|
||||
*/
|
||||
public FTPClientConfig getFTPClientConfig(String key);
|
||||
|
||||
/**
|
||||
* Returns a Set of key names
|
||||
* @return a Set containing the name attribute of the extension points
|
||||
*/
|
||||
public Set getKeySet();
|
||||
|
||||
}
|
|
@ -9,14 +9,15 @@ Bundle-Localization: plugin
|
|||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.rse.services,
|
||||
org.eclipse.rse.services.files.ftp,
|
||||
org.eclipse.rse.subsystems.files.core,
|
||||
org.eclipse.rse.core,
|
||||
org.eclipse.rse.ui,
|
||||
org.eclipse.ui.console
|
||||
org.eclipse.ui.console,
|
||||
org.eclipse.rse.services.files.ftp
|
||||
Eclipse-LazyStart: true
|
||||
Export-Package: org.eclipse.rse.internal.subsystems.files.ftp;x-internal:=true,
|
||||
org.eclipse.rse.internal.subsystems.files.ftp.connectorservice;x-internal:=true,
|
||||
org.eclipse.rse.internal.subsystems.files.ftp.model;x-internal:=true,
|
||||
org.eclipse.rse.internal.subsystems.files.ftp.parser;x-friends:="org.eclipse.rse.services.files.ftp",
|
||||
org.eclipse.rse.subsystems.files.ftp
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
||||
|
|
|
@ -15,6 +15,7 @@ Contributors:
|
|||
Javier Montalvo Orus (Symbian) - add Windows to list of valid FTP systems
|
||||
Martin Oberhuber (Wind River) - add FTP Only system type
|
||||
Javier Montalvo Orus (Symbian) - [plan] Improve Discovery and Autodetect in RSE
|
||||
Javier Montalvo Orus (Symbian) - Fixing 176216 - [api] FTP sould provide API to allow clients register their own FTPListingParser
|
||||
-->
|
||||
<?eclipse version="3.1"?>
|
||||
<plugin>
|
||||
|
@ -42,5 +43,34 @@ Javier Montalvo Orus (Symbian) - [plan] Improve Discovery and Autodetect in RSE
|
|||
serviceType="_ftp._tcp">
|
||||
</configuration>
|
||||
</extension>
|
||||
|
||||
<extension-point id="ftpFileEntryParser" name="ftpFileEntryParser" schema="schema/ftpFileEntryParser.exsd"/>
|
||||
|
||||
<extension point="org.eclipse.rse.subsystems.files.ftp.ftpFileEntryParser">
|
||||
<parser
|
||||
class="org.apache.commons.net.ftp.parser.UnixFTPEntryParser"
|
||||
name="UNIX">
|
||||
</parser>
|
||||
<parser
|
||||
class="org.apache.commons.net.ftp.parser.MVSFTPEntryParser"
|
||||
name="MVS">
|
||||
</parser>
|
||||
<parser
|
||||
class="org.eclipse.rse.internal.subsystems.files.ftp.parser.RSENTFTPEntryParser"
|
||||
name="WinNT">
|
||||
</parser>
|
||||
<parser
|
||||
class="org.apache.commons.net.ftp.parser.OS2FTPEntryParser"
|
||||
name="OS2">
|
||||
</parser>
|
||||
<parser
|
||||
class="org.apache.commons.net.ftp.parser.OS400FTPEntryParser"
|
||||
name="OS400">
|
||||
</parser>
|
||||
<parser
|
||||
class="org.eclipse.rse.internal.subsystems.files.ftp.parser.RSEVMSFTPEntryParser"
|
||||
name="VMS">
|
||||
</parser>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.rse.services.files.ftp">
|
||||
<schema targetNamespace="org.eclipse.rse.subsystems.files.ftp">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.schema plugin="org.eclipse.rse.services.files.ftp" id="ftpFileEntryParser" name="ftpFileEntryParser"/>
|
||||
<meta.schema plugin="org.eclipse.rse.subsystems.files.ftp" id="ftpFileEntryParser" name="ftpFileEntryParser"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
Extension point that allows providing extra parsers for the FTP LIST command output.
|
||||
|
@ -167,7 +167,7 @@ The string attributes <code>defaultDateFormatStr</code> <code>
|
|||
<meta.section type="implementation"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
Customized VMS and WinNT implementations are supplied in the <code>org.eclipse.rse.services.files.ftp</code> plug-in.
|
||||
Customized VMS and WinNT implementations are supplied in the <code>org.eclipse.rse.subsystems.files.ftp</code> plug-in.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
|
@ -31,7 +31,7 @@ import org.eclipse.rse.core.model.IPropertySet;
|
|||
import org.eclipse.rse.core.model.PropertyType;
|
||||
import org.eclipse.rse.core.model.SystemSignonInformation;
|
||||
import org.eclipse.rse.internal.services.files.ftp.FTPService;
|
||||
import org.eclipse.rse.internal.services.files.ftp.parser.FTPClientConfigFactory;
|
||||
import org.eclipse.rse.internal.subsystems.files.ftp.parser.FTPClientConfigFactory;
|
||||
import org.eclipse.rse.internal.subsystems.files.ftp.FTPSubsystemResources;
|
||||
import org.eclipse.rse.services.files.IFileService;
|
||||
import org.eclipse.rse.ui.subsystems.StandardConnectorService;
|
||||
|
@ -88,6 +88,9 @@ public class FTPConnectorService extends StandardConnectorService
|
|||
_ftpService.setPortNumber(getPort());
|
||||
_ftpService.setLoggingStream(getLoggingStream(info.getHostname(),getPort()));
|
||||
_ftpService.setPropertySet(_propertySet);
|
||||
_ftpService.setFTPClientConfigFactory(FTPClientConfigFactory.getParserFactory());
|
||||
|
||||
|
||||
_ftpService.connect();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,21 +8,21 @@
|
|||
* Javier Montalvo Orus (Symbian) - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.files.ftp.parser;
|
||||
package org.eclipse.rse.internal.subsystems.files.ftp.parser;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPClientConfig;
|
||||
import org.apache.commons.net.ftp.FTPFileEntryParser;
|
||||
import org.apache.commons.net.ftp.parser.FTPFileEntryParserFactory;
|
||||
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.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory;
|
||||
|
||||
public class FTPClientConfigFactory implements FTPFileEntryParserFactory {
|
||||
public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||
|
||||
private static FTPClientConfigFactory factory = null;
|
||||
|
||||
|
@ -47,7 +47,7 @@ private static FTPClientConfigFactory factory = null;
|
|||
|
||||
FTPClientConfig config = null;
|
||||
|
||||
IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.services.files.ftp","ftpFileEntryParser"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.subsystems.files.ftp","ftpFileEntryParser"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
IConfigurationElement[] ce = ep.getConfigurationElements();
|
||||
for (int i = 0; i < ce.length; i++) {
|
||||
|
||||
|
@ -86,19 +86,18 @@ private static FTPClientConfigFactory factory = null;
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key name attribute of the extension point to be returned
|
||||
* @return FTPClientConfig instance created from the attributes passed in the extension point
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory#getFTPClientConfig(java.lang.String)
|
||||
*/
|
||||
public FTPClientConfig getFTPClientConfig(String key)
|
||||
{
|
||||
return (FTPClientConfig)ftpConfig.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Set of key names
|
||||
* @return a Set containing the name attribute of the extension points
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.internal.services.files.ftp.parser.IFTPClientConfigFactory#getKeySet()
|
||||
*/
|
||||
public Set getKeySet()
|
||||
{
|
|
@ -0,0 +1,37 @@
|
|||
/********************************************************************************
|
||||
* 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) - [198272] Classification for executable in WinNT parser
|
||||
* Javier Montalvo Orus (Symbian) - [198635] On Windows servers, only lowercase *.exe files are treated as executable
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.subsystems.files.ftp.parser;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
import org.apache.commons.net.ftp.parser.NTFTPEntryParser;
|
||||
|
||||
public class RSENTFTPEntryParser extends NTFTPEntryParser {
|
||||
|
||||
public FTPFile parseFTPEntry(String entry)
|
||||
{
|
||||
FTPFile f = super.parseFTPEntry(entry);
|
||||
|
||||
if(f != null)
|
||||
{
|
||||
// only USER permission is shown in RSE
|
||||
f.setPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION, true);
|
||||
f.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION, true);
|
||||
|
||||
if(f.getName().toLowerCase().endsWith(".exe")) //$NON-NLS-1$
|
||||
{
|
||||
f.setPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION, true);
|
||||
}
|
||||
}
|
||||
return (f);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/********************************************************************************
|
||||
* 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.subsystems.files.ftp.parser;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
import org.apache.commons.net.ftp.parser.VMSFTPEntryParser;
|
||||
|
||||
public class RSEVMSFTPEntryParser extends VMSFTPEntryParser {
|
||||
|
||||
private static final Pattern PERMISSIONS_PATTERN= Pattern.compile(".*(\\([a-zA-Z]*,[a-zA-Z]*,[a-zA-Z]*,[a-zA-Z]*\\))"); //$NON-NLS-1$
|
||||
|
||||
public FTPFile parseFTPEntry(String entry)
|
||||
{
|
||||
FTPFile f = super.parseFTPEntry(entry);
|
||||
|
||||
if(f != null)
|
||||
{
|
||||
if (!isVersioning())
|
||||
{
|
||||
if(f.getName().lastIndexOf(".DIR")!=-1) //$NON-NLS-1$
|
||||
{
|
||||
f.setName(f.getName().substring(0, f.getName().lastIndexOf(".DIR"))); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
Matcher m = PERMISSIONS_PATTERN.matcher(entry.trim());
|
||||
|
||||
if(m.matches())
|
||||
{
|
||||
//Set file permission.
|
||||
//VMS has (SYSTEM,OWNER,GROUP,WORLD) users that can contain
|
||||
//R (read) W (write) E (execute) D (delete)
|
||||
|
||||
StringTokenizer t = new StringTokenizer(m.group(1), ","); //$NON-NLS-1$
|
||||
|
||||
//discard SYSTEM permission
|
||||
t.nextElement();
|
||||
|
||||
//iterate for OWNER GROUP WORLD permissions
|
||||
for (int access = 0; access < 3; access++)
|
||||
{
|
||||
String token = t.nextToken();
|
||||
|
||||
f.setPermission(access, FTPFile.READ_PERMISSION, token.indexOf('R') >= 0);
|
||||
f.setPermission(access, FTPFile.WRITE_PERMISSION, token.indexOf('W') >= 0);
|
||||
f.setPermission(access, FTPFile.EXECUTE_PERMISSION, token.indexOf('E') >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue