From d15ef22e34c284ec53f4348be84ec8936b9e070a Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Tue, 8 Oct 2019 12:45:54 -0400 Subject: [PATCH] REOC-70 Change build version to 1.8 and rebuild it --- .../reoc/rets/client/CapabilityUrls.java | 16 ++++--- .../reoc/rets/client/KeyValueResponse.java | 48 +++++++------------ src/test/resources/logback.xml | 10 ++-- 3 files changed, 32 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/ossez/reoc/rets/client/CapabilityUrls.java b/src/main/java/com/ossez/reoc/rets/client/CapabilityUrls.java index 42788a4..05701a4 100644 --- a/src/main/java/com/ossez/reoc/rets/client/CapabilityUrls.java +++ b/src/main/java/com/ossez/reoc/rets/client/CapabilityUrls.java @@ -1,17 +1,20 @@ package com.ossez.reoc.rets.client; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; import java.util.Map; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** * */ public class CapabilityUrls { + + private final static Logger logger = LoggerFactory.getLogger(CapabilityUrls.class); + public static final String ACTION_URL = "Action"; public static final String CHANGE_PASSWORD_URL = "ChangePassword"; public static final String GET_OBJECT_URL = "GetObject"; @@ -22,7 +25,6 @@ public class CapabilityUrls { public static final String GET_METADATA_URL = "GetMetadata"; public static final String UPDATE_URL = "Update"; public static final String SERVER_INFO_URL = "ServerInformation";// for rets 1.7 - private static final Log LOG = LogFactory.getLog(CapabilityUrls.class); private final Map mCapabilityUrls; private URL mUrl; @@ -41,13 +43,13 @@ public class CapabilityUrls { try { String newurl = new URL(this.mUrl, url).toString(); if (!newurl.equals(url)) { - LOG.info("qualified " + capability + " URL different: " + logger.info("qualified " + capability + " URL different: " + url + " -> " + newurl); url = newurl; } } catch (MalformedURLException e) { - LOG.warn("Couldn't normalize URL", e); + logger.warn("Couldn't normalize URL", e); } } this.mCapabilityUrls.put(capability, url); @@ -91,7 +93,7 @@ public class CapabilityUrls { try { this.mUrl = new URL(url); } catch (MalformedURLException e) { - LOG.debug("java.net.URL can't parse login url: " + url); + logger.debug("java.net.URL can't parse login url: " + url); this.mUrl = null; } } diff --git a/src/main/java/com/ossez/reoc/rets/client/KeyValueResponse.java b/src/main/java/com/ossez/reoc/rets/client/KeyValueResponse.java index d711345..5140291 100644 --- a/src/main/java/com/ossez/reoc/rets/client/KeyValueResponse.java +++ b/src/main/java/com/ossez/reoc/rets/client/KeyValueResponse.java @@ -4,14 +4,17 @@ import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.InputStream; -import java.util.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; import static com.ossez.reoc.rets.client.CapabilityUrls.LOGIN_URL; @@ -20,7 +23,7 @@ import static com.ossez.reoc.rets.client.CapabilityUrls.LOGIN_URL; */ abstract public class KeyValueResponse { protected static final String CRLF = "\r\n"; - private static final Log LOG = LogFactory.getLog(KeyValueResponse.class); + private static final Logger logger = LoggerFactory.getLogger(KeyValueResponse.class); protected Document mDoc; protected int mReplyCode; @@ -85,43 +88,26 @@ abstract public class KeyValueResponse { String[] splits = StringUtils.split(keyValueStr, "="); if (!ArrayUtils.isEmpty(splits) && splits.length > 1) { String key = StringUtils.trimToNull(splits[0]); - // guard against a missing value in a KeyValueResponse String value = StringUtils.trimToEmpty(splits[1]); + // PROCESS LOGIN_URL if (StringUtils.equalsIgnoreCase(LOGIN_URL, key)) retsResponseMap.put(LOGIN_URL, value); else retsResponseMap.put(key, value); } -// // LOOP TO LOAD LOGIN URL -// tokenizeList.parallelStream().forEach(keyValueString -> { -// -// //parallelStream -// try { -// String line = StringUtils.trimToEmpty(keyValueString); -// String splits[] = StringUtils.split(line, "="); -// if (!ArrayUtils.isEmpty(splits) && splits.length > 1) { -// String key = StringUtils.trimToNull(splits[0]); -// // guard against a missing value in a KeyValueResponse -// String value = StringUtils.trimToEmpty(splits[1]); -// -// if (StringUtils.equalsIgnoreCase(LOGIN_URL, key)) -// retsResponseMap.put(LOGIN_URL, value); -// else -// retsResponseMap.put(key, value); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// }); - // LOOP TO LOAD OTHERS - this.handleKeyValue(LOGIN_URL, retsResponseMap.get(LOGIN_URL)); - - for (String k : retsResponseMap.keySet()) { - this.handleKeyValue(k, retsResponseMap.get(k)); - } } + + retsResponseMap.entrySet().parallelStream().forEach(entry -> { + try { + this.handleKeyValue(entry.getKey(), entry.getValue()); + } catch (RetsException ex) { + logger.warn("Unable process rests login response value", ex); + } + }); + + } protected abstract void handleKeyValue(String key, String value) throws RetsException; diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml index 682ff22..e0d940b 100644 --- a/src/test/resources/logback.xml +++ b/src/test/resources/logback.xml @@ -1,8 +1,10 @@ - + + - - + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n