* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
throw e;
}
}
+ private boolean isAlphaNumeric(String query){
+ return query.matches("[a-zA-Z_0-9]+");
+ }
@Override
public JestResult search(PolicyIndexType type, String text) throws IllegalStateException, IllegalArgumentException {
throw new IllegalArgumentException("No search string provided");
}
+ if(!isAlphaNumeric(text)){
+ throw new IllegalArgumentException("Search must be alpha numeric");
+ }
+
QueryStringQueryBuilder mQ = QueryBuilders.queryStringQuery("*"+text+"*");
SearchSourceBuilder searchSourceBuilder =
new SearchSourceBuilder().query(mQ);
String errorMessage = result.getErrorMessage();
if (errorMessage != null && !errorMessage.isEmpty()) {
- String xMessage = errorMessage;
+ String xMessage;
if (errorMessage.contains("TokenMgrError")) {
int indexError = errorMessage.lastIndexOf("TokenMgrError");
xMessage = "Invalid Search Expression. Details: " + errorMessage.substring(indexError);
return search(type, text);
}
+ if(!isAlphaNumeric(text)){
+ throw new IllegalArgumentException("Search must be alpha numeric");
+ }
+
String matches_s = "";
matches_s = "{\n" +
" \"size\" : "+ ElkConnectorImpl.QUERY_MAXRECORDS + ",\n" +
if (result.isSucceeded()) {
if (LOGGER.isInfoEnabled())
- LOGGER.info("OK: PUT operation of " + "->" + ": " +
+ LOGGER.info("ElkConnector: OK: PUT operation of " + "->" + ": " +
"success=" + result.isSucceeded() + "[" + result.getResponseCode() + ":" +
result.getPathToResult() + "]" + System.lineSeparator() +
result.getJsonString());
} else {
if (LOGGER.isWarnEnabled())
- LOGGER.warn("FAILURE: PUT operation of "+ "->" + ": " +
+ LOGGER.warn("ElkConnector: FAILURE: PUT operation of "+ "->" + ": " +
"success=" + result.isSucceeded() + "[" + result.getResponseCode() + ":" +
result.getPathToResult() + "]" + System.lineSeparator() +
result.getJsonString());