Search in sources :

Example 61 with Document

use of com.google.cloud.documentai.v1beta2.Document in project aws-doc-sdk-examples by awsdocs.

the class SendNotifications method handleVoiceMessage.

public String handleVoiceMessage(String myDom) throws JDOMException, IOException {
    String mobileNum = "";
    List<String> listVal = new ArrayList<>();
    listVal.add("application/json");
    Map<String, List<String>> values = new HashMap<>();
    values.put("Content-Type", listVal);
    ClientOverrideConfiguration config2 = ClientOverrideConfiguration.builder().headers(values).build();
    PinpointSmsVoiceClient client = PinpointSmsVoiceClient.builder().overrideConfiguration(config2).region(Region.US_EAST_1).build();
    SAXBuilder builder = new SAXBuilder();
    Document jdomDocument = builder.build(new InputSource(new StringReader(myDom)));
    org.jdom2.Element root = jdomDocument.getRootElement();
    // get a list of children elements.
    List<org.jdom2.Element> students = root.getChildren("Student");
    for (org.jdom2.Element element : students) {
        mobileNum = element.getChildText("Phone");
        sendVoiceMsg(client, mobileNum);
    }
    client.close();
    return mobileNum;
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) InputSource(org.xml.sax.InputSource) HashMap(java.util.HashMap) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) ArrayList(java.util.ArrayList) Document(org.jdom2.Document) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) List(java.util.List) PinpointSmsVoiceClient(software.amazon.awssdk.services.pinpointsmsvoice.PinpointSmsVoiceClient)

Example 62 with Document

use of com.google.cloud.documentai.v1beta2.Document in project aws-doc-sdk-examples by awsdocs.

the class DynamoDBService method injectETLData.

public void injectETLData(String myDom) throws JDOMException, IOException {
    SAXBuilder builder = new SAXBuilder();
    Document jdomDocument = builder.build(new InputSource(new StringReader(myDom)));
    org.jdom2.Element root = ((org.jdom2.Document) jdomDocument).getRootElement();
    PopData pop = new PopData();
    List<org.jdom2.Element> items = root.getChildren("Item");
    for (org.jdom2.Element element : items) {
        pop.setName(element.getChildText("Name"));
        pop.setCode(element.getChildText("Code"));
        pop.set2010(element.getChildText("Date2010"));
        pop.set2011(element.getChildText("Date2011"));
        pop.set2012(element.getChildText("Date2012"));
        pop.set2013(element.getChildText("Date2013"));
        pop.set2014(element.getChildText("Date2014"));
        pop.set2015(element.getChildText("Date2015"));
        pop.set2016(element.getChildText("Date2016"));
        pop.set2017(element.getChildText("Date2017"));
        pop.set2018(element.getChildText("Date2018"));
        pop.set2019(element.getChildText("Date2019"));
        setItem(pop);
    }
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) InputSource(org.xml.sax.InputSource) StringReader(java.io.StringReader) Document(org.jdom2.Document)

Example 63 with Document

use of com.google.cloud.documentai.v1beta2.Document in project jena by apache.

the class GMLReader method extract.

public static GMLReader extract(String gmlText) throws JDOMException, IOException {
    if (gmlText.isEmpty()) {
        gmlText = EMPTY_GML_TEXT;
    }
    SAXBuilder jdomBuilder = newSAXBuilder();
    InputStream stream = new ByteArrayInputStream(gmlText.getBytes(StandardCharsets.UTF_8));
    Document xmlDoc = jdomBuilder.build(stream);
    Element gmlElement = xmlDoc.getRootElement();
    return new GMLReader(gmlElement);
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Element(org.jdom2.Element) Document(org.jdom2.Document)

Example 64 with Document

use of com.google.cloud.documentai.v1beta2.Document in project gocd by gocd.

the class GoConfigMigration method getCurrentSchemaVersion.

private int getCurrentSchemaVersion(String content) {
    try {
        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(new ByteArrayInputStream(content.getBytes()));
        Element root = document.getRootElement();
        String currentVersion = root.getAttributeValue(schemaVersion) == null ? "0" : root.getAttributeValue(schemaVersion);
        return Integer.parseInt(currentVersion);
    } catch (Exception e) {
        throw bomb(e);
    }
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Element(org.jdom2.Element) XmlUtils.buildXmlDocument(com.thoughtworks.go.util.XmlUtils.buildXmlDocument) Document(org.jdom2.Document) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException)

Example 65 with Document

use of com.google.cloud.documentai.v1beta2.Document in project gocd by gocd.

the class GoConfigMigrationIntegrationTest method shouldRemoveAllLuauConfigurationFromConfig.

@Test
public void shouldRemoveAllLuauConfigurationFromConfig() throws Exception {
    String configString = "<cruise schemaVersion='66'>" + "<server siteUrl='https://hostname'>" + "<security>" + "      <luau url='https://luau.url.com' clientKey='0d010cf97ec505ee3788a9b5b8cf71d482c394ae88d32f0333' authState='authorized' />" + "      <ldap uri='ldap' managerDn='managerDn' encryptedManagerPassword='+XhtUNvVAxJdHGF4qQGnWw==' searchFilter='(sAMAccountName={0})'>" + "        <bases>" + "          <base value='ou=Enterprise,ou=Principal,dc=corporate,dc=thoughtworks,dc=com' />" + "        </bases>" + "      </ldap>" + "      <roles>" + "         <role name='luau-role'><groups><luauGroup>luau-group</luauGroup></groups></role>" + "         <role name='ldap-role'><users><user>some-user</user></users></role>" + "</roles>" + "</security>" + "</server>" + "</cruise>";
    String migratedContent = migrateXmlString(configString, 66);
    Document document = new SAXBuilder().build(new StringReader(migratedContent));
    assertThat(document.getDescendants(new ElementFilter("luau")).hasNext()).isFalse();
    assertThat(document.getDescendants(new ElementFilter("groups")).hasNext()).isFalse();
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) ElementFilter(org.jdom2.filter.ElementFilter) StringReader(java.io.StringReader) Document(org.jdom2.Document) Test(org.junit.jupiter.api.Test)

Aggregations

Document (org.jdom2.Document)559 Element (org.jdom2.Element)330 Test (org.junit.Test)170 SAXBuilder (org.jdom2.input.SAXBuilder)160 IOException (java.io.IOException)146 JDOMException (org.jdom2.JDOMException)94 File (java.io.File)84 XMLOutputter (org.jdom2.output.XMLOutputter)80 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)48 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)34 ArrayList (java.util.ArrayList)33 HashMap (java.util.HashMap)32 MCRNodeBuilder (org.mycore.common.xml.MCRNodeBuilder)31 MCRContent (org.mycore.common.content.MCRContent)30 MCRObject (org.mycore.datamodel.metadata.MCRObject)30 MCRException (org.mycore.common.MCRException)28 InputStream (java.io.InputStream)27 StringReader (java.io.StringReader)26 Path (java.nio.file.Path)26 URL (java.net.URL)24