* <li>state
* <li>all (config + state)
* </ul>
- *
*/
public final class ReadDataTransactionUtil {
+ private static final String READ_TYPE_TX = "READ";
private ReadDataTransactionUtil() {
throw new UnsupportedOperationException("Util class.");
}
// check only allowed parameters
- checkParametersTypes(RestconfDataServiceConstant.ReadData.READ_TYPE_TX,
- uriInfo.getQueryParameters().keySet(),
+ checkParametersTypes(uriInfo.getQueryParameters().keySet(),
RestconfDataServiceConstant.ReadData.CONTENT,
RestconfDataServiceConstant.ReadData.DEPTH,
RestconfDataServiceConstant.ReadData.FIELDS, RestconfDataServiceConstant.ReadData.WITH_DEFAULTS);
/**
* Check if URI does not contain not allowed parameters for specified operation.
*
- * @param operationType type of operation (READ, POST, PUT, DELETE...)
* @param usedParameters parameters used in URI request
* @param allowedParameters allowed parameters for operation
*/
@VisibleForTesting
- static void checkParametersTypes(final @NonNull String operationType,
- final @NonNull Set<String> usedParameters,
+ static void checkParametersTypes(final @NonNull Set<String> usedParameters,
final @NonNull String... allowedParameters) {
// FIXME: there should be a speedier way to do this
final Set<String> notAllowedParameters = Sets.newHashSet(usedParameters);
if (!notAllowedParameters.isEmpty()) {
throw new RestconfDocumentedException(
- "Not allowed parameters for " + operationType + " operation: " + notAllowedParameters,
+ "Not allowed parameters for " + READ_TYPE_TX + " operation: " + notAllowedParameters,
RestconfError.ErrorType.PROTOCOL,
RestconfError.ErrorTag.INVALID_VALUE);
}
final ListenableFuture<Optional<NormalizedNode<?, ?>>> listenableFuture = strategy.read(store, path);
if (closeTransactionChain) {
//Method close transactionChain if any
- FutureCallbackTx.addCallback(listenableFuture, RestconfDataServiceConstant.ReadData.READ_TYPE_TX,
- dataFactory, strategy.getTransactionChain());
+ FutureCallbackTx.addCallback(listenableFuture, READ_TYPE_TX, dataFactory, strategy.getTransactionChain());
} else {
- FutureCallbackTx.addCallback(listenableFuture, RestconfDataServiceConstant.ReadData.READ_TYPE_TX,
- dataFactory);
+ FutureCallbackTx.addCallback(listenableFuture, READ_TYPE_TX, dataFactory);
}
return dataFactory.build();
}
@Test(expected = RestconfDocumentedException.class)
public void readDataFailTest() {
- final String valueOfContent = RestconfDataServiceConstant.ReadData.READ_TYPE_TX;
+ final String valueOfContent = "nonsense";
NormalizedNode<?, ?> normalizedNode = readData(valueOfContent, null, mdsalStrategy);
assertNull(normalizedNode);
*/
@Test
public void checkParametersTypesTest() {
- ReadDataTransactionUtil.checkParametersTypes(RestconfDataServiceConstant.ReadData.READ_TYPE_TX,
- Set.of("content"),
+ ReadDataTransactionUtil.checkParametersTypes(Set.of("content"),
RestconfDataServiceConstant.ReadData.CONTENT, RestconfDataServiceConstant.ReadData.DEPTH);
}
@Test
public void checkParametersTypesNegativeTest() {
final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
- () -> ReadDataTransactionUtil.checkParametersTypes(RestconfDataServiceConstant.ReadData.READ_TYPE_TX,
- Set.of("not-allowed-parameter"),
+ () -> ReadDataTransactionUtil.checkParametersTypes(Set.of("not-allowed-parameter"),
RestconfDataServiceConstant.ReadData.CONTENT, RestconfDataServiceConstant.ReadData.DEPTH));
assertEquals("Error type is not correct", ErrorType.PROTOCOL, ex.getErrors().get(0).getErrorType());
assertEquals("Error tag is not correct", ErrorTag.INVALID_VALUE, ex.getErrors().get(0).getErrorTag());