Source:
public Group createGroupUnion(PerunSession sess, Group resultGroup, Group operandGroup, boolean parentFlag) throws WrongReferenceAttributeValueException , AlreadyMemberException, WrongAttributeValueException, GroupNotExistsException, InternalErrorException, GroupRelationAlreadyExists, GroupRelationNotAllowed { if(resultGroup.getName().equals(VosManager.MEMBERS_GROUP)) { throw new GroupRelationNotAllowed("Union cannot be created when result group " + resultGroup + " is members group."); } if (resultGroup.getVoId() != operandGroup.getVoId()) { throw new GroupRelationNotAllowed("Union cannot be created on groups: " + resultGroup + ", " + operandGroup + ". They are not from the same VO."); } if (resultGroup.getId() == operandGroup.getId()) { throw new GroupRelationNotAllowed("Result group " + resultGroup + " cannot be the same as operand group " + operandGroup); } if (this.groupsManagerImpl.isRelationBetweenGroups(resultGroup, operandGroup)) { throw new GroupRelationAlreadyExists("There is already a relation defined between result group " + resultGroup + " and operand group " + operandGroup + " or they are in hierarchical structure."); } if (checkGroupsCycle(sess, resultGroup.getId(), operandGroup.getId())) { throw new GroupRelationNotAllowed("Union between result group " + resultGroup + " and operand group " + operandGroup + " would create group cycle."); } groupsManagerImpl.saveGroupRelation(sess, resultGroup, operandGroup, parentFlag); try { addRelationMembers(sess, resultGroup, getGroupMembers(sess, operandGroup), operandGroup.getId()); } catch (WrongReferenceAttributeValueException | AlreadyMemberException | WrongAttributeValueException e ) { throw new InternalErrorException("Some operation was not allowed during processing members relations", e); } catch (GroupNotExistsException e) { throw new InternalErrorException("Some group does not exists...", e); } return resultGroup; }

Target:
public Group createGroupUnion(PerunSession sess, Group resultGroup, Group operandGroup, boolean parentFlag) throws WrongReferenceAttributeValueException, WrongAttributeValueException, GroupNotExistsException, InternalErrorException, GroupRelationAlreadyExists, GroupRelationNotAllowed { if(resultGroup.getName().equals(VosManager.MEMBERS_GROUP)) { throw new GroupRelationNotAllowed("Union cannot be created when result group " + resultGroup + " is members group."); } if (resultGroup.getVoId() != operandGroup.getVoId()) { throw new GroupRelationNotAllowed("Union cannot be created on groups: " + resultGroup + ", " + operandGroup + ". They are not from the same VO."); } if (resultGroup.getId() == operandGroup.getId()) { throw new GroupRelationNotAllowed("Result group " + resultGroup + " cannot be the same as operand group " + operandGroup); } if (this.groupsManagerImpl.isRelationBetweenGroups(resultGroup, operandGroup)) { throw new GroupRelationAlreadyExists("There is already a relation defined between result group " + resultGroup + " and operand group " + operandGroup + " or they are in hierarchical structure."); } if (checkGroupsCycle(sess, resultGroup.getId(), operandGroup.getId())) { throw new GroupRelationNotAllowed("Union between result group " + resultGroup + " and operand group " + operandGroup + " would create group cycle."); } groupsManagerImpl.saveGroupRelation(sess, resultGroup, operandGroup, parentFlag); try { addRelationMembers(sess, resultGroup, getGroupMembers(sess, operandGroup), operandGroup.getId()); } catch(AlreadyMemberException ex) { throw new ConsistencyErrorException("AlreadyMemberException caused by DB inconsistency.",ex); } return resultGroup; }