use of org.vcell.util.ObjectNotFoundException in project vcell by virtualcell.
the class MathModelDbDriver method getMathModelMetaData.
/**
* getModel method comment.
*/
private MathModelMetaData getMathModelMetaData(Connection con, User user, KeyValue mathModelKey) throws SQLException, DataAccessException, ObjectNotFoundException {
if (user == null || mathModelKey == null) {
throw new IllegalArgumentException("Improper parameters for getMathModelMetaData");
}
if (lg.isTraceEnabled())
lg.trace("MathModelDbDriver.getMathModelMetaData(user=" + user + ", id=" + mathModelKey + ")");
//
// to construct a MathModelMetaData as an immutable object, lets collect all keys first
// (even before authentication). If the user doesn't authenticate, then throw away the
// child keys (from link tables).
//
//
// get Simulation Keys for mathModelKey
//
KeyValue[] simKeys = getSimulationEntriesFromMathModel(con, mathModelKey);
//
// get MathModelMetaData object for mathModelKey
//
String sql;
Field[] f = { new cbit.sql.StarField(mathModelTable), userTable.userid };
Table[] t = { mathModelTable, userTable };
String condition = mathModelTable.id.getQualifiedColName() + " = " + mathModelKey + " AND " + userTable.id.getQualifiedColName() + " = " + mathModelTable.ownerRef.getQualifiedColName();
sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, null, dbSyntax, true);
Statement stmt = con.createStatement();
MathModelMetaData mathModelMetaData = null;
try {
ResultSet rset = stmt.executeQuery(sql);
if (rset.next()) {
mathModelMetaData = mathModelTable.getMathModelMetaData(rset, con, simKeys, dbSyntax);
} else {
throw new ObjectNotFoundException("MathModel id=" + mathModelKey + " not found for user '" + user + "'");
}
} finally {
// Release resources include resultset
stmt.close();
}
return mathModelMetaData;
}
use of org.vcell.util.ObjectNotFoundException in project vcell by virtualcell.
the class DBTopLevel method getMathModelXML.
/**
* This method was created in VisualAge.
* @return cbit.sql.Versionable
* @param object cbit.sql.Versionable
* @param name java.lang.String
* @param bVersion boolean
* @exception org.vcell.util.DataAccessException The exception description.
* @exception java.sql.SQLException The exception description.
* @exception cbit.sql.RecordChangedException The exception description.
*/
String getMathModelXML(User user, KeyValue key, boolean bEnableRetry) throws DataAccessException, java.sql.SQLException, ObjectNotFoundException {
Object lock = new Object();
VersionableType versionableType = VersionableType.MathModelMetaData;
Connection con = conFactory.getConnection(lock);
DbDriver driver = getDbDriver(versionableType);
try {
//
// Getting the corresponding VersionInfo will fail if you don't have permission to the object.
// This is needed because the DbDriver-level services can return objects directly from the
// cache without checking for permissions first.
//
// This check is placed in DbTopLevel because this is the client API entry point.
// Child objects (of the requested object) are given permission by reachablity anyway,
// so if the user is allowed permission to the parent, no further checks are necessary.
//
Vector<VersionInfo> vInfos = getVersionableInfos(user, key, versionableType, true, true, false);
if (vInfos.size() == 0) {
throw new ObjectNotFoundException(versionableType.getTypeName() + " not found");
}
return driver.getVersionableXML(con, versionableType, key);
} catch (Throwable e) {
lg.error(e.getMessage(), e);
if (bEnableRetry && isBadConnection(con)) {
conFactory.failed(con, lock);
return getMathModelXML(user, key, false);
} else {
handle_DataAccessException_SQLException(e);
// never gets here;
return null;
}
} finally {
conFactory.release(con, lock);
}
}
Aggregations