shortUrl 로그 추가
This commit is contained in:
parent
a4b3a4b33f
commit
1febce9602
@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.apache.poi.util.SystemOutLogger;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -455,14 +456,18 @@ public class NlibSearchController extends NlibCommonController {
|
|||||||
try {
|
try {
|
||||||
String originUrl = URLEncoder.encode(paramMap.getString("url"), "UTF-8");
|
String originUrl = URLEncoder.encode(paramMap.getString("url"), "UTF-8");
|
||||||
URL url = new URL( NlibProperty.getProperty("shorturl.api") + "&action=shorturl&format=xml&title=nculture&url=" + originUrl);
|
URL url = new URL( NlibProperty.getProperty("shorturl.api") + "&action=shorturl&format=xml&title=nculture&url=" + originUrl);
|
||||||
|
log.debug("shorturl > url : "+ url);
|
||||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
con.setRequestMethod("GET");
|
con.setRequestMethod("GET");
|
||||||
//con.setRequestProperty("Authorization", header);
|
//con.setRequestProperty("Authorization", header);
|
||||||
int responseCode = con.getResponseCode();
|
int responseCode = con.getResponseCode();
|
||||||
if(responseCode==200) { // 정상 호출
|
if(responseCode==200) { // 정상 호출
|
||||||
br = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
br = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||||
|
log.debug("정상코드 : 200");
|
||||||
} else { // 에러 발생
|
} else { // 에러 발생
|
||||||
br = new BufferedReader(new InputStreamReader(con.getErrorStream()));
|
br = new BufferedReader(new InputStreamReader(con.getErrorStream()));
|
||||||
|
log.debug("shorturl > Error : " + br.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String inputLine;
|
String inputLine;
|
||||||
@ -474,11 +479,15 @@ public class NlibSearchController extends NlibCommonController {
|
|||||||
String str = response.toString();
|
String str = response.toString();
|
||||||
Pattern pattern = Pattern.compile("<shorturl>(.+?)</shorturl>");
|
Pattern pattern = Pattern.compile("<shorturl>(.+?)</shorturl>");
|
||||||
Matcher matcher = pattern.matcher(str);
|
Matcher matcher = pattern.matcher(str);
|
||||||
|
|
||||||
|
log.debug("shorturl > matcher : find() ? " + matcher.find());
|
||||||
|
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
returnUrl = matcher.group(1);
|
|
||||||
if(matcher.group(1) == null){
|
if(matcher.group(1) == null){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
returnUrl = matcher.group(1);
|
||||||
|
log.debug("shorturl > returnUrl : "+ returnUrl);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("shorturl-data.do 단축url > IOException 발생 : " + e.toString());
|
log.error("shorturl-data.do 단축url > IOException 발생 : " + e.toString());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user