public static XmlElement fromString(String s) throws DocumentedException { try { return new XmlElement(XmlUtil.readXmlToElement(s)); } catch (IOException | SAXException e) { throw DocumentedException.wrap(e); } }
@Override protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws DocumentedException { checkXml(xml); CommitStatus status; try { status = getConfigSubsystemFacade().commitTransaction(); LOG.trace("Datastore {} committed successfully: {}", Datastore.candidate, status); } catch (ConflictingVersionException | ValidationException e) { throw DocumentedException.wrap(e); } LOG.trace("Datastore {} committed successfully: {}", Datastore.candidate, status); return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent()); }
@Override protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws DocumentedException { checkXml(xml); try { getConfigSubsystemFacade().validateConfiguration(); } catch (ValidationException e) { LOG.warn("Validation failed", e); throw DocumentedException.wrap(e); } catch (IllegalStateException e) { LOG.warn("Validation failed", e); final Map<String, String> errorInfo = new HashMap<>(); errorInfo .put(ErrorTag.operation_failed.name(), "Datastore is not present. Use 'get-config' or 'edit-config' before triggering 'operations' operation"); throw new DocumentedException(e.getMessage(), e, ErrorType.application, ErrorTag.operation_failed, ErrorSeverity.error, errorInfo); } LOG.trace("Datastore {} validated successfully", Datastore.candidate); return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent()); } }
GetSchemaEntry(final XmlElement getSchemaElement) throws DocumentedException { getSchemaElement.checkName(GET_SCHEMA); getSchemaElement.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_YANG_IETF_NETCONF_MONITORING); XmlElement identifierElement = null; try { identifierElement = getSchemaElement.getOnlyChildElementWithSameNamespace(IDENTIFIER); } catch (final DocumentedException e) { LOG.trace("Can't get identifier element as only child element with same namespace due to ",e); throw DocumentedException.wrap(e); } identifier = identifierElement.getTextContent(); final Optional<XmlElement> versionElement = getSchemaElement .getOnlyChildElementWithSameNamespaceOptionally(VERSION); if (versionElement.isPresent()) { version = Optional.of(versionElement.get().getTextContent()); } else { version = Optional.absent(); } } }
throw DocumentedException.wrap(e);