Authored by gemingdan

联盟点击userAgent过长处理

... ... @@ -432,10 +432,12 @@ public class ClickUnionRest implements ApplicationEventPublisherAware{
try{
if (!StringUtils.isEmpty(agent)) {
if (agent.toLowerCase().indexOf("mac os x") >= 0 || agent.toLowerCase().indexOf("iphone") >= 0) {
String version = agent.substring(agent.indexOf(" OS ") + 4, agent.indexOf(" like"));
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("1048984814");
if(agent.indexOf(" OS ") + 4>=0&& agent.indexOf(" like")<=agent.length()&&agent.indexOf(" OS ") + 4<= agent.indexOf(" like")){
String version = agent.substring(agent.indexOf(" OS ") + 4, agent.indexOf(" like"));
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("1048984814");
}
}else {
int index = agent.indexOf("android");
if (index > 0) {
... ...
... ... @@ -222,7 +222,7 @@ public class UnionServiceImpl implements IUnionService, IBusinessExportService,
try {
saveLog(request,type.getName());
} catch (Exception e) {
log.error("", e);
log.error("clickUnion error", e);
}
//组装redis保存的key
... ... @@ -1110,6 +1110,10 @@ public class UnionServiceImpl implements IUnionService, IBusinessExportService,
unionClickLogs.setAppId(request.getAppid());
unionClickLogs.setCreateTime(DateUtil.getCurrentTimeSecond());
unionClickLogs.setUserAgent(request.getUserAgent());
if (request.getUserAgent().length() > 250) {
unionClickLogs.setUserAgent(request.getUserAgent().substring(0,250));
log.info("userAgent too long,substring from {} to {}.",request.getUserAgent(),unionClickLogs.getUserAgent());
}
if(StringUtils.isNotEmpty(request.getInterfaceType())
&&(request.getInterfaceType().equals("addUnion_android")
||request.getInterfaceType().equals("addMonitor_android")
... ...