List of usage examples for org.apache.commons.net.ftp FTPFile getRawListing
public String getRawListing()
From source file:de.quadrillenschule.azocamsyncd.ftpservice.AZoFTPFile.java
public AZoFTPFile(FTPFile ftpFile, String dir) { this.ftpFile = ftpFile; this.rawname = ftpFile.getRawListing(); this.dir = dir; }
From source file:lucee.runtime.tag.Ftp.java
/** * List data of a ftp connection/*from w w w . j av a 2s . c om*/ * @return FTPCLient * @throws PageException * @throws IOException */ private FTPClient actionListDir() throws PageException, IOException { required("name", name); required("directory", directory); FTPClient client = getClient(); FTPFile[] files = client.listFiles(directory); if (files == null) files = new FTPFile[0]; String[] cols = new String[] { "attributes", "isdirectory", "lastmodified", "length", "mode", "name", "path", "url", "type", "raw" }; String[] types = new String[] { "VARCHAR", "BOOLEAN", "DATE", "DOUBLE", "VARCHAR", "VARCHAR", "VARCHAR", "VARCHAR", "VARCHAR", "VARCHAR" }; lucee.runtime.type.Query query = new QueryImpl(cols, types, 0, "query"); // translate directory path for display if (directory.length() == 0) directory = "/"; else if (directory.startsWith("./")) directory = directory.substring(1); else if (directory.charAt(0) != '/') directory = '/' + directory; if (directory.charAt(directory.length() - 1) != '/') directory = directory + '/'; pageContext.setVariable(name, query); int row = 0; for (int i = 0; i < files.length; i++) { FTPFile file = files[i]; if (file.getName().equals(".") || file.getName().equals("..")) continue; query.addRow(); row++; query.setAt("attributes", row, ""); query.setAt("isdirectory", row, Caster.toBoolean(file.isDirectory())); query.setAt("lastmodified", row, new DateTimeImpl(file.getTimestamp())); query.setAt("length", row, Caster.toDouble(file.getSize())); query.setAt("mode", row, FTPConstant.getPermissionASInteger(file)); query.setAt("type", row, FTPConstant.getTypeAsString(file.getType())); //query.setAt("permission",row,FTPConstant.getPermissionASInteger(file)); query.setAt("raw", row, file.getRawListing()); query.setAt("name", row, file.getName()); query.setAt("path", row, directory + file.getName()); query.setAt("url", row, "ftp://" + client.getRemoteAddress().getHostName() + "" + directory + file.getName()); } writeCfftp(client); return client; }
From source file:nl.nn.adapterframework.filesystem.FtpFileSystem.java
@Override public Map<String, Object> getAdditionalFileProperties(FTPFile f) { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("user", f.getUser()); attributes.put("group", f.getGroup()); attributes.put("type", f.getType()); attributes.put("rawListing", f.getRawListing()); attributes.put("link", f.getLink()); attributes.put("hardLinkCount", f.getHardLinkCount()); return attributes; }
From source file:org.ikasan.connector.ftp.net.FileTransferProtocolClient.java
/** * Constructing a <code>ClientListEntry</code> object from an * <code>FTPFile</code> object. This is a direct map with some formatting * changes.//from w ww .j a va2s .co m * * @param ftpFile The <code>FTPFile</code> to map to a * <code>ClientListEntry</code> * @param fileUri The URI of the underlying file for the particular * <code>FTPFile</code> * @return ClientListEntry */ private ClientListEntry convertFTPFileToClientListEntry(FTPFile ftpFile, URI fileUri, String currentDir) { ClientListEntry clientListEntry = new ClientListEntry(); clientListEntry.setUri(fileUri); clientListEntry.setName(ftpFile.getName()); clientListEntry.setFullPath(currentDir + System.getProperty("file.separator") + ftpFile.getName()); clientListEntry.setClientId(null); // Can't distinguish between Last Accessed and Last Modified clientListEntry.setDtLastAccessed(ftpFile.getTimestamp().getTime()); clientListEntry.setDtLastModified(ftpFile.getTimestamp().getTime()); clientListEntry.setSize(ftpFile.getSize()); clientListEntry.isDirectory(ftpFile.isDirectory()); clientListEntry.isLink(ftpFile.isSymbolicLink()); clientListEntry.setLongFilename(ftpFile.getRawListing()); clientListEntry.setAtime(ftpFile.getTimestamp().getTime().getTime()); clientListEntry.setMtime(ftpFile.getTimestamp().getTime().getTime()); clientListEntry.setAtimeString(ftpFile.getTimestamp().toString()); clientListEntry.setMtimeString(ftpFile.getTimestamp().toString()); // clientListEntry.setFlags(); clientListEntry.setGid(ftpFile.getGroup()); clientListEntry.setUid(ftpFile.getUser()); // TODO might be able to ask which permissions it has and build an int // and String from there // clientListEntry.setPermissions(); // clientListEntry.setPermissionsString(); // No extended information clientListEntry.setExtended(null); return clientListEntry; }
From source file:ro.kuberam.libs.java.ftclient.FTP.FTP.java
private static void _generateResourceElement(XMLStreamWriter xmlWriter, FTPFile resource, InputStream is, String resourceAbsolutePath) throws IOException, Exception { String resourceName = resource.getName(); String resourceType = ((resource.getType() == 1) ? "directory" : (((resource.getType() == 0) ? "file" : "link"))); Calendar resourceTimeStamp = resource.getTimestamp(); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ"); String lastModified = formatter.format(resourceTimeStamp.getTimeInMillis()); lastModified = lastModified.replace(" ", "T"); lastModified = lastModified.substring(0, 22) + ":" + lastModified.substring(22, 24); long resourceSize = resource.getSize(); String user = resource.getUser(); String userGroup = resource.getGroup(); String permissions = resource.getRawListing().substring(0, 10); String linkTo = resource.getLink(); GenerateResourceElement.run(is, xmlWriter, modulePrefix, moduleNsUri, resourceName, resourceType, resourceAbsolutePath, lastModified, resourceSize, user, userGroup, permissions, linkTo); }