in server/storage/hbase/src/main/java/org/apache/vysper/storage/hbase/roster/HBaseRosterManager.java [70:128]
protected Roster retrieveRosterInternal(Entity bareJid) {
final Result entityRow = hBaseStorage.getEntityRow(bareJid, COLUMN_FAMILY_NAME_CONTACT, COLUMN_FAMILY_NAME_ROSTER);
MutableRoster roster = new MutableRoster();
final NavigableMap<byte[],byte[]> contacts = entityRow.getFamilyMap(COLUMN_FAMILY_NAME_CONTACT_BYTES);
if (contacts == null) return roster;
for (byte[] contactBytes : contacts.keySet()) {
String contactAsString = null;
EntityImpl contactJID = null;
try {
contactAsString = new String(contactBytes, "UTF-8");
contactJID = EntityImpl.parse(contactAsString);
} catch (Exception e) {
LOG.warn("failed to read contact identified by '{}' for user {}", bareJid, contactAsString);
continue;
}
final NavigableMap<byte[],byte[]> contactDetails = entityRow.getFamilyMap(COLUMN_FAMILY_NAME_ROSTER_BYTES);
String name = toStr(contactDetails.get(asBytes(COLUMN_PREFIX_NAME + contactAsString)));
String typeString = toStr(contactDetails.get(asBytes(COLUMN_PREFIX_TYPE + contactAsString)));
String askTypeString = toStr(contactDetails.get(asBytes(COLUMN_PREFIX_ASKTYPE + contactAsString)));
SubscriptionType subscriptionType = null;
try {
subscriptionType = SubscriptionType.valueOf(typeString == null ? "NONE" : typeString.toUpperCase());
} catch (IllegalArgumentException e) {
LOG.warn("when loading roster for user " + bareJid + ", contact " + contactJID + " misses a subscription type");
}
AskSubscriptionType askSubscriptionType = AskSubscriptionType.NOT_SET;
try {
if (StringUtils.isNotBlank(askTypeString)) {
askSubscriptionType = AskSubscriptionType.valueOf(askTypeString);
}
} catch (IllegalArgumentException e) {
LOG.warn("when loading roster for user " + bareJid.getFullQualifiedName() + ", contact "
+ contactJID.getFullQualifiedName() + ", the ask subscription type '" + askTypeString + "' is unparsable. skipping!");
continue; // don't return it, don't set a default!
}
List<RosterGroup> groups = new ArrayList<RosterGroup>();
int i = 1;
while (true) {
String columnName = COLUMN_PREFIX_GROUP + i + ":" + contactAsString;
String groupName = toStr(contactDetails.get(asBytes(columnName)));
if (groupName == null) break;
groups.add(new RosterGroup(groupName));
i++;
}
RosterItem item = new RosterItem(contactJID, name, subscriptionType, askSubscriptionType, groups);
LOG.info("item loaded for " + bareJid.getFullQualifiedName() + ": " + item.toString());
roster.addItem(item);
}
return roster;
}