import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
-import org.onap.cps.ncmp.api.impl.config.embeddedcache.TrustLevelCacheConfig;
import org.onap.cps.ncmp.api.impl.exception.InvalidDatastoreException;
import org.onap.cps.ncmp.api.impl.inventory.CompositeState;
import org.onap.cps.ncmp.api.impl.operations.DatastoreType;
import org.onap.cps.ncmp.rest.util.DeprecationHelper;
import org.onap.cps.spi.model.ModuleDefinition;
import org.onap.cps.utils.JsonObjectMapper;
-import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
private final NcmpCachedResourceRequestHandler ncmpCachedResourceRequestHandler;
private final NcmpPassthroughResourceRequestHandler ncmpPassthroughResourceRequestHandler;
private final DataOperationRequestMapper dataOperationRequestMapper;
- @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_CM_HANDLE_BEAN_NAME)
private final Map<String, TrustLevel> trustLevelPerCmHandle;
/**
* @param optionsParamInQuery options query parameter
* @param topicParamInQuery topic query parameter
* @param includeDescendants whether to include descendants or not
+ * @param authorization contents of Authorization header, or null if not present
* @return {@code ResponseEntity} response from dmi plugin
*/
@Override
final String resourceIdentifier,
final String optionsParamInQuery,
final String topicParamInQuery,
- final Boolean includeDescendants) {
+ final Boolean includeDescendants,
+ final String authorization) {
final NcmpDatastoreRequestHandler ncmpDatastoreRequestHandler = getNcmpDatastoreRequestHandler(datastoreName);
return ncmpDatastoreRequestHandler.executeRequest(datastoreName, cmHandle, resourceIdentifier,
- optionsParamInQuery, topicParamInQuery, includeDescendants);
+ optionsParamInQuery, topicParamInQuery, includeDescendants, authorization);
}
@Override
public ResponseEntity<Object> executeDataOperationForCmHandles(final String topicParamInQuery,
- final DataOperationRequest
- dataOperationRequest) {
+ final DataOperationRequest dataOperationRequest,
+ final String authorization) {
return ncmpPassthroughResourceRequestHandler.executeRequest(topicParamInQuery,
- dataOperationRequestMapper.toDataOperationRequest(dataOperationRequest));
+ dataOperationRequestMapper.toDataOperationRequest(dataOperationRequest), authorization);
}
/**
* @param resourceIdentifier resource identifier
* @param requestBody the request body
* @param contentType content type of body
+ * @param authorization contents of Authorization header, or null if not present
* @return {@code ResponseEntity} response from dmi plugin
*/
final String cmHandle,
final String resourceIdentifier,
final Object requestBody,
- final String contentType) {
+ final String contentType,
+ final String authorization) {
validateDataStore(PASSTHROUGH_RUNNING, datastoreName);
final Object responseObject = networkCmProxyDataService
.writeResourceDataPassThroughRunningForCmHandle(
cmHandle, resourceIdentifier, PATCH,
- jsonObjectMapper.asJsonString(requestBody), contentType);
+ jsonObjectMapper.asJsonString(requestBody), contentType, authorization);
return ResponseEntity.ok(responseObject);
}
* @param resourceIdentifier resource identifier
* @param requestBody the request body
* @param contentType content type of body
+ * @param authorization contents of Authorization header, or null if not present
* @return {@code ResponseEntity} response from dmi plugin
*/
@Override
final String cmHandle,
final String resourceIdentifier,
final Object requestBody,
- final String contentType) {
-
+ final String contentType,
+ final String authorization) {
validateDataStore(PASSTHROUGH_RUNNING, datastoreName);
networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
- resourceIdentifier, CREATE, jsonObjectMapper.asJsonString(requestBody), contentType);
+ resourceIdentifier, CREATE, jsonObjectMapper.asJsonString(requestBody), contentType, authorization);
return new ResponseEntity<>(HttpStatus.CREATED);
}
* @param resourceIdentifier resource identifier
* @param requestBody the request body
* @param contentType content type of the body
+ * @param authorization contents of Authorization header, or null if not present
* @return response entity
*/
final String cmHandle,
final String resourceIdentifier,
final Object requestBody,
- final String contentType) {
+ final String contentType,
+ final String authorization) {
validateDataStore(PASSTHROUGH_RUNNING, datastoreName);
networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
- resourceIdentifier, UPDATE, jsonObjectMapper.asJsonString(requestBody), contentType);
+ resourceIdentifier, UPDATE, jsonObjectMapper.asJsonString(requestBody), contentType, authorization);
return new ResponseEntity<>(HttpStatus.OK);
}
* @param cmHandle cm handle identifier
* @param resourceIdentifier resource identifier
* @param contentType content type of the body
+ * @param authorization contents of Authorization header, or null if not present
* @return response entity no content if request is successful
*/
@Override
public ResponseEntity<Void> deleteResourceDataRunningForCmHandle(final String datastoreName,
final String cmHandle,
final String resourceIdentifier,
- final String contentType) {
+ final String contentType,
+ final String authorization) {
validateDataStore(PASSTHROUGH_RUNNING, datastoreName);
networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
- resourceIdentifier, DELETE, NO_BODY, contentType);
+ resourceIdentifier, DELETE, NO_BODY, contentType, authorization);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}