public String getSecurityJSON(@PathParam("securityExternalId") String securityExternalIdStr) {
if (StringUtils.isEmpty(securityExternalIdStr)) {
return new JSONObject().toString();
}
ExternalId securityExternalId = ExternalId.parse(securityExternalIdStr);
SecuritySearchResult searchResult = _securityMaster.search(new SecuritySearchRequest(securityExternalId));
if (searchResult.getSecurities().size() == 0) {
throw new DataNotFoundException("No security found with ID " + securityExternalId);
}
ManageableSecurity security = searchResult.getFirstSecurity();
BeanVisitor<JSONObject> securityVisitor =
new BuildingBeanVisitor<>(security, new JsonDataSink(BlotterUtils.getJsonBuildingConverters()));
BeanTraverser securityTraverser = BlotterUtils.securityJsonBuildingTraverser();
MetaBean securityMetaBean = JodaBeanUtils.metaBean(security.getClass());
JSONObject securityJson = (JSONObject) securityTraverser.traverse(securityMetaBean, securityVisitor);