|
@@ -104,6 +104,11 @@ public class FaceppClient {
|
|
*/
|
|
*/
|
|
public JsonHttpResponseHolder compareWithTokenAndImageUrl(String faceToken, String imageUrl) {
|
|
public JsonHttpResponseHolder compareWithTokenAndImageUrl(String faceToken, String imageUrl) {
|
|
|
|
|
|
|
|
+ if (log.isDebugEnabled()) {
|
|
|
|
+ log.debug("[Face++]. compareWithTokenAndImageUrl(String,String); faceToken=" + faceToken
|
|
|
|
+ + "; imageUrl=" + imageUrl);
|
|
|
|
+ }
|
|
|
|
+
|
|
String url = System.getProperty("facepp.compare.url");
|
|
String url = System.getProperty("facepp.compare.url");
|
|
if (StringUtils.isBlank(url)) {
|
|
if (StringUtils.isBlank(url)) {
|
|
url = compareUrl;
|
|
url = compareUrl;
|
|
@@ -133,12 +138,12 @@ public class FaceppClient {
|
|
responseHolder = new JsonHttpResponseHolder(statusCode, obj);
|
|
responseHolder = new JsonHttpResponseHolder(statusCode, obj);
|
|
|
|
|
|
if (HttpStatus.SC_OK != responseHolder.getStatusCode()) {
|
|
if (HttpStatus.SC_OK != responseHolder.getStatusCode()) {
|
|
- log.error("[Face++]. compareWithTokenAndImageUrl; statusCode=" + statusCode
|
|
|
|
- + "; responseEntity=" + entityStr);
|
|
|
|
|
|
+ log.error("[Face++]. compareWithTokenAndImageUrl(String,String); statusCode="
|
|
|
|
+ + statusCode + "; responseEntity=" + entityStr);
|
|
} else {
|
|
} else {
|
|
if (log.isDebugEnabled()) {
|
|
if (log.isDebugEnabled()) {
|
|
- log.debug("[Face++]. compareWithTokenAndImageUrl; statusCode=" + statusCode
|
|
|
|
- + "; responseEntity=" + entityStr);
|
|
|
|
|
|
+ log.debug("[Face++]. compareWithTokenAndImageUrl(String,String); statusCode="
|
|
|
|
+ + statusCode + "; responseEntity=" + entityStr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -149,9 +154,9 @@ public class FaceppClient {
|
|
}
|
|
}
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
if (log.isDebugEnabled()) {
|
|
- log.debug(
|
|
|
|
- "[Face++]. compareWithTokenAndImageUrl. faceToken=" + faceToken + "; imageUrl="
|
|
|
|
- + imageUrl + "; cost " + (System.currentTimeMillis() - s) + " ms.");
|
|
|
|
|
|
+ log.debug("[Face++]. compareWithTokenAndImageUrl(String,String); faceToken=" + faceToken
|
|
|
|
+ + "; imageUrl=" + imageUrl + "; cost " + (System.currentTimeMillis() - s)
|
|
|
|
+ + " ms.");
|
|
}
|
|
}
|
|
|
|
|
|
return responseHolder;
|
|
return responseHolder;
|
|
@@ -178,6 +183,11 @@ public class FaceppClient {
|
|
public JsonHttpResponseHolder compareWithTokenAndImageUrl(String faceToken, String imageUrl,
|
|
public JsonHttpResponseHolder compareWithTokenAndImageUrl(String faceToken, String imageUrl,
|
|
String backupImageUrl) throws StatusException {
|
|
String backupImageUrl) throws StatusException {
|
|
|
|
|
|
|
|
+ if (log.isDebugEnabled()) {
|
|
|
|
+ log.debug("[Face++]. compareWithTokenAndImageUrl(String,String,String); faceToken="
|
|
|
|
+ + faceToken + "; imageUrl=" + imageUrl + "; backupImageUrl=" + backupImageUrl);
|
|
|
|
+ }
|
|
|
|
+
|
|
JsonHttpResponseHolder responseHolder = compareWithTokenAndImageUrl(faceToken, imageUrl);
|
|
JsonHttpResponseHolder responseHolder = compareWithTokenAndImageUrl(faceToken, imageUrl);
|
|
|
|
|
|
if (HttpStatus.SC_OK == responseHolder.getStatusCode()) {
|
|
if (HttpStatus.SC_OK == responseHolder.getStatusCode()) {
|
|
@@ -198,6 +208,7 @@ public class FaceppClient {
|
|
get.setConfig(FaceppClient.requestConfig);
|
|
get.setConfig(FaceppClient.requestConfig);
|
|
CloseableHttpResponse response = null;
|
|
CloseableHttpResponse response = null;
|
|
String imageBase64 = null;
|
|
String imageBase64 = null;
|
|
|
|
+ long s = System.currentTimeMillis();
|
|
try {
|
|
try {
|
|
response = httpclient.execute(get);
|
|
response = httpclient.execute(get);
|
|
|
|
|
|
@@ -214,13 +225,22 @@ public class FaceppClient {
|
|
imageBase64 = Base64.encodeBase64String(byteArray);
|
|
imageBase64 = Base64.encodeBase64String(byteArray);
|
|
|
|
|
|
} catch (StatusException e) {
|
|
} catch (StatusException e) {
|
|
|
|
+ log.error("fail to download file. url=" + backupImageUrl, e);
|
|
throw e;
|
|
throw e;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
+ log.error("fail to download file. url=" + backupImageUrl, e);
|
|
throw new StatusException("803", "fail to download file. url=" + backupImageUrl, e);
|
|
throw new StatusException("803", "fail to download file. url=" + backupImageUrl, e);
|
|
} finally {
|
|
} finally {
|
|
IOUtils.closeQuietly(response);
|
|
IOUtils.closeQuietly(response);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (log.isDebugEnabled()) {
|
|
|
|
+ log.debug(
|
|
|
|
+ "[Face++]. compareWithTokenAndImageUrl(String,String,String); download image; url="
|
|
|
|
+ + backupImageUrl + "; cost " + (System.currentTimeMillis() - s)
|
|
|
|
+ + " ms.");
|
|
|
|
+ }
|
|
|
|
+
|
|
responseHolder = compareWithTokenAndBase64(faceToken, imageBase64);
|
|
responseHolder = compareWithTokenAndBase64(faceToken, imageBase64);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -266,12 +286,12 @@ public class FaceppClient {
|
|
responseHolder = new JsonHttpResponseHolder(statusCode, obj);
|
|
responseHolder = new JsonHttpResponseHolder(statusCode, obj);
|
|
|
|
|
|
if (HttpStatus.SC_OK != responseHolder.getStatusCode()) {
|
|
if (HttpStatus.SC_OK != responseHolder.getStatusCode()) {
|
|
- log.error("[Face++]. compareWithTokenAndBase64; statusCode=" + statusCode
|
|
|
|
- + "; responseEntity=" + entityStr);
|
|
|
|
|
|
+ log.error("[Face++]. compareWithTokenAndBase64(String,String); statusCode="
|
|
|
|
+ + statusCode + "; responseEntity=" + entityStr);
|
|
} else {
|
|
} else {
|
|
if (log.isDebugEnabled()) {
|
|
if (log.isDebugEnabled()) {
|
|
- log.debug("[Face++]. compareWithTokenAndBase64; statusCode=" + statusCode
|
|
|
|
- + "; responseEntity=" + entityStr);
|
|
|
|
|
|
+ log.debug("[Face++]. compareWithTokenAndBase64(String,String); statusCode="
|
|
|
|
+ + statusCode + "; responseEntity=" + entityStr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -282,9 +302,9 @@ public class FaceppClient {
|
|
}
|
|
}
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
if (log.isDebugEnabled()) {
|
|
- log.debug(
|
|
|
|
- "[Face++]. compareWithTokenAndBase64; faceToken=" + faceToken + "; imageBase64="
|
|
|
|
- + imageBase64 + "; cost " + (System.currentTimeMillis() - s) + " ms.");
|
|
|
|
|
|
+ log.debug("[Face++]. compareWithTokenAndBase64(String,String); faceToken=" + faceToken
|
|
|
|
+ + "; imageBase64=" + imageBase64 + "; cost " + (System.currentTimeMillis() - s)
|
|
|
|
+ + " ms.");
|
|
}
|
|
}
|
|
|
|
|
|
return responseHolder;
|
|
return responseHolder;
|
|
@@ -329,12 +349,12 @@ public class FaceppClient {
|
|
responseHolder = new JsonHttpResponseHolder(statusCode, obj);
|
|
responseHolder = new JsonHttpResponseHolder(statusCode, obj);
|
|
|
|
|
|
if (HttpStatus.SC_OK != responseHolder.getStatusCode()) {
|
|
if (HttpStatus.SC_OK != responseHolder.getStatusCode()) {
|
|
- log.error("[Face++]. compareWithImageUrl; statusCode=" + statusCode
|
|
|
|
|
|
+ log.error("[Face++]. compareWithImageUrl(String,String); statusCode=" + statusCode
|
|
+ "; responseEntity=" + entityStr);
|
|
+ "; responseEntity=" + entityStr);
|
|
} else {
|
|
} else {
|
|
if (log.isDebugEnabled()) {
|
|
if (log.isDebugEnabled()) {
|
|
- log.debug("[Face++]. compareWithImageUrl; statusCode=" + statusCode
|
|
|
|
- + "; responseEntity=" + entityStr);
|
|
|
|
|
|
+ log.debug("[Face++]. compareWithImageUrl(String,String); statusCode="
|
|
|
|
+ + statusCode + "; responseEntity=" + entityStr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -345,8 +365,9 @@ public class FaceppClient {
|
|
}
|
|
}
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
if (log.isDebugEnabled()) {
|
|
- log.debug("[Face++]. compareWithImageUrl; image_url1=" + imageUrl1 + "; imageUrl2="
|
|
|
|
- + imageUrl2 + "; cost " + (System.currentTimeMillis() - s) + " ms.");
|
|
|
|
|
|
+ log.debug("[Face++]. compareWithImageUrl(String,String); image_url1=" + imageUrl1
|
|
|
|
+ + "; imageUrl2=" + imageUrl2 + "; cost " + (System.currentTimeMillis() - s)
|
|
|
|
+ + " ms.");
|
|
}
|
|
}
|
|
|
|
|
|
return responseHolder;
|
|
return responseHolder;
|