use of org.eclipse.ecf.presence.search.ISearch in project ecf by eclipse.
the class XMPPSearchTest method testRetrieveBuddiesEmailFieldSync.
/**
* Try to locate buddies on the XMPP server in a call block way
*
* @throws ContainerConnectException
*/
public void testRetrieveBuddiesEmailFieldSync() throws Exception {
assertNotNull(searchManager);
IRestriction selection = searchManager.createRestriction();
assertNotNull(selection);
// search field for XMPP, criterion to match the search
// fields to consider on XMPP server side search
ICriterion email = selection.eq(EMAIL, "mayworm*");
// create a specific criteria
ICriteria criteria = searchManager.createCriteria();
assertNotNull(criteria);
criteria.add(email);
// call the block search
try {
ISearch search = searchManager.search(criteria);
// the collection of IResult
IResultList resultList = search.getResultList();
// check if there is at least one result
int resultListSize = resultList.getResults().size();
if (resultListSize == 0)
System.out.println("XMPPSearchTest.testRetrieveBuddiesEmailFieldSync...no email field retrieved");
else
assertTrue(1 == resultListSize);
} catch (UserSearchException e) {
e.printStackTrace();
}
}
use of org.eclipse.ecf.presence.search.ISearch in project ecf by eclipse.
the class XMPPUserSearchManager method search.
/**
* Specific implementation for XMPP
*
* @see IUserSearchManager#search(ICriteria, IUserSearchListener)
*/
public void search(final ICriteria criteria, final IUserSearchListener listener) {
Assert.isNotNull(criteria);
Assert.isNotNull(listener);
Job job = new Job(Messages.XMPPUserSearchManager_JOB) {
protected IStatus run(IProgressMonitor monitor) {
try {
ISearch search = search(criteria);
UserSearchCompleteEvent complete = new UserSearchCompleteEvent(search);
listener.handleUserSearchEvent(complete);
} catch (UserSearchException e) {
log(e.getLocalizedMessage(), e);
return new Status(IStatus.ERROR, XmppPlugin.PLUGIN_ID, IStatus.ERROR, "Exception in user search", e);
}
return Status.OK_STATUS;
}
};
job.schedule();
}
use of org.eclipse.ecf.presence.search.ISearch in project ecf by eclipse.
the class XMPPSearchTest method testRetrieveBuddiesAllFieldsSync.
/**
* Try to locate buddies on the XMPP server in a call block way
*
* @throws ContainerConnectException
*/
public void testRetrieveBuddiesAllFieldsSync() throws ContainerConnectException {
try {
assertNotNull(searchManager);
IRestriction selection = searchManager.createRestriction();
assertNotNull(selection);
// fields to consider on XMPP server side search
// search field for XMPP, criterion to match the search
ICriterion name = selection.eq(NAME, "Marcelo*");
ICriterion email = selection.eq(EMAIL, "zx*");
ICriterion username = selection.eq(USERNAME, "sl*");
// create a specific criteria
ICriteria criteria = searchManager.createCriteria();
assertNotNull(criteria);
criteria.add(name);
criteria.add(email);
criteria.add(username);
// call the block search
ISearch search = searchManager.search(criteria);
// the collection of IResult
IResultList resultList = search.getResultList();
// check if there is at least one result
assertTrue(0 != resultList.getResults().size());
Iterator it = resultList.getResults().iterator();
while (it.hasNext()) {
IResult type = (IResult) it.next();
System.out.println(type.getUser().getName() + " : " + type.getUser().getID());
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.eclipse.ecf.presence.search.ISearch in project ecf by eclipse.
the class XMPPSearchTest method testRetrieveBuddiesNameFieldSync.
/**
* Try to locate buddies on the XMPP server in a call block way
*
* @throws ContainerConnectException
*/
public void testRetrieveBuddiesNameFieldSync() throws Exception {
assertNotNull(searchManager);
IRestriction selection = searchManager.createRestriction();
assertNotNull(selection);
// fields to consider on XMPP server side search
// search field for XMPP, criterion to match the search
ICriterion name = selection.eq(NAME, "marcelo*");
// create a specific criteria
try {
ICriteria criteria = searchManager.createCriteria();
assertNotNull(criteria);
// criteria.add(searchCriterion);
criteria.add(name);
// call the block search
ISearch search = searchManager.search(criteria);
// the collection of IResult
IResultList resultList = search.getResultList();
int resultListSize = resultList.getResults().size();
if (resultListSize == 0)
System.out.println("XMPPSearchTest.testRetrieveBuddiesNameFieldSync...no email field retrieved");
else
assertTrue(1 == resultListSize);
} catch (UserSearchException e) {
e.printStackTrace();
}
}
Aggregations