use of org.vcell.util.document.GroupAccess in project vcell by virtualcell.
the class DbDriver method updateVersionableInit.
/**
* This method was created in VisualAge.
* @return cbit.image.VCImage
* @param user cbit.vcell.server.User
* @param image cbit.image.VCImage
*/
protected Version updateVersionableInit(InsertHashtable hash, Connection con, User user, Versionable versionable, boolean bVersion) throws DataAccessException, SQLException, RecordChangedException {
if (hash.getDatabaseKey(versionable) != null) {
throw new DataAccessException(versionable + " already inserted in this transaction");
}
if (versionable.getVersion() == null || versionable.getVersion().getVersionKey() == null) {
throw new DataAccessException(versionable + " Not expecting null key before update. Update Failed");
}
// Can only update things we own
if (!versionable.getVersion().getOwner().equals(user)) {
throw new PermissionException("Versionable name=" + versionable.getName() + " type=" + VersionTable.versionableTypeFromVersionable(versionable) + "\nuser=" + versionable.getVersion().getOwner() + " Not Equal to client user=" + user);
}
//
// get new Version info
//
User owner = user;
GroupAccess accessInfo = versionable.getVersion().getGroupAccess();
//
if (versionable instanceof BioModelMetaData || versionable instanceof MathModelMetaData || versionable instanceof Geometry) {
Statement stmt = null;
try {
stmt = con.createStatement();
String sql = "SELECT " + VersionTable.privacy_ColumnName + " FROM " + VersionTable.getVersionTable(versionable).getTableName() + " WHERE " + VersionTable.id_ColumnName + " = " + versionable.getVersion().getVersionKey();
ResultSet rset = stmt.executeQuery(sql);
BigDecimal dbgrpid = null;
if (rset.next()) {
dbgrpid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
}
rset.close();
if (!dbgrpid.equals(versionable.getVersion().getGroupAccess().getGroupid())) {
accessInfo = getGroupAccessFromGroupID(con, dbgrpid);
}
} catch (Throwable e) {
// Don't fail, just keep the permission versionable came in with
} finally {
if (stmt != null) {
stmt.close();
}
}
}
KeyValue versionKey = keyFactory.getNewKey(con);
java.util.Date date = getNewDate(con);
//
// always use the previous BranchPointReference unless branching
//
KeyValue branchPointRefKey = versionable.getVersion().getBranchPointRefKey();
// Check for Archive and Publish not needed in update because versionflag is always forced to Current
VersionFlag versionFlag = null;
// if (bVersion){
// versionFlag = VersionFlag.Archived;
// }else{
versionFlag = VersionFlag.Current;
// }
String versionName = versionable.getVersion().getName();
java.math.BigDecimal branchID = versionable.getVersion().getBranchID();
String annot = versionable.getDescription();
//
// Insert Software Version
//
insertSoftwareVersion(con, versionKey);
//
return new Version(versionKey, versionName, owner, accessInfo, branchPointRefKey, branchID, date, versionFlag, annot);
}
Aggregations