/** * Initialises the command for execution * Retrieves required parameters from the execution context * * @throws ResourceException Exception from Connector */ private void initialise() throws ResourceException { oldFilePath = executionContext.getRequiredString(ExecutionContext.RENAMABLE_FILE_PATH_PARAM); newFilePath = executionContext.getRequiredString(ExecutionContext.NEW_FILE_PATH_PARAM); }
@Override protected ExecutionOutput performExecute() { logger.info("execute called on this command: [" + this + "]"); //$NON-NLS-1$ //$NON-NLS-2$ // Don't need to do anything on execute except remember the // fileChunkHeader Id this.fileChunkHeader = ((FileChunkHeader) executionContext.get(ExecutionContext.FILE_CHUNK_HEADER)); this.fileChunkHeaderId = fileChunkHeader.getId(); return new ExecutionOutput(); }
/** * * @param command */ protected void addListenersToCommand(TransactionalResourceCommand command) { logger.info("Attempting to add listeners to the command!"); for(TransactionCommitFailureListener listener: this.listeners) { logger.info("Adding listener: " + listener); command.addListener(listener); } }
final String tempFileName) throws ResourceException ExecutionContext executionContext = new ExecutionContext(); TransactionalResourceCommand deliveryCommand = null; if (!unzip) executionContext.put(ExecutionContext.FILE_INPUT_STREAM, inputStream); executionContext.put(ExecutionContext.RELATIVE_FILE_PATH_PARAM, fileName); deliveryCommand = new DeliverFileCommand(outputDir, renameExtension, overwrite, createParentDirectory, tempFileName); executionContext.put(ExecutionContext.BATCHED_FILE_PROVIDER, new UnzippingFileProvider(inputStream)); executionContext.put(ExecutionContext.BATCHED_FILE_NAME, fileName); deliveryCommand = new DeliverBatchCommand(outputDir, overwrite); executeCommand(deliveryCommand, executionContext).getResult();
ExecutionContext executionContext = new ExecutionContext(); executionContext.put(ExecutionContext.CLIENT_ID, this.clientId); FileDiscoveryCommand fileDiscoveryCommand = new FileDiscoveryCommand(sourceDir, filenamePattern, baseFileTransferDao, minAge, filterDuplicates, filterOnFilename, filterOnLastModifiedDate,isRecursive); List<?> entries = executeCommand(fileDiscoveryCommand, executionContext).getResultList(); if(!(entries.isEmpty()) && chronological)
.get(ExecutionContext.BASE_FILE_TRANSFER_MAPPED_RECORD); InputStream inputStream = (InputStream) this.executionContext.getRequired(ExecutionContext.FILE_INPUT_STREAM); String filePath = (String) this.executionContext.getRequired(ExecutionContext.RELATIVE_FILE_PATH_PARAM); return new ExecutionOutput(destinationPath);
.getRequiredString(ExecutionContext.DELIVERED_FILE_PATH_PARAM); .getRequired(ExecutionContext.PAYLOAD); return new ExecutionOutput();
/** * Executes a command with a given ExecutionContext * * @param command to execute * @param executionContext - * @return ExecutionOutput * @throws ResourceException - */ @Override protected ExecutionOutput executeCommand(TransactionalResourceCommand command, ExecutionContext executionContext) throws ResourceException { command.setExecutionContext(executionContext); return executeCommand(command); }
/** * Executes the supplied command * * @param command Command to execute * @return ExecutionOutput * @throws ResourceException Exception from FTP Connector */ private ExecutionOutput executeCommand(TransactionalResourceCommand command) throws ResourceException { super.addListenersToCommand(command); return (this.getManagedConnection().executeCommand(command)); }
.getRequired(ExecutionContext.BATCHED_FILE_PROVIDER); String batchedFileName = (String) executionContext.getRequired(ExecutionContext.BATCHED_FILE_NAME); batchFolder = batchedFileName; int suffix = 1; return new ExecutionOutput(tempDirectory);
@Override protected ExecutionOutput performExecute() throws ResourceException { logger.debug("execute called on command: [" + getClass().getName() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ List<ClientListEntry> list = getList(); logger.debug("got resulting list:" + list); //$NON-NLS-1$ return new ExecutionOutput(list); }
/** * static accessor for singleton TransactionalResourceCommandDAO * * @return singleton instance of TransactionalResourceCommandDAO */ public static TransactionalResourceCommandDAO getTransactionalResourceCommandDAO() { if (transactionalResourceCommandDAO == null) { InputStream transactionalResourceCommandMappings = Thread .currentThread() .getContextClassLoader() .getResourceAsStream("TransactionalResourceCommand.hbm.xml"); InputStream xidImplMappings = Thread.currentThread() .getContextClassLoader().getResourceAsStream( "XidImpl.hbm.xml"); Configuration cfg = generateConfiguration(); cfg.setProperty(Environment.DATASOURCE, "java:/datasource/ikasan/ds"); cfg.addInputStream(transactionalResourceCommandMappings); cfg.addInputStream(xidImplMappings); transactionalResourceCommandDAO = new HibernateTransactionalResourceCommandDAO( cfg.buildSessionFactory()); } return transactionalResourceCommandDAO; }
/** * Associate a connection with this managed connection */ @Override public void associateConnection(Object connection) throws ResourceException { logger.debug("Called associateConnection()"); //$NON-NLS-1$ this.throwIfDestroyed(); if (connection instanceof BaseFileTransferConnection) { BaseFileTransferConnection sc = (BaseFileTransferConnection) connection; TransactionalCommandConnection smc = sc.getManagedConnection(); // If it's already associated with us then leave if (smc == this) { return; } smc.removeConnection(sc); addConnection(sc); sc.setManagedConnection(this); } else { throw new javax.resource.spi.IllegalStateException("Invalid connection object [" + connection + "]"); //$NON-NLS-1$ //$NON-NLS-2$ } }
logger.info("move on success = [" + moveOnSuccess + "] and path = [" + moveOnSuccessNewPath + "]."); Payload result = null; ExecutionContext executionContext = new ExecutionContext(); executionContext.put(ExecutionContext.CLIENT_ID, clientID); executionContext.put(ExecutionContext.RETRIEVABLE_FILE_PARAM, entry); if (chunking && shouldChunk(entry)) baseFileTransferDao, clientID, renameOnSuccess, renameOnSuccessExtension, moveOnSuccess, moveOnSuccessNewPath, fileChunkDao, chunkSize, destructive); Object executionResult = executeCommand(chunkingRetrieveFileCommand, executionContext).getResult(); FileChunkHeader fileChunkHeader = (FileChunkHeader) executionResult; BaseFileTransferMappedRecord sftpMappedRecord = (BaseFileTransferMappedRecord) executionResult.getResult(); if (sftpMappedRecord == null) executionContext.put(ExecutionContext.PAYLOAD, result); logger.debug("About to call ChecksumValidatorCommand"); //$NON-NLS-1$
ExecutionContext executionContext = new ExecutionContext(); executionContext.put(ExecutionContext.CLIENT_ID, clientId); List<?> entries = executeCommand(fileDiscoveryCommand, executionContext).getResultList(); if (chronological)
/** * (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); }
/** * Executes a command with a given ExecutionContext * * @param command - The command to execute * @param executionContext - The context of execution * @return ExecutionOutput - The output from executing the command * @throws ResourceException - Exception from the FTP connector */ @Override protected ExecutionOutput executeCommand(TransactionalResourceCommand command, ExecutionContext executionContext) throws ResourceException { command.setExecutionContext(executionContext); super.addListenersToCommand(command); return executeCommand(command); }
/** * Executes the supplied command * * @param command * @return ExecutionOutput * @throws ResourceException */ protected ExecutionOutput executeCommand(TransactionalResourceCommand command) throws ResourceException { super.addListenersToCommand(command); return (this.getManagedConnection().executeCommand(command)); } }
/** * @see org.ikasan.connector.basefiletransfer.outbound.command.AbstractBaseFileTransferTransactionalResourceCommand#performExecute() */ @Override protected ExecutionOutput performExecute() throws ResourceException { logger.info("execute called on command: [" + this + "]"); //$NON-NLS-1$ //$NON-NLS-2$ initialise(); renameFile(this.oldFilePath, this.newFilePath); return new ExecutionOutput(); }
@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); }