RequestUtils.java
1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.dam.commons.xml.DocumentBuilderFactoryProvider
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.dam.scene7.impl.utils;
import com.day.cq.dam.commons.xml.DocumentBuilderFactoryProvider;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
public class RequestUtils {
private static final Logger LOG = LoggerFactory.getLogger(RequestUtils.class);
public static Document getResponseDOM(InputStream response) {
Document document = null;
try {
DocumentBuilderFactoryProvider factoryprovider = new DocumentBuilderFactoryProvider();
DocumentBuilderFactory factory = factoryprovider.createSecureBuilderFactory(Boolean.valueOf(false));
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(response);
}
catch (Exception e) {
LOG.error("Error parsing response", (Throwable)e);
}
return document;
}
public static String buildURL(String baseURL, String path, String query) throws URISyntaxException {
URI uri = URI.create(baseURL);
uri = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath() + path, query, null);
return uri.toASCIIString();
}
}