упразднение старого объекта аккаунта
This commit is contained in:
@@ -9,9 +9,9 @@ import _VisualDVM.ComponentsServer.BugReport.Json.RecipientsJson;
|
||||
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingsJson;
|
||||
import _VisualDVM.ComponentsServer.Component.ComponentType;
|
||||
import _VisualDVM.ComponentsServer.Subscribes.Subscriber;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Account.Account;
|
||||
import _VisualDVM.ProjectData.SapforData.SapforProperties;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
@@ -127,7 +127,7 @@ public class BugReport extends rDBObject {
|
||||
}
|
||||
public String getSettingsSummary() {
|
||||
Vector<String> res = new Vector_<String>(
|
||||
(Global.mainModule.HasAccount() ? (Global.mainModule.getAccount().isAdmin() ? ("Адрес отправителя: " + sender_address + "\n") : "") : ""),
|
||||
(Global.mainModule.getAccount().isAdmin() ? ("Адрес отправителя: " + sender_address + "\n") : ""),
|
||||
"Версия SAPFOR: " + sapfor_version,
|
||||
"Версия визуализатора: " + visualiser_version,
|
||||
"----------------------------------"
|
||||
@@ -177,7 +177,7 @@ public class BugReport extends rDBObject {
|
||||
public SapforProperties getPropertiesJson() {
|
||||
return packedSettingsJson.isEmpty() ? new SapforProperties() : Utils_.gson.fromJson(packedSettingsJson, SapforProperties.class);
|
||||
}
|
||||
public boolean canAppend(Account account, TextLog log) {
|
||||
public boolean canAppend(UserAccount account, TextLog log) {
|
||||
if (account.CheckRegistered(log)) {
|
||||
if (account.email.equals(sender_address) || account.email.equals(executor_address)) {
|
||||
return true;
|
||||
@@ -195,7 +195,7 @@ public class BugReport extends rDBObject {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean canModify(Account account, TextLog log) {
|
||||
public boolean canModify(UserAccount account, TextLog log) {
|
||||
if (account.CheckRegistered(log)) {
|
||||
switch (account.role) {
|
||||
case Admin:
|
||||
|
||||
@@ -11,8 +11,7 @@ import _VisualDVM.ComponentsServer.Subscribes.Subscriber;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Account.Account;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||
import _VisualDVM.GlobalData.Machine.Machine;
|
||||
import _VisualDVM.GlobalData.Machine.MachineType;
|
||||
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
|
||||
@@ -237,20 +236,6 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
throw new RepositoryRefuseException("Баг репорт с ключом " + oldBugReport.id + " не существует.");
|
||||
}
|
||||
//--
|
||||
void CheckSubscriberRole() throws Exception {
|
||||
Account account = (Account) request.object;
|
||||
Subscriber subscriber = null;
|
||||
if (db.subscribers.containsKey(account.email)) {
|
||||
subscriber = db.subscribers.get(account.email);
|
||||
} else {
|
||||
subscriber = new Subscriber();
|
||||
subscriber.name = account.name;
|
||||
subscriber.address = account.email;
|
||||
subscriber.mailOn = 1;
|
||||
db.Insert(subscriber);
|
||||
}
|
||||
response.object = subscriber; //возвращаем информацию о подписчике.
|
||||
}
|
||||
void GetComponentsBackUps() throws Exception {
|
||||
File backupsDirectory = Paths.get(Utils_.getHomePath(), "Components", request.arg, "Backups").toFile();
|
||||
//--
|
||||
@@ -364,9 +349,6 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
case GetUserAccountByEmail:
|
||||
GetUserAccountByEmail();
|
||||
break;
|
||||
case CheckSubscriberRole: //todo устарело
|
||||
CheckSubscriberRole();
|
||||
break;
|
||||
case GetComponentsBackups:
|
||||
GetComponentsBackUps();
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package _VisualDVM.ComponentsServer.Subscribes;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
public class Subscriber extends DBObject {
|
||||
//todo скорее всего вывести.ибо дублер UserAccount
|
||||
|
||||
@@ -4,7 +4,7 @@ import Common.Visual.UI;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import _VisualDVM.ComponentsServer.Subscribes.Subscriber;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||
public class SubscriberDialog extends DBObjectDialog<Subscriber, SubscriberFields> {
|
||||
public SubscriberDialog() {
|
||||
super(SubscriberFields.class);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package _VisualDVM.ComponentsServer.Subscribes.UI;
|
||||
import Common.Visual.TextField.StyledTextField;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -8,7 +8,7 @@ import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
import _VisualDVM.ComponentsServer.Subscribes.Subscriber;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||
import _VisualDVM.Passes.PassCode;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
23
src/_VisualDVM/ComponentsServer/UserAccount/AccountRole.java
Normal file
23
src/_VisualDVM/ComponentsServer/UserAccount/AccountRole.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package _VisualDVM.ComponentsServer.UserAccount;
|
||||
import java.io.Serializable;
|
||||
public enum AccountRole implements Serializable {
|
||||
Undefined,
|
||||
User,
|
||||
Developer,
|
||||
Admin;
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case Undefined:
|
||||
return "не зарегистрирован";
|
||||
case User:
|
||||
return "Пользователь";
|
||||
case Developer:
|
||||
return "Разработчик";
|
||||
case Admin:
|
||||
return "Администратор";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import Common.Visual.UI;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||
public class UserAccountDialog extends DBObjectDialog<UserAccount, UserAccountFields> {
|
||||
public UserAccountDialog() {
|
||||
super(UserAccountFields.class);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package _VisualDVM.ComponentsServer.UserAccount.UI;
|
||||
import Common.Visual.TextField.StyledTextField;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package _VisualDVM.ComponentsServer.UserAccount;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.iDBObject;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import Common.Utils.TextLog;
|
||||
import _VisualDVM.ComponentsServer.BugReport.BugReport;
|
||||
import _VisualDVM.Global;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
public class UserAccount extends iDBObject {
|
||||
public String name = "";
|
||||
@@ -31,4 +33,55 @@ public class UserAccount extends iDBObject {
|
||||
name = name_in;
|
||||
email=email_in;
|
||||
}
|
||||
//todo часть устарело.разобрать.
|
||||
public boolean CheckRegistered(TextLog Log) {
|
||||
if (role.equals(AccountRole.Undefined)) {
|
||||
if (Log != null) {
|
||||
Log.Writeln("Пользователь не зарегистрирован");
|
||||
if (Global.mainModule.getUI().hasMainWindow())
|
||||
Global.mainModule.getUI().getMainWindow().FocusCallback();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean isRegistered() {
|
||||
return !role.equals(AccountRole.Undefined);
|
||||
}
|
||||
public boolean CheckAuthorship(String address_in, TextLog log) {
|
||||
if (!isAdmin() && (!email.equals(address_in))) {
|
||||
if (log != null)
|
||||
log.Writeln_("Вы не являетесь автором или администратором");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean CheckAccessRights(String address_in, TextLog log) {
|
||||
return (CheckRegistered(log) && CheckAuthorship(address_in, log));
|
||||
}
|
||||
public boolean ExtendedCheckAccessRights(BugReport bugReport, TextLog log) {
|
||||
if (CheckRegistered(log)) {
|
||||
if (email.equals(bugReport.executor_address)) {
|
||||
//метод вывести как нерабочий.когда будет изменена схема админства.
|
||||
return true;
|
||||
} else {
|
||||
if (!isAdmin() && (!email.equals(bugReport.sender_address))) {
|
||||
log.Writeln_("Вы не являетесь автором, исполнителем, или администратором");
|
||||
return false;
|
||||
} else return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean isAdmin() {
|
||||
return role.equals(AccountRole.Admin);
|
||||
}
|
||||
public boolean CheckAdmin(TextLog log) {
|
||||
if (!isAdmin()) {
|
||||
log.Writeln_("Вы не являетесь администратором!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//---
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user