提交 4b2fb51f 编写于 作者: A ascrutae

修复没有登录也可以搜索viewpoint的bug,以及在重启机器情况下,再次点击搜索页面没有跳转到登录页面

上级 76d5baab
package com.ai.cloud.skywalking.web.common; package com.ai.cloud.skywalking.web.common;
import com.ai.cloud.skywalking.web.exception.UserInvalidateException;
import com.ai.cloud.skywalking.web.exception.UserNotLoginException;
import com.ai.cloud.skywalking.web.util.Constants; import com.ai.cloud.skywalking.web.util.Constants;
import com.ai.cloud.skywalking.web.dto.LoginUserInfo; import com.ai.cloud.skywalking.web.dto.LoginUserInfo;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
...@@ -29,11 +31,11 @@ public class BaseController { ...@@ -29,11 +31,11 @@ public class BaseController {
LoginUserInfo loginUserInfo = (LoginUserInfo) request.getSession(). LoginUserInfo loginUserInfo = (LoginUserInfo) request.getSession().
getAttribute(Constants.SESSION_LOGIN_INFO_KEY); getAttribute(Constants.SESSION_LOGIN_INFO_KEY);
if (loginUserInfo == null) { if (loginUserInfo == null) {
throw new RuntimeException("Failed to find login user info"); throw new UserNotLoginException("Failed to find login user info");
} }
if (loginUserInfo.getUid() == null) { if (loginUserInfo.getUid() == null) {
throw new RuntimeException("Login user Id is null"); throw new UserInvalidateException("Login user Id is null");
} }
return loginUserInfo; return loginUserInfo;
......
...@@ -6,6 +6,7 @@ import com.ai.cloud.skywalking.web.entity.BreviaryChainNode; ...@@ -6,6 +6,7 @@ import com.ai.cloud.skywalking.web.entity.BreviaryChainNode;
import com.ai.cloud.skywalking.web.dto.LoginUserInfo; import com.ai.cloud.skywalking.web.dto.LoginUserInfo;
import com.ai.cloud.skywalking.web.dto.TraceTreeInfo; import com.ai.cloud.skywalking.web.dto.TraceTreeInfo;
import com.ai.cloud.skywalking.web.entity.BreviaryChainTree; import com.ai.cloud.skywalking.web.entity.BreviaryChainTree;
import com.ai.cloud.skywalking.web.exception.UserNotLoginException;
import com.ai.cloud.skywalking.web.service.inter.ICallChainTreeService; import com.ai.cloud.skywalking.web.service.inter.ICallChainTreeService;
import com.ai.cloud.skywalking.web.service.inter.ITraceTreeService; import com.ai.cloud.skywalking.web.service.inter.ITraceTreeService;
import com.ai.cloud.skywalking.web.util.Constants; import com.ai.cloud.skywalking.web.util.Constants;
...@@ -115,7 +116,11 @@ public class SearchController extends BaseController { ...@@ -115,7 +116,11 @@ public class SearchController extends BaseController {
result.add("children", jsonElements); result.add("children", jsonElements);
jsonObject.put("code", "200"); jsonObject.put("code", "200");
jsonObject.put("result", result.toString()); jsonObject.put("result", result.toString());
} catch (Exception e) { }catch (UserNotLoginException e){
logger.error("Failed to search chain tree:{}", key, e);
jsonObject.put("code", "505");
jsonObject.put("result", "User is not login.");
}catch (Exception e) {
logger.error("Failed to search chain tree:{}", key, e); logger.error("Failed to search chain tree:{}", key, e);
jsonObject.put("code", "500"); jsonObject.put("code", "500");
jsonObject.put("result", "Fatal error"); jsonObject.put("result", "Fatal error");
......
...@@ -6,9 +6,10 @@ import com.ai.cloud.skywalking.web.util.ViewPointBeautiUtil; ...@@ -6,9 +6,10 @@ import com.ai.cloud.skywalking.web.util.ViewPointBeautiUtil;
* Created by xin on 16-4-14. * Created by xin on 16-4-14.
*/ */
public class BreviaryChainNode { public class BreviaryChainNode {
private String traceLevelId=""; private String traceLevelId = "";
private String viewPoint; private String viewPoint;
private boolean isGuess; private boolean isGuess;
public BreviaryChainNode(String traceLevelId, String viewPoint, boolean isGuess) { public BreviaryChainNode(String traceLevelId, String viewPoint, boolean isGuess) {
this.traceLevelId = traceLevelId; this.traceLevelId = traceLevelId;
this.viewPoint = viewPoint; this.viewPoint = viewPoint;
...@@ -32,10 +33,8 @@ public class BreviaryChainNode { ...@@ -32,10 +33,8 @@ public class BreviaryChainNode {
} }
public void beautiViewPointString(String searchKey) { public void beautiViewPointString(String searchKey) {
if (viewPoint.length() > 100) {
viewPoint = ViewPointBeautiUtil.beautifulViewPoint(viewPoint, searchKey); viewPoint = ViewPointBeautiUtil.beautifulViewPoint(viewPoint, searchKey);
} }
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
......
package com.ai.cloud.skywalking.web.exception;
public class UserInvalidateException extends RuntimeException {
public UserInvalidateException(String message) {
super(message);
}
}
package com.ai.cloud.skywalking.web.exception;
public class UserNotLoginException extends RuntimeException {
public UserNotLoginException(String message) {
super(message);
}
}
...@@ -24,7 +24,8 @@ public class AccessControllerFilter implements Filter { ...@@ -24,7 +24,8 @@ public class AccessControllerFilter implements Filter {
contained.add("addApplication"); contained.add("addApplication");
contained.add("createGlobalApplication"); contained.add("createGlobalApplication");
contained.add("modifyApplication"); contained.add("modifyApplication");
contained.add("showAnlyResult"); contained.add("showAnlySearchResult");
contained.add("showAnalysisResult");
} }
@Override @Override
......
package com.ai.cloud.skywalking.web.util; package com.ai.cloud.skywalking.web.util;
import java.util.ArrayList;
import java.util.List;
/** /**
* Created by xin on 16-4-19. * Created by xin on 16-4-19.
*/ */
...@@ -10,7 +7,10 @@ public class ViewPointBeautiUtil { ...@@ -10,7 +7,10 @@ public class ViewPointBeautiUtil {
public static String beautifulViewPoint(String viewPoint, String searchKey) { public static String beautifulViewPoint(String viewPoint, String searchKey) {
String highLightViewPoint = ViewPointBeautiUtil.addViewPoint(viewPoint, searchKey); String highLightViewPoint = viewPoint;
if (viewPoint.length() > 100) {
highLightViewPoint = ViewPointBeautiUtil.addViewPoint(viewPoint, searchKey);
}
return ViewPointBeautiUtil.highLightViewPoint(highLightViewPoint, searchKey); return ViewPointBeautiUtil.highLightViewPoint(highLightViewPoint, searchKey);
} }
...@@ -27,7 +27,9 @@ public class ViewPointBeautiUtil { ...@@ -27,7 +27,9 @@ public class ViewPointBeautiUtil {
result.append("<span class='highlight-viewpoint'>"); result.append("<span class='highlight-viewpoint'>");
result.append(searchKey); result.append(searchKey);
result.append("</span>"); result.append("</span>");
if (viewPoint.length() > index + searchKey.length() + 1) {
result.append(viewPoint.substring(index + searchKey.length() + 1)); result.append(viewPoint.substring(index + searchKey.length() + 1));
}
return result.toString(); return result.toString();
} }
......
...@@ -89,6 +89,8 @@ function loadAnalyResult(searchKey, pageSize) { ...@@ -89,6 +89,8 @@ function loadAnalyResult(searchKey, pageSize) {
$("#anlyResultmPanel").append(htmlOutput); $("#anlyResultmPanel").append(htmlOutput);
bindPagerBtn(); bindPagerBtn();
} }
}else if (data.code == '505'){
window.location.href = baseUrl + "/usr/login";
} }
}, },
error: function () { error: function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册