public String switchVersion() { CheckIn check = workspaceMgr.getVersion(getVersionId()); workspaceMgr.prepareForVersionSwitch(check); projectMgr.updateProject( check.getProject().getId(), check.getProjectData(), "[]", new HashMap<Long, Long>()); Project project = projectMgr.getProject(check.getProject().getId()); String projectData = project.toString(Project.TO_STRING_TYPE.TO_PARAMETER); setJson("{\"projectData\":" + projectData + ", \"isOk\":true}"); project.setProjectData(projectData); projectMgr.updateProject(project); return SUCCESS; }
public String checkIn() throws Exception { User curUser = getCurUser(); if (curUser == null) { setErrMsg(LOGIN_WARN_MSG); setIsOk(false); logger.error("Unlogined user trying to checkin and failed."); return JSON_ERROR; } if (!getAccountMgr().canUserManageProject(getCurUserId(), getId())) { setErrMsg("access deny"); setIsOk(false); logger.error( "User %s trying to checkedin project(id=$d) and denied.", getCurAccount(), getId()); return JSON_ERROR; } /*//save pb content String requestPBParameters = getRequestPBParameters(); String responsePBParameters = getResponsePBParameters(); System.out.println("requestPBParameters:"+ requestPBParameters); System.out.println("responsePBParameters:"+ responsePBParameters);*/ // update project Map<Long, Long> actionIdMap = new HashMap<Long, Long>(); projectMgr.updateProject(getId(), getProjectData(), getDeletedObjectListData(), actionIdMap); project = projectMgr.getProject(getId()); // generate one check-in of VSS mode submit CheckIn checkIn = new CheckIn(); checkIn.setCreateDate(new Date()); checkIn.setDescription(getDescription()); checkIn.setProject(project); checkIn.setProjectData(project.toString(Project.TO_STRING_TYPE.TO_PARAMETER)); checkIn.setTag(getTag()); checkIn.setUser(curUser); checkIn.setVersion(project.getVersion()); checkIn.versionUpgrade(getVersionPosition()); // after version upgrade, set back to project project.setVersion(checkIn.getVersion()); checkIn.setWorkspaceMode(Workspace.ModeType.VSS); workspaceMgr.addCheckIn(checkIn); // calculate JSON string for client project = projectMgr.getProject(getId()); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("{\"projectData\":" + checkIn.getProjectData()); stringBuilder.append(",\"checkList\":["); Iterator<CheckIn> iterator = project.getCheckInListOrdered().iterator(); while (iterator.hasNext()) { stringBuilder.append(iterator.next()); if (iterator.hasNext()) { stringBuilder.append(","); } } Gson g = new Gson(); stringBuilder .append("],\"actionIdMap\":") .append(g.toJson(actionIdMap)) .append(",\"isOk\":true}"); setJson(stringBuilder.toString()); // update project data project.setProjectData(checkIn.getProjectData()); projectMgr.updateProject(project); // unlock the workspace unlock(); // 记录操作日志 RapLog log = new RapLog(); log.setIp(org.apache.struts2.ServletActionContext.getRequest().getRemoteAddr()); log.setOperation("更新接口文档.项目名称:" + project.getName()); log.setUserName(getAccountMgr().getUser(getCurUserId()).getName()); logMgr.createLog(log); // notification for doc change /* for (User user : project.getUserList()) { Notification notification = new Notification(); notification.setParam1(new Integer(id).toString()); notification.setParam2(project.getName()); notification.setTypeId((short) 1); notification.setTargetUser(getCurUser()); notification.setUser(user); if (notification.getUser().getId() != getCurUserId()) getAccountMgr().addNotification(notification); } Notification notification = new Notification(); notification.setParam1(new Integer(id).toString()); notification.setParam2(project.getName()); notification.setTypeId((short) 1); notification.setTargetUser(getCurUser()); notification.setUser(project.getUser()); if (notification.getUser().getId() != getCurUserId()) getAccountMgr().addNotification(notification); */ // unfinished Callable<String> taskSub = new Callable<String>() { @Override public String call() throws Exception { try { // async update doc // projectMgr.updateDoc(id); // async update disableCache projectMgr.updateCache(id); // async update batch jsonschem added by liweiguang 2016-1-15 // System.out.println("in call....id:"+id); validationMgr.generateJsonSchemaByProject(id); // add by liweiguang 2016-03-01 validationMgr.generateMockdataByProject(id); // request jsonschema validationMgr.generateRequestSchemaByProject(id); } catch (Exception ex) { ex.printStackTrace(); } return null; } }; FutureTask<String> futureTask = new FutureTask<String>(taskSub); Thread asyncThread = new Thread(futureTask); asyncThread.start(); logger.info("Future task CHECK_IN running..."); return SUCCESS; }