Search in sources :

Example 1 with Domain

use of org.apache.syncope.core.persistence.api.entity.Domain in project syncope by apache.

the class JPADomainDAO method delete.

@Override
public void delete(final String key) {
    Domain domain = find(key);
    if (domain == null) {
        return;
    }
    entityManager().remove(domain);
}
Also used : JPADomain(org.apache.syncope.core.persistence.jpa.entity.JPADomain) Domain(org.apache.syncope.core.persistence.api.entity.Domain)

Example 2 with Domain

use of org.apache.syncope.core.persistence.api.entity.Domain in project syncope by apache.

the class DomainDataBinderImpl method create.

@Override
public Domain create(final DomainTO domainTO) {
    Domain domain = entityFactory.newEntity(Domain.class);
    update(domain, domainTO);
    return domain;
}
Also used : Domain(org.apache.syncope.core.persistence.api.entity.Domain)

Example 3 with Domain

use of org.apache.syncope.core.persistence.api.entity.Domain in project syncope by apache.

the class DomainLogic method delete.

@PreAuthorize("hasRole('" + StandardEntitlement.DOMAIN_DELETE + "') and authentication.details.domain == " + "T(org.apache.syncope.common.lib.SyncopeConstants).MASTER_DOMAIN")
public DomainTO delete(final String key) {
    Domain domain = domainDAO.find(key);
    if (domain == null) {
        LOG.error("Could not find domain '" + key + "'");
        throw new NotFoundException(key);
    }
    DomainTO deleted = binder.getDomainTO(domain);
    domainDAO.delete(key);
    return deleted;
}
Also used : DomainTO(org.apache.syncope.common.lib.to.DomainTO) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) Domain(org.apache.syncope.core.persistence.api.entity.Domain) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 4 with Domain

use of org.apache.syncope.core.persistence.api.entity.Domain in project syncope by apache.

the class DomainLogic method update.

@PreAuthorize("hasRole('" + StandardEntitlement.DOMAIN_UPDATE + "') and authentication.details.domain == " + "T(org.apache.syncope.common.lib.SyncopeConstants).MASTER_DOMAIN")
public DomainTO update(final DomainTO domainTO) {
    Domain domain = domainDAO.find(domainTO.getKey());
    if (domain == null) {
        LOG.error("Could not find domain '" + domainTO.getKey() + "'");
        throw new NotFoundException(domainTO.getKey());
    }
    binder.update(domain, domainTO);
    domain = domainDAO.save(domain);
    return binder.getDomainTO(domain);
}
Also used : NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) Domain(org.apache.syncope.core.persistence.api.entity.Domain) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 5 with Domain

use of org.apache.syncope.core.persistence.api.entity.Domain in project syncope by apache.

the class DomainTest method findAll.

@Test
public void findAll() {
    List<Domain> list = domainDAO.findAll();
    assertNotNull(list);
    assertFalse(list.isEmpty());
    for (Domain domain : list) {
        assertNotNull(domain);
    }
}
Also used : Domain(org.apache.syncope.core.persistence.api.entity.Domain) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

Domain (org.apache.syncope.core.persistence.api.entity.Domain)9 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)4 Test (org.junit.jupiter.api.Test)4 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 Pair (org.apache.commons.lang3.tuple.Pair)1 DomainTO (org.apache.syncope.common.lib.to.DomainTO)1 JPADomain (org.apache.syncope.core.persistence.jpa.entity.JPADomain)1 BadCredentialsException (org.springframework.security.authentication.BadCredentialsException)1 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)1