/** * Returns true if roster item represents a rejected subscription request. * * @param item The roster item. * @return True, if the roster item represents a rejected subscription request. */ private static boolean isSubscriptionRejected(RosterItem item) { return item.getSubStatus() == RosterItem.SUB_NONE && item.getRecvStatus() == RosterItem.RECV_NONE && item.getAskStatus() == RosterItem.AskType.NONE; }
/** * Create a roster item from the data in another one. * * @param item Item that contains the info of the roster item. */ public RosterItem(org.xmpp.packet.Roster.Item item) { this(item.getJID(), getSubType(item), getAskStatus(item), RosterItem.RECV_NONE, item.getName(), new LinkedList<>(item.getGroups())); }
@Override public void updateItem(String username, RosterItem item) { Connection con = null; PreparedStatement pstmt = null; long rosterID = item.getID(); try { con = DbConnectionManager.getConnection(); // Update existing roster item pstmt = con.prepareStatement(UPDATE_ROSTER_ITEM); pstmt.setInt(1, item.getSubStatus().getValue()); pstmt.setInt(2, item.getAskStatus().getValue()); pstmt.setInt(3, item.getRecvStatus().getValue()); pstmt.setString(4, item.getNickname()); pstmt.setLong(5, rosterID); pstmt.executeUpdate(); // Close now the statement (do not wait to be GC'ed) DbConnectionManager.fastcloseStmt(pstmt); // Delete old group list pstmt = con.prepareStatement(DELETE_ROSTER_ITEM_GROUPS); pstmt.setLong(1, rosterID); pstmt.executeUpdate(); insertGroups(rosterID, item.getGroups().iterator(), con); } catch (SQLException e) { Log.error(LocaleUtils.getLocalizedString("admin.error"), e); } finally { DbConnectionManager.closeConnection(pstmt, con); } }
@Override public RosterItem createItem(String username, RosterItem item) throws UserAlreadyExistsException { Connection con = null; PreparedStatement pstmt = null; try { long rosterID = SequenceManager.nextID(JiveConstants.ROSTER); con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(CREATE_ROSTER_ITEM); pstmt.setString(1, username); pstmt.setLong(2, rosterID); pstmt.setString(3, item.getJid().toBareJID()); pstmt.setInt(4, item.getSubStatus().getValue()); pstmt.setInt(5, item.getAskStatus().getValue()); pstmt.setInt(6, item.getRecvStatus().getValue()); pstmt.setString(7, item.getNickname()); pstmt.executeUpdate(); item.setID(rosterID); insertGroups(rosterID, item.getGroups().iterator(), con); } catch (SQLException e) { Log.warn("Error trying to insert a new row in ofRoster", e); throw new UserAlreadyExistsException(item.getJid().toBareJID()); } finally { DbConnectionManager.closeConnection(pstmt, con); } return item; }
continue; org.xmpp.packet.Roster.Ask ask = getAskStatus(item.getAskStatus()); org.xmpp.packet.Roster.Subscription sub = org.xmpp.packet.Roster.Subscription.valueOf(item.getSubStatus() .getName());
oldAsk = item.getAskStatus(); oldSub = item.getSubStatus(); oldRecv = item.getRecvStatus(); if (oldAsk != item.getAskStatus() || oldSub != item.getSubStatus() || oldRecv != item.getRecvStatus()) { roster.updateRosterItem(item);
roster.setType(IQ.Type.set); roster.addItem(item.getJid(), item.getNickname(), getAskStatus(item.getAskStatus()), org.xmpp.packet.Roster.Subscription.valueOf(item.getSubStatus().getName()), groups);
/** * Determine and call the update method based on the item's subscription state. * <p/> * * @param item The item to be updated * @param action The new state change request * @param isSending True if the roster owner of the item is sending the new state change request */ private static void updateState(RosterItem item, Presence.Type action, boolean isSending) { Change change = getStateChange(item.getSubStatus(), action, isSending); if (change.getNewAsk() != null && change.getNewAsk() != item.getAskStatus()) { item.setAskStatus(change.getNewAsk()); } if (change.getNewSub() != null && change.getNewSub() != item.getSubStatus()) { item.setSubStatus(change.getNewSub()); } if (change.getNewRecv() != null && change.getNewRecv() != item.getRecvStatus()) { item.setRecvStatus(change.getNewRecv()); } }
/** * Returns true if roster item represents a rejected subscription request. * * @param item The roster item. * @return True, if the roster item represents a rejected subscription request. */ private static boolean isSubscriptionRejected(RosterItem item) { return item.getSubStatus() == RosterItem.SUB_NONE && item.getRecvStatus() == RosterItem.RECV_NONE && item.getAskStatus() == RosterItem.AskType.NONE; }
/** * Create a roster item from the data in another one. * * @param item Item that contains the info of the roster item. */ public RosterItem(org.xmpp.packet.Roster.Item item) { this(item.getJID(), getSubType(item), getAskStatus(item), RosterItem.RECV_NONE, item.getName(), new LinkedList<>(item.getGroups())); }
@Override public void updateItem(String username, RosterItem item) throws UserNotFoundException { Connection con = null; PreparedStatement pstmt = null; long rosterID = item.getID(); try { con = DbConnectionManager.getConnection(); // Update existing roster item pstmt = con.prepareStatement(UPDATE_ROSTER_ITEM); pstmt.setInt(1, item.getSubStatus().getValue()); pstmt.setInt(2, item.getAskStatus().getValue()); pstmt.setInt(3, item.getRecvStatus().getValue()); pstmt.setString(4, item.getNickname()); pstmt.setLong(5, rosterID); pstmt.executeUpdate(); // Close now the statement (do not wait to be GC'ed) DbConnectionManager.fastcloseStmt(pstmt); // Delete old group list pstmt = con.prepareStatement(DELETE_ROSTER_ITEM_GROUPS); pstmt.setLong(1, rosterID); pstmt.executeUpdate(); insertGroups(rosterID, item.getGroups().iterator(), con); } catch (SQLException e) { Log.error(LocaleUtils.getLocalizedString("admin.error"), e); } finally { DbConnectionManager.closeConnection(pstmt, con); } }
@Override public RosterItem createItem(String username, RosterItem item) throws UserAlreadyExistsException { Connection con = null; PreparedStatement pstmt = null; try { long rosterID = SequenceManager.nextID(JiveConstants.ROSTER); con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(CREATE_ROSTER_ITEM); pstmt.setString(1, username); pstmt.setLong(2, rosterID); pstmt.setString(3, item.getJid().toBareJID()); pstmt.setInt(4, item.getSubStatus().getValue()); pstmt.setInt(5, item.getAskStatus().getValue()); pstmt.setInt(6, item.getRecvStatus().getValue()); pstmt.setString(7, item.getNickname()); pstmt.executeUpdate(); item.setID(rosterID); insertGroups(rosterID, item.getGroups().iterator(), con); } catch (SQLException e) { Log.warn("Error trying to insert a new row in ofRoster", e); throw new UserAlreadyExistsException(item.getJid().toBareJID()); } finally { DbConnectionManager.closeConnection(pstmt, con); } return item; }
continue; org.xmpp.packet.Roster.Ask ask = getAskStatus(item.getAskStatus()); org.xmpp.packet.Roster.Subscription sub = org.xmpp.packet.Roster.Subscription.valueOf(item.getSubStatus() .getName());
oldAsk = item.getAskStatus(); oldSub = item.getSubStatus(); oldRecv = item.getRecvStatus(); if (oldAsk != item.getAskStatus() || oldSub != item.getSubStatus() || oldRecv != item.getRecvStatus()) { roster.updateRosterItem(item);
roster.setType(IQ.Type.set); roster.addItem(item.getJid(), item.getNickname(), getAskStatus(item.getAskStatus()), org.xmpp.packet.Roster.Subscription.valueOf(item.getSubStatus().getName()), groups);
/** * Determine and call the update method based on the item's subscription state. * <p/> * * @param item The item to be updated * @param action The new state change request * @param isSending True if the roster owner of the item is sending the new state change request */ private static void updateState(RosterItem item, Presence.Type action, boolean isSending) { Change change = getStateChange(item.getSubStatus(), action, isSending); if (change.getNewAsk() != null && change.getNewAsk() != item.getAskStatus()) { item.setAskStatus(change.getNewAsk()); } if (change.getNewSub() != null && change.getNewSub() != item.getSubStatus()) { item.setSubStatus(change.getNewSub()); } if (change.getNewRecv() != null && change.getNewRecv() != item.getRecvStatus()) { item.setRecvStatus(change.getNewRecv()); } }