Java Code Examples for org.apache.commons.net.ftp.FTPReply#isNegativeTransient()

The following examples show how to use org.apache.commons.net.ftp.FTPReply#isNegativeTransient() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FTPTransfer.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
public void sendCommands(final List<String> commands, final FlowFile flowFile) throws IOException {
    if (commands.isEmpty()) {
        return;
    }

    final FTPClient client = getClient(flowFile);
    for (String cmd : commands) {
        if (!cmd.isEmpty()) {
            int result;
            result = client.sendCommand(cmd);
            logger.debug(this + " sent command to the FTP server: " + cmd + " for " + flowFile);

            if (FTPReply.isNegativePermanent(result) || FTPReply.isNegativeTransient(result)) {
                throw new IOException(this + " negative reply back from FTP server cmd: " + cmd + " reply:" + result + ": " + client.getReplyString() + " for " + flowFile);
            }
        }
    }
}
 
Example 2
Source File: FtpClient.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void processEvent(ProtocolCommandEvent event) {
    String message = event.getMessage();
    if (message.startsWith("PASS ")) { // NOI18N
        // hide password
        message = "PASS ******"; // NOI18N
    }
    OutputWriter writer = null;
    if (event.isReply()
            && (FTPReply.isNegativeTransient(event.getReplyCode()) || FTPReply.isNegativePermanent(event.getReplyCode()))) {
        writer = io.getErr();
    } else {
        writer = io.getOut();
    }
    writer.println(message.trim());
    writer.flush();
    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(Level.FINE, "Command listener: {0}", message.trim());
    }
}
 
Example 3
Source File: FTPTransfer.java    From nifi with Apache License 2.0 6 votes vote down vote up
public void sendCommands(final List<String> commands, final FlowFile flowFile) throws IOException {
    if (commands.isEmpty()) {
        return;
    }

    final FTPClient client = getClient(flowFile);
    for (String cmd : commands) {
        if (!cmd.isEmpty()) {
            int result;
            result = client.sendCommand(cmd);
            logger.debug(this + " sent command to the FTP server: " + cmd + " for " + flowFile);

            if (FTPReply.isNegativePermanent(result) || FTPReply.isNegativeTransient(result)) {
                throw new IOException(this + " negative reply back from FTP server cmd: " + cmd + " reply:" + result + ": " + client.getReplyString() + " for " + flowFile);
            }
        }
    }
}
 
Example 4
Source File: FtpClient.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized String getNegativeReplyString() {
    int replyCode = ftpClient.getReplyCode();
    if (FTPReply.isNegativePermanent(replyCode)
            || FTPReply.isNegativeTransient(replyCode)) {
        return getReplyString();
    }
    return null;
}
 
Example 5
Source File: FtpFileUtil.java    From hsac-fitnesse-fixtures with Apache License 2.0 4 votes vote down vote up
private static void validatResponse(FTPClient ftpClient) {
    if (FTPReply.isNegativeTransient(ftpClient.getReplyCode()) || FTPReply.isNegativePermanent(ftpClient.getReplyCode())) {
        throw new RuntimeException("Got error response: " + ftpClient.getReplyCode());
    }
}