System.exit(success ? 0 : 1);
}
@Override
protected void doRun() {
PortfolioSearchRequest portfolioSearchRequest = new PortfolioSearchRequest();
portfolioSearchRequest.setName(getCommandLine().getOptionValue(ORIGINAL_PORTFOLIO_NAME));
PortfolioSearchResult portfolioSearchResult = getToolContext().getPortfolioMaster().search(portfolioSearchRequest);
if (portfolioSearchResult.getDocuments().size() == 0) {
throw new OpenGammaRuntimeException("No matching portfolio could be found, will not proceed.");
} else if (portfolioSearchResult.getDocuments().size() > 1) {
throw new OpenGammaRuntimeException("More than one portfolio matches, will not proceed.");
} else {
PortfolioDocument portfolioDocument = portfolioSearchResult.getFirstDocument();
PortfolioSearchRequest portfolioSearchRequest1 = new PortfolioSearchRequest();
portfolioSearchRequest1.setName(getCommandLine().getOptionValue(NEW_PORTFOLIO_NAME));
PortfolioSearchResult portfolioSearchResult1 = getToolContext().getPortfolioMaster().search(portfolioSearchRequest1);
if (portfolioSearchResult1.getDocuments().size() != 0) {
throw new OpenGammaRuntimeException("A portfolio with the specified new name already exists, will not proceed.");
}
if (getCommandLine().hasOption(COPY_OPT)) {