* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017 Amdocs
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.sa.rest;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import org.json.simple.JSONObject;
-import org.onap.aai.sa.rest.AnalysisConfiguration;
-import org.onap.aai.sa.rest.BulkRequest;
import org.onap.aai.sa.searchdbabstraction.elasticsearch.dao.DocumentStoreDataEntity;
import org.onap.aai.sa.searchdbabstraction.elasticsearch.dao.DocumentStoreInterface;
import org.onap.aai.sa.searchdbabstraction.elasticsearch.exception.DocumentStoreOperationException;
-import org.onap.aai.sa.searchdbabstraction.entity.*;
-import org.onap.aai.sa.searchdbabstraction.util.DocumentSchemaUtil;
import org.onap.aai.sa.searchdbabstraction.entity.Document;
-import org.onap.aai.sa.rest.DocumentSchema;
-
-import java.util.HashMap;
-import java.util.Map;
+import org.onap.aai.sa.searchdbabstraction.entity.DocumentOperationResult;
+import org.onap.aai.sa.searchdbabstraction.entity.OperationResult;
+import org.onap.aai.sa.searchdbabstraction.entity.SearchHit;
+import org.onap.aai.sa.searchdbabstraction.entity.SearchHits;
+import org.onap.aai.sa.searchdbabstraction.entity.SearchOperationResult;
+import org.onap.aai.sa.searchdbabstraction.util.DocumentSchemaUtil;
/**
* This class implements a stubbed version of the document store DAO so
OperationResult opResult = new OperationResult();
opResult.setResultCode(200);
- opResult.setResult(index + "@" + analysisConfig.getEsIndexSettings() + "@"
- + DocumentSchemaUtil.generateDocumentMappings(documentSchema));
+ try {
+ opResult.setResult(index + "@" + analysisConfig.getEsIndexSettings() + "@"
+ + DocumentSchemaUtil.generateDocumentMappings(documentSchema));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return opResult;
+ }
+ @Override
+ public OperationResult createDynamicIndex(String index, String dynamicSchema) {
+ OperationResult opResult = new OperationResult();
+ opResult.setResultCode(200);
+ // Directly return the json as this flow should not edit the json in any way
+ opResult.setResult(dynamicSchema);
return opResult;
}
if (opResult.getDocument() != null) {
opResult.getDocument().setEtag(null);
opResult.getDocument().setUrl(null);
+ opResult.setResultVersion("1");
}
opResult.setResultCode(200);
opResult.setResult(indexName + "@" + document.getId());
+ opResult.setResultVersion("1");
}
return opResult;
if (indexName.equals(DOES_NOT_EXIST_INDEX)) {
opResult.setResultCode(404);
+ // Adding it to make the tests pass.
+ opResult.setResultVersion ("1");
} else {
opResult.setResultCode(200);
+ // Adding it to make the tests pass.
+ opResult.setResultVersion ("1");
}
return opResult;
return opResult;
}
+ @Override
+ public SearchOperationResult suggestionQueryWithPayload(String indexName, String query)
+ throws DocumentStoreOperationException {
+ SearchOperationResult opResult = new SearchOperationResult();
+
+ if (indexName.equals(DOES_NOT_EXIST_INDEX)) {
+ opResult.setResultCode(404);
+ } else {
+ opResult.setResultCode(200);
+ opResult.setResult(indexName + "@" + query);
+ }
+
+ return opResult;
+ }
+
@Override
public OperationResult performBulkOperations(BulkRequest[] requests) throws DocumentStoreOperationException {