use of io.joynr.accesscontrol.global.jee.persistence.MasterAccessControlEntryEntity in project joynr by bmwcarit.
the class MasterAccessControlEntryManager method findByUserIdDomainInterfaceNameOperationAndType.
private MasterAccessControlEntryEntity findByUserIdDomainInterfaceNameOperationAndType(String userId, String domain, String interfaceName, String operation, ControlEntryType type) {
Query query = entityManager.createQuery("select mace from MasterAccessControlEntryEntity mace " + "where mace.userId = :userId and mace.domain = :domain and mace.interfaceName = :interfaceName " + "and mace.operation = :operation and mace.type = :type", MasterAccessControlEntryEntity.class);
query.setParameter("userId", userId);
query.setParameter("domain", domain);
query.setParameter("interfaceName", interfaceName);
query.setParameter("operation", operation);
query.setParameter("type", type);
List<MasterAccessControlEntryEntity> resultList = query.getResultList();
MasterAccessControlEntryEntity entity = null;
if (resultList.size() == 1) {
entity = resultList.get(0);
} else if (resultList.size() > 1) {
throw new JoynrIllegalStateException(format("Too many master access control entries for unique key uid / domain / interfaceName /operation: %s / %s / %s / %s", userId, domain, interfaceName, operation));
}
return entity;
}
use of io.joynr.accesscontrol.global.jee.persistence.MasterAccessControlEntryEntity in project joynr by bmwcarit.
the class MasterAccessControlEntryManager method findByUserIdThatAreEditable.
public MasterAccessControlEntry[] findByUserIdThatAreEditable(String userId, ControlEntryType type) {
Query query = entityManager.createQuery("select mace from MasterAccessControlEntryEntity mace, " + "DomainRoleEntryEntity dre, in(dre.domains) dds where mace.userId = :userId and mace.type = :type " + "and mace.domain = dds and dre.userId = :userId and dre.role = :role");
query.setParameter("userId", userId);
query.setParameter("type", type);
query.setParameter("role", Role.MASTER);
List<MasterAccessControlEntryEntity> resultList = query.getResultList();
Set<MasterAccessControlEntry> resultSet = resultList.stream().map(this::mapEntityToJoynrType).collect(toSet());
return resultSet.toArray(new MasterAccessControlEntry[resultSet.size()]);
}
use of io.joynr.accesscontrol.global.jee.persistence.MasterAccessControlEntryEntity in project joynr by bmwcarit.
the class MasterAccessControlEntryManager method findByUserId.
public MasterAccessControlEntry[] findByUserId(String userId, ControlEntryType type) {
Query query = entityManager.createQuery("select mace from MasterAccessControlEntryEntity mace where mace.userId = :userId and mace.type = :type", MasterAccessControlEntryEntity.class);
query.setParameter("userId", userId);
query.setParameter("type", type);
List<MasterAccessControlEntryEntity> resultList = query.getResultList();
Set<MasterAccessControlEntry> resultSet = resultList.stream().map(this::mapEntityToJoynrType).collect(toSet());
return resultSet.toArray(new MasterAccessControlEntry[resultSet.size()]);
}
Aggregations