/** * 获取vncviewer连接VNC的参数 * * @return */ public String getClientVNC() { long beginRunTime = 0; if (logger.isDebugEnabled()) { beginRunTime = System.currentTimeMillis(); logger.debug("enter getClientVNC method."); } ControlPanelUser controlPanelUser = (ControlPanelUser) super.getSession().getAttribute(Constants.LOGIN_CURRENTUSER); if (controlPanelUser == null) { super.fillActionResult(Constants.OPTIONS_TIMEOUT); return null; } String vmId = controlPanelUser.getVmId(); String operateObject = "VM[vmId:" + vmId + "]"; VncClientVO vnc = null; int exceptionType = 0; // 0:验证码错误 1:获取远程连接参数异常 try { // 检查验证码是否正确 String sessionCode = (String) ServletActionContext.getRequest().getSession().getAttribute("code"); if (null == this.code || "".equals(this.code)) { fillActionResult(Constants.VERCODE_IS_NULL); } else if (null == sessionCode || !sessionCode.equalsIgnoreCase(this.code)) { fillActionResult(Constants.VERCODE_IS_ERROR); } else { exceptionType = 1; vnc = facade.getClientVnc(vmId); } } catch (HsCloudException e) { if (exceptionType == 0) { if (e.getClass() == new HsCloudException().getClass()) { HsCloudException ex = (HsCloudException) e; dealThrow(new HsCloudException(ex.getCode(), "getClientVNC异常", logger, e), "000"); } else { dealThrow( new HsCloudException(Constants.VERCODE_IS_ERROR, "getClientVNC异常", logger, e), "000"); } return null; } else { if (e.getClass() == new HsCloudException().getClass()) { HsCloudException ex = (HsCloudException) e; dealThrow(new HsCloudException(ex.getCode(), "getClientVNC异常", logger, e), "000"); } else { dealThrow( new HsCloudException(Constants.VM_VNC_ERROR, "getClientVNC异常", logger, e), "000"); } return null; } } if (exceptionType == 1 && vnc != null) { super.fillActionResult((Object) vnc); } else if (exceptionType == 1 && vnc == null) { super.fillActionResult(Constants.VM_VNC_ERROR); } if (logger.isDebugEnabled()) { long takeTime = System.currentTimeMillis() - beginRunTime; logger.debug("exit getVNC method.takeTime:" + takeTime + "ms"); } return null; }