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

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

@@ -8,7 +8,6 @@ import _VisualDVM.ComponentsServer.BugReport.Json.BugReportAdditionJson;
import _VisualDVM.ComponentsServer.Component.ComponentType;
import _VisualDVM.ComponentsServer.Component.Json.ComponentPublicationInfoJson;
import _VisualDVM.ComponentsServer.Component.Json.ComponentVersionsInfoJson;
import _VisualDVM.ComponentsServer.SubscriberWorkspace.SubscriberWorkspace;
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
import _VisualDVM.Constants;
@@ -25,7 +24,6 @@ import org.apache.commons.io.FileUtils;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.nio.file.Paths;
import java.util.Arrays;
@@ -133,14 +131,13 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
}
void AppendBugReportField() throws Exception {
BugReportAdditionJson transport = (BugReportAdditionJson) request.object;
if (db.bugReports.containsKey(transport.id)) {
BugReport actual = db.bugReports.get(transport.id);
Field field = BugReport.class.getField(transport.fieldName);
field.set(actual, field.get(actual) + "\n" + transport.textAddition);
actual.change_date = new Date().getTime();
db.Update(actual);
response.object = actual;
} else throw new RepositoryRefuseException("Баг репорт с ключом " + transport.id + " не существует.");
checkExistense(transport.id, BugReport.class);
BugReport actual = db.bugReports.get(transport.id);
Field field = BugReport.class.getField(transport.fieldName);
field.set(actual, field.get(actual) + "\n" + transport.textAddition);
actual.change_date = new Date().getTime();
db.Update(actual);
response.object = actual;
}
void ReceiveAllArchives() throws Exception {
ZipFolderPass zip = new ZipFolderPass();
@@ -159,13 +156,11 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
}
void UpdateBugReport() throws Exception {
BugReport oldBugReport = (BugReport) request.object;
if (db.bugReports.containsKey(oldBugReport.id)) {
BugReport bugReport = db.bugReports.get(oldBugReport.id);
bugReport.SynchronizeFields(oldBugReport);
bugReport.change_date = new Date().getTime();
db.Update(bugReport);
} else
throw new RepositoryRefuseException("Баг репорт с ключом " + oldBugReport.id + " не существует.");
checkExistense(oldBugReport.id, BugReport.class);
BugReport bugReport = db.bugReports.get(oldBugReport.id);
bugReport.SynchronizeFields(oldBugReport);
bugReport.change_date = new Date().getTime();
db.Update(bugReport);
}
//--
void GetComponentsBackUps() throws Exception {