// Get security token.
final String token = parameters.getParameter(
ChemSpiderParameters.SECURITY_TOKEN).getValue();
// Fetch compound info.
ExtendedCompoundInfo info = null;
try {
info = massSpec.getExtendedCompoundInfo(Integer.valueOf(ID), token);
} catch (final RemoteException e) {
// We need to catch exceptions here - usually from deprecated
// structures in the ChemSpider database or
// invalid security token.
LOG.log(Level.WARNING, "Failed to fetch compound info for CSID #"
+ ID, e);
}
// Determine name and formula.
final String name;
final String formula;
if (info != null) {
// Use returned info.
final String commonName = info.getCommonName();
name = commonName == null ? UNKNOWN_NAME : commonName;
formula = FORMULA_PATTERN.matcher(info.getMF()).replaceAll("");
} else {
// An error occurred.
name = ERROR_MESSAGE;