Skip to content

Commit

Permalink
Merge branch 'async-support' into bugs/231-julroot
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Jul 13, 2016
2 parents 5f4683b + 2dfca00 commit 143dccf
Show file tree
Hide file tree
Showing 25 changed files with 4,277 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,48 +231,48 @@ private void processSecondLevelNode(Element elt, AppEngineWebXml appEngineWebXml
}

private void processApplicationNode(Element node, AppEngineWebXml appEngineWebXml) {
appEngineWebXml.setAppId(getTextNode(node));
appEngineWebXml.setAppId(XmlUtils.getText(node));
}

private void processPublicRootNode(Element node, AppEngineWebXml appEngineWebXml) {
appEngineWebXml.setPublicRoot(getTextNode(node));
appEngineWebXml.setPublicRoot(XmlUtils.getText(node));
}

private void processVersionNode(Element node, AppEngineWebXml appEngineWebXml) {
appEngineWebXml.setMajorVersionId(getTextNode(node));
appEngineWebXml.setMajorVersionId(XmlUtils.getText(node));
}

private void processSourceLanguageNode(Element node, AppEngineWebXml appEngineWebXml) {
appEngineWebXml.setSourceLanguage(getTextNode(node));
appEngineWebXml.setSourceLanguage(XmlUtils.getText(node));
}

private void processModuleNode(Element node, AppEngineWebXml appEngineWebXml) {
appEngineWebXml.setModule(getTextNode(node));
appEngineWebXml.setModule(XmlUtils.getText(node));
}

private void processServiceNode(Element node, AppEngineWebXml appEngineWebXml) {
appEngineWebXml.setService(getTextNode(node));
appEngineWebXml.setService(XmlUtils.getText(node));
}

private void processInstanceClassNode(Element node, AppEngineWebXml appEngineWebXml) {

appEngineWebXml.setInstanceClass(getTextNode(node));
appEngineWebXml.setInstanceClass(XmlUtils.getText(node));
}

private String getChildNodeText(Element parentNode, String childTag) {
String result = null;
Element node = XmlUtils.getOptionalChildElement(parentNode, childTag);
if (node != null) {
result = XmlUtils.getBody(node);
if (node == null) {
return null;
}
return result;
String result = XmlUtils.getText(node);
return result.isEmpty() ? null : result;
}

private Integer getChildNodePositiveInteger(Element parentNode, String childTag) {
Integer result = null;
Element node = XmlUtils.getOptionalChildElement(parentNode, childTag);
if (node != null && XmlUtils.getBody(node) != null) {
String trimmedText = (XmlUtils.getBody(node)).trim();
if (node != null) {
String trimmedText = XmlUtils.getText(node);
if (!trimmedText.isEmpty()) {
try {
result = Integer.parseInt(trimmedText);
Expand All @@ -291,8 +291,8 @@ private Integer getChildNodePositiveInteger(Element parentNode, String childTag)
private Double getChildNodeDouble(Element parentNode, String childTag) {
Double result = null;
Element node = XmlUtils.getOptionalChildElement(parentNode, childTag);
if (node != null && XmlUtils.getBody(node) != null) {
String trimmedText = (XmlUtils.getBody(node)).trim();
if (node != null) {
String trimmedText = XmlUtils.getText(node);
if (!trimmedText.isEmpty()) {
try {
result = Double.parseDouble(trimmedText);
Expand Down Expand Up @@ -407,7 +407,7 @@ private void processThreadsafeNode(Element node, AppEngineWebXml appEngineWebXml
}

private void processAutoIdPolicyNode(Element node, AppEngineWebXml appEngineWebXml) {
appEngineWebXml.setAutoIdPolicy(getTextNode(node));
appEngineWebXml.setAutoIdPolicy(XmlUtils.getText(node));
}

private void processCodeLockNode(Element node, AppEngineWebXml appEngineWebXml) {
Expand All @@ -419,7 +419,7 @@ private void processVmNode(Element node, AppEngineWebXml appEngineWebXml) {
}

private void processEnvNode(Element node, AppEngineWebXml appEngineWebXml) {
appEngineWebXml.setEnv(getTextNode(node));
appEngineWebXml.setEnv(XmlUtils.getText(node));
}

private void processFilesetNode(Element node, AppEngineWebXml appEngineWebXml, FileType type) {
Expand Down Expand Up @@ -521,7 +521,7 @@ private void processNetworkNode(Element settingsNode, AppEngineWebXml appEngineW
network.setInstanceTag(instanceTag);
}
for (Element subNode : getNodeIterable(settingsNode, "forwarded-port")) {
String forwardedPort = getTextNode(subNode);
String forwardedPort = XmlUtils.getText(subNode);
network.addForwardedPort(forwardedPort);
}
String name = trim(getChildNodeText(settingsNode, "name"));
Expand Down Expand Up @@ -558,7 +558,7 @@ private void processPermissionsNode(Element node, AppEngineWebXml appEngineWebXm

private void processInboundServicesNode(Element node, AppEngineWebXml appEngineWebXml) {
for (Element subNode : getNodeIterable(node, "service")) {
String service = getTextNode(subNode);
String service = XmlUtils.getText(subNode);
appEngineWebXml.addInboundService(service);
}
}
Expand Down Expand Up @@ -591,7 +591,7 @@ private void processApiConfigNode(Element node, AppEngineWebXml appEngineWebXml)
appEngineWebXml.setApiConfig(new ApiConfig(servlet, url));

for (Element subNode : getNodeIterable(node, "endpoint-servlet-mapping-id")) {
String id = trim(getTextNode(subNode));
String id = XmlUtils.getText(subNode);
if (id != null && id.length() > 0) {
appEngineWebXml.addApiEndpoint(id);
}
Expand All @@ -615,11 +615,11 @@ private void processClassPathPrioritySpecifier(Element node, ClassLoaderConfig c
}

private void processUrlStreamHandler(Element node, AppEngineWebXml appEngineWebXml) {
appEngineWebXml.setUrlStreamHandlerType(getTextNode(node));
appEngineWebXml.setUrlStreamHandlerType(XmlUtils.getText(node));
}

private boolean getBooleanValue(Element node) {
return toBoolean(getTextNode(node));
return toBoolean(XmlUtils.getText(node));
}

private boolean getBooleanAttributeValue(Element node, String attribute) {
Expand All @@ -631,14 +631,6 @@ private boolean toBoolean(String value) {
return (value.equalsIgnoreCase("true") || value.equals("1"));
}

private String getTextNode(Element node) {
String value = XmlUtils.getBody(node);
if (value == null) {
value = "";
}
return value.trim();
}

private String trim(String attribute) {
return attribute == null ? null : attribute.trim();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ static String getOptionalChildElementBody(Element element, String tagName) {

static String getChildElementBody(Element element, String tagName, boolean required) {
Element elt = getChildElement(element, tagName, required);
return (elt != null) ? getBody(elt) : null;
if (elt == null) {
return null;
}
String result = getText(elt);
return result.isEmpty() ? null : result;
}

static Element getOptionalChildElement(Element parent, String tagName) {
Expand Down Expand Up @@ -181,20 +185,6 @@ static String getAttributeOrNull(Element element, String name) {
}
}

static String getBody(Element element) {
NodeList nodes = element.getChildNodes();
if (nodes == null || nodes.getLength() == 0) {
return null;
}

Node firstNode = nodes.item(0);
if (firstNode == null) {
return null;
}

return firstNode.getNodeValue();
}

static List<Element> getChildren(Element element) {
return getChildren(element, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.apphosting.logging.SystemLogger;

import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
Expand Down
Loading

0 comments on commit 143dccf

Please sign in to comment.