SUPPORT-9213: переход на idm3

This commit is contained in:
adel.ka 2025-06-02 18:14:30 +03:00
parent 6c0df3a717
commit 2013b52742
27 changed files with 653 additions and 964 deletions

View file

@ -20,11 +20,13 @@ import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider;
import net.javacrumbs.shedlock.spring.ScheduledLockConfiguration;
import net.javacrumbs.shedlock.spring.ScheduledLockConfigurationBuilder;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@ -66,6 +68,12 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@EnableScheduling
public class AppConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(AppConfig.class);
@Value("${ervu.http.connectTimeout:5000}")
private int connectTimeout;
@Value("${ervu.http.readTimeout:15000}")
private int readTimeout;
@Value("${ervu.http.connectionRequestTimeout:5000}")
private int connectionRequestTimeout;
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(){
@ -99,12 +107,19 @@ public class AppConfig {
@Bean
public RestTemplate restTemplate() {
CloseableHttpClient httpClient = HttpClients.custom()
.setSSLContext(sslContext())
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(connectTimeout)
.setSocketTimeout(readTimeout)
.setConnectionRequestTimeout(connectionRequestTimeout)
.build();
RestTemplate restTemplate = new RestTemplate();
restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(httpClient));
return restTemplate;
CloseableHttpClient httpClient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
return new RestTemplate(requestFactory);
}
@Bean

View file

@ -1,6 +1,8 @@
package ru.micord.ervu.account_applications.component.model;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -13,19 +15,14 @@ import com.fasterxml.jackson.annotation.JsonProperty;
public class Account {
@JsonProperty("id")
private String accountId;
private int version;
private long modified;
private long createDate;
private String start;
private String finish;
private boolean enabled;
private String position;
private String fio;
private String workMail;
private boolean esiaAccount;
@JsonProperty("user-domain")
private UserDomain userDomain;
private boolean active;
private String appointment;
private int sessionsLimit;
private Domain domain;
private Person person;
private List<Role> roles;
public String getAccountId() {
return accountId;
@ -35,30 +32,6 @@ public class Account {
this.accountId = accountId;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public long getModified() {
return modified;
}
public void setModified(long modified) {
this.modified = modified;
}
public long getCreateDate() {
return createDate;
}
public void setCreateDate(long createDate) {
this.createDate = createDate;
}
public String getStart() {
return start;
}
@ -75,52 +48,36 @@ public class Account {
this.finish = finish;
}
public boolean isEnabled() {
return enabled;
public boolean isActive() {
return active;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
public void setActive(boolean active) {
this.active = active;
}
public String getPosition() {
return position;
public String getAppointment() {
return appointment;
}
public void setPosition(String position) {
this.position = position;
public void setAppointment(String appointment) {
this.appointment = appointment;
}
public String getFio() {
return fio;
public int getSessionsLimit() {
return sessionsLimit;
}
public void setFio(String fio) {
this.fio = fio;
public void setSessionsLimit(int sessionsLimit) {
this.sessionsLimit = sessionsLimit;
}
public String getWorkMail() {
return workMail;
public Domain getDomain() {
return domain;
}
public void setWorkMail(String workMail) {
this.workMail = workMail;
}
public boolean isEsiaAccount() {
return esiaAccount;
}
public void setEsiaAccount(boolean esiaAccount) {
this.esiaAccount = esiaAccount;
}
public UserDomain getUserDomain() {
return userDomain;
}
public void setUserDomain(UserDomain userDomain) {
this.userDomain = userDomain;
public void setDomain(Domain domain) {
this.domain = domain;
}
public Person getPerson() {
@ -130,4 +87,12 @@ public class Account {
public void setPerson(Person person) {
this.person = person;
}
public List<Role> getRoles() {
return roles;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}
}

View file

@ -1,46 +0,0 @@
package ru.micord.ervu.account_applications.component.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/**
* @author Adel Kalimullin
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class Credential {
private String id;
private long modified;
private String userName;
private boolean blocked;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public long getModified() {
return modified;
}
public void setModified(long modified) {
this.modified = modified;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public boolean isBlocked() {
return blocked;
}
public void setBlocked(boolean blocked) {
this.blocked = blocked;
}
}

View file

@ -7,36 +7,38 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* @author Adel Kalimullin
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class UserDomain {
public class Domain {
@JsonProperty("id")
private String domainId;
@JsonProperty("name")
private String name;
private String shortname;
private String fullname;
private String dns;
@JsonProperty("shortName")
private String shortName;
@JsonProperty("fullName")
private String fullName;
private boolean active;
private boolean reportsEnabled;
@JsonProperty("type")
private String type;
private String email;
private String dns;
private String phone;
private String address;
private String postalAddress;
private String address;
private String addressId;
private String postalAddressId;
private String militaryCode;
private String timezone;
private boolean reportsEnabled;
private String ogrn;
private boolean enabled;
private String aliasKey;
private String oktmo;
private boolean esiaEmployeeAuthorization;
private String regionId;
private String passKey;
private String govOrganizationType;
private String inn;
private String certificate;
private String ogrn;
private String kpp;
private String tnsDepartmentId;
private String region;
private String leg;
private String bik;
private String bankName;
private String okato;
private String oktmo;
private String subpoenaSeriesCode;
private boolean nsiOrganization;
private boolean tnsOrganization;
public String getDomainId() {
return domainId;
@ -54,28 +56,44 @@ public class UserDomain {
this.name = name;
}
public String getShortname() {
return shortname;
public String getShortName() {
return shortName;
}
public void setShortname(String shortname) {
this.shortname = shortname;
public void setShortName(String shortName) {
this.shortName = shortName;
}
public String getFullname() {
return fullname;
public String getFullName() {
return fullName;
}
public void setFullname(String fullname) {
this.fullname = fullname;
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getDns() {
return dns;
public boolean isActive() {
return active;
}
public void setDns(String dns) {
this.dns = dns;
public void setActive(boolean active) {
this.active = active;
}
public boolean isReportsEnabled() {
return reportsEnabled;
}
public void setReportsEnabled(boolean reportsEnabled) {
this.reportsEnabled = reportsEnabled;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getEmail() {
@ -86,6 +104,14 @@ public class UserDomain {
this.email = email;
}
public String getDns() {
return dns;
}
public void setDns(String dns) {
this.dns = dns;
}
public String getPhone() {
return phone;
}
@ -94,14 +120,6 @@ public class UserDomain {
this.phone = phone;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPostalAddress() {
return postalAddress;
}
@ -110,6 +128,14 @@ public class UserDomain {
this.postalAddress = postalAddress;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getAddressId() {
return addressId;
}
@ -142,12 +168,12 @@ public class UserDomain {
this.timezone = timezone;
}
public boolean isReportsEnabled() {
return reportsEnabled;
public String getInn() {
return inn;
}
public void setReportsEnabled(boolean reportsEnabled) {
this.reportsEnabled = reportsEnabled;
public void setInn(String inn) {
this.inn = inn;
}
public String getOgrn() {
@ -158,20 +184,36 @@ public class UserDomain {
this.ogrn = ogrn;
}
public boolean isEnabled() {
return enabled;
public String getKpp() {
return kpp;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
public void setKpp(String kpp) {
this.kpp = kpp;
}
public String getAliasKey() {
return aliasKey;
public String getBik() {
return bik;
}
public void setAliasKey(String aliasKey) {
this.aliasKey = aliasKey;
public void setBik(String bik) {
this.bik = bik;
}
public String getBankName() {
return bankName;
}
public void setBankName(String bankName) {
this.bankName = bankName;
}
public String getOkato() {
return okato;
}
public void setOkato(String okato) {
this.okato = okato;
}
public String getOktmo() {
@ -182,83 +224,27 @@ public class UserDomain {
this.oktmo = oktmo;
}
public boolean isEsiaEmployeeAuthorization() {
return esiaEmployeeAuthorization;
public String getSubpoenaSeriesCode() {
return subpoenaSeriesCode;
}
public void setEsiaEmployeeAuthorization(boolean esiaEmployeeAuthorization) {
this.esiaEmployeeAuthorization = esiaEmployeeAuthorization;
public void setSubpoenaSeriesCode(String subpoenaSeriesCode) {
this.subpoenaSeriesCode = subpoenaSeriesCode;
}
public String getRegionId() {
return regionId;
public boolean isNsiOrganization() {
return nsiOrganization;
}
public void setRegionId(String regionId) {
this.regionId = regionId;
public void setNsiOrganization(boolean nsiOrganization) {
this.nsiOrganization = nsiOrganization;
}
public String getPassKey() {
return passKey;
public boolean isTnsOrganization() {
return tnsOrganization;
}
public void setPassKey(String passKey) {
this.passKey = passKey;
}
public String getGovOrganizationType() {
return govOrganizationType;
}
public void setGovOrganizationType(String govOrganizationType) {
this.govOrganizationType = govOrganizationType;
}
public String getInn() {
return inn;
}
public void setInn(String inn) {
this.inn = inn;
}
public String getCertificate() {
return certificate;
}
public void setCertificate(String certificate) {
this.certificate = certificate;
}
public String getKpp() {
return kpp;
}
public void setKpp(String kpp) {
this.kpp = kpp;
}
public String getTnsDepartmentId() {
return tnsDepartmentId;
}
public void setTnsDepartmentId(String tnsDepartmentId) {
this.tnsDepartmentId = tnsDepartmentId;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getLeg() {
return leg;
}
public void setLeg(String leg) {
this.leg = leg;
public void setTnsOrganization(boolean tnsOrganization) {
this.tnsOrganization = tnsOrganization;
}
}

View file

@ -12,17 +12,18 @@ import com.fasterxml.jackson.annotation.JsonProperty;
public class Person {
@JsonProperty("id")
private String personId;
private long modified;
private long createDate;
private String birthdate;
private String firstname;
private String middlename;
private String surname;
private String sex;
private String email;
private String photo;
private String phone;
@JsonProperty("fio")
private String fullName;
@JsonProperty("firstName")
private String firstName;
@JsonProperty("lastName")
private String lastName;
@JsonProperty("middleName")
private String middleName;
private String snils;
private String login;
private boolean active;
private boolean blocked;
private boolean secondFactorEnabled;
private List<String> ipAddresses;
@ -34,84 +35,36 @@ public class Person {
this.personId = personId;
}
public long getModified() {
return modified;
public String getFullName() {
return fullName;
}
public void setModified(long modified) {
this.modified = modified;
public void setFullName(String fullName) {
this.fullName = fullName;
}
public long getCreateDate() {
return createDate;
public String getFirstName() {
return firstName;
}
public void setCreateDate(long createDate) {
this.createDate = createDate;
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getBirthdate() {
return birthdate;
public String getLastName() {
return lastName;
}
public void setBirthdate(String birthdate) {
this.birthdate = birthdate;
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getFirstname() {
return firstname;
public String getMiddleName() {
return middleName;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getMiddlename() {
return middlename;
}
public void setMiddlename(String middlename) {
this.middlename = middlename;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhoto() {
return photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
public String getSnils() {
@ -122,6 +75,30 @@ public class Person {
this.snils = snils;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public boolean isBlocked() {
return blocked;
}
public void setBlocked(boolean blocked) {
this.blocked = blocked;
}
public boolean isSecondFactorEnabled() {
return secondFactorEnabled;
}

View file

@ -11,10 +11,8 @@ public class Role {
private String id;
private String name;
private String displayName;
private String parentId;
private boolean ervuRole;
private String finish;
private int sessionsLimit;
private String description;
private boolean active;
public String getId() {
return id;
@ -40,35 +38,19 @@ public class Role {
this.displayName = displayName;
}
public String getParentId() {
return parentId;
public String getDescription() {
return description;
}
public void setParentId(String parentId) {
this.parentId = parentId;
public void setDescription(String description) {
this.description = description;
}
public boolean isErvuRole() {
return ervuRole;
public boolean isActive() {
return active;
}
public void setErvuRole(boolean ervuRole) {
this.ervuRole = ervuRole;
}
public String getFinish() {
return finish;
}
public void setFinish(String finish) {
this.finish = finish;
}
public int getSessionsLimit() {
return sessionsLimit;
}
public void setSessionsLimit(int sessionsLimit) {
this.sessionsLimit = sessionsLimit;
public void setActive(boolean active) {
this.active = active;
}
}

View file

@ -2,21 +2,24 @@ package ru.micord.ervu.account_applications.component.model.dto;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author Adel Kalimullin
*/
public class GridServiceRequest {
public class SearchRequest {
@JsonProperty("search")
private Map<String, Object> searchFilter;
private int page;
private int perPage;
public GridServiceRequest(Map<String, Object> searchFilter, int page, int perPage) {
public SearchRequest(Map<String, Object> searchFilter, int page, int perPage) {
this.searchFilter = searchFilter;
this.page = page;
this.perPage = perPage;
}
public GridServiceRequest() {
public SearchRequest() {
}
public Map<String, Object> getSearchFilter() {

View file

@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
* @author Adel Kalimullin
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class GridServiceResponse<T> {
public class SearchResponse<T> {
private Set<T> data;
private int page;
private int perPage;

View file

@ -7,7 +7,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import ru.micord.ervu.account_applications.dao.UserApplicationListDao;
import ru.micord.ervu.account_applications.service.RoleServiceImpl;
import ru.micord.ervu.account_applications.service.AccountDataService;
import ru.cg.webbpm.modules.webkit.annotations.RpcCall;
import ru.cg.webbpm.modules.webkit.annotations.RpcService;
@ -23,7 +23,7 @@ public class UserApplicationListRpcService extends Behavior {
@Autowired
private UserApplicationListDao applicationListDao;
@Autowired
private RoleServiceImpl roleService;
private AccountDataService accountService;
@RpcCall
public void saveTraceId(String traceId, long appNumber) {
@ -38,6 +38,6 @@ public class UserApplicationListRpcService extends Behavior {
@RpcCall
public List<String> getRemovedRoleIds(String accountId, Set<String> roleIds) {
return roleService.fetchRemovedRoleIds(accountId, roleIds);
return accountService.fetchRemovedRoleIdsByAccountId(accountId, roleIds);
}
}

View file

@ -1,10 +1,14 @@
package ru.micord.ervu.account_applications.component.service;
import java.net.URI;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import ru.micord.ervu.account_applications.component.exception.IdmValidatorException;
import ru.micord.ervu.account_applications.service.constant.PathConstant;
/**
* @author Emir Suleimanov
@ -15,13 +19,35 @@ public abstract class AbstractIdmValidatorService implements IdmValidatorService
@Value("${idm.url}")
protected String idmUrl;
public AbstractIdmValidatorService(RestTemplate restTemplate) {
protected AbstractIdmValidatorService(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
public HttpEntity<Void> createRequestEntity() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
return new HttpEntity<>(headers);
}
protected boolean checkExistsByQuery(String endpoint, String queryParamName, String queryParamValue) {
URI uri = UriComponentsBuilder
.fromHttpUrl(idmUrl)
.pathSegment(PathConstant.PERSONS_PATH)
.path(endpoint)
.queryParam(queryParamName, queryParamValue)
.build()
.encode()
.toUri();
try {
ResponseEntity<Boolean> response = restTemplate.exchange(
uri,
HttpMethod.GET,
null,
Boolean.class
);
return Boolean.TRUE.equals(response.getBody());
}
catch (Exception e) {
throw new IdmValidatorException(String.format(
"Ошибка при проверке значения [%s] через параметр [%s] по адресу [%s]",
queryParamValue, queryParamName, uri
), e);
}
}
}

View file

@ -0,0 +1,115 @@
package ru.micord.ervu.account_applications.component.service;
import java.util.*;
import java.util.stream.Collectors;
import model.FileModel;
import model.Filter;
import model.grid.GridDataExportFormat;
import model.grid.GridRow;
import model.grid.GridRows;
import model.grid.SortInfo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import ru.micord.ervu.account_applications.component.field.persist.filter.StaticFilterComponent;
import ru.micord.ervu.account_applications.component.model.Account;
import ru.micord.ervu.account_applications.component.model.dto.SearchRequest;
import ru.micord.ervu.account_applications.component.model.dto.SearchResponse;
import ru.micord.ervu.account_applications.security.context.SecurityContext;
import ru.micord.ervu.account_applications.security.model.jwt.UserSession;
import ru.micord.ervu.account_applications.security.model.role.ErvuRoleAuthority;
import ru.micord.ervu.account_applications.service.AccountDataService;
import ru.micord.ervu.account_applications.util.StringUtils;
import service.GridService;
import ru.cg.webbpm.modules.webkit.beans.Behavior;
/**
* @author Adel Kalimullin
*/
@Service
public class AccountGridLoadService extends Behavior implements GridService {
private final SecurityContext securityContext;
private final AccountDataService accountDataService;
@Value("${ervu.role.admin:#{null}}")
private String ervuAdminRole;
public AccountGridLoadService(SecurityContext securityContext,
AccountDataService accountDataService) {
this.securityContext = securityContext;
this.accountDataService = accountDataService;
}
@Override
public GridRows loadData(Integer offset, Integer limit, Filter[] filters,
SortInfo[] sortInfos) {
SearchRequest searchRequest = createLoadServiceRequest(offset, limit, filters);
SearchResponse<Account> searchResponse = accountDataService.fetchByFilter(searchRequest);
List<GridRow> gridRows = searchResponse.getData() != null
? convertToGridRows(searchResponse.getData())
: List.of();
return new GridRows(gridRows);
}
@Override
public GridRows loadDataWithRowCount(Integer offset, Integer limit, Filter[] filters,
SortInfo[] sortInfos) {
SearchRequest searchRequest = createLoadServiceRequest(offset, limit, filters);
SearchResponse<Account> searchResponse = accountDataService.fetchByFilter(searchRequest);
List<GridRow> gridRows = searchResponse.getData() != null
? convertToGridRows(searchResponse.getData())
: List.of();
return new GridRows(gridRows, searchResponse.getTotalRows());
}
@Override
public FileModel exportData(String[] columnIdsToExport, GridDataExportFormat exportFormat,
Filter[] filters, SortInfo[] sortInfo) {
return GridService.super.exportData(columnIdsToExport, exportFormat, filters, sortInfo);
}
private List<GridRow> convertToGridRows(Set<Account> accounts) {
List<GridRow> gridRows = new ArrayList<>();
for (Account account : accounts) {
GridRow gridRow = new GridRow();
gridRow.put("row_uid", account.getAccountId() != null ? account.getAccountId() : "");
if (account.getPerson() != null && account.getPerson().getFullName() != null) {
gridRow.putAll(StringUtils.splitFio(account.getPerson().getFullName()));
}
if (account.getDomain() != null && account.getDomain().getFullName() != null) {
gridRow.put("organizationName", account.getDomain().getFullName());
}
gridRows.add(gridRow);
}
return gridRows;
}
private SearchRequest createLoadServiceRequest(Integer offset, Integer limit,
Filter[] filters) {
int page = (offset / limit) + 1;
Map<String, Object> filterMap = new HashMap<>();
UserSession userSession = securityContext.getUserSession();
Set<ErvuRoleAuthority> roles = userSession.roles();
if (ervuAdminRole == null || roles.stream().noneMatch(role -> role.getAuthority().equals(
ervuAdminRole))) {
filterMap.put("domainId", securityContext.getDomainId());
}
if (filters != null && filters.length > 0) {
filterMap.putAll(Arrays.stream(filters)
.filter(filter -> filter.getFilterModels() != null && filter.getFilterModels().length > 0)
.collect(Collectors.toMap(
filter -> getScriptInObject(filter.componentGuid, StaticFilterComponent.class).name,
filter -> filter.getFilterModels()[0].value,
(existing, replacement) -> replacement
))
);
}
return new SearchRequest(filterMap, page, limit);
}
}

View file

@ -8,7 +8,7 @@ import model.FieldData;
import org.springframework.stereotype.Service;
import ru.micord.ervu.account_applications.component.exception.UserDataLoadException;
import ru.micord.ervu.account_applications.component.util.FormUtils;
import ru.micord.ervu.account_applications.service.UserDataService;
import ru.micord.ervu.account_applications.service.EntityDataService;
import service.container.FormMode;
import service.container.FormService;
@ -20,8 +20,8 @@ import ru.cg.webbpm.modules.webkit.beans.Behavior;
* @author Adel Kalimullin
*/
@Service
public class ErvuUserFormLoadService extends Behavior implements FormService {
public UserDataService userDataService;
public class ErvuFormLoadService extends Behavior implements FormService {
public EntityDataService entityDataService;
@RpcSharedProperty
public FormMode mode = FormMode.SIMPLE;
@ -29,7 +29,7 @@ public class ErvuUserFormLoadService extends Behavior implements FormService {
public List<FieldData> loadData(Object id) {
try {
Map<String, List<String>> componentNameToIdMap = FormUtils.getComponentNameToIdMap(this);
Map<String, Object> fieldNameAndValueMap = userDataService.fetchDataById(id);
Map<String, Object> fieldNameAndValueMap = entityDataService.fetchDataById(id);
return FormUtils.createFieldData(componentNameToIdMap, fieldNameAndValueMap);
}
catch (Exception e) {

View file

@ -1,180 +0,0 @@
package ru.micord.ervu.account_applications.component.service;
import java.lang.reflect.Field;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.*;
import java.util.stream.Collectors;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import model.FileModel;
import model.Filter;
import model.grid.GridDataExportFormat;
import model.grid.GridRow;
import model.grid.GridRows;
import model.grid.SortInfo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import org.springframework.web.util.UriComponentsBuilder;
import ru.micord.ervu.account_applications.component.exception.ApiResponseException;
import ru.micord.ervu.account_applications.component.exception.UserDataLoadException;
import ru.micord.ervu.account_applications.component.field.persist.filter.StaticFilterComponent;
import ru.micord.ervu.account_applications.component.model.dto.GridServiceRequest;
import ru.micord.ervu.account_applications.component.model.dto.GridServiceResponse;
import ru.micord.ervu.account_applications.component.model.User;
import ru.micord.ervu.account_applications.security.context.SecurityContext;
import ru.micord.ervu.account_applications.security.model.jwt.UserSession;
import ru.micord.ervu.account_applications.security.model.role.ErvuRoleAuthority;
import ru.micord.ervu.account_applications.service.constant.PathConstant;
import ru.micord.ervu.account_applications.util.StringUtils;
import service.GridService;
import ru.cg.webbpm.modules.webkit.beans.Behavior;
/**
* @author Adel Kalimullin
*/
@Service
public class ErvuUserGridLoadService extends Behavior implements GridService {
private static final String FILTER_PATH = "search/filter/v1";
private final ObjectMapper objectMapper;
private final SecurityContext securityContext;
@Value("${ervu.http.timeout:30}")
private int httpTimeout;
@Value("${idm.url}")
private String idmUrl;
@Value("${ervu.role.admin:#{null}}")
private String ervuAdminRole;
public ErvuUserGridLoadService(ObjectMapper objectMapper,
SecurityContext securityContext) {
this.objectMapper = objectMapper;
this.securityContext = securityContext;
}
@Override
public GridRows loadData(Integer offset, Integer limit, Filter[] filters,
SortInfo[] sortInfos) {
GridServiceResponse<User> gridServiceResponse = loadDataFromApi(offset, limit, filters);
List<GridRow> gridRows = convertToGridRows(gridServiceResponse.getData());
return new GridRows(gridRows);
}
@Override
public GridRows loadDataWithRowCount(Integer offset, Integer limit, Filter[] filters,
SortInfo[] sortInfos) {
GridServiceResponse<User> gridServiceResponse = loadDataFromApi(offset, limit, filters);
List<GridRow> gridRows = convertToGridRows(gridServiceResponse.getData());
return new GridRows(gridRows, gridServiceResponse.getTotalRows());
}
@Override
public FileModel exportData(String[] columnIdsToExport, GridDataExportFormat exportFormat,
Filter[] filters, SortInfo[] sortInfo) {
return GridService.super.exportData(columnIdsToExport, exportFormat, filters, sortInfo);
}
private GridServiceResponse<User> loadDataFromApi(Integer offset, Integer limit,
Filter[] filters) {
try {
GridServiceRequest gridServiceRequest = createLoadServiceRequest(offset, limit, filters);
String requestBody = objectMapper.writeValueAsString(gridServiceRequest);
HttpClient httpClient = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(httpTimeout))
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(UriComponentsBuilder.fromHttpUrl(idmUrl)
.pathSegment(PathConstant.ACCOUNTS_PATH, FILTER_PATH)
.build().toUri())
.header(HttpHeaders.CONTENT_TYPE, "application/json")
.timeout(Duration.ofSeconds(httpTimeout))
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = httpClient.send(request,
HttpResponse.BodyHandlers.ofString()
);
if (response.statusCode() != 200) {
throw new ApiResponseException(
String.format("Некорректный статус ответа. Статус: %d. Тело ответа: %s.",
response.statusCode(), response.body())
);
}
return objectMapper.readValue(response.body(),
new TypeReference<GridServiceResponse<User>>() {
}
);
}
catch (Exception e) {
throw new UserDataLoadException("Ошибка при загрузке данных", e);
}
}
private List<GridRow> convertToGridRows(Set<User> users) {
List<GridRow> gridRows = new ArrayList<>();
for (User user : users) {
GridRow gridRow = new GridRow();
for (Field field : User.class.getDeclaredFields()) {
processField(field, user, gridRow);
}
gridRows.add(gridRow);
}
return gridRows;
}
private GridServiceRequest createLoadServiceRequest(Integer offset, Integer limit, Filter[] filters) {
int page = (offset / limit) + 1;
Map<String, Object> filterMap = new HashMap<>();
UserSession userSession = securityContext.getUserSession();
Set<ErvuRoleAuthority> roles = userSession.roles();
if (ervuAdminRole == null || roles.stream().noneMatch(role -> role.getAuthority().equals(
ervuAdminRole))) {
filterMap.put("domainId", securityContext.getDomainId());
}
if (filters != null && filters.length > 0) {
filterMap.putAll(Arrays.stream(filters)
.filter(filter -> filter.getFilterModels() != null && filter.getFilterModels().length > 0)
.collect(Collectors.toMap(
filter -> getScriptInObject(filter.componentGuid, StaticFilterComponent.class).name,
filter -> filter.getFilterModels()[0].value,
(existing, replacement) -> replacement
))
);
}
return new GridServiceRequest(filterMap, page, limit);
}
private void processField(Field field, User user, GridRow gridRow) {
field.setAccessible(true);
try {
Object value = field.get(user);
if ("accountId".equals(field.getName())) {
gridRow.put("row_uid", value != null ? value : "");
return;
}
if ("accountFullName".equals(field.getName())) {
gridRow.putAll(StringUtils.splitFio((String) value));
return;
}
gridRow.put(field.getName(), value != null ? value : "");
}
catch (IllegalAccessException e) {
throw new UserDataLoadException("Ошибка при получении значения поля: " + field.getName(), e);
}
}
}

View file

@ -1,21 +1,13 @@
package ru.micord.ervu.account_applications.component.service;
import java.util.List;
import java.util.Map;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import ru.micord.ervu.account_applications.component.exception.IdmValidatorException;
/**
* @author Emir Suleimanov
*/
@Service
public class IdmLoginValidatorService extends AbstractIdmValidatorService{
public class IdmLoginValidatorService extends AbstractIdmValidatorService {
public IdmLoginValidatorService(RestTemplate restTemplate) {
super(restTemplate);
@ -23,18 +15,6 @@ public class IdmLoginValidatorService extends AbstractIdmValidatorService{
@Override
public boolean valueExists(String login) {
String url = String.format("%s/credentials/login/%s", idmUrl, login);
HttpEntity<Void> entity = createRequestEntity();
try {
ResponseEntity<List<Map<String, Object>>> response = restTemplate.exchange(
url, HttpMethod.GET, entity, new ParameterizedTypeReference<>() {}
);
return response.getBody() != null &&
response.getBody().stream()
.anyMatch(user -> login.equals(user.get("userName")));
}
catch (Exception e) {
throw new IdmValidatorException("Ошибка при проверке логина: " + login, e);
}
return checkExistsByQuery("checkLogin/v1", "login", login);
}
}

View file

@ -1,16 +1,7 @@
package ru.micord.ervu.account_applications.component.service;
import java.util.List;
import java.util.Optional;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import ru.micord.ervu.account_applications.component.exception.IdmValidatorException;
import ru.micord.ervu.account_applications.component.model.dto.IdmPersonsResponse;
/**
* @author Emir Suleimanov
@ -24,20 +15,6 @@ public class IdmSnilsValidatorService extends AbstractIdmValidatorService {
@Override
public boolean valueExists(String snils) {
String url = String.format("%s/persons?query=snils==\"%s\"", idmUrl, snils);
HttpEntity<Void> entity = createRequestEntity();
try {
ResponseEntity<IdmPersonsResponse> response = restTemplate.exchange(
url, HttpMethod.GET, entity, new ParameterizedTypeReference<>() {}
);
return Optional.ofNullable(response.getBody())
.map(IdmPersonsResponse::getRecords)
.stream()
.flatMap(List::stream)
.anyMatch(value -> snils.equals(value.get("snils")));
}
catch (Exception e) {
throw new IdmValidatorException("Ошибка при проверке СНИЛС: " + snils, e);
}
return checkExistsByQuery("checkSnils/v1", "snils", snils);
}
}

View file

@ -1,57 +0,0 @@
package ru.micord.ervu.account_applications.service;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.net.HttpHeaders;
import org.springframework.beans.factory.annotation.Value;
import ru.micord.ervu.account_applications.component.exception.ApiResponseException;
/**
* @author Adel Kalimullin
*/
public abstract class AbstractUserDataService implements UserDataService {
protected final ObjectMapper objectMapper;
@Value("${ervu.http.timeout:30}")
protected int httpTimeout;
@Value("${idm.url}")
protected String idmUrl;
protected AbstractUserDataService(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
protected HttpResponse<String> sendGetRequest(String url)
throws IOException, InterruptedException {
HttpClient httpClient = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(httpTimeout))
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header(HttpHeaders.CONTENT_TYPE, "application/json")
.timeout(Duration.ofSeconds(httpTimeout))
.GET()
.build();
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() != 200) {
throw new ApiResponseException(
String.format("Некорректный статус ответа. Статус: %d. Тело ответа: %s.",
response.statusCode(), response.body())
);
}
return response;
}
protected abstract Map<String, Object> objectToMap(Object object);
}

View file

@ -0,0 +1,219 @@
package ru.micord.ervu.account_applications.service;
import java.net.URI;
import java.util.Map;
import java.util.List;
import java.util.Set;
import java.util.HashMap;
import java.util.ArrayList;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import component.editablegrid.columns.EditableGridColumn;
import model.grid.GridRow;
import model.grid.GridRows;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.ClassUtils;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import ru.micord.ervu.account_applications.component.exception.UserDataLoadException;
import ru.micord.ervu.account_applications.component.model.Account;
import ru.micord.ervu.account_applications.component.model.Role;
import ru.micord.ervu.account_applications.component.model.dto.SearchRequest;
import ru.micord.ervu.account_applications.component.model.dto.SearchResponse;
import ru.micord.ervu.account_applications.service.constant.PathConstant;
import ru.cg.webbpm.modules.standard_annotations.editor.ObjectRef;
/**
* @author Adel Kalimullin
*/
@Service
public class AccountDataService implements EntityDataService<Account> {
private static final String FIELD_SEX = "sex";
private static final String FIELD_IP_ADDRESSES = "ipAddresses";
private static final String FIELD_SNILS = "snils";
private static final String FIELD_ROLES = "roles";
private final RestTemplate restTemplate;
private final ObjectMapper mapper;
@Value("${idm.url}")
private String idmUrl;
@ObjectRef
public EditableGridColumn editableGridColumnRef;
public AccountDataService(RestTemplate restTemplate, ObjectMapper mapper) {
this.restTemplate = restTemplate;
this.mapper = mapper;
}
@Override
public Map<String, Object> fetchDataById(Object id) {
Account account = fetchAccountById(id);
return objectToFlatMap(account);
}
@Override
public SearchResponse<Account> fetchByFilter(SearchRequest request) {
try {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<SearchRequest> httpEntity = new HttpEntity<>(request, headers);
URI uri = UriComponentsBuilder.fromHttpUrl(idmUrl)
.pathSegment(PathConstant.ACCOUNTS_PATH, "search", "v1")
.build()
.toUri();
ResponseEntity<SearchResponse<Account>> response = restTemplate.exchange(
uri,
HttpMethod.POST,
httpEntity,
new ParameterizedTypeReference<SearchResponse<Account>>() {
}
);
return response.getBody();
}
catch (Exception e) {
throw new UserDataLoadException("Ошибка при поиске аккаунтов", e);
}
}
public List<String> fetchRemovedRoleIdsByAccountId(String accountId, Set<String> newRoleIds) {
try {
Account account = fetchAccountById(accountId);
List<Role> roles = account.getRoles();
if (roles == null) {
return List.of();
}
return roles.stream()
.map(Role::getId)
.filter(roleId -> !newRoleIds.contains(roleId))
.toList();
}
catch (Exception e) {
throw new UserDataLoadException("Ошибка при получении ролей пользователя", e);
}
}
private Account fetchAccountById(Object id) {
URI uri = UriComponentsBuilder.fromHttpUrl(idmUrl)
.pathSegment(PathConstant.ACCOUNTS_PATH, id.toString(), "v1")
.build()
.toUri();
try {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Void> request = new HttpEntity<>(headers);
ResponseEntity<Account> response = restTemplate.exchange(
uri,
HttpMethod.GET,
request,
Account.class
);
return response.getBody();
}
catch (Exception e) {
throw new UserDataLoadException("Ошибка при выполнении GET-запроса", e);
}
}
private Map<String, Object> objectToFlatMap(Object obj) {
return objectToFlatMapInternal(obj, "");
}
private Map<String, Object> objectToFlatMapInternal(Object obj, String prefix) {
Map<String, Object> result = new HashMap<>();
if (obj == null) {
return result;
}
Map<String, Object> map = mapper.convertValue(obj, new TypeReference<>() {
});
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = prefix.isEmpty() ? entry.getKey() : prefix + "." + entry.getKey();
Object value = entry.getValue();
if (value == null || (value instanceof String str && str.isBlank())) {
continue;
}
if (FIELD_SEX.equalsIgnoreCase(entry.getKey()) && value instanceof String sex) {
result.put(key, sex.toLowerCase());
continue;
}
if (FIELD_SNILS.equalsIgnoreCase(entry.getKey()) && value instanceof String snils) {
result.put(key, snils.replaceAll("\\D", ""));
continue;
}
if (value instanceof List<?> list && !list.isEmpty()) {
if (FIELD_IP_ADDRESSES.equalsIgnoreCase(entry.getKey())) {
result.put(key, convertIpAddressesToGridRows(list));
}
else if (FIELD_ROLES.equalsIgnoreCase(entry.getKey())) {
result.put(key, convertRolesToGridRows(list));
}
continue;
}
if (isSimple(value.getClass())) {
result.put(key, value);
}
else {
result.putAll(objectToFlatMapInternal(value, key));
}
}
return result;
}
private GridRows convertIpAddressesToGridRows(List<?> ipList) {
List<GridRow> rows = new ArrayList<>();
int i = 0;
for (Object ip : ipList) {
GridRow row = new GridRow();
row.put("row_uid", i++);
row.put(
editableGridColumnRef != null ? editableGridColumnRef.getObjectId() : FIELD_IP_ADDRESSES,
ip
);
rows.add(row);
}
return new GridRows(rows);
}
private GridRows convertRolesToGridRows(List<?> list) {
List<GridRow> rows = new ArrayList<>();
for (Object item : list) {
if (item instanceof Map<?, ?> map) {
GridRow row = new GridRow();
row.put("row_uid", map.get("id"));
row.put("name", map.get("name"));
row.put("displayName", map.get("displayName"));
row.put("description", map.get("description"));
row.put("active", map.get("active"));
rows.add(row);
}
}
return new GridRows(rows);
}
private boolean isSimple(Class<?> type) {
return ClassUtils.isPrimitiveOrWrapper(type) || type == String.class;
}
}

View file

@ -1,120 +0,0 @@
package ru.micord.ervu.account_applications.service;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.http.HttpResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import component.editablegrid.columns.EditableGridColumn;
import model.grid.GridRow;
import model.grid.GridRows;
import org.springframework.stereotype.Service;
import org.springframework.util.ClassUtils;
import org.springframework.web.util.UriComponentsBuilder;
import ru.micord.ervu.account_applications.component.exception.UserDataLoadException;
import ru.micord.ervu.account_applications.component.model.Account;
import ru.micord.ervu.account_applications.service.constant.PathConstant;
import ru.cg.webbpm.modules.standard_annotations.editor.ObjectRef;
/**
* @author Adel Kalimullin
*/
@Service
public class AccountServiceImpl extends AbstractUserDataService {
private static final String FIELD_SEX = "sex";
private static final String FIELD_IP_ADDRESSES = "ipAddresses";
private static final String FIELD_SNILS = "snils";
@ObjectRef
public EditableGridColumn editableGridColumnRef;
public AccountServiceImpl(ObjectMapper objectMapper) {
super(objectMapper);
}
@Override
public Map<String, Object> fetchDataById(Object id) throws IOException, InterruptedException {
Account account = fetchAccountById(id);
return objectToMap(account);
}
private Account fetchAccountById(Object id) throws IOException, InterruptedException {
String url = UriComponentsBuilder.fromHttpUrl(idmUrl)
.path(PathConstant.ACCOUNTS_PATH)
.pathSegment(id.toString())
.queryParam("expand", "person,user-domain,region")
.toUriString();
HttpResponse<String> response = sendGetRequest(url);
return objectMapper.readValue(response.body(), Account.class);
}
@Override
protected Map<String, Object> objectToMap(Object object) {
Map<String, Object> map = new HashMap<>();
if (object == null) {
return map;
}
Field[] fields = object.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
try {
Object value = field.get(object);
if (value == null || (value instanceof String string && string.isEmpty())) {
continue;
}
if (FIELD_SEX.equals(field.getName()) && value instanceof String sex) {
map.put(field.getName(), sex.toLowerCase());
continue;
}
if (FIELD_SNILS.equals(field.getName()) && value instanceof String snils) {
map.put(field.getName(), snils.replaceAll("\\D", ""));
continue;
}
if (FIELD_IP_ADDRESSES.equals(field.getName()) && value instanceof List<?> ipList
&& !ipList.isEmpty()) {
map.put(field.getName(), convertIpAddressesToGridRows(ipList));
continue;
}
if (isSimple(value.getClass())) {
map.put(field.getName(), value);
}
else {
map.putAll(objectToMap(value));
}
}
catch (IllegalAccessException e) {
throw new UserDataLoadException("Ошибка при получении значения поля: " + field.getName(),
e
);
}
}
return map;
}
private GridRows convertIpAddressesToGridRows(List<?> ipList) {
List<GridRow> rows = new ArrayList<>();
int i = 0;
for (Object ip : ipList) {
GridRow row = new GridRow();
row.put("row_uid", i++);
row.put(editableGridColumnRef != null ? editableGridColumnRef.getObjectId() : "ipAddresses", ip);
rows.add(row);
}
return new GridRows(rows);
}
private boolean isSimple(Class<?> type) {
return ClassUtils.isPrimitiveOrWrapper(type) || type == String.class;
}
}

View file

@ -0,0 +1,15 @@
package ru.micord.ervu.account_applications.service;
import java.util.Map;
import ru.micord.ervu.account_applications.component.model.dto.SearchRequest;
import ru.micord.ervu.account_applications.component.model.dto.SearchResponse;
/**
* @author Adel Kalimullin
*/
public interface EntityDataService<T> {
Map<String, Object> fetchDataById(Object id);
SearchResponse<T> fetchByFilter(SearchRequest request);
}

View file

@ -1,92 +0,0 @@
package ru.micord.ervu.account_applications.service;
import java.io.IOException;
import java.net.http.HttpResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import model.grid.GridRow;
import model.grid.GridRows;
import org.springframework.stereotype.Service;
import org.springframework.web.util.UriComponentsBuilder;
import ru.micord.ervu.account_applications.component.exception.UserDataLoadException;
import ru.micord.ervu.account_applications.component.model.Role;
import ru.micord.ervu.account_applications.service.constant.PathConstant;
/**
* @author Adel Kalimullin
*/
@Service
public class RoleServiceImpl extends AbstractUserDataService {
private static final String ROLES = "roles";
protected RoleServiceImpl(ObjectMapper objectMapper) {
super(objectMapper);
}
@Override
public Map<String, Object> fetchDataById(Object accountId) throws IOException, InterruptedException {
List<Role> roles = fetchRolesByAccountId(accountId);
return objectToMap(roles);
}
public List<String> fetchRemovedRoleIds(String accountId, Set<String> newRoleIds) {
try {
return fetchRolesByAccountId(accountId).stream()
.filter(role -> role.isErvuRole() && !newRoleIds.contains(role.getId()))
.map(Role::getId)
.toList();
}
catch (Exception e) {
throw new UserDataLoadException("Ошибка при получении ролей пользователя", e);
}
}
private List<Role> fetchRolesByAccountId(Object accountId) throws IOException, InterruptedException {
String url = UriComponentsBuilder.fromHttpUrl(idmUrl)
.path(PathConstant.ACCOUNTS_PATH)
.pathSegment(accountId.toString(), ROLES)
.toUriString();
HttpResponse<String> response = sendGetRequest(url);
CollectionType collectionType = objectMapper.getTypeFactory()
.constructCollectionType(List.class, Role.class);
return objectMapper.readValue(response.body(), collectionType);
}
@Override
protected Map<String, Object> objectToMap(Object object) {
Map<String, Object> map = new HashMap<>();
if (object == null) {
return map;
}
if (object instanceof List<?> credentialList) {
List<GridRow> rows = new ArrayList<>();
for (Object item : credentialList) {
if (item instanceof Role role && role.isErvuRole()) {
GridRow row = new GridRow();
row.put("row_uid", role.getId());
row.put("name", role.getName());
row.put("displayName", role.getDisplayName());
row.put("parentId", role.getParentId());
row.put("finish", role.getFinish());
row.put("sessionLimit", role.getSessionsLimit());
rows.add(row);
}
}
GridRows gridRows = new GridRows(rows);
map.put(ROLES, gridRows);
}
return map;
}
}

View file

@ -1,65 +0,0 @@
package ru.micord.ervu.account_applications.service;
import java.io.IOException;
import java.net.http.HttpResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import org.springframework.stereotype.Service;
import org.springframework.web.util.UriComponentsBuilder;
import ru.micord.ervu.account_applications.component.model.Credential;
import ru.micord.ervu.account_applications.service.constant.PathConstant;
/**
* @author Adel Kalimullin
*/
@Service
public class UserCredentialsServiceIpml extends AbstractUserDataService {
private static final String CREDENTIALS = "credentials";
public UserCredentialsServiceIpml(ObjectMapper objectMapper) {
super(objectMapper);
}
@Override
public Map<String, Object> fetchDataById(Object personId) throws IOException, InterruptedException {
List<Credential> credentials = fetchCredentialsByPersonId(personId);
return objectToMap(credentials);
}
private List<Credential> fetchCredentialsByPersonId(Object personId) throws IOException, InterruptedException {
String url = UriComponentsBuilder.fromHttpUrl(idmUrl)
.path(PathConstant.PERSONS_PATH)
.pathSegment(personId.toString(), CREDENTIALS)
.toUriString();
HttpResponse<String> response = sendGetRequest(url);
CollectionType collectionType = objectMapper.getTypeFactory()
.constructCollectionType(List.class, Credential.class);
return objectMapper.readValue(response.body(), collectionType);
}
@Override
protected Map<String, Object> objectToMap(Object object) {
Map<String, Object> map = new HashMap<>();
if (object == null) {
return map;
}
if (object instanceof List<?> credentialList && !credentialList.isEmpty()) {
Object firstItem = credentialList.get(0);
if (firstItem instanceof Credential credential) {
map.put("credentialId", credential.getId());
map.put("userName", credential.getUserName());
map.put("modified", credential.getModified());
map.put("blocked", credential.isBlocked());
}
}
return map;
}
}

View file

@ -1,11 +0,0 @@
package ru.micord.ervu.account_applications.service;
import java.io.IOException;
import java.util.Map;
/**
* @author Adel Kalimullin
*/
public interface UserDataService{
Map<String, Object> fetchDataById(Object id) throws IOException, InterruptedException;
}

View file

@ -229,7 +229,7 @@ export class DropdownTreeViewComponent extends InputControl {
}
hasValidModel(): boolean {
return !this.isRequired() || !this.isValueEmpty()
return !this.isRequired() || !this.isValueEmpty();
}
getPresentationValue(): string | number | boolean {

View file

@ -848,14 +848,14 @@
</entry>
</complex>
<implRef type="JAVA">
<className>AccountServiceImpl</className>
<className>AccountDataService</className>
<packageName>ru.micord.ervu.account_applications.service</packageName>
</implRef>
</value>
</entry>
</complex>
<implRef type="JAVA">
<className>ErvuUserFormLoadService</className>
<className>ErvuFormLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -3363,7 +3363,7 @@
<key>gridService</key>
<value>
<implRef type="JAVA">
<className>ErvuUserGridLoadService</className>
<className>AccountGridLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -3583,14 +3583,14 @@
<key>userDataService</key>
<value>
<implRef type="JAVA">
<className>UserCredentialsServiceIpml</className>
<className>AccountDataService</className>
<packageName>ru.micord.ervu.account_applications.service</packageName>
</implRef>
</value>
</entry>
</complex>
<implRef type="JAVA">
<className>ErvuUserFormLoadService</className>
<className>ErvuFormLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -4311,14 +4311,14 @@
<key>userDataService</key>
<value>
<implRef type="JAVA">
<className>RoleServiceImpl</className>
<className>AccountDataService</className>
<packageName>ru.micord.ervu.account_applications.service</packageName>
</implRef>
</value>
</entry>
</complex>
<implRef type="JAVA">
<className>ErvuUserFormLoadService</className>
<className>ErvuFormLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -4478,7 +4478,7 @@
<value>
<expanded>false</expanded>
<implRef type="JAVA">
<className>ErvuUserGridLoadService</className>
<className>AccountGridLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -8978,7 +8978,7 @@
<key>gridService</key>
<value>
<implRef type="JAVA">
<className>ErvuUserGridLoadService</className>
<className>AccountGridLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>

View file

@ -849,14 +849,14 @@
</entry>
</complex>
<implRef type="JAVA">
<className>AccountServiceImpl</className>
<className>AccountDataService</className>
<packageName>ru.micord.ervu.account_applications.service</packageName>
</implRef>
</value>
</entry>
</complex>
<implRef type="JAVA">
<className>ErvuUserFormLoadService</className>
<className>ErvuFormLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -3364,7 +3364,7 @@
<key>gridService</key>
<value>
<implRef type="JAVA">
<className>ErvuUserGridLoadService</className>
<className>AccountGridLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -3584,14 +3584,14 @@
<key>userDataService</key>
<value>
<implRef type="JAVA">
<className>UserCredentialsServiceIpml</className>
<className>AccountDataService</className>
<packageName>ru.micord.ervu.account_applications.service</packageName>
</implRef>
</value>
</entry>
</complex>
<implRef type="JAVA">
<className>ErvuUserFormLoadService</className>
<className>ErvuFormLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -4312,14 +4312,14 @@
<key>userDataService</key>
<value>
<implRef type="JAVA">
<className>RoleServiceImpl</className>
<className>AccountDataService</className>
<packageName>ru.micord.ervu.account_applications.service</packageName>
</implRef>
</value>
</entry>
</complex>
<implRef type="JAVA">
<className>ErvuUserFormLoadService</className>
<className>ErvuFormLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -4479,7 +4479,7 @@
<value>
<expanded>false</expanded>
<implRef type="JAVA">
<className>ErvuUserGridLoadService</className>
<className>AccountGridLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -8979,7 +8979,7 @@
<key>gridService</key>
<value>
<implRef type="JAVA">
<className>ErvuUserGridLoadService</className>
<className>AccountGridLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>

View file

@ -854,14 +854,14 @@
</entry>
</complex>
<implRef type="JAVA">
<className>AccountServiceImpl</className>
<className>AccountDataService</className>
<packageName>ru.micord.ervu.account_applications.service</packageName>
</implRef>
</value>
</entry>
</complex>
<implRef type="JAVA">
<className>ErvuUserFormLoadService</className>
<className>ErvuFormLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -4698,7 +4698,7 @@
<key>gridService</key>
<value>
<implRef type="JAVA">
<className>ErvuUserGridLoadService</className>
<className>AccountGridLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -8383,14 +8383,14 @@
<key>userDataService</key>
<value>
<implRef type="JAVA">
<className>UserCredentialsServiceIpml</className>
<className>AccountDataService</className>
<packageName>ru.micord.ervu.account_applications.service</packageName>
</implRef>
</value>
</entry>
</complex>
<implRef type="JAVA">
<className>ErvuUserFormLoadService</className>
<className>ErvuFormLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -12400,14 +12400,14 @@
<key>userDataService</key>
<value>
<implRef type="JAVA">
<className>RoleServiceImpl</className>
<className>AccountDataService</className>
<packageName>ru.micord.ervu.account_applications.service</packageName>
</implRef>
</value>
</entry>
</complex>
<implRef type="JAVA">
<className>ErvuUserFormLoadService</className>
<className>ErvuFormLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -12568,7 +12568,7 @@
<value>
<expanded>false</expanded>
<implRef type="JAVA">
<className>ErvuUserGridLoadService</className>
<className>AccountGridLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -17950,7 +17950,7 @@
<key>gridService</key>
<value>
<implRef type="JAVA">
<className>ErvuUserGridLoadService</className>
<className>AccountGridLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>

View file

@ -843,14 +843,14 @@
</entry>
</complex>
<implRef type="JAVA">
<className>AccountServiceImpl</className>
<className>AccountDataService</className>
<packageName>ru.micord.ervu.account_applications.service</packageName>
</implRef>
</value>
</entry>
</complex>
<implRef type="JAVA">
<className>ErvuUserFormLoadService</className>
<className>ErvuFormLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -3357,7 +3357,7 @@
<key>gridService</key>
<value>
<implRef type="JAVA">
<className>ErvuUserGridLoadService</className>
<className>AccountGridLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -3576,7 +3576,7 @@
<key>userDataService</key>
<value>
<implRef type="JAVA">
<className>UserCredentialsServiceIpml</className>
<className>AccountDataService</className>
<packageName>ru.micord.ervu.account_applications.service</packageName>
</implRef>
</value>
@ -4305,14 +4305,14 @@
<key>userDataService</key>
<value>
<implRef type="JAVA">
<className>RoleServiceImpl</className>
<className>AccountDataService</className>
<packageName>ru.micord.ervu.account_applications.service</packageName>
</implRef>
</value>
</entry>
</complex>
<implRef type="JAVA">
<className>ErvuUserFormLoadService</className>
<className>ErvuFormLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -4482,7 +4482,7 @@
<value>
<expanded>false</expanded>
<implRef type="JAVA">
<className>ErvuUserGridLoadService</className>
<className>AccountGridLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>
@ -8906,7 +8906,7 @@
<key>gridService</key>
<value>
<implRef type="JAVA">
<className>ErvuUserGridLoadService</className>
<className>AccountGridLoadService</className>
<packageName>ru.micord.ervu.account_applications.component.service</packageName>
</implRef>
</value>