use of edu.uiuc.ncsa.myproxy.oa4mp.client.Asset in project OA4MP by ncsa.
the class SQLAssetStore method getByToken.
@Override
public Asset getByToken(Identifier token) {
if (token == null) {
return null;
}
Connection c = getConnection();
Asset t = null;
try {
PreparedStatement stmt = c.prepareStatement(getAST().getByTokenStatement());
stmt.setString(1, token.toString());
stmt.executeQuery();
ResultSet rs = stmt.getResultSet();
// Now we have to pull in all the values.
if (!rs.next()) {
rs.close();
stmt.close();
// returning a null fulfills contract for this being a map.
return null;
}
ColumnMap map = rsToMap(rs);
rs.close();
stmt.close();
t = create();
populate(map, t);
} catch (SQLException e) {
destroyConnection(c);
throw new GeneralException("Error getting object with identifier \"" + token + "\"", e);
} finally {
releaseConnection(c);
}
return t;
}
Aggregations