private void checkActualOperationParamsAreDescribed(final ModelNode description, final ModelNode operation, final Map<String, ModelNode> describedProperties, final Map<String, ModelNode> actualParams) { for (String paramName : actualParams.keySet()) { final ModelNode param = actualParams.get(paramName); if(! param.isDefined()) { continue; } if(param.getType() == ModelType.OBJECT && param.keys().isEmpty()) { return; } if (!describedProperties.containsKey(paramName)) { throw MESSAGES.validationFailedActualParameterNotDescribed(paramName, describedProperties.keySet(), formatOperationForMessage(operation)); } } }
private void checkActualOperationParamsAreDescribed(final ModelNode operation, final Map<String, ModelNode> describedProperties, final Map<String, ModelNode> actualParams) { for (String paramName : actualParams.keySet()) { final ModelNode param = actualParams.get(paramName); if(! param.isDefined()) { continue; } if(param.getType() == ModelType.OBJECT && param.keys().isEmpty()) { return; } if (!describedProperties.containsKey(paramName)) { throw ControllerLogger.ROOT_LOGGER.validationFailedActualParameterNotDescribed(paramName, describedProperties.keySet(), formatOperationForMessage(operation)); } } }
private void checkActualOperationParamsAreDescribed(final ModelNode operation, final Map<String, ModelNode> describedProperties, final Map<String, ModelNode> actualParams) { for (String paramName : actualParams.keySet()) { final ModelNode param = actualParams.get(paramName); if(! param.isDefined()) { continue; } if(param.getType() == ModelType.OBJECT && param.keys().isEmpty()) { return; } if (!describedProperties.containsKey(paramName)) { throw ControllerLogger.ROOT_LOGGER.validationFailedActualParameterNotDescribed(paramName, describedProperties.keySet(), formatOperationForMessage(operation)); } } }
private void checkActualOperationParamsAreDescribed(final ModelNode description, final ModelNode operation, final Map<String, ModelNode> describedProperties, final Map<String, ModelNode> actualParams) { for (String paramName : actualParams.keySet()) { final ModelNode param = actualParams.get(paramName); if(! param.isDefined()) { continue; } if(param.getType() == ModelType.OBJECT && param.keys().isEmpty()) { return; } if (!describedProperties.containsKey(paramName)) { throw MESSAGES.validationFailedActualParameterNotDescribed(paramName, describedProperties.keySet(), formatOperationForMessage(operation)); } } }
private DescriptionProvider getDescriptionProvider(final ModelNode operation) { if (!operation.hasDefined(OP)) { throw ControllerLogger.ROOT_LOGGER.validationFailedOperationHasNoField(OP, formatOperationForMessage(operation)); } if (!operation.hasDefined(OP_ADDR)) { throw ControllerLogger.ROOT_LOGGER.validationFailedOperationHasNoField(OP_ADDR, formatOperationForMessage(operation)); } final String name = operation.get(OP).asString(); if (name == null || name.trim().length() == 0) { throw ControllerLogger.ROOT_LOGGER.validationFailedOperationHasANullOrEmptyName(formatOperationForMessage(operation)); } final PathAddress addr = getPathAddress(operation); final DescriptionProvider provider = root.getOperationDescription(addr, name); if (provider == null) { throw ControllerLogger.ROOT_LOGGER.validationFailedNoOperationFound(name, addr, formatOperationForMessage(operation)); } return provider; }
private DescriptionProvider getDescriptionProvider(final ModelNode operation) { if (!operation.hasDefined(OP)) { throw MESSAGES.validationFailedOperationHasNoField(OP, formatOperationForMessage(operation)); } if (!operation.hasDefined(OP_ADDR)) { throw MESSAGES.validationFailedOperationHasNoField(OP_ADDR, formatOperationForMessage(operation)); } final String name = operation.get(OP).asString(); if (name == null || name.trim().length() == 0) { throw MESSAGES.validationFailedOperationHasANullOrEmptyName(formatOperationForMessage(operation)); } final PathAddress addr = getPathAddress(operation); final DescriptionProvider provider = root.getOperationDescription(addr, name); if (provider == null) { throw MESSAGES.validationFailedNoOperationFound(name, addr, formatOperationForMessage(operation)); } return provider; }
private DescriptionProvider getDescriptionProvider(final ModelNode operation) { if (!operation.hasDefined(OP)) { throw ControllerLogger.ROOT_LOGGER.validationFailedOperationHasNoField(OP, formatOperationForMessage(operation)); } if (!operation.hasDefined(OP_ADDR)) { throw ControllerLogger.ROOT_LOGGER.validationFailedOperationHasNoField(OP_ADDR, formatOperationForMessage(operation)); } final String name = operation.get(OP).asString(); if (name == null || name.trim().length() == 0) { throw ControllerLogger.ROOT_LOGGER.validationFailedOperationHasANullOrEmptyName(formatOperationForMessage(operation)); } final PathAddress addr = getPathAddress(operation); final DescriptionProvider provider = root.getOperationDescription(addr, name); if (provider == null) { throw ControllerLogger.ROOT_LOGGER.validationFailedNoOperationFound(name, addr, formatOperationForMessage(operation)); } return provider; }
private DescriptionProvider getDescriptionProvider(final ModelNode operation) { if (!operation.hasDefined(OP)) { throw MESSAGES.validationFailedOperationHasNoField(OP, formatOperationForMessage(operation)); } if (!operation.hasDefined(OP_ADDR)) { throw MESSAGES.validationFailedOperationHasNoField(OP_ADDR, formatOperationForMessage(operation)); } final String name = operation.get(OP).asString(); if (name == null || name.trim().length() == 0) { throw MESSAGES.validationFailedOperationHasANullOrEmptyName(formatOperationForMessage(operation)); } final PathAddress addr = getPathAddress(operation); final DescriptionProvider provider = root.getOperationDescription(addr, name); if (provider == null) { throw MESSAGES.validationFailedNoOperationFound(name, addr, formatOperationForMessage(operation)); } return provider; }
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 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 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)); } } } } }
if (required) { if(!exist && !alternativeExist) { throw ControllerLogger.ROOT_LOGGER.validationFailedRequiredParameterNotPresent(paramName, formatOperationForMessage(operation)); throw ControllerLogger.ROOT_LOGGER.validationFailedRequiredParameterPresentAsWellAsAlternative(alternative, paramName, formatOperationForMessage(operation));
if (required) { if(!exist && !alternativeExist) { throw MESSAGES.validationFailedRequiredParameterNotPresent(paramName, formatOperationForMessage(operation)); throw MESSAGES.validationFailedRequiredParameterPresentAsWellAsAlternative(alternative, paramName, formatOperationForMessage(operation));
if (required) { if(!exist && !alternativeExist) { throw ControllerLogger.ROOT_LOGGER.validationFailedRequiredParameterNotPresent(paramName, formatOperationForMessage(operation)); throw ControllerLogger.ROOT_LOGGER.validationFailedRequiredParameterPresentAsWellAsAlternative(alternative, paramName, formatOperationForMessage(operation));
if (required) { if(!exist && !alternativeExist) { throw MESSAGES.validationFailedRequiredParameterNotPresent(paramName, formatOperationForMessage(operation)); throw MESSAGES.validationFailedRequiredParameterPresentAsWellAsAlternative(alternative, paramName, 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(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(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(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); } }