Merged 1.4 to HEAD

svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4192 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4197 .
   svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4205 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4206 .
   svn resolved root\projects\repository\source\java\org\alfresco\filesys\server\config\ServerConfiguration.java
   svn revert root\projects\repository\config\alfresco\version.properties
   svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4219 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4224 .


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4631 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-12-18 11:58:55 +00:00
parent df4fd38e52
commit ff07ea1e7d
18 changed files with 1411 additions and 149 deletions

View File

@@ -68,8 +68,10 @@ public class FTPCommand
public final static int XRmd = 39;
public final static int XCup = 40;
public final static int XCwd = 41;
public final static int MLst = 42;
public final static int MLsd = 43;
public final static int MaxId = 41;
public final static int MaxId = 43;
public final static int InvalidCmd = -1;
@@ -78,7 +80,7 @@ public class FTPCommand
private static final String[] _cmds = { "USER", "PASS", "ACCT", "CWD", "CDUP", "SMNT", "REIN", "QUIT", "PORT",
"PASV", "TYPE", "STRU", "MODE", "RETR", "STOR", "STOU", "APPE", "ALLO", "REST", "RNFR", "RNTO", "ABOR",
"DELE", "RMD", "MKD", "PWD", "LIST", "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "SIZE",
"OPTS", "FEAT", "XPWD", "XMKD", "XRMD", "XCUP", "XCWD" };
"OPTS", "FEAT", "XPWD", "XMKD", "XRMD", "XCUP", "XCWD", "MLST", "MLSD" };
/**
* Convert an FTP command to an id

View File

@@ -16,6 +16,7 @@
*/
package org.alfresco.filesys.ftp;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@@ -37,6 +38,11 @@ public class FTPDate
protected final static String[] _months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
"Nov", "Dec" };
// Machine listing date/time formatters
protected final static SimpleDateFormat _mlstFormat = new SimpleDateFormat( "yyyyMMddHHmmss");
protected final static SimpleDateFormat _mlstFormatLong = new SimpleDateFormat( "yyyyMMddHHmmss.SSS");
/**
* Pack a date string in Unix format The format is 'Mmm dd hh:mm' if the file is less than six
* months old, else the format is 'Mmm dd yyyy'.
@@ -104,4 +110,26 @@ public class FTPDate
buf.append(min);
}
}
/**
* Return a machine listing date/time, in the format 'YYYYMMDDHHSS'.
*
* @param dateTime long
* @return String
*/
public final static String packMlstDateTime( long dateTime)
{
return _mlstFormat.format( new Date( dateTime));
}
/**
* Return a machine listing date/time, in the format 'YYYYMMDDHHSS.sss'.
*
* @param dateTime long
* @return String
*/
public final static String packMlstDateTimeLong( long dateTime)
{
return _mlstFormatLong.format( new Date( dateTime));
}
}

View File

@@ -21,6 +21,7 @@ import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.nio.charset.Charset;
import java.util.Enumeration;
import org.alfresco.filesys.server.ServerListener;
@@ -46,8 +47,8 @@ public class FTPNetworkServer extends NetworkFileServer implements Runnable
// Constants
//
// Session Thread group
private static final ThreadGroup THREAD_GROUP_SESSION = new ThreadGroup("FTP_SESSION_GROUP");
// Listen backlog for the server socket
@@ -86,6 +87,14 @@ public class FTPNetworkServer extends NetworkFileServer implements Runnable
private String m_localFTPaddress;
// SITE command interface
private FTPSiteInterface m_siteInterface;
// Default character encoding to use for file names
private String m_charSet;
/**
* Class constructor
*
@@ -122,6 +131,12 @@ public class FTPNetworkServer extends NetworkFileServer implements Runnable
logger.error(ex);
}
}
// Set the default character set
m_charSet = config.getFTPCharacterSet();
if ( m_charSet == null)
m_charSet = Charset.defaultCharset().name();
}
/**
@@ -333,6 +348,16 @@ public class FTPNetworkServer extends NetworkFileServer implements Runnable
return m_rootPath;
}
/**
* Get the character set to use for file name encoding/decoding
*
* @return String
*/
public final String getCharacterSet()
{
return m_charSet;
}
/**
* Notify the server that a user has logged on.
*
@@ -357,6 +382,8 @@ public class FTPNetworkServer extends NetworkFileServer implements Runnable
if (logger.isDebugEnabled() && hasDebug())
{
logger.debug("FTP Server starting on port " + getPort());
if ( getCharacterSet() != null)
logger.debug( "Using character set " + getCharacterSet());
}
// Create a server socket to listen for incoming FTP session requests
@@ -582,4 +609,34 @@ public class FTPNetworkServer extends NetworkFileServer implements Runnable
fireServerEvent(ServerListener.ServerStartup);
}
/**
* Check if the site interface is valid
*
* @return boolean
*/
public final boolean hasSiteInterface()
{
return m_siteInterface != null ? true : false;
}
/**
* Return the site interface
*
* @return FTPSiteInterface
*/
public final FTPSiteInterface getSiteInterface()
{
return m_siteInterface;
}
/**
* Set the site specific commands interface
*
* @param siteInterface FTPSiteInterface
*/
public final void setSiteInterface( FTPSiteInterface siteInterface)
{
m_siteInterface = siteInterface;
}
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.filesys.ftp;
/**
* FTP SITE Command Interface
*
* <p>Optional interface that is used to provide processing for the FTP SITE command.
*/
public interface FTPSiteInterface {
/**
* Process an FTP SITE specific command
*
* @param sess FTPSrvSession
* @param req FTPRequest
*/
void processFTPSiteCommand( FTPSrvSession sess, FTPRequest req);
}

File diff suppressed because it is too large Load Diff

View File

@@ -23,6 +23,9 @@ import java.net.NetworkInterface;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
import java.security.Provider;
import java.security.Security;
import java.util.ArrayList;
@@ -315,6 +318,10 @@ public class ServerConfiguration extends AbstractLifecycleBean
private int m_ftpDebug;
// FTP character set
private String m_ftpCharSet;
//--------------------------------------------------------------------------------
// NFS specific configuration parameters
//
@@ -1660,6 +1667,29 @@ public class ServerConfiguration extends AbstractLifecycleBean
setFTPDebug(ftpDbg);
}
// Check if a character set has been specified
elem = config.getConfigElement( "charSet");
if ( elem != null) {
try {
// Validate the character set name
Charset.forName( elem.getValue());
// Set the FTP character set
setFTPCharacterSet( elem.getValue());
}
catch ( IllegalCharsetNameException ex) {
throw new AlfrescoRuntimeException("Illegal character set name, " + elem.getValue());
}
catch ( UnsupportedCharsetException ex) {
throw new AlfrescoRuntimeException("Unsupported character set name, " + elem.getValue());
}
}
}
/**
@@ -3639,6 +3669,16 @@ public class ServerConfiguration extends AbstractLifecycleBean
m_ftpBindAddress = addr;
}
/**
* Return the FTP character set
*
* @return String
*/
public final String getFTPCharacterSet()
{
return m_ftpCharSet;
}
/**
* Set the FTP server port to use for incoming connections, -1 indicates disable the FTP server
*
@@ -3688,6 +3728,16 @@ public class ServerConfiguration extends AbstractLifecycleBean
{
m_ftpDebug = dbg;
}
/**
* Set the FTP character set
*
* @param charSet String
*/
public final void setFTPCharacterSet( String charSet)
{
m_ftpCharSet = charSet;
}
/**
* Check if the NFS server is enabled

View File

@@ -69,7 +69,7 @@ public class JavaScriptDesktopAction extends DesktopAction {
*/
public JavaScriptDesktopAction()
{
super( DesktopAction.AttrAnyFiles, DesktopAction.PreConfirmAction + DesktopAction.PreCopyToTarget);
super( 0, 0);
}
/**
@@ -209,30 +209,31 @@ public class JavaScriptDesktopAction extends DesktopAction {
{
// Check if the pre-process string is empty
if ( elem.getValue().length() == 0)
throw new DesktopActionException("Empty desktop action pre-processing flags");
// Parse the pre-process string
int pre = 0;
StringTokenizer tokens = new StringTokenizer( elem.getValue(), ",");
while ( tokens.hasMoreTokens())
if ( elem.getValue() != null && elem.getValue().length() > 0)
{
// Get the current pre-process token and validate
// Parse the pre-process string
String token = tokens.nextToken().trim();
StringTokenizer tokens = new StringTokenizer( elem.getValue(), ",");
if ( token.equalsIgnoreCase( "copyToTarget"))
pre |= PreCopyToTarget;
else if ( token.equalsIgnoreCase( "confirm"))
pre |= PreConfirmAction;
else if ( token.equalsIgnoreCase( "localToWorkingCopy"))
pre |= PreLocalToWorkingCopy;
else
throw new DesktopActionException("Unknown pre-processing flag, " + token);
while ( tokens.hasMoreTokens())
{
// Get the current pre-process token and validate
String token = tokens.nextToken().trim();
if ( token.equalsIgnoreCase( "copyToTarget"))
pre |= PreCopyToTarget;
else if ( token.equalsIgnoreCase( "confirm"))
pre |= PreConfirmAction;
else if ( token.equalsIgnoreCase( "localToWorkingCopy"))
pre |= PreLocalToWorkingCopy;
else
throw new DesktopActionException("Unknown pre-processing flag, " + token);
}
}
// Set the action pre-processing flags
setPreProcessActions( pre);