Skip to content
Snippets Groups Projects
Commit 76747a90 authored by Lukáš Majdan's avatar Lukáš Majdan
Browse files

Merge branch 'develop' into 'master'

Merge Develop into Master

See merge request muni-kypo-crp/backend-java/kypo-elasticsearch-service!72
parents 687e66c8 cccd5c3c
No related branches found
No related tags found
No related merge requests found
2.1.1 Updated command filtering with optional command type parameter.
22.12-rc.1 Changed sandboxId type to string. 22.12-rc.1 Changed sandboxId type to string.
2.1.0 Added option to filter commands retrieved from elasticsearch, removed stacktrace from errors. 2.1.0 Added option to filter commands retrieved from elasticsearch, removed stacktrace from errors.
2.0.2 Bump version of the rest high client to prevent warnings, added parameter case insensitive to wildcard queries. 2.0.2 Bump version of the rest high client to prevent warnings, added parameter case insensitive to wildcard queries.
......
package cz.muni.ics.kypo.elasticsearch.data; package cz.muni.ics.kypo.elasticsearch.data;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import cz.muni.ics.kypo.elasticsearch.data.enums.CommandType;
import cz.muni.ics.kypo.elasticsearch.data.exceptions.ElasticsearchTrainingDataLayerException; import cz.muni.ics.kypo.elasticsearch.data.exceptions.ElasticsearchTrainingDataLayerException;
import cz.muni.ics.kypo.elasticsearch.data.indexpaths.AbstractKypoElasticTermQueryFields; import cz.muni.ics.kypo.elasticsearch.data.indexpaths.AbstractKypoElasticTermQueryFields;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
...@@ -59,12 +60,14 @@ public class TrainingConsoleCommandsDao extends AbstractElasticClientDAO { ...@@ -59,12 +60,14 @@ public class TrainingConsoleCommandsDao extends AbstractElasticClientDAO {
/** /**
* Find all bash commands from a pool by its id. * Find all bash commands from a pool by its id.
* *
* @param index index used to search for commands * @param index index used to search for commands
* @param filterCommands list of commands to filter
* @param commandType type of filtered commands
* @return the list * @return the list
* @throws ElasticsearchTrainingDataLayerException the elasticsearch training data layer exception * @throws ElasticsearchTrainingDataLayerException the elasticsearch training data layer exception
* @throws IOException the io exception * @throws IOException the io exception
*/ */
public List<Map<String, Object>> findAllConsoleCommands(String index, List<String> filterCommands) throws ElasticsearchTrainingDataLayerException, IOException { public List<Map<String, Object>> findAllConsoleCommands(String index, List<String> filterCommands, CommandType commandType) throws ElasticsearchTrainingDataLayerException, IOException {
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.sort(AbstractKypoElasticTermQueryFields.KYPO_ELASTICSEARCH_TIMESTAMP_STR, SortOrder.ASC); searchSourceBuilder.sort(AbstractKypoElasticTermQueryFields.KYPO_ELASTICSEARCH_TIMESTAMP_STR, SortOrder.ASC);
searchSourceBuilder.size(indexDocumentsMaxReturnNumber); searchSourceBuilder.size(indexDocumentsMaxReturnNumber);
...@@ -72,6 +75,10 @@ public class TrainingConsoleCommandsDao extends AbstractElasticClientDAO { ...@@ -72,6 +75,10 @@ public class TrainingConsoleCommandsDao extends AbstractElasticClientDAO {
if(filterCommands != null && !filterCommands.isEmpty()) { if(filterCommands != null && !filterCommands.isEmpty()) {
searchSourceBuilder.query(QueryBuilders.regexpQuery(AbstractKypoElasticTermQueryFields.KYPO_ELASTICSEARCH_COMMAND, StringUtils.collectionToDelimitedString(filterCommands, "|"))); searchSourceBuilder.query(QueryBuilders.regexpQuery(AbstractKypoElasticTermQueryFields.KYPO_ELASTICSEARCH_COMMAND, StringUtils.collectionToDelimitedString(filterCommands, "|")));
} }
if (commandType != null) {
String commandTypeString = commandType.toString().toLowerCase() + "-command";
searchSourceBuilder.query(QueryBuilders.regexpQuery(AbstractKypoElasticTermQueryFields.KYPO_ELASTICSEARCH_COMMAND_TYPE, commandTypeString));
}
SearchRequest searchRequest = new SearchRequest(index); SearchRequest searchRequest = new SearchRequest(index);
searchRequest.source(searchSourceBuilder); searchRequest.source(searchSourceBuilder);
...@@ -98,11 +105,13 @@ public class TrainingConsoleCommandsDao extends AbstractElasticClientDAO { ...@@ -98,11 +105,13 @@ public class TrainingConsoleCommandsDao extends AbstractElasticClientDAO {
* @param index index under which commands from local or cloud sandboxes are stored * @param index index under which commands from local or cloud sandboxes are stored
* @param from the lower bound of the time range (epoch_millis timestamp format) * @param from the lower bound of the time range (epoch_millis timestamp format)
* @param to the upper bound of the time range (epoch_millis timestamp format) * @param to the upper bound of the time range (epoch_millis timestamp format)
* @param filterCommands list of commands to filter
* @param commandType type of filtered commands
* @return the list of commands in given time range * @return the list of commands in given time range
* @throws ElasticsearchTrainingDataLayerException the elasticsearch training data layer exception * @throws ElasticsearchTrainingDataLayerException the elasticsearch training data layer exception
* @throws IOException the io exception * @throws IOException the io exception
*/ */
public List<Map<String, Object>> findAllConsoleCommandsBySandboxAndTimeRange(String index, Long from, Long to, List<String> filterCommands) throws ElasticsearchTrainingDataLayerException, IOException { public List<Map<String, Object>> findAllConsoleCommandsBySandboxAndTimeRange(String index, Long from, Long to, List<String> filterCommands, CommandType commandType) throws ElasticsearchTrainingDataLayerException, IOException {
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.sort(AbstractKypoElasticTermQueryFields.KYPO_ELASTICSEARCH_TIMESTAMP_STR, SortOrder.ASC); searchSourceBuilder.sort(AbstractKypoElasticTermQueryFields.KYPO_ELASTICSEARCH_TIMESTAMP_STR, SortOrder.ASC);
searchSourceBuilder.size(indexDocumentsMaxReturnNumber); searchSourceBuilder.size(indexDocumentsMaxReturnNumber);
...@@ -117,6 +126,11 @@ public class TrainingConsoleCommandsDao extends AbstractElasticClientDAO { ...@@ -117,6 +126,11 @@ public class TrainingConsoleCommandsDao extends AbstractElasticClientDAO {
if(filterCommands != null && !filterCommands.isEmpty()) { if(filterCommands != null && !filterCommands.isEmpty()) {
boolMustQueries.add(QueryBuilders.regexpQuery(AbstractKypoElasticTermQueryFields.KYPO_ELASTICSEARCH_COMMAND, StringUtils.collectionToDelimitedString(filterCommands, "|"))); boolMustQueries.add(QueryBuilders.regexpQuery(AbstractKypoElasticTermQueryFields.KYPO_ELASTICSEARCH_COMMAND, StringUtils.collectionToDelimitedString(filterCommands, "|")));
} }
if (commandType != null) {
String commandTypeString = commandType.toString().toLowerCase() + "-command";
boolMustQueries.add(QueryBuilders.regexpQuery(AbstractKypoElasticTermQueryFields.KYPO_ELASTICSEARCH_COMMAND_TYPE, commandTypeString));
}
searchSourceBuilder.query(boolQueryBuilder); searchSourceBuilder.query(boolQueryBuilder);
SearchRequest searchRequest = new SearchRequest(index); SearchRequest searchRequest = new SearchRequest(index);
......
package cz.muni.ics.kypo.elasticsearch.data.enums;
public enum CommandType {
/**
* Bash command type.
*/
BASH,
/**
* Msfconsole command type.
*/
MSF
}
\ No newline at end of file
...@@ -57,6 +57,10 @@ public abstract class AbstractKypoElasticTermQueryFields { ...@@ -57,6 +57,10 @@ public abstract class AbstractKypoElasticTermQueryFields {
* The constant KYPO_ELASTICSEARCH_EVENT_TYPE. * The constant KYPO_ELASTICSEARCH_EVENT_TYPE.
*/ */
public static final String KYPO_ELASTICSEARCH_EVENT_TYPE = "type"; public static final String KYPO_ELASTICSEARCH_EVENT_TYPE = "type";
/**
* The constant KYPO_ELASTICSEARCH_COMMAND_TYPE.
*/
public static final String KYPO_ELASTICSEARCH_COMMAND_TYPE = "command_type";
/** /**
* The constant KYPO_ELASTICSEARCH_ANSWER_CONTENT. * The constant KYPO_ELASTICSEARCH_ANSWER_CONTENT.
*/ */
......
...@@ -2,6 +2,7 @@ package cz.muni.ics.kypo.elasticsearch.rest.controllers; ...@@ -2,6 +2,7 @@ package cz.muni.ics.kypo.elasticsearch.rest.controllers;
import cz.muni.ics.kypo.elasticsearch.api.exceptions.ResourceNotFoundException; import cz.muni.ics.kypo.elasticsearch.api.exceptions.ResourceNotFoundException;
import cz.muni.ics.kypo.elasticsearch.api.exceptions.ResourceNotModifiedException; import cz.muni.ics.kypo.elasticsearch.api.exceptions.ResourceNotModifiedException;
import cz.muni.ics.kypo.elasticsearch.data.enums.CommandType;
import cz.muni.ics.kypo.elasticsearch.rest.ApiError; import cz.muni.ics.kypo.elasticsearch.rest.ApiError;
import cz.muni.ics.kypo.elasticsearch.service.TrainingConsoleCommandsService; import cz.muni.ics.kypo.elasticsearch.service.TrainingConsoleCommandsService;
import cz.muni.ics.kypo.elasticsearch.service.exceptions.ElasticsearchTrainingServiceLayerException; import cz.muni.ics.kypo.elasticsearch.service.exceptions.ElasticsearchTrainingServiceLayerException;
...@@ -15,9 +16,9 @@ import org.springframework.web.bind.annotation.*; ...@@ -15,9 +16,9 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@Api(value = "/training-platform-commands", @Api(value = "/training-platform-commands",
tags = "Training commands", tags = "Training commands",
consumes = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE,
authorizations = @Authorization(value = "bearerAuth")) authorizations = @Authorization(value = "bearerAuth"))
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 401, message = "Full authentication is required to access this resource.", response = ApiError.class), @ApiResponse(code = 401, message = "Full authentication is required to access this resource.", response = ApiError.class),
...@@ -52,10 +53,12 @@ public class TrainingConsoleCommandsRestController { ...@@ -52,10 +53,12 @@ public class TrainingConsoleCommandsRestController {
@GetMapping(path = "/pools/{poolId}", produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(path = "/pools/{poolId}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> findAllConsoleCommandsByPoolId( public ResponseEntity<Object> findAllConsoleCommandsByPoolId(
@ApiParam(value = "Training pool ID", required = true) @PathVariable("poolId") Long poolId, @ApiParam(value = "Training pool ID", required = true) @PathVariable("poolId") Long poolId,
@ApiParam(value = "List of command to filter", required = false) @ApiParam(value = "List of command to filter")
@RequestParam(value = "commands", required = false) List<String> commands) { @RequestParam(value = "commands", required = false) List<String> commands,
@ApiParam(value = "Command type")
@RequestParam(value = "commandType", required = false) CommandType commandType) {
try { try {
return ResponseEntity.ok(trainingConsoleCommandsService.findAllConsoleCommandsByPoolId(poolId, commands)); return ResponseEntity.ok(trainingConsoleCommandsService.findAllConsoleCommandsByPoolId(poolId, commands, commandType));
} catch (ElasticsearchTrainingServiceLayerException ex) { } catch (ElasticsearchTrainingServiceLayerException ex) {
throw new ResourceNotFoundException(ex); throw new ResourceNotFoundException(ex);
} }
...@@ -80,10 +83,12 @@ public class TrainingConsoleCommandsRestController { ...@@ -80,10 +83,12 @@ public class TrainingConsoleCommandsRestController {
@GetMapping(path = "/access-tokens/{accessToken}", produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(path = "/access-tokens/{accessToken}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> findAllConsoleCommandsByAccessToken( public ResponseEntity<Object> findAllConsoleCommandsByAccessToken(
@ApiParam(value = "Training access token.", required = true) @PathVariable("accessToken") String accessToken, @ApiParam(value = "Training access token.", required = true) @PathVariable("accessToken") String accessToken,
@ApiParam(value = "List of command to filter", required = false) @ApiParam(value = "List of command to filter")
@RequestParam(value = "commands", required = false) List<String> commands) { @RequestParam(value = "commands", required = false) List<String> commands,
@ApiParam(value = "Command type")
@RequestParam(value = "commandType", required = false) CommandType commandType) {
try { try {
return ResponseEntity.ok(trainingConsoleCommandsService.findAllConsoleCommandsByAccessToken(accessToken, commands)); return ResponseEntity.ok(trainingConsoleCommandsService.findAllConsoleCommandsByAccessToken(accessToken, commands, commandType));
} catch (ElasticsearchTrainingServiceLayerException ex) { } catch (ElasticsearchTrainingServiceLayerException ex) {
throw new ResourceNotFoundException(ex); throw new ResourceNotFoundException(ex);
} }
...@@ -108,9 +113,11 @@ public class TrainingConsoleCommandsRestController { ...@@ -108,9 +113,11 @@ public class TrainingConsoleCommandsRestController {
public ResponseEntity<Object> findAllConsoleCommandsBySandboxId( public ResponseEntity<Object> findAllConsoleCommandsBySandboxId(
@ApiParam(value = "Training sandbox ID", required = true) @PathVariable("sandboxId") String sandboxId, @ApiParam(value = "Training sandbox ID", required = true) @PathVariable("sandboxId") String sandboxId,
@ApiParam(value = "List of command to filter", required = false) @ApiParam(value = "List of command to filter", required = false)
@RequestParam(value = "commands", required = false) List<String> commands) { @RequestParam(value = "commands", required = false) List<String> commands,
@ApiParam(value = "Command type")
@RequestParam(value = "commandType", required = false) CommandType commandType) {
try { try {
return ResponseEntity.ok(trainingConsoleCommandsService.findAllConsoleCommandsBySandboxId(sandboxId, commands)); return ResponseEntity.ok(trainingConsoleCommandsService.findAllConsoleCommandsBySandboxId(sandboxId, commands, commandType));
} catch (ElasticsearchTrainingServiceLayerException ex) { } catch (ElasticsearchTrainingServiceLayerException ex) {
throw new ResourceNotFoundException(ex); throw new ResourceNotFoundException(ex);
} }
...@@ -120,7 +127,7 @@ public class TrainingConsoleCommandsRestController { ...@@ -120,7 +127,7 @@ public class TrainingConsoleCommandsRestController {
* Get all training commands specified by an access token and user identifier. * Get all training commands specified by an access token and user identifier.
* *
* @param accessToken access token of the training instance * @param accessToken access token of the training instance
* @param userId identifier of the user * @param userId identifier of the user
* @return all commands executed during training. * @return all commands executed during training.
*/ */
@ApiOperation(httpMethod = "GET", @ApiOperation(httpMethod = "GET",
...@@ -136,10 +143,13 @@ public class TrainingConsoleCommandsRestController { ...@@ -136,10 +143,13 @@ public class TrainingConsoleCommandsRestController {
public ResponseEntity<Object> findAllConsoleCommandsByAccessTokenAndUserId( public ResponseEntity<Object> findAllConsoleCommandsByAccessTokenAndUserId(
@ApiParam(value = "Training instance access token", required = true) @PathVariable("accessToken") String accessToken, @ApiParam(value = "Training instance access token", required = true) @PathVariable("accessToken") String accessToken,
@ApiParam(value = "User identifier", required = true) @PathVariable("userId") Long userId, @ApiParam(value = "User identifier", required = true) @PathVariable("userId") Long userId,
@ApiParam(value = "List of command to filter", required = false) @ApiParam(value = "List of command to filter")
@RequestParam(value = "commands", required = false) List<String> commands) { @RequestParam(value = "commands", required = false) List<String> commands,
@ApiParam(value = "Command type")
@RequestParam(value = "commandType", required = false) CommandType commandType) {
try { try {
return ResponseEntity.ok(trainingConsoleCommandsService.findAllConsoleCommandsByAccessTokenAndUserId(accessToken, userId, commands)); return ResponseEntity.ok(trainingConsoleCommandsService
.findAllConsoleCommandsByAccessTokenAndUserId(accessToken, userId, commands, commandType));
} catch (ElasticsearchTrainingServiceLayerException ex) { } catch (ElasticsearchTrainingServiceLayerException ex) {
throw new ResourceNotFoundException(ex); throw new ResourceNotFoundException(ex);
} }
...@@ -169,10 +179,13 @@ public class TrainingConsoleCommandsRestController { ...@@ -169,10 +179,13 @@ public class TrainingConsoleCommandsRestController {
@RequestParam(value = "from") Long from, @RequestParam(value = "from") Long from,
@ApiParam(value = "Upper bound of the time range (timestamp in epoch_millis format) of the the resulting console commands.", required = true) @ApiParam(value = "Upper bound of the time range (timestamp in epoch_millis format) of the the resulting console commands.", required = true)
@RequestParam(value = "to") Long to, @RequestParam(value = "to") Long to,
@ApiParam(value = "List of command to filter", required = false) @ApiParam(value = "List of command to filter")
@RequestParam(value = "commands", required = false) List<String> commands) { @RequestParam(value = "commands", required = false) List<String> commands,
@ApiParam(value = "Command type")
@RequestParam(value = "commandType", required = false) CommandType commandType) {
try { try {
return ResponseEntity.ok(trainingConsoleCommandsService.findAllConsoleCommandsBySandboxIdAndTimeRange(sandboxId, from, to, commands)); return ResponseEntity.ok(trainingConsoleCommandsService
.findAllConsoleCommandsBySandboxIdAndTimeRange(sandboxId, from, to, commands, commandType));
} catch (ElasticsearchTrainingServiceLayerException ex) { } catch (ElasticsearchTrainingServiceLayerException ex) {
throw new ResourceNotFoundException(ex); throw new ResourceNotFoundException(ex);
} }
...@@ -182,9 +195,9 @@ public class TrainingConsoleCommandsRestController { ...@@ -182,9 +195,9 @@ public class TrainingConsoleCommandsRestController {
* Get all commands aggregated by timestamp ranges of training specified by access token and user identifier. * Get all commands aggregated by timestamp ranges of training specified by access token and user identifier.
* *
* @param accessToken access token of the training instance * @param accessToken access token of the training instance
* @param userId identifier of the user * @param userId identifier of the user
* @param from the lower bound of the time range * @param from the lower bound of the time range
* @param to the upper bound of the time range * @param to the upper bound of the time range
* @return all commands in selected sandbox. * @return all commands in selected sandbox.
*/ */
@ApiOperation(httpMethod = "GET", @ApiOperation(httpMethod = "GET",
...@@ -204,10 +217,13 @@ public class TrainingConsoleCommandsRestController { ...@@ -204,10 +217,13 @@ public class TrainingConsoleCommandsRestController {
@RequestParam(value = "from") Long from, @RequestParam(value = "from") Long from,
@ApiParam(value = "Upper bound of the time range (timestamp in epoch_millis format) of the the resulting console commands.", required = true) @ApiParam(value = "Upper bound of the time range (timestamp in epoch_millis format) of the the resulting console commands.", required = true)
@RequestParam(value = "to") Long to, @RequestParam(value = "to") Long to,
@ApiParam(value = "List of command to filter", required = false) @ApiParam(value = "List of command to filter")
@RequestParam(value = "commands", required = false) List<String> commands) { @RequestParam(value = "commands", required = false) List<String> commands,
@ApiParam(value = "Command type")
@RequestParam(value = "commandType", required = false) CommandType commandType) {
try { try {
return ResponseEntity.ok(trainingConsoleCommandsService.findAllConsoleCommandsByAccessTokenAndUserIdAndTimeRange(accessToken, userId, from, to, commands)); return ResponseEntity.ok(trainingConsoleCommandsService
.findAllConsoleCommandsByAccessTokenAndUserIdAndTimeRange(accessToken, userId, from, to, commands, commandType));
} catch (ElasticsearchTrainingServiceLayerException ex) { } catch (ElasticsearchTrainingServiceLayerException ex) {
throw new ResourceNotFoundException(ex); throw new ResourceNotFoundException(ex);
} }
...@@ -293,7 +309,7 @@ public class TrainingConsoleCommandsRestController { ...@@ -293,7 +309,7 @@ public class TrainingConsoleCommandsRestController {
* Delete all commands executed in the training specified by access token and user identifier. * Delete all commands executed in the training specified by access token and user identifier.
* *
* @param accessToken access token of the training instance * @param accessToken access token of the training instance
* @param userId identifier of the user * @param userId identifier of the user
* @return Confirmation that the request process is ok. * @return Confirmation that the request process is ok.
*/ */
@ApiOperation(httpMethod = "DELETE", @ApiOperation(httpMethod = "DELETE",
......
package cz.muni.ics.kypo.elasticsearch.service; package cz.muni.ics.kypo.elasticsearch.service;
import cz.muni.ics.kypo.elasticsearch.data.TrainingConsoleCommandsDao; import cz.muni.ics.kypo.elasticsearch.data.TrainingConsoleCommandsDao;
import cz.muni.ics.kypo.elasticsearch.data.enums.CommandType;
import cz.muni.ics.kypo.elasticsearch.data.exceptions.ElasticsearchTrainingDataLayerException; import cz.muni.ics.kypo.elasticsearch.data.exceptions.ElasticsearchTrainingDataLayerException;
import cz.muni.ics.kypo.elasticsearch.data.indexpaths.AbstractKypoIndexPath; import cz.muni.ics.kypo.elasticsearch.data.indexpaths.AbstractKypoIndexPath;
import cz.muni.ics.kypo.elasticsearch.service.exceptions.ElasticsearchTrainingServiceLayerException; import cz.muni.ics.kypo.elasticsearch.service.exceptions.ElasticsearchTrainingServiceLayerException;
...@@ -24,49 +25,49 @@ public class TrainingConsoleCommandsService { ...@@ -24,49 +25,49 @@ public class TrainingConsoleCommandsService {
this.trainingConsoleCommandsDao = trainingConsoleCommandsDao; this.trainingConsoleCommandsDao = trainingConsoleCommandsDao;
} }
public List<Map<String, Object>> findAllConsoleCommandsByPoolId(Long poolId, List<String> filterCommands) { public List<Map<String, Object>> findAllConsoleCommandsByPoolId(Long poolId, List<String> filterCommands, CommandType commandType) {
try { try {
return trainingConsoleCommandsDao.findAllConsoleCommands(AbstractKypoIndexPath.KYPO_CONSOLE_COMMANDS_INDEX + "*" + ".pool=" + poolId + ".*", filterCommands); return trainingConsoleCommandsDao.findAllConsoleCommands(AbstractKypoIndexPath.KYPO_CONSOLE_COMMANDS_INDEX + "*" + ".pool=" + poolId + ".*", filterCommands, commandType);
} catch (ElasticsearchTrainingDataLayerException | IOException ex) { } catch (ElasticsearchTrainingDataLayerException | IOException ex) {
throw new ElasticsearchTrainingServiceLayerException(ex); throw new ElasticsearchTrainingServiceLayerException(ex);
} }
} }
public List<Map<String, Object>> findAllConsoleCommandsByAccessToken(String accessToken, List<String> filterCommands) { public List<Map<String, Object>> findAllConsoleCommandsByAccessToken(String accessToken, List<String> filterCommands, CommandType commandType) {
try { try {
return trainingConsoleCommandsDao.findAllConsoleCommands(AbstractKypoIndexPath.KYPO_CONSOLE_COMMANDS_INDEX + "*" + ".access-token=" + accessToken + ".*", filterCommands); return trainingConsoleCommandsDao.findAllConsoleCommands(AbstractKypoIndexPath.KYPO_CONSOLE_COMMANDS_INDEX + "*" + ".access-token=" + accessToken + ".*", filterCommands, commandType);
} catch (ElasticsearchTrainingDataLayerException | IOException ex) { } catch (ElasticsearchTrainingDataLayerException | IOException ex) {
throw new ElasticsearchTrainingServiceLayerException(ex); throw new ElasticsearchTrainingServiceLayerException(ex);
} }
} }
public List<Map<String, Object>> findAllConsoleCommandsBySandboxId(String sandboxId, List<String> filterCommands) { public List<Map<String, Object>> findAllConsoleCommandsBySandboxId(String sandboxId, List<String> filterCommands, CommandType commandType) {
try { try {
return trainingConsoleCommandsDao.findAllConsoleCommands(AbstractKypoIndexPath.KYPO_CONSOLE_COMMANDS_INDEX + "*" + ".sandbox=" + sandboxId, filterCommands); return trainingConsoleCommandsDao.findAllConsoleCommands(AbstractKypoIndexPath.KYPO_CONSOLE_COMMANDS_INDEX + "*" + ".sandbox=" + sandboxId, filterCommands, commandType);
} catch (ElasticsearchTrainingDataLayerException | IOException ex) { } catch (ElasticsearchTrainingDataLayerException | IOException ex) {
throw new ElasticsearchTrainingServiceLayerException(ex); throw new ElasticsearchTrainingServiceLayerException(ex);
} }
} }
public List<Map<String, Object>> findAllConsoleCommandsByAccessTokenAndUserId(String accessToken, Long userId, List<String> filterCommands) { public List<Map<String, Object>> findAllConsoleCommandsByAccessTokenAndUserId(String accessToken, Long userId, List<String> filterCommands, CommandType commandType) {
try { try {
return trainingConsoleCommandsDao.findAllConsoleCommands(AbstractKypoIndexPath.KYPO_CONSOLE_COMMANDS_INDEX + "*" + ".access-token=" + accessToken + ".user=" + userId, filterCommands); return trainingConsoleCommandsDao.findAllConsoleCommands(AbstractKypoIndexPath.KYPO_CONSOLE_COMMANDS_INDEX + "*" + ".access-token=" + accessToken + ".user=" + userId, filterCommands, commandType);
} catch (ElasticsearchTrainingDataLayerException | IOException ex) { } catch (ElasticsearchTrainingDataLayerException | IOException ex) {
throw new ElasticsearchTrainingServiceLayerException(ex); throw new ElasticsearchTrainingServiceLayerException(ex);
} }
} }
public List<Map<String, Object>> findAllConsoleCommandsBySandboxIdAndTimeRange(String sandboxId, Long from, Long to, List<String> filterCommands) { public List<Map<String, Object>> findAllConsoleCommandsBySandboxIdAndTimeRange(String sandboxId, Long from, Long to, List<String> filterCommands, CommandType commandType) {
try { try {
return trainingConsoleCommandsDao.findAllConsoleCommandsBySandboxAndTimeRange(AbstractKypoIndexPath.KYPO_CONSOLE_COMMANDS_INDEX + "*" + ".sandbox=" + sandboxId, from, to, filterCommands); return trainingConsoleCommandsDao.findAllConsoleCommandsBySandboxAndTimeRange(AbstractKypoIndexPath.KYPO_CONSOLE_COMMANDS_INDEX + "*" + ".sandbox=" + sandboxId, from, to, filterCommands, commandType);
} catch (ElasticsearchTrainingDataLayerException | IOException ex) { } catch (ElasticsearchTrainingDataLayerException | IOException ex) {
throw new ElasticsearchTrainingServiceLayerException(ex); throw new ElasticsearchTrainingServiceLayerException(ex);
} }
} }
public List<Map<String, Object>> findAllConsoleCommandsByAccessTokenAndUserIdAndTimeRange(String accessToken, Long userId, Long from, Long to, List<String> filterCommands) { public List<Map<String, Object>> findAllConsoleCommandsByAccessTokenAndUserIdAndTimeRange(String accessToken, Long userId, Long from, Long to, List<String> filterCommands, CommandType commandType) {
try { try {
return trainingConsoleCommandsDao.findAllConsoleCommandsBySandboxAndTimeRange(AbstractKypoIndexPath.KYPO_CONSOLE_COMMANDS_INDEX + "*" + ".access-token=" + accessToken + ".user=" + userId, from, to, filterCommands); return trainingConsoleCommandsDao.findAllConsoleCommandsBySandboxAndTimeRange(AbstractKypoIndexPath.KYPO_CONSOLE_COMMANDS_INDEX + "*" + ".access-token=" + accessToken + ".user=" + userId, from, to, filterCommands, commandType);
} catch (ElasticsearchTrainingDataLayerException | IOException ex) { } catch (ElasticsearchTrainingDataLayerException | IOException ex) {
throw new ElasticsearchTrainingServiceLayerException(ex); throw new ElasticsearchTrainingServiceLayerException(ex);
} }
...@@ -103,4 +104,4 @@ public class TrainingConsoleCommandsService { ...@@ -103,4 +104,4 @@ public class TrainingConsoleCommandsService {
} }
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment