private void abort() { site.logger.write("ABORT"); StateHelper.aborted(site); site.participantFields.waitingForCommit = false; site.participantFields.waitingForPrecommit = false; System.out.println("Aborted!"); site.endTransaction(); }
private void commit() { site.playlist = site.tempPlaylist; site.logger.write("COMMIT"); StateHelper.committed(site); site.participantFields.waitingForCommit = false; System.out.println("Committed!"); site.endTransaction(); }
/** * @see {@link * javax.faces.render.ResponseStateManager#getViewState(javax.faces.context.FacesContext, * Object)} */ @Override public String getViewState(FacesContext context, Object state) { StringBuilder sb = new StringBuilder(32); try { helper.writeState(context, state, sb); } catch (IOException e) { throw new FacesException(e); } return sb.toString(); }
/** * @see {@link javax.faces.render.ResponseStateManager#getState(javax.faces.context.FacesContext, * String)} */ @Override public Object getState(FacesContext context, String viewId) { Object state = RequestStateManager.get(context, RequestStateManager.FACES_VIEW_STATE); if (state == null) { try { state = helper.getState(context, viewId); if (state != null) { RequestStateManager.set(context, RequestStateManager.FACES_VIEW_STATE, state); } } catch (IOException e) { throw new FacesException(e); } } return state; }
private void sendVoteResp(boolean status) { String decision = (status) ? "YES" : "NO"; site.logger.write(decision); if (status) StateHelper.uncertain(site); else { abort(); } site.sendMsg( site.leader, "VOTERESP\t" + site.procNum + "\t" + site.currentTransaction + "\t" + (decision)); if (status) { site.participantFields.waitingForPrecommit = true; site.participantFields.precommitTimer = new Timer(TIMEOUT); System.out.println("Waiting for precommit.."); } }
@Override public String getCryptographicallyStrongTokenFromSession(FacesContext context) { return helper.getCryptographicallyStrongTokenFromSession(context); }
/** * @see {@link * javax.faces.render.ResponseStateManager#writeState(javax.faces.context.FacesContext, * Object)} */ @Override public void writeState(FacesContext context, Object state) throws IOException { helper.writeState(context, state, null); }
@Override public List<AbstractBean> getAllActiveFilterRecords(String array, String field, String username) { List<AbstractBean> retValue = new ArrayList<AbstractBean>(); String query = "select * from tbl_crm_lead where type = 0 and status = ? and userId = ? and " + field + " IN (" + array + ") UNION select * from tbl_crm_lead where leadId IN (select leadId from tbl_crm_share where userId = ?) and type = 0 and status = ? and " + field + " IN (" + array + ");"; try { preparedStatement = DBUtility.connection.prepareStatement(query); preparedStatement.setBoolean(1, true); preparedStatement.setString(2, username); preparedStatement.setString(3, username); preparedStatement.setBoolean(4, true); } catch (SQLException e) { ZLog.err("VNC CRM for Zimbra", "Error in getting all active records in LeadHelper", e); } ResultSet rs = dbu.select(preparedStatement); LeadBean leadBean = null; CountryHelper countryHelper = new CountryHelper(); StateHelper stateHelper = new StateHelper(); ChannelHelper channelHelper = new ChannelHelper(); SectionHelper sectionHelper = new SectionHelper(); CategoryHelper categoryHelper = new CategoryHelper(); PriorityHelper priorityHelper = new PriorityHelper(); StageHelper stageHelper = new StageHelper(); CompanyHelper companyHelper = new CompanyHelper(); LeadClassHelper leadClassHelper = new LeadClassHelper(); try { while (rs.next()) { leadBean = new LeadBean(); leadBean.setLeadId(rs.getInt("leadId")); leadBean.setSubjectName(rs.getString("subjectName")); leadBean.setLeadDescription(rs.getString("leadDescription")); leadBean.setContactName(rs.getString("contactName")); leadBean.setCompanyBean( (CompanyBean) (companyHelper.getRecordById(rs.getString("companyId")))); leadBean.setValuation(rs.getString("valuation")); leadBean.setLeadState(rs.getString("leadState")); leadBean.setLeadClassBean( (LeadClassBean) (leadClassHelper.getRecordById(rs.getString("leadClassId")))); leadBean.setPartnerName(rs.getString("partnerName")); leadBean.setPhone(rs.getString("phone")); leadBean.setFax(rs.getString("fax")); leadBean.setEmail(rs.getString("email")); leadBean.setWorkPhone(rs.getString("workPhone")); leadBean.setMobile(rs.getString("mobile")); leadBean.setStreet1(rs.getString("street1")); leadBean.setStreet2(rs.getString("street2")); leadBean.setCity(rs.getString("city")); leadBean.setZip(rs.getString("zip")); leadBean.setCountryBean( (CountryBean) (countryHelper.getRecordById(rs.getString("countryId")))); leadBean.setStateBean((StateBean) (stateHelper.getRecordById(rs.getString("stateId")))); leadBean.setChannelBean( (ChannelBean) (channelHelper.getRecordById(rs.getString("channelId")))); leadBean.setPriorityBean( (PriorityBean) (priorityHelper.getRecordById(rs.getString("priorityId")))); leadBean.setStageBean((StageBean) (stageHelper.getRecordById(rs.getString("stageId")))); leadBean.setCategoryBean( (CategoryBean) (categoryHelper.getRecordById(rs.getString("categoryId")))); leadBean.setSectionBean( (SectionBean) (sectionHelper.getRecordById(rs.getString("sectionId")))); leadBean.setType(rs.getString("type")); leadBean.setDateOpen(rs.getString("dateOpen")); leadBean.setDateClose(rs.getString("dateClose")); leadBean.setExpectedDateClose(rs.getString("expectedDateClose")); leadBean.setProbability(rs.getString("probability")); leadBean.setDayClose(rs.getString("dayClose")); leadBean.setDayOpen(rs.getString("dayOpen")); leadBean.setReferredBy(rs.getString("referredBy")); leadBean.setUserId(rs.getString("userId")); leadBean.setNextActionDate(rs.getString("nextActionDate")); leadBean.setNextAction(rs.getString("nextAction")); leadBean.setStatus(rs.getBoolean("status")); leadBean.setCreateBy(rs.getString("createBy")); leadBean.setCreateDate(rs.getString("createDate")); leadBean.setWriteBy(rs.getString("writeBy")); leadBean.setWriteDate(rs.getString("writeDate")); retValue.add(leadBean); } } catch (SQLException e) { ZLog.err("VNC CRM for Zimbra", "Error in Lead Helper Class", e); } return retValue; }
@Override public boolean processMsg(String msg) { String[] parts = msg.split("\t"); if (parts[0].equals("UPLIST")) { if (Integer.parseInt(parts[1]) == site.leader) { String[] hosts = parts[2].split(" "); for (int i = 0; i < site.numProcs; ++i) site.upList[i] = false; for (String host : hosts) site.upList[Integer.parseInt(host)] = true; if (site.logger != null) site.logger.write(parts[0] + "\t" + parts[2]); } return true; } else if (parts[0].equals("VOTEREQ")) { site.leader = Integer.parseInt(parts[1]); site.transactionLogger.write(parts[2]); site.startTransaction(Long.parseLong(parts[2])); if (site.FAILURE == 2) site.dirtyDie(); if (parts[3].equals("ADD")) { boolean status = PlaylistHelper.addSong(site, parts, 3, true); sendVoteResp(status); } else if (parts[3].equals("REMOVE")) { boolean status = PlaylistHelper.removeSong(site, parts, 3, true); sendVoteResp(status); } else if (parts[3].equals("EDIT")) { boolean status = PlaylistHelper.editSong(site, parts, 3, true); sendVoteResp(status); } site.countMsg(Integer.parseInt(parts[1])); return true; } else if (parts[0].equals("PRECOMMIT")) { if (Integer.parseInt(parts[1]) == site.leader && Long.parseLong(parts[2]) == site.currentTransaction) { StateHelper.precommit(site); if (site.FAILURE == 3) site.dirtyDie(); sendAck(); } site.countMsg(Integer.parseInt(parts[1])); return true; } else if (parts[0].equals("COMMIT")) { if (Integer.parseInt(parts[1]) == site.leader && Long.parseLong(parts[2]) == site.currentTransaction) { if (site.FAILURE == 10) site.dirtyDie(); commit(); } site.countMsg(Integer.parseInt(parts[1])); return true; } else if (parts[0].equals("ABORT")) { if (Integer.parseInt(parts[1]) == site.leader && Long.parseLong(parts[2]) == site.currentTransaction) { abort(); } site.countMsg(Integer.parseInt(parts[1])); return true; } else if (parts[0].equals("LEADER") && !site.leader()) { site.leader = site.procNum; site.iLeader(false); return true; } else if (parts[0].equals("LEADER_NEW") && !site.leader()) { site.leader = site.procNum; site.iLeader(true); return true; } else if (parts[0].equals("DEAD") && Integer.parseInt(parts[1]) == site.leader) { handleDeadLeader(); return true; } else if (parts[0].equals("STATEREQ")) { site.upList[site.leader] = false; site.leader = Integer.parseInt(parts[1]); site.upList[site.leader] = true; long transactionID = Long.parseLong(parts[2]); String myState = site.getState(transactionID); site.sendMsg( site.leader, "STATERESP\t" + site.procNum + "\t" + transactionID + "\t" + myState); resetTimers(); site.countMsg(Integer.parseInt(parts[1])); return true; } else if (parts[0].equals("STATEREQ-RECOVERY")) { long transactionID = Long.parseLong(parts[2]); String myState = site.getState(Long.parseLong(parts[2])); site.sendMsg( Integer.parseInt(parts[1]), "STATERESP-RECOVERY\t" + site.procNum + "\t" + transactionID + "\t" + myState); site.countMsg(Integer.parseInt(parts[1])); return true; } else if (parts[0].equals("STATERESP-RECOVERY") && site.recoveryFields != null) { if (Long.parseLong(parts[2]) == site.recoveryFields.recoveryTransaction) { if (parts[3].equals(Process.State.stateStr.get(Process.State.ABORTED))) site.recoveryFields.stateVector[Integer.parseInt(parts[1])] = Process.State.ABORTED; if (parts[3].equals(Process.State.stateStr.get(Process.State.COMMITTED))) site.recoveryFields.stateVector[Integer.parseInt(parts[1])] = Process.State.COMMITTED; if (parts[3].equals(Process.State.stateStr.get(Process.State.UNCERTAIN))) site.recoveryFields.stateVector[Integer.parseInt(parts[1])] = Process.State.UNCERTAIN; if (parts[3].equals(Process.State.stateStr.get(Process.State.PRECOMMIT))) site.recoveryFields.stateVector[Integer.parseInt(parts[1])] = Process.State.PRECOMMIT; if (parts[3].equals(Process.State.stateStr.get(Process.State.LOST))) site.recoveryFields.stateVector[Integer.parseInt(parts[1])] = Process.State.LOST; } if (site.recoveryFields.anyState(Process.State.ABORTED)) { abort(); site.recoveryFields = null; } else if (site.recoveryFields.anyState(Process.State.COMMITTED)) { String[] tparts = site.recoveryFields.recoveryTransactionParts; if (tparts[0].equals("ADD")) { PlaylistHelper.addSong(site, tparts, 0, false); commit(); } else if (tparts[0].equals("REMOVE")) { PlaylistHelper.removeSong(site, tparts, 0, false); commit(); } else if (tparts[0].equals("EDIT")) { PlaylistHelper.editSong(site, tparts, 0, false); commit(); } site.recoveryFields = null; } else if (site.recoveryFields.allStatesAre(Process.State.LOST)) { System.out.println("All states lost. Aborting.."); abort(); site.recoveryFields = null; } site.countMsg(Integer.parseInt(parts[1])); return true; } return false; }