*/
public synchronized IReviewboardClient getClient(boolean refreshForce, IProgressMonitor monitor) {
if( null == monitor ){
monitor = new NullProgressMonitor();
}
RbConfig rbConfig = RbConfigReader.getServerConfig(null);
if( null == rbConfig || null == rbConfig.getServer() ){
return null;
}
IReviewboardClient reviewboardClient = this.urlToClientMap.get(rbConfig.getServer());
boolean isClientDataNull = false;
ReviewboardClientData clientData = null;
if (null == reviewboardClient) {
isClientDataNull = true;
clientData = new ReviewboardClientData();
reviewboardClient = new ReviewboardClientImpl(clientData, rbConfig.getServer(),
rbConfig.getUserId(), rbConfig.getPassword(), CHARACTER_ENCODING );
}
clientData = reviewboardClient.getClientData();
if( null == clientData ||
null == clientData.getReviewGroupList() || clientData.getReviewGroupList().isEmpty()
|| null == clientData.getRepositoryList() || clientData.getRepositoryList().isEmpty()
|| null == clientData.getUserList() || clientData.getUserList().isEmpty() ){
isClientDataNull = true;
}
//强制刷新RepositoryData
if( isClientDataNull || refreshForce ){
IReviewboardService reviewboardService = new ReviewboardServiceImpl( reviewboardClient );
boolean loginSuccess = reviewboardService.validCredentials(rbConfig.getUserId(), rbConfig.getPassword(), null);
if( loginSuccess ){
reviewboardService.updateRepositoryData(true, monitor);
this.urlToClientMap.put(rbConfig.getServer(), reviewboardClient);
}
}
return reviewboardClient;
}