Re: [Hypercontent-users] HyperContent 2 RC Questions
Brought to you by:
alexvigdor
From: Carl B. <C.P...@hu...> - 2005-11-14 16:24:44
|
Hi Alex Thanks, the new FTPUnixFileSystemImpl.java file did the trick. It does still say file not found on your first build but then goes though to complete without errors. I'll check out the navigation issues tomorrow morning and get back to you on that.... Cheers Carl Alex Vigdor wrote: > Hi Carl, > I'm glad you've had a chance to look at RC1. I think you have > found a bug in the FTP client - we only use SFTP here, so that wasn't > as rigorously tested. I've attached an updated version of the > FTPUnixFileSystemImpl - drop it into the source tree, and when you run > the ant script it will recompile and deploy the changes. This should > solve that error, which was caused by a failure to check if a value is > null. Let me know how it works; I'll wait to check it into CVS until > then. > HC2 selectively rewrites the links on your page in the inline > frame; it only changes relative links (links starting with "."). If > you have any sort of absolute link (including links starting with "/") > HC2 leaves it alone, so even if it points to another page managed by > HC2 it won't be recognized. Try setting it up as a relative link and > it should work. > For the navigation problem, I'd have an easier time debugging it > if I could see it in context. If you could zip up the repository of a > project with the problem, I'll install it locally and have a look. > > Cheers, > Alex > >------------------------------------------------------------------------ > >/** > * Copyright (c) 2003 Columbia University in the City of New York. > * > * Permission is hereby granted, free of charge, to any person obtaining > * a copy of this software and associated documentation files (the > * "Software"), to deal in the Software without restriction, including > * without limitation the rights to use, copy, modify, merge, publish, > * distribute, sublicense, and/or sell copies of the Software, and to > * permit persons to whom the Software is furnished to do so, subject to > * the following conditions: > * > * The above copyright notice and this permission notice shall be > * included in all copies or substantial portions of the Software. > * > * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. > * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY > * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, > * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE > * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. > * > */ >package org.hypercontent.filesystem.impl; > >//java imports >import java.io.*; >import java.util.*; >import java.text.*; > > >// used for FTP commands >import com.enterprisedt.net.ftp.*; > >import org.hypercontent.filesystem.FileSystemException; > >import org.hypercontent.filesystem.*; >import org.hypercontent.util.Paths; >/** > * <p>FTPUnixFileSystemImpl contains methods to perform operations > * on a UNIX FTP file system. </p> > * > * <p>Columbia University </p> > * > * @author Adam Carl ac...@co... > * @author Alex Vigdor av...@co... > * @version $Revision: 1.3 $ > */ > >public class FTPUnixFileSystemImpl extends RemoteFileSystemImpl implements IRemoteClient{ > > private String chmod; > private FTPClient ftpClient; > private String FTP_STATUS_CMD = "NOOP"; > private FTPTransferType transferMode = FTPTransferType.BINARY; > private static String[] replyCodes = new String[] {"200"}; > > protected IRemoteClient getClient() { > return this; > } > > public FTPUnixFileSystemImpl(){ > super(); > } > > /** > * Mounts the File System > * @throws FileSystemException > */ > public void connect(RemoteConnection conn) throws FileSystemException{ > // set up host > try{ > ftpClient = new FTPClient(); > ftpClient.setRemoteHost(conn.host); > } > catch (FTPException ftpe){ > FileSystemException fe = new FileSystemException(X_GENERAL_ERROR); > throw fe; > } > catch (IOException ioe){ > FileSystemException fe = new FileSystemException(X_IO_ERROR); > throw fe; > } > > synchronized (ftpClient){ > // open connection > try{ > ftpClient.connect(); > ftpClient.login(conn.username, conn.password); > ftpClient.setConnectMode(FTPConnectMode.PASV); > ftpClient.setType(transferMode); > } > catch (FTPException ftpe){ > FileSystemException fe = new FileSystemException(X_BAD_MOUNT_ARGUMENTS,ftpe); > throw fe; > } > catch (IOException ioe){ > FileSystemException fe = new FileSystemException(X_BAD_MOUNT_ARGUMENTS,ioe); > throw fe; > } > > // now try and change to directory > try{ > ftpClient.chdir(conn.root); > } > // would fail if directory does not exist > catch (Exception ioe){ > FileSystemException fe = new FileSystemException(X_BAD_MOUNT_ARGUMENTS, ioe); > throw fe; > } > } > } > > /** > * Unmounts the File System > * > */ > public void disconnect(){ > synchronized (ftpClient){ > try{ > ftpClient.quit(); > } > catch (Exception e){} > } > } > > public boolean isConnected() { > try { > checkFileSystemConnectionStatus(); > return true; > } > catch(FileSystemException e) { > return false; > } > } > > > /* > * given the logical path of a directory, return String[] of the > * logical paths of its elements. Make sure directories end in / > * and throw an exception if the directory is not found > */ > public RemoteFile[] ls(String dir) throws FileSystemException{ > try{ > FTPFile[] listing; > synchronized (ftpClient){ > try{ > ftpClient.chdir(dir); > } > catch(Exception e){ > throw new FileSystemException(X_DIRECTORY_NOT_FOUND,dir); > } > listing = ftpClient.dirDetails(dir); > } > ArrayList files = new ArrayList(listing.length); > for (int x=0;x<listing.length;x++){ > FTPFile ftpFile = listing[x]; > RemoteFile file = new RemoteFile(); > file.date= ftpFile.lastModified(); > file.name=ftpFile.getName(); > file.isFile = !ftpFile.isDir(); > if(!file.isFile){ > file.name = Paths.concat(file.name,"/"); > } > files.add(file); > } > > RemoteFile[] rfiles = (RemoteFile[]) files.toArray(new RemoteFile[0]); > > return rfiles; > } > catch (FTPException ftpe){ > checkFileSystemConnectionStatus(); > throw new FileSystemException(X_GENERAL_ERROR,ftpe); > } > catch (IOException ioe){ > checkFileSystemConnectionStatus(); > throw new FileSystemException(X_IO_ERROR,ioe); > } > catch(ParseException e){ > throw new FileSystemException(X_GENERAL_ERROR,e); > } > } > > public void chmod(String mask, String path) throws FileSystemException { > chmod = "SITE chmod " + mask + " "; > try{ // set permissions > ftpClient.quote(chmod + path, replyCodes); > } > catch (FTPException ftpe) { > throw new FileSystemException(X_GENERAL_ERROR,ftpe); > } > catch(IOException e) { > throw new FileSystemException(X_IO_ERROR,e); > } > } > > /** > * Stores data to a file on the File System. Use the newFile metod > * to create a file before calling this method. > * > * @throws FileSystemException > */ > public void store(InputStream data,String path) throws FileSystemException{ > String fullDirectory = getParentDirectory(path); > synchronized (ftpClient){ > try{ > ftpClient.chdir(fullDirectory); > ftpClient.put(data,path); > } > catch (FTPException ftpe){ > if (ftpe.getReplyCode() == 550){ > throw new FileSystemException(X_DIRECTORY_NOT_FOUND,ftpe,fullDirectory); > } > checkFileSystemConnectionStatus(); > throw new FileSystemException(X_GENERAL_ERROR,ftpe); > } > catch (IOException ioe){ > checkFileSystemConnectionStatus(); > throw new FileSystemException(X_IO_ERROR,ioe); > } > finally{ > try{ > data.close(); > } > catch(IOException e){} > } > } > } > > public IDataLoader getDataLoader(String path) { > return new FTPFileDataLoader(ftpClient,path); > } > > public void deleteFileEdition(String path, int index, String actor) throws FileSystemException{ > deleteFile(path,actor); > } > > /** > * Removes a file from the File System > * @param path Path and filename of the file to remove > * @throws FileSystemException > */ > public void delete(String path) throws FileSystemException{ > try{ > ftpClient.delete(path); > } > catch (FTPException ftpe){ > checkFileSystemConnectionStatus(); > throw new FileSystemException(X_GENERAL_ERROR,ftpe); > } > catch (IOException ioe){ > checkFileSystemConnectionStatus(); > throw new FileSystemException(X_IO_ERROR,ioe); > } > } > > /** > * Create a new directory on the File System > * @param path Path and directory of the directory to create > * @throws FileSystemException > */ > public void mkdir(String path) throws FileSystemException{ > try{ > ftpClient.mkdir(path); > } > catch (FTPException ftpe){ > switch (ftpe.getReplyCode()){ > case 550: > throw new FileSystemException(X_DIRECTORY_NOT_FOUND,path); > default: > checkFileSystemConnectionStatus(); > throw new FileSystemException(X_GENERAL_ERROR,ftpe); > } > } > catch (IOException ioe){ > checkFileSystemConnectionStatus(); > throw new FileSystemException(X_GENERAL_ERROR,ioe); > } > } > > public void rmdir(String path) throws FileSystemException { > try { > ftpClient.rmdir(path); > } > catch(IOException e) { > checkFileSystemConnectionStatus(); > throw new FileSystemException(X_IO_ERROR,e); > } > catch(FTPException e) { > checkFileSystemConnectionStatus(); > throw new FileSystemException(X_GENERAL_ERROR,e); > } > } > > /* > * Checks to see if the FTP Server can receive a command > */ > protected void checkFileSystemConnectionStatus() throws FileSystemException > { > if(ftpClient==null){ > throw new FileSystemException(X_FILESYSTEM_NOT_MOUNTED); > } > synchronized(ftpClient){ > // send a NOOP comamnd to ftp server. If active will reply with 200 > // the NOOP command just tells the FTP seerver to respond with "Ok" > try{ > ftpClient.quote(FTP_STATUS_CMD, replyCodes); > } > > // for some reason ftp server is no longer available, throw mount exception, > // probably timed out > catch(Exception e){ > throw new FileSystemException(X_FILESYSTEM_NOT_MOUNTED,e); > } > } > } > >} > > -- ************************************ Carl Barrow Systems Integrator e-Services The University of Hull Cottingham Road Hull HU6 7RX Ext. 6838 ************************************ |