test_class.declarator: igniteHome = System.getProperty("user.dir")
test_class.modifier: private
test_class.original_string: private String igniteHome = System.getProperty("user.dir");
test_class.type: String
test_class.var_name: igniteHome
test_class.file: modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java
test_class.identifier: GridLogCommandHandlerTest
test_class.superclass: extends GridCommonAbstractTest
test_case.body: @Test
      public void testHandleAsync() throws Exception {
          IgniteConfiguration cfg = new IgniteConfiguration();
          cfg.setIgniteHome(igniteHome);
          GridTestKernalContext ctx = newContext(cfg);
          GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
          GridRestLogRequest req = new GridRestLogRequest();
  
          req.to(5);
          req.from(2);
  
          req.path(igniteHome + "/work/log/" + "test.log");
          IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
  
          assertNull(resp.result().getError());
          assertEquals(GridRestResponse.STATUS_SUCCESS, resp.result().getSuccessStatus());
          assertNotNull(resp.result().getResponse());
      }
test_case.class_method_signature: GridLogCommandHandlerTest.testHandleAsync()
test_case.full_signature: @Test public void testHandleAsync()
test_case.identifier: testHandleAsync
test_case.invocations: setIgniteHome newContext to from path handleAsync assertNull getError result assertEquals getSuccessStatus result assertNotNull getResponse result
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testHandleAsync()
focal_class.declarator: SUPPORTED_COMMANDS = U.sealList(LOG)
focal_class.modifier: private static final
focal_class.original_string: private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(LOG);
focal_class.type: Collection<GridRestCommand>
focal_class.var_name: SUPPORTED_COMMANDS
focal_class.declarator: DEFAULT_FROM = 0
focal_class.modifier: private static final
focal_class.original_string: private static final int DEFAULT_FROM = 0;
focal_class.type: int
focal_class.var_name: DEFAULT_FROM
focal_class.declarator: DEFAULT_TO = 1
focal_class.modifier: private static final
focal_class.original_string: private static final int DEFAULT_TO = 1;
focal_class.type: int
focal_class.var_name: DEFAULT_TO
focal_class.file: modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandler.java
focal_class.identifier: GridLogCommandHandler
focal_class.class_method_signature: GridLogCommandHandler.GridLogCommandHandler(GridKernalContext ctx)
focal_class.full_signature: public  GridLogCommandHandler(GridKernalContext ctx)
focal_class.identifier: GridLogCommandHandler
focal_class.modifiers: public
focal_class.parameters: (GridKernalContext ctx)
focal_class.signature:  GridLogCommandHandler(GridKernalContext ctx)
focal_class.class_method_signature: GridLogCommandHandler.supportedCommands()
focal_class.full_signature: @Override public Collection<GridRestCommand> supportedCommands()
focal_class.identifier: supportedCommands
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Collection<GridRestCommand>
focal_class.signature: Collection<GridRestCommand> supportedCommands()
focal_class.class_method_signature: GridLogCommandHandler.handleAsync(GridRestRequest req)
focal_class.full_signature: @Override public IgniteInternalFuture<GridRestResponse> handleAsync(GridRestRequest req)
focal_class.identifier: handleAsync
focal_class.modifiers: @Override public
focal_class.parameters: (GridRestRequest req)
focal_class.return: IgniteInternalFuture<GridRestResponse>
focal_class.signature: IgniteInternalFuture<GridRestResponse> handleAsync(GridRestRequest req)
focal_class.class_method_signature: GridLogCommandHandler.readLog(int from, int to, File logFile)
focal_class.full_signature: private String readLog(int from, int to, File logFile)
focal_class.identifier: readLog
focal_class.modifiers: private
focal_class.parameters: (int from, int to, File logFile)
focal_class.return: String
focal_class.signature: String readLog(int from, int to, File logFile)
focal_class.superclass: extends GridRestCommandHandlerAdapter
focal_method.body: @Override public IgniteInternalFuture<GridRestResponse> handleAsync(GridRestRequest req) {
          assert req != null;
  
          if (req.command() == LOG) {
              if (log.isDebugEnabled())
                  log.debug("Handling log REST request: " + req);
  
              GridRestLogRequest req0 = (GridRestLogRequest)req;
  
              if (req0.from() < -1 || req0.to() < -1)
                  return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                      "One of the request parameters is invalid [from=" + req0.from() + ", to=" + req0.to() + ']'));
  
              int from;
  
              if (req0.from() != -1) {
                  if (req0.to() == -1)
                      return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                          "Request parameter 'to' is not set."));
  
                  from = req0.from();
              }
              else
                  from = DEFAULT_FROM;
  
              int to;
  
              if (req0.to() != -1) {
                  if (req0.from() == -1)
                      return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                          "Request parameter 'from' is not set."));
  
                  to = req0.to();
              }
              else
                  to = DEFAULT_TO;
  
              if (from >= to)
                  return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                      "Request parameter 'from' must be less than 'to'."));
  
              File logFile;
  
              try {
                  if (req0.path() != null) {
                      if (log.fileName() != null) {
                          if (!req0.path().equals(log.fileName())) {
                              return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                                  "Request parameter 'path' must contain a path to valid log file."));
                          }
                          else
                              logFile = new File(req0.path());
                      }
                      else if (req0.path().startsWith(ctx.config().getIgniteHome()))
                          logFile = new File(req0.path());
                      else {
                          return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                              "Request parameter 'path' must contain a path to valid log file."));
                      }
                  }
                  else if (log.fileName() == null)
                      logFile = new File(ctx.config().getIgniteHome() + "/work/log/ignite.log");
                  else
                      logFile = new File(log.fileName());
              }
              catch (InvalidPathException e) {
                  return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED,
                      "Incorrect path to a log file [msg=" + e.getMessage() + ']'));
              }
  
              try {
                  String content = readLog(from, to, logFile);
  
                  return new GridFinishedFuture<>(new GridRestResponse(content));
              }
              catch (IgniteCheckedException e) {
                  return new GridFinishedFuture<>(new GridRestResponse(GridRestResponse.STATUS_FAILED, e.getMessage()));
              }
          }
  
          return new GridFinishedFuture<>();
      }
focal_method.class_method_signature: GridLogCommandHandler.handleAsync(GridRestRequest req)
focal_method.full_signature: @Override public IgniteInternalFuture<GridRestResponse> handleAsync(GridRestRequest req)
focal_method.identifier: handleAsync
focal_method.invocations: command isDebugEnabled debug from to from to from to from to from to path fileName equals path fileName path startsWith path getIgniteHome config path fileName getIgniteHome config fileName getMessage readLog getMessage
focal_method.modifiers: @Override public
focal_method.parameters: (GridRestRequest req)
focal_method.return: IgniteInternalFuture<GridRestResponse>
focal_method.signature: IgniteInternalFuture<GridRestResponse> handleAsync(GridRestRequest req)