Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
import lombok.extern.slf4j.Slf4j;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;

import java.io.*;
import java.nio.file.Path;
import java.util.*;
Expand Down Expand Up @@ -1066,17 +1068,16 @@ protected void createRole(Role importRole) {
if (shouldInitializeRole(importRole)) {
role = initRole(importRole);
} else {
role = processRoleService.findByImportId(ProcessRole.GLOBAL + importRole.getId());
role = processRoleService.findAllByImportId(ProcessRole.GLOBAL + importRole.getId(), Pageable.ofSize(1)).getContent().getFirst();
}
role.set_id(new ProcessResourceId(new ObjectId(net.getStringId())));

net.addRole(role);
roles.put(importRole.getId(), role);
}

protected boolean shouldInitializeRole(Role importRole) {
return importRole.isGlobal() == null || !importRole.isGlobal() ||
(importRole.isGlobal() && processRoleService.findByImportId(ProcessRole.GLOBAL + importRole.getId()) == null);
(importRole.isGlobal() && processRoleService.findAllByImportId(ProcessRole.GLOBAL + importRole.getId(), Pageable.ofSize(1)).getContent().isEmpty());
}

protected ProcessRole initRole(Role importRole) {
Expand All @@ -1090,8 +1091,10 @@ protected ProcessRole initRole(Role importRole) {
role.setName(toI18NString(importRole.getName()));
}
if (importRole.isGlobal() != null && importRole.isGlobal()) {
role.set_id(new ProcessResourceId(new ObjectId()));
role.setGlobal(importRole.isGlobal());
} else {
role.set_id(new ProcessResourceId(new ObjectId(net.getStringId())));
role.setProcessId(net.getStringId());
role.setProcessTitle(net.getTitle());
role.setProcessIdentifier(net.getIdentifier());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class UserServiceImpl implements UserService {

private AbstractUser systemUser;

@Getter
private PaginationProperties paginationProperties;

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ default Page<User> findAll(Predicate predicate, Pageable pageable) {
throw new UnsupportedOperationException("This method is not supported. Use 'UserRepository.findAll(Predicate, Pageable, MongoTemplate, Collection<String>)' instead.'");
}

default long countAll(String collection, MongoTemplate mongoTemplate) {
return mongoTemplate.count(new Query(), User.class, collection);
}

/**
* Throws an exception since this method is not supported.
* Use {@link #deleteAll(MongoTemplate, Collection)} instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@ Page<AbstractUser> searchAllCoMembers(String query, Collection<ProcessResourceId


/**
* Updates the admin user or users with the specified roles.
* This method assigns the provided roles to all the admin user of system, updating their current set of roles.
* Assigns the provided process roles to all admin users in the system, updating their current set of roles.
* Behavior: roles are added (union) and duplicates are ignored; no existing roles are removed.
*
* @param roles a list of role identifiers to assign to the admin user
* @param roles collection of process roles to assign to admin users
*/
void updateAdminWithRoles(Collection<ProcessRole> roles);
}
Loading