/** * Deletes a remote file * * @param filename - for file to be deleted * @throws ResourceException when removing a file fails */ protected void deleteFile(String filename) throws ResourceException { if(logger.isDebugEnabled()) { logger.debug("Deleting file [" + filename + "]"); //$NON-NLS-1$//$NON-NLS-2$ } try { getClient().ensureConnection(); getClient().deleteRemoteFile(filename); } catch (ClientException e) { logger.warn("Underlying File Transfer operation failed [RM]!", e); //$NON-NLS-1$ throw new ResourceException("Exception thrown when trying to delete file [" + filename + "]", e); //$NON-NLS-1$ //$NON-NLS-2$ } }
/** * Rename the file from oldPath to newPath * * @param oldPath Original Path * @param newPath New Path * @throws ResourceException when renaming a file fails */ protected void renameFile(String oldPath, String newPath) throws ResourceException { if(logger.isDebugEnabled()) { logger.debug("Renaming file from [" + oldPath + "] to [" //$NON-NLS-1$ //$NON-NLS-2$ + newPath + "]"); //$NON-NLS-1$ } try { getClient().ensureConnection(); this.getClient().rename(oldPath, newPath); } catch (ClientCommandRenameException e) { logger.warn("Failed to rename file [" + oldPath //$NON-NLS-1$ + "] to [" + newPath //$NON-NLS-1$ + "]. Exception occured [" + e.getMessage() + "]", e); //$NON-NLS-1$ //$NON-NLS-2$ throw new ResourceException(e); } }
List<ClientListEntry> result = new ArrayList<ClientListEntry>(); getClient().ensureConnection();
client.ensureConnection(); String originalDirectory = printWorkingDirectoryName(); if(!this.outputDirectory.equals(".") && !this.outputDirectory.equals(originalDirectory))
/** * (non-Javadoc) Needs to move everything out of the temp directory to which * it was delivered, to its final destination * * @see org.ikasan.connector.base.command.AbstractTransactionalResourceCommand#doCommit() */ @Override protected void doCommit() throws ResourceException { try { logger.info("commit called on this command:" + this + "]"); //$NON-NLS-1$ //$NON-NLS-2$); getClient().ensureConnection(); String originalDirectory = printWorkingDirectoryName(); changeDirectory(outputDirectory); renameFile(tempDirectory, batchFolder); changeDirectory(originalDirectory); } catch(ResourceException exception) { TransactionCommitException transactionCommitException = new TransactionCommitException(exception); super.notifyListeners(transactionCommitException); throw exception; } }