private void checkList(final ModelNode operation, final String paramName, final ModelType modelType, final ModelNode describedProperty, final ModelNode value) { if (describedProperty.get(TYPE).asType() == ModelType.LIST) { if (describedProperty.hasDefined(VALUE_TYPE) && describedProperty.get(VALUE_TYPE).getType() == ModelType.TYPE) { ModelType elementType = describedProperty.get(VALUE_TYPE).asType(); for (ModelNode element : value.asList()) { try { checkType(elementType, element); } catch (IllegalArgumentException e) { throw MESSAGES.validationFailedInvalidElementType(paramName, elementType, formatOperationForMessage(operation)); } } } } }
private void checkList(final ModelNode operation, final String paramName, final ModelNode describedProperty, final ModelNode value) { if (describedProperty.get(TYPE).asType() == ModelType.LIST) { if (describedProperty.hasDefined(VALUE_TYPE) && describedProperty.get(VALUE_TYPE).getType() == ModelType.TYPE) { ModelType elementType = describedProperty.get(VALUE_TYPE).asType(); for (ModelNode element : value.asList()) { try { checkType(elementType, element); } catch (IllegalArgumentException e) { throw ControllerLogger.ROOT_LOGGER.validationFailedInvalidElementType(paramName, elementType, formatOperationForMessage(operation)); } } } } }
private void checkList(final ModelNode operation, final String paramName, final ModelType modelType, final ModelNode describedProperty, final ModelNode value) { if (describedProperty.get(TYPE).asType() == ModelType.LIST) { if (describedProperty.hasDefined(VALUE_TYPE) && describedProperty.get(VALUE_TYPE).getType() == ModelType.TYPE) { ModelType elementType = describedProperty.get(VALUE_TYPE).asType(); for (ModelNode element : value.asList()) { try { checkType(elementType, element); } catch (IllegalArgumentException e) { throw MESSAGES.validationFailedInvalidElementType(paramName, elementType, formatOperationForMessage(operation)); } } } } }
private void checkList(final ModelNode operation, final String paramName, final ModelNode describedProperty, final ModelNode value) { if (describedProperty.get(TYPE).asType() == ModelType.LIST) { if (describedProperty.hasDefined(VALUE_TYPE) && describedProperty.get(VALUE_TYPE).getType() == ModelType.TYPE) { ModelType elementType = describedProperty.get(VALUE_TYPE).asType(); for (ModelNode element : value.asList()) { try { checkType(elementType, element); } catch (IllegalArgumentException e) { throw ControllerLogger.ROOT_LOGGER.validationFailedInvalidElementType(paramName, elementType, formatOperationForMessage(operation)); } } } } }
private void checkParameterTypes(final ModelNode description, final ModelNode operation, final Map<String, ModelNode> describedProperties, final Map<String, ModelNode> actualParams) { for (String paramName : actualParams.keySet()) { final ModelNode value = actualParams.get(paramName); if(!value.isDefined()) { continue; } if(value.getType() == ModelType.OBJECT && value.keys().isEmpty()) { return; } final ModelNode typeNode = describedProperties.get(paramName).get(TYPE); if (!typeNode.isDefined()) { throwOrWarnAboutDescriptorProblem(ControllerLogger.ROOT_LOGGER.invalidDescriptionNoParamTypeInDescription(paramName, getPathAddress(operation), description)); return; } final ModelType modelType; try { modelType = Enum.valueOf(ModelType.class, typeNode.asString()); } catch (Exception e) { throwOrWarnAboutDescriptorProblem(ControllerLogger.ROOT_LOGGER.invalidDescriptionInvalidParamTypeInDescription(paramName, getPathAddress(operation), description)); return; } try { checkType(modelType, value); } catch (IllegalArgumentException e) { throw ControllerLogger.ROOT_LOGGER.validationFailedCouldNotConvertParamToType(paramName, modelType, formatOperationForMessage(operation)); } checkRange(operation, description, paramName, modelType, describedProperties.get(paramName), value); checkList(operation, paramName, describedProperties.get(paramName), value); } }
private void checkParameterTypes(final ModelNode description, final ModelNode operation, final Map<String, ModelNode> describedProperties, final Map<String, ModelNode> actualParams) { for (String paramName : actualParams.keySet()) { final ModelNode value = actualParams.get(paramName); if(!value.isDefined()) { continue; } if(value.getType() == ModelType.OBJECT && value.keys().isEmpty()) { return; } final ModelNode typeNode = describedProperties.get(paramName).get(TYPE); if (!typeNode.isDefined()) { throwOrWarnAboutDescriptorProblem(ControllerLogger.ROOT_LOGGER.invalidDescriptionNoParamTypeInDescription(paramName, getPathAddress(operation), description)); return; } final ModelType modelType; try { modelType = Enum.valueOf(ModelType.class, typeNode.asString()); } catch (Exception e) { throwOrWarnAboutDescriptorProblem(ControllerLogger.ROOT_LOGGER.invalidDescriptionInvalidParamTypeInDescription(paramName, getPathAddress(operation), description)); return; } try { checkType(modelType, value); } catch (IllegalArgumentException e) { throw ControllerLogger.ROOT_LOGGER.validationFailedCouldNotConvertParamToType(paramName, modelType, formatOperationForMessage(operation)); } checkRange(operation, description, paramName, modelType, describedProperties.get(paramName), value); checkList(operation, paramName, describedProperties.get(paramName), value); } }
private void checkParameterTypes(final ModelNode description, final ModelNode operation, final Map<String, ModelNode> describedProperties, final Map<String, ModelNode> actualParams) { for (String paramName : actualParams.keySet()) { final ModelNode value = actualParams.get(paramName); if(!value.isDefined()) { continue; } if(value.getType() == ModelType.OBJECT && value.keys().isEmpty()) { return; } final ModelNode typeNode = describedProperties.get(paramName).get(TYPE); if (!typeNode.isDefined()) { throwOrWarnAboutDescriptorProblem(MESSAGES.invalidDescriptionNoParamTypeInDescription(paramName, getPathAddress(operation), description)); return; } final ModelType modelType; try { modelType = Enum.valueOf(ModelType.class, typeNode.asString()); } catch (Exception e) { throwOrWarnAboutDescriptorProblem(MESSAGES.invalidDescriptionInvalidParamTypeInDescription(paramName, getPathAddress(operation), description)); return; } try { checkType(modelType, value); } catch (IllegalArgumentException e) { throw MESSAGES.validationFailedCouldNotConvertParamToType(paramName, modelType, formatOperationForMessage(operation)); } checkRange(operation, description, paramName, modelType, describedProperties.get(paramName), value); checkList(operation, paramName, modelType, describedProperties.get(paramName), value); } }
private void checkParameterTypes(final ModelNode description, final ModelNode operation, final Map<String, ModelNode> describedProperties, final Map<String, ModelNode> actualParams) { for (String paramName : actualParams.keySet()) { final ModelNode value = actualParams.get(paramName); if(!value.isDefined()) { continue; } if(value.getType() == ModelType.OBJECT && value.keys().isEmpty()) { return; } final ModelNode typeNode = describedProperties.get(paramName).get(TYPE); if (!typeNode.isDefined()) { throwOrWarnAboutDescriptorProblem(MESSAGES.invalidDescriptionNoParamTypeInDescription(paramName, getPathAddress(operation), description)); return; } final ModelType modelType; try { modelType = Enum.valueOf(ModelType.class, typeNode.asString()); } catch (Exception e) { throwOrWarnAboutDescriptorProblem(MESSAGES.invalidDescriptionInvalidParamTypeInDescription(paramName, getPathAddress(operation), description)); return; } try { checkType(modelType, value); } catch (IllegalArgumentException e) { throw MESSAGES.validationFailedCouldNotConvertParamToType(paramName, modelType, formatOperationForMessage(operation)); } checkRange(operation, description, paramName, modelType, describedProperties.get(paramName), value); checkList(operation, paramName, modelType, describedProperties.get(paramName), value); } }