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); } }
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); } }