рефакторинг взаимодействия с бд сервера. был индийский код при альтернативной базе на сервере компонент
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
package _VisualDVM.ComponentsServer;
|
||||
import Common.Database.Database;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.RepositoryRefuseException;
|
||||
import Common.Utils.Utils_;
|
||||
@@ -48,6 +49,12 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
zip.Do("Bugs", new File(todayBackUp, "Bugs.zip").getAbsolutePath());
|
||||
}
|
||||
@Override
|
||||
public Database getDb() {
|
||||
if (request.arg.equals("credentials"))
|
||||
return credentials_db;
|
||||
return super.getDb();
|
||||
}
|
||||
@Override
|
||||
protected void beforePublishAction(DBObject object) throws Exception {
|
||||
if (object instanceof BugReport) {
|
||||
BugReport bugReport = (BugReport) object;
|
||||
@@ -287,32 +294,6 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
void ReceiveCredentialsDatabase() throws Exception {
|
||||
response.object = Utils_.fileToBytes(credentials_db.getFile());
|
||||
}
|
||||
void PublishUserAccount() throws Exception {
|
||||
DBObject dbObject = (DBObject) request.object;
|
||||
response.object = (Serializable) credentials_db.InsertS(dbObject).getPK();
|
||||
credentials_db.userAccounts.get(response.object).generateKey();
|
||||
}
|
||||
void EditUserAccount() throws Exception {
|
||||
UserAccount new_object = (UserAccount) request.object;
|
||||
credentials_db.UpdateWithCheck(new_object);
|
||||
afterEditAction(new_object);
|
||||
}
|
||||
void DeleteUserAccount() throws Exception {
|
||||
Pair<Class, Object> to_delete = (Pair<Class, Object>) request.object;
|
||||
afterDeleteAction(credentials_db.DeleteByPK(to_delete.getKey(), to_delete.getValue()));
|
||||
}
|
||||
void PublishSubscriberWorkspace() throws Exception {
|
||||
DBObject dbObject = (DBObject) request.object;
|
||||
response.object = (Serializable) credentials_db.InsertS(dbObject).getPK();
|
||||
}
|
||||
void EditSubcriberWorkpace() throws Exception {
|
||||
SubscriberWorkspace new_object = (SubscriberWorkspace) request.object;
|
||||
credentials_db.UpdateWithCheck(new_object);
|
||||
}
|
||||
void DeleteSubscriberWorkspace() throws Exception {
|
||||
Pair<Class, Object> to_delete = (Pair<Class, Object>) request.object;
|
||||
afterDeleteAction(credentials_db.DeleteByPK(to_delete.getKey(), to_delete.getValue()));
|
||||
}
|
||||
//--
|
||||
@Override
|
||||
protected void UnsafeSession() throws Exception {
|
||||
@@ -346,21 +327,6 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
@Override
|
||||
protected void Session() throws Exception {
|
||||
switch (code) {
|
||||
case PublishUserAccount:
|
||||
PublishUserAccount();
|
||||
break;
|
||||
case EditUserAccount:
|
||||
EditUserAccount();
|
||||
break;
|
||||
case PublishSubscriberWorkspace:
|
||||
PublishSubscriberWorkspace();
|
||||
break;
|
||||
case EditSubcriberWorkpace:
|
||||
EditSubcriberWorkpace();
|
||||
break;
|
||||
case DeleteSubscriberWorkspace:
|
||||
DeleteSubscriberWorkspace();
|
||||
break;
|
||||
case ReceiveCredentialsDatabase:
|
||||
ReceiveCredentialsDatabase();
|
||||
break;
|
||||
@@ -382,9 +348,6 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
case DVMConvertProject:
|
||||
DVMConvertProject();
|
||||
break;
|
||||
case DeleteUserAccount:
|
||||
DeleteUserAccount();
|
||||
break;
|
||||
case CheckURLRegistered:
|
||||
CheckURLRegistered();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user