final YangModelCmHandle yangModelCmHandle = getAndValidateYangModelCmHandle(requestParameters);
final UrlTemplateParameters urlTemplateParameters = parametersBuilder.createUrlTemplateParametersForRead(
yangModelCmHandle, requestParameters.fdn(), scope, filter, attributes, fields, dataNodeSelector);
- return dmiRestClient.synchronousGetOperation(DATA, urlTemplateParameters);
+ return dmiRestClient.synchronousGetOperation(DATA,
+ urlTemplateParameters, requestParameters.authorization());
} catch (final Exception exception) {
throw toProvMnSException(httpServletRequest.getMethod(), exception, NO_OP);
}
final UrlTemplateParameters urlTemplateParameters =
parametersBuilder.createUrlTemplateParametersForWrite(yangModelCmHandle, requestParameters.fdn());
return dmiRestClient.synchronousPatchOperation(DATA, patchItems, urlTemplateParameters,
- httpServletRequest.getContentType());
+ httpServletRequest.getContentType(), requestParameters.authorization());
} catch (final Exception exception) {
throw toProvMnSException(httpServletRequest.getMethod(), exception, NO_OP);
}
checkPermission(yangModelCmHandle, operationDetails, requestParameters);
final UrlTemplateParameters urlTemplateParameters =
parametersBuilder.createUrlTemplateParametersForWrite(yangModelCmHandle, requestParameters.fdn());
- return dmiRestClient.synchronousPutOperation(DATA, resource, urlTemplateParameters);
+ return dmiRestClient.synchronousPutOperation(DATA, resource,
+ urlTemplateParameters, requestParameters.authorization());
} catch (final Exception exception) {
throw toProvMnSException(httpServletRequest.getMethod(), exception, NO_OP);
}
checkPermission(yangModelCmHandle, operationDetails, requestParameters);
final UrlTemplateParameters urlTemplateParameters =
parametersBuilder.createUrlTemplateParametersForWrite(yangModelCmHandle, requestParameters.fdn());
- return dmiRestClient.synchronousDeleteOperation(DATA, urlTemplateParameters);
+ return dmiRestClient.synchronousDeleteOperation(DATA,
+ urlTemplateParameters, requestParameters.authorization());
} catch (final Exception exception) {
throw toProvMnSException(httpServletRequest.getMethod(), exception, NO_OP);
}
*
* @param requiredDmiService Determines if the required service is for a data or model operation.
* @param urlTemplateParameters The DMI resource URL template with variables.
+ * @param authorization The authorization token to be added to the request headers.
* @return ResponseEntity containing the response from the DMI.
*/
public ResponseEntity<Object> synchronousGetOperation(final RequiredDmiService requiredDmiService,
- final UrlTemplateParameters urlTemplateParameters) {
+ final UrlTemplateParameters urlTemplateParameters,
+ final String authorization) {
return getWebClient(requiredDmiService)
.get()
.uri(urlTemplateParameters.urlTemplate(), urlTemplateParameters.urlVariables())
- .headers(httpHeaders -> configureHttpHeaders(httpHeaders, NO_AUTHORIZATION))
+ .headers(httpHeaders -> configureHttpHeaders(httpHeaders, authorization))
.exchangeToMono(this::createIdenticalResponseForClient)
.block();
}
* @param requiredDmiService Determines if the required service is for a data or model operation.
* @param body resource object to be forwarded.
* @param urlTemplateParameters The DMI resource URL template with variables.
+ * @param authorization The authorization token to be added to the request headers.
* @return ResponseEntity containing the response from the DMI.
*/
public ResponseEntity<Object> synchronousPutOperation(final RequiredDmiService requiredDmiService,
final Object body,
- final UrlTemplateParameters urlTemplateParameters) {
+ final UrlTemplateParameters urlTemplateParameters,
+ final String authorization) {
return getWebClient(requiredDmiService)
.put()
.uri(urlTemplateParameters.urlTemplate(), urlTemplateParameters.urlVariables())
* @param body object
* @param urlTemplateParameters The DMI resource URL template with variables.
* @param contentType Content type example: application/json
+ * @param authorization The authorization token to be added to the request headers.
* @return ResponseEntity containing the response from the DMI.
*/
public ResponseEntity<Object> synchronousPatchOperation(final RequiredDmiService requiredDmiService,
final Object body,
final UrlTemplateParameters urlTemplateParameters,
- final String contentType) {
+ final String contentType,
+ final String authorization) {
return getWebClient(requiredDmiService)
.patch()
.uri(urlTemplateParameters.urlTemplate(), urlTemplateParameters.urlVariables())
- .headers(httpHeaders -> configureHttpHeaders(httpHeaders, NO_AUTHORIZATION))
+ .headers(httpHeaders -> configureHttpHeaders(httpHeaders, authorization))
.contentType(MediaType.parseMediaType(contentType))
.bodyValue(body)
.exchangeToMono(this::createIdenticalResponseForClient)
*
* @param requiredDmiService Determines if the required service is for a data or model operation.
* @param urlTemplateParameters The DMI resource URL template with variables.
+ * @param authorization The authorization token to be added to the request headers.
* @return ResponseEntity containing the response from the DMI.
*
*/
public ResponseEntity<Object> synchronousDeleteOperation(final RequiredDmiService requiredDmiService,
- final UrlTemplateParameters urlTemplateParameters) {
+ final UrlTemplateParameters urlTemplateParameters,
+ final String authorization) {
return getWebClient(requiredDmiService)
.delete()
.uri(urlTemplateParameters.urlTemplate(), urlTemplateParameters.urlVariables())
- .headers(httpHeaders -> configureHttpHeaders(httpHeaders, NO_AUTHORIZATION))
+ .headers(httpHeaders -> configureHttpHeaders(httpHeaders, authorization))
.exchangeToMono(this::createIdenticalResponseForClient)
.block();
}
def result
switch(method) {
case 'get':
- result = objectUnderTest.synchronousGetOperation(DATA, urlTemplateParameters)
+ result = objectUnderTest.synchronousGetOperation(DATA, urlTemplateParameters, 'some-authorization')
break
case 'post':
result = objectUnderTest.synchronousPostOperation(DATA, urlTemplateParameters, 'body', CREATE, '')
break
case 'put':
- result = objectUnderTest.synchronousPutOperation(DATA, 'body', urlTemplateParameters)
+ result = objectUnderTest.synchronousPutOperation(DATA, 'body', urlTemplateParameters, 'some-authorization')
break
case 'patch':
- result = objectUnderTest.synchronousPatchOperation(DATA, 'body', urlTemplateParameters, 'application/json-patch+json')
+ result = objectUnderTest.synchronousPatchOperation(DATA, 'body', urlTemplateParameters, 'application/json-patch+json', 'some-authorization')
break
case 'delete':
- result = objectUnderTest.synchronousDeleteOperation(DATA, urlTemplateParameters)
+ result = objectUnderTest.synchronousDeleteOperation(DATA, urlTemplateParameters, 'some-authorization')
}
then: 'the result has the same status code of 200'
assert result.statusCode.value() == 200
given: 'Mock a bad URL that causes IllegalArgumentException before HTTP call'
def badUrlParameters = new UrlTemplateParameters(':://bad url', [someParam: 'value'])
when: 'a synchronous request is attempted'
- objectUnderTest.synchronousGetOperation(DATA, badUrlParameters)
+ objectUnderTest.synchronousGetOperation(DATA, badUrlParameters, 'some-authorization')
then: 'a invalid url exception is thrown (no mapping)'
thrown(InvalidUrlException)
}