рефакторинг. прописал стандартную проверку существования объекта в бд сервера

This commit is contained in:
2025-03-21 12:56:12 +03:00
parent 637e9c5c0f
commit 2d0d69fd7a
4 changed files with 46 additions and 88 deletions

View File

@@ -377,6 +377,17 @@ public abstract class RepositoryServer<D extends Database> {
public Database getDb() {
return db;
}
public void checkExistense(Database database, Object pk, Class d_class) throws Exception {
if (!database.getTable(d_class).containsKey(pk))
throw new RepositoryRefuseException(
database.getTable(d_class).getSingleDescription()+
" с ключом "+
Utils_.Brackets(pk.toString())+
" не существует");
}
public void checkExistense(Object pk, Class d_class) throws Exception {
checkExistense(db, pk, d_class);
}
//-------------
void publishObject_(Database database, DBObject dbObject) throws Exception {
beforePublishAction(dbObject);