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.HttpSession;
|
||||
|
||||
import org.apache.poi.util.SystemOutLogger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -455,14 +456,18 @@ public class NlibSearchController extends NlibCommonController {
|
||||
try {
|
||||
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);
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
log.debug("shorturl > url : "+ url);
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
//con.setRequestProperty("Authorization", header);
|
||||
int responseCode = con.getResponseCode();
|
||||
if(responseCode==200) { // 정상 호출
|
||||
br = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
log.debug("정상코드 : 200");
|
||||
} else { // 에러 발생
|
||||
br = new BufferedReader(new InputStreamReader(con.getErrorStream()));
|
||||
log.debug("shorturl > Error : " + br.toString());
|
||||
|
||||
}
|
||||
|
||||
String inputLine;
|
||||
@ -474,11 +479,15 @@ public class NlibSearchController extends NlibCommonController {
|
||||
String str = response.toString();
|
||||
Pattern pattern = Pattern.compile("<shorturl>(.+?)</shorturl>");
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
|
||||
log.debug("shorturl > matcher : find() ? " + matcher.find());
|
||||
|
||||
while (matcher.find()) {
|
||||
returnUrl = matcher.group(1);
|
||||
if(matcher.group(1) == null){
|
||||
break;
|
||||
}
|
||||
returnUrl = matcher.group(1);
|
||||
log.debug("shorturl > returnUrl : "+ returnUrl);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("shorturl-data.do 단축url > IOException 발생 : " + e.toString());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user