ClientListEntry clientListEntry = new ClientListEntry(); clientListEntry.setUri(fileUri); clientListEntry.setName(ftpFile.getName()); clientListEntry.setFullPath(currentDir +System.getProperty("file.separator")+ ftpFile.getName()); clientListEntry.setClientId(null); 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.setGid(ftpFile.getGroup()); clientListEntry.setUid(ftpFile.getUser()); clientListEntry.setExtended(null); return clientListEntry;
if (l.getPermissionsString() != null) sb.append(l.getPermissionsString()); sb.append(l.getLongFilename()); sb.append(EOL); sb.append(l.toString()); sb.append(EOL);
int dClientId = this.clientId.compareTo(e.getClientId()); int dUri = this.uri.compareTo(e.getUri()); int dLastModified = this.dtLastModified.compareTo(e.getDtLastModified()); int dLastAccessed = this.dtLastAccessed.compareTo(e.getDtLastAccessed()); int dSize = (new Long(this.size)).compareTo(new Long(e.getSize()));
/** * Used to create a <code>FileFilter</code> object which can * be used for persisting/filtering the entry. * * <p>Note: size is currently downcast from long to int. Maybe change the * persist object and table definition to handle this.</p> * * NOTE: Order is important due to the Hibernate mapping * * @return An <code>FileFilter</code> object holding this * entry's URI as string, lastModified, lastAccessed and size. */ public FileFilter toPersistObject() { return new FileFilter( this.getClientId(), this.getFullPath(), this.getDtLastModified(), this.getDtLastAccessed(), (int)this.getSize()); }
protected List<ClientListEntry> listDirectory(String directory, List<ClientListEntry> allFiles) throws ResourceException { if(!this.isRecursive) { return listDirectory(directory); } else{ List<ClientListEntry> tmpFiles = listDirectory(directory); for(ClientListEntry clientListEntry:tmpFiles){ if(clientListEntry.isDirectory()&&!clientListEntry.getName().equals("..")&&!clientListEntry.getName().equals(".")) { String subdir = directory+this.fileSeparator+clientListEntry.getName(); allFiles.add(clientListEntry); listDirectory(subdir, allFiles); } else { allFiles.add(clientListEntry); } } return allFiles; } }
/** * Method to match <code>ClientListEntry</code> objects based on * whether they the regular expression provided when the object is * instantiated. * * @param entry The <code>ClientListEntry</code> to match. * @return <code>true</code> if <code>ClientListEntry</code>'s filename * matches the pattern, <code>false</code> otherwise. */ public boolean match(ClientListEntry entry) { if (this.pattern != null && this.patternString != null) { File file = new File(entry.getUri().getPath()); Matcher matcher = pattern.matcher(file.getName()); return (matcher.matches()) ? true : false; } return false; }
for (ClientListEntry entry : entryList) String filePath = entry.getUri().getPath(); if (entry.isDirectory())
@Override protected ExecutionOutput performExecute() throws ResourceException { logger.info("execute called on this command: [" + this + "]"); //$NON-NLS-1$ //$NON-NLS-2$ ClientListEntry entry = (ClientListEntry) executionContext.get(ExecutionContext.RETRIEVABLE_FILE_PARAM); this.sourcePath = entry.getUri().getPath(); File file = new File(entry.getUri().getPath()); try { String directory = file.getParent() + "/"; chunker.chunkFile(directory, file.getName(), chunkSize); } catch (ChunkException e) { throw new ResourceException("Exception caught whilst trying to chunk", e); //$NON-NLS-1$ } FileChunkHeader fileChunkHeader = ((ChunkerImpl) chunker).getFileChunkHeader(); clientId = (String) executionContext.get(ExecutionContext.CLIENT_ID); entry.setClientId(clientId); dao.persistClientListEntry(entry); return new ExecutionOutput(fileChunkHeader); }
entry.setClientId(clientId); Date lastModifiedDate = entry.getDtLastModified(); long ageInMillis = (now.getTime()) - (lastModifiedDate.getTime()); long ageInSec = ageInMillis / 1000; logger.debug("file [" + entry.getLongFilename() + "] ageInSec [" + ageInSec + "] vs minAge [" + minAge //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + "]"); //$NON-NLS-1$
logger .debug("Checksum File URI is: [" + checksumURI.toString() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ ClientListEntry checksumEntry = new ClientListEntry(); checksumEntry.setUri(checksumURI);
/** * Determines if this file should be chunked or not * * @param entry * @return true if the file should be chunked */ private boolean shouldChunk(ClientListEntry entry) { boolean result = false; if (chunkableThreshold != null) { result = entry.getSize() > chunkableThreshold; } return result; }
File entryFile = new File(iterator.next().getLongFilename());
/** * Method to match <code>ClientListEntry</code> objects based on * whether they represent symbolic links or not. * * @param entry The <code>ClientListEntry</code> to match. * @return <code>true</code> if <code>ClientListEntry</code> is a * symbolic link, <code>false</code> otherwise. */ public boolean match(ClientListEntry entry) { return (entry.isLink()) ? true : false; }
/** * Method to match <code>ClientListEntry</code> objects based on * whether they represent directories or not. * * @param lsEntry The <code>ClientListEntry</code> to match. * @return <code>true</code> if <code>ClientListEntry</code> is a * directory, <code>false</code> otherwise. */ public boolean match(ClientListEntry lsEntry) { return (lsEntry.isDirectory()) ? true: false; }
/** * By default case sensitive and based on US ASCII characters * * @param patternString * @param fileList * @return List of ClientListEntries */ public ArrayList<ClientListEntry> matchFiles(String patternString, ArrayList<ClientListEntry> fileList) { ArrayList<ClientListEntry> filteredList = new ArrayList<ClientListEntry>(); Pattern pattern = Pattern.compile(patternString); for (ClientListEntry fileEntry : fileList) { File file = new File(fileEntry.getUri().getPath()); Matcher matcher = pattern.matcher(file.getName()); if (matcher.matches()) { filteredList.add(fileEntry); } } return filteredList; }
for (ClientListEntry entry : entryList) String filePath = entry.getUri().getPath(); if(entry.isDirectory())
/** * (non-Javadoc) * @see org.ikasan.connector.basefiletransfer.outbound.command.AbstractBaseFileTransferTransactionalResourceCommand#performExecute() */ @Override protected ExecutionOutput performExecute() throws ResourceException { logger.info("execute called on this command: [" + this + "]"); //$NON-NLS-1$ //$NON-NLS-2$ ClientListEntry entry = (ClientListEntry) executionContext.get(ExecutionContext.RETRIEVABLE_FILE_PARAM); //sourcePath = entry.getUri().getPath(); // We change the path to be file based as opposed to URI based, // means that root starts as '/' as opposed to '//' which // some FTP servers don't like String uriPath = entry.getUri().getPath(); File path = new File(uriPath); sourcePath = path.getPath(); BaseFileTransferMappedRecord record = getFile(entry); String clientId = (String) executionContext.get(ExecutionContext.CLIENT_ID); logger.debug("got clientId [" + clientId + "]"); //$NON-NLS-1$ //$NON-NLS-2$ entry.setClientId(clientId); dao.persistClientListEntry(entry); return new ExecutionOutput(record); }
/** * Determines if this file should be chunked or not * * @param entry File to check * @return true if the file should be chunked */ private boolean shouldChunk(ClientListEntry entry) { boolean result = false; if(chunkableThreshold != null) { result = entry.getSize() > chunkableThreshold; } return result; }
while (iterator.hasNext()) File entryFile = new File(iterator.next().getLongFilename()); if(entryFile.getName().equals(directory.getName()))
ClientListEntry clientListEntry = new ClientListEntry(); clientListEntry.setUri(fileUri); clientListEntry.setName(ftpFile.getName()); clientListEntry.setFullPath(currentDir +System.getProperty("file.separator")+ ftpFile.getName()); clientListEntry.setClientId(null); 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.setGid(ftpFile.getGroup()); clientListEntry.setUid(ftpFile.getUser()); clientListEntry.setExtended(null); return clientListEntry;