Search in sources :

Example 6 with OwnerRegistrationControlEntryEntity

use of io.joynr.accesscontrol.global.jee.persistence.OwnerRegistrationControlEntryEntity in project joynr by bmwcarit.

the class OwnerRegistrationControlEntryManager method createOrUpdate.

public CreateOrUpdateResult<OwnerRegistrationControlEntry> createOrUpdate(OwnerRegistrationControlEntry updatedOwnerRce) {
    if (!domainRoleEntryManager.hasCurrentUserGotRoleForDomain(Role.OWNER, updatedOwnerRce.getDomain())) {
        return null;
    }
    OwnerRegistrationControlEntryEntity entity = findByUserIdDomainAndInterfaceName(updatedOwnerRce.getUid(), updatedOwnerRce.getDomain(), updatedOwnerRce.getInterfaceName());
    boolean created = entity == null;
    if (created) {
        entity = new OwnerRegistrationControlEntryEntity();
        entity.setUserId(updatedOwnerRce.getUid());
        entity.setDomain(updatedOwnerRce.getDomain());
        entity.setInterfaceName(updatedOwnerRce.getInterfaceName());
        entityManager.persist(entity);
    }
    entity.setRequiredTrustLevel(updatedOwnerRce.getRequiredTrustLevel());
    entity.setRequiredAceChangeTrustLevel(updatedOwnerRce.getRequiredAceChangeTrustLevel());
    entity.setProviderPermission(updatedOwnerRce.getProviderPermission());
    return new CreateOrUpdateResult<>(mapEntityToJoynrType(entity), created ? ChangeType.ADD : ChangeType.UPDATE);
}
Also used : OwnerRegistrationControlEntryEntity(io.joynr.accesscontrol.global.jee.persistence.OwnerRegistrationControlEntryEntity)

Aggregations

OwnerRegistrationControlEntryEntity (io.joynr.accesscontrol.global.jee.persistence.OwnerRegistrationControlEntryEntity)6 Test (org.junit.Test)3 OwnerRegistrationControlEntry (joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry)2 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)1 Query (javax.persistence.Query)1