}
private UniqueId lookupPortfolioByName(String name) {
PortfolioSearchRequest searchRequest = new PortfolioSearchRequest();
searchRequest.setName(name);
PortfolioSearchResult searchResult = _portfolioMaster.search(searchRequest);
try {
ManageablePortfolio singlePortfolio = searchResult.getSinglePortfolio();
if (_verbose) {
s_logger.info("Found portfolio called " + name + " mapping in it's id: " + singlePortfolio.getUniqueId());
}
return singlePortfolio.getUniqueId();
} catch (IllegalStateException ise) {
s_logger.warn("Found multiple portfolios called " + name + " so skipping");
return null;
} catch (OpenGammaRuntimeException ogre) {
if (searchResult.getDocuments().size() > 1) {
s_logger.warn("Found multiple portfolios called " + name + " so skipping");
} else {
s_logger.warn("Didn't find a portfolio called " + name + " so skipping");
}
return null;