private Pair<String /* Username */, String /* Domain */> splitUserAndDomain(String username) { if (NTLM_PROXY_ENABLED && StringUtils.isSet(username) && username.contains(DOMAIN_SEPARATOR)) { String user = null; String domain = null; StringTokenizer tokenizer = new StringTokenizer(username, DOMAIN_SEPARATOR); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); if (StringUtils.isSet(token)) { if (domain == null) domain = token; else if (user == null) user = token; } } if (StringUtils.isSet(user) && StringUtils.isSet(domain)) return Pair.create(user, domain); } return Pair.create(username, null); }
public Pair<Boolean, Boolean> setNews(Map<INews.State, List<NewsReference>> newsMap) { Assert.isNotNull(newsMap, "newsMap"); // $NON-NLS-1$ boolean changed = false; boolean isNewNewsAdded = false; Set<INews.State> statesToReset = EnumSet.allOf(INews.State.class); statesToReset.removeAll(newsMap.keySet()); /* Reset all ArrayLists whose state is not present in newsMap */ for (INews.State state : statesToReset) { int index = state.ordinal(); LongArrayList currentArrayList = fNewsIds[index]; if (currentArrayList.size() > 0) { currentArrayList.clear(); changed = true; } } /* For each Result */ for (Map.Entry<INews.State, List<NewsReference>> mapEntry : newsMap.entrySet()) { List<NewsReference> news = mapEntry.getValue(); INews.State state = mapEntry.getKey(); Assert.isNotNull(news, "news"); // $NON-NLS-1$ Assert.isNotNull(state, "state"); // $NON-NLS-1$ long[] newArray = new long[news.size()]; /* Fill Bucket */ for (int i = 0; i < news.size(); i++) { newArray[i] = news.get(i).getId(); } int index = state.ordinal(); LongArrayList currentArrayList = fNewsIds[index]; if (state.equals(INews.State.NEW)) { /* Check for added *new* News */ if (newArray.length > currentArrayList.size()) isNewNewsAdded = true; else { for (long value : newArray) { if (currentArrayList.indexOf(value) < 0) { isNewNewsAdded = true; break; } } } if (isNewNewsAdded || (newArray.length != currentArrayList.size())) { changed = true; currentArrayList.setAll(newArray); } } else { if (!currentArrayList.elementsEqual(newArray)) { currentArrayList.setAll(newArray); changed = true; } } } return Pair.create(changed, isNewNewsAdded); }