@Test public void testValidate7() throws Exception { result = editXml.xPathReplaceNode(EMPTY, "asd", DELETE, "/test/test", EMPTY, EMPTY, "wrong type", EMPTY, ""); assertEquals(RETURN_CODE_FAILURE, (result.get(RETURN_CODE))); assertEquals("Invalid type. Only supported : elem, attr, text", (result.get(EXCEPTION))); }
@Action(name = "Edit XML", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(EXCEPTION)}, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE)}) public Map<String, String> xPathReplaceNode( @Param(value = XML) String xml, @Param(value = FILE_PATH) String filePath, @Param(value = ACTION, required = true) String action, @Param(value = XPATH1, required = true) String xpath1, @Param(value = XPATH2) String xpath2, @Param(value = VALUE) String value, @Param(value = TYPE) String type, @Param(value = TYPE_NAME) String name, @Param(value = FEATURES) String parsingFeatures) { try { final EditXmlInputs inputs = new EditXmlInputs.EditXmlInputsBuilder() .withXml(xml) .withFilePath(filePath) .withAction(action) .withXpath1(xpath1) .withXpath2(xpath2) .withName(name) .withType(type) .withValue(value) .withParsingFeatures(parsingFeatures) .build(); ValidateUtils.validateInputs(inputs); final ActionType myAction = ActionType.valueOf(action.toLowerCase()); final OperationService operationService = OperationFactory.getOperation(myAction); return getSuccessResultsMap(operationService.execute(inputs)); } catch (IllegalArgumentException e) { return getFailureResultsMap("Invalid action " + e.getMessage()); } catch (Exception e) { return getFailureResultsMap(e.getMessage()); } }
EditXml { @Action(name = "Edit XML", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(EXCEPTION)}, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE)}) public Map<String, String> xPathReplaceNode( @Param(value = XML) String xml, @Param(value = FILE_PATH) String filePath, @Param(value = ACTION, required = true) String action, @Param(value = XPATH1, required = true) String xpath1, @Param(value = XPATH2) String xpath2, @Param(value = VALUE) String value, @Param(value = TYPE) String type, @Param(value = TYPE_NAME) String name, @Param(value = FEATURES) String parsingFeatures) { try { final EditXmlInputs inputs = new EditXmlInputs.EditXmlInputsBuilder() .withXml(xml) .withFilePath(filePath) .withAction(action) .withXpath1(xpath1) .withXpath2(xpath2) .withName(name) .withType(type) .withValue(value) .withParsingFeatures(parsingFeatures) .build(); ValidateUtils.validateInputs(inputs); final ActionType myAction = ActionType.valueOf(action.toLowerCase()); final OperationService operationService = OperationFactory.getOperation(myAction); return getSuccessResultsMap(operationService.execute(inputs)); } catch (IllegalArgumentException e) { return getFailureResultsMap("Invalid action " + e.getMessage()); } catch (Exception e) { return getFailureResultsMap(e.getMessage()); } } }
EditXml { @Action(name = "Edit XML", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(EXCEPTION)}, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE)}) public Map<String, String> xPathReplaceNode( @Param(value = XML) String xml, @Param(value = FILE_PATH) String filePath, @Param(value = ACTION, required = true) String action, @Param(value = XPATH1, required = true) String xpath1, @Param(value = XPATH2) String xpath2, @Param(value = VALUE) String value, @Param(value = TYPE) String type, @Param(value = TYPE_NAME) String name, @Param(value = FEATURES) String parsingFeatures) { try { final EditXmlInputs inputs = new EditXmlInputs.EditXmlInputsBuilder() .withXml(xml) .withFilePath(filePath) .withAction(action) .withXpath1(xpath1) .withXpath2(xpath2) .withName(name) .withType(type) .withValue(value) .withParsingFeatures(parsingFeatures) .build(); ValidateUtils.validateInputs(inputs); final ActionType myAction = ActionType.valueOf(action.toLowerCase()); final OperationService operationService = OperationFactory.getOperation(myAction); return getSuccessResultsMap(operationService.execute(inputs)); } catch (IllegalArgumentException e) { return getFailureResultsMap("Invalid action " + e.getMessage()); } catch (Exception e) { return getFailureResultsMap(e.getMessage()); } }  }
EditXml { @Action(name = "Edit XML", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(EXCEPTION)}, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE)}) public Map<String, String> xPathReplaceNode( @Param(value = XML) String xml, @Param(value = FILE_PATH) String filePath, @Param(value = ACTION, required = true) String action, @Param(value = XPATH1, required = true) String xpath1, @Param(value = XPATH2) String xpath2, @Param(value = VALUE) String value, @Param(value = TYPE) String type, @Param(value = TYPE_NAME) String name, @Param(value = FEATURES) String parsingFeatures) { try { final EditXmlInputs inputs = new EditXmlInputs.EditXmlInputsBuilder() .withXml(xml) .withFilePath(filePath) .withAction(action) .withXpath1(xpath1) .withXpath2(xpath2) .withName(name) .withType(type) .withValue(value) .withParsingFeatures(parsingFeatures) .build(); ValidateUtils.validateInputs(inputs); final ActionType myAction = ActionType.valueOf(action.toLowerCase()); final OperationService operationService = OperationFactory.getOperation(myAction); return getSuccessResultsMap(operationService.execute(inputs)); } catch (IllegalArgumentException e) { return getFailureResultsMap("Invalid action " + e.getMessage()); } catch (Exception e) { return getFailureResultsMap(e.getMessage()); } }  @Action(name = "Edit XML", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(EXCEPTION)}, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE)}) Map<String, String> xPathReplaceNode(
            @Param(value = XML) String xml,
            @Param(value = FILE_PATH) String filePath,
            @Param(value = ACTION, required = true) String action,
            @Param(value = XPATH1, required = true) String xpath1,
            @Param(value = XPATH2) String xpath2,
            @Param(value = VALUE) String value,
            @Param(value = TYPE) String type,
            @Param(value = TYPE_NAME) String name,
            @Param(value = FEATURES) String parsingFeatures); }
EditXml { @Action(name = "Edit XML", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(EXCEPTION)}, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE)}) public Map<String, String> xPathReplaceNode( @Param(value = XML) String xml, @Param(value = FILE_PATH) String filePath, @Param(value = ACTION, required = true) String action, @Param(value = XPATH1, required = true) String xpath1, @Param(value = XPATH2) String xpath2, @Param(value = VALUE) String value, @Param(value = TYPE) String type, @Param(value = TYPE_NAME) String name, @Param(value = FEATURES) String parsingFeatures) { try { final EditXmlInputs inputs = new EditXmlInputs.EditXmlInputsBuilder() .withXml(xml) .withFilePath(filePath) .withAction(action) .withXpath1(xpath1) .withXpath2(xpath2) .withName(name) .withType(type) .withValue(value) .withParsingFeatures(parsingFeatures) .build(); ValidateUtils.validateInputs(inputs); final ActionType myAction = ActionType.valueOf(action.toLowerCase()); final OperationService operationService = OperationFactory.getOperation(myAction); return getSuccessResultsMap(operationService.execute(inputs)); } catch (IllegalArgumentException e) { return getFailureResultsMap("Invalid action " + e.getMessage()); } catch (Exception e) { return getFailureResultsMap(e.getMessage()); } }  @Action(name = "Edit XML", outputs = { @Output(RETURN_RESULT), @Output(RETURN_CODE), @Output(EXCEPTION)}, responses = { @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = SUCCESS), @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = FAILURE)}) Map<String, String> xPathReplaceNode(
            @Param(value = XML) String xml,
            @Param(value = FILE_PATH) String filePath,
            @Param(value = ACTION, required = true) String action,
            @Param(value = XPATH1, required = true) String xpath1,
            @Param(value = XPATH2) String xpath2,
            @Param(value = VALUE) String value,
            @Param(value = TYPE) String type,
            @Param(value = TYPE_NAME) String name,
            @Param(value = FEATURES) String parsingFeatures);  }