Examples of StringCommandResponse


Examples of com.cisco.telnet.server.domain.response.StringCommandResponse

  }

  abstract protected CommandResponse executeOperation(ShellOperation shellOperation, SessionContext sessionContext);

  protected CommandResponse buildErrorResponse(ShellOperation shellOperation, String errorMessage) {
    return new StringCommandResponse(shellOperation.getName() + ": " + errorMessage, ResponseStatusEnum.ERROR);
  }
View Full Code Here

Examples of com.cisco.telnet.server.domain.response.StringCommandResponse

    } else {
      toListDirectory = shellOperation.getFirstParameter();
    }
    File toListDirectoryFile = buildAbsolutePath(currentDirectory, toListDirectory);
    if (!toListDirectoryFile.exists()) {
      return new StringCommandResponse(FOLDER_TO_LIST_NOT_FOUND_MESSAGE + toListDirectory);
    }

    // Build toListDirectory absolute path

    // List the files
    String[] content = toListDirectoryFile.list();
    String lsResult = "";
    for (int i = 0; i < content.length; i++) {
      lsResult += buildFileInfo(content[i], toListDirectory);
      if (i < content.length - 1) {
        lsResult += LINE_SEPARATOR;
      }
    }
    return new StringCommandResponse(lsResult);
  }
View Full Code Here

Examples of com.cisco.telnet.server.domain.response.StringCommandResponse

    } catch (IOException e) {
      logger.error(e);
      return buildErrorResponse(shellOperation, FAILURE_MESSAGE + newDirectory);
    }

    return new StringCommandResponse(message);
  }
View Full Code Here

Examples of com.cisco.telnet.server.domain.response.StringCommandResponse

public class PwdCommand extends ShellCommand {

  @Override
  protected CommandResponse executeOperation(ShellOperation shellOperation, SessionContext sessionContext) {
    return new StringCommandResponse(sessionContext.getCurrentDirectory());
  }
View Full Code Here

Examples of com.cisco.telnet.server.domain.response.StringCommandResponse

    File destinationDirectoryFile = buildAbsolutePath(currentDirectory, destinationDirectory);

    if (destinationDirectoryFile.exists()) {
      sessionContext.setCurrentDirectory(destinationDirectoryFile.getAbsolutePath());
      // return the new dir message
      return new StringCommandResponse("New directory:" + destinationDirectory);
    } else {
      // Error
      return buildErrorResponse(shellOperation, destinationDirectory + NO_SUCH_FILE_OR_DIRECTORY_MESSAGE);
    }
  }
View Full Code Here

Examples of com.cisco.telnet.server.domain.response.StringCommandResponse

    when(connection.getRemoteSocketAddress()).thenReturn(new InetSocketAddress(1111));

    when(commandFactory.getCommand(PWD)).thenReturn(pwdCommand);
    anyRequest = Matchers.any();
    sessionContext = Matchers.any();
    CommandResponse anyResponse = new StringCommandResponse(TMP_DIR);
    when(pwdCommand.execute(anyRequest, sessionContext)).thenReturn(anyResponse);

    requestProcessorTask.call();
    // Should exist because the second call to the test reader will return
    // null
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.