Search in sources :

Example 26 with AnyObject

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

the class GroupMemberProvisionTaskJobDelegate method doExecute.

@Override
protected String doExecute(final boolean dryRun) throws JobExecutionException {
    Group group = groupDAO.authFind(groupKey);
    StringBuilder result = new StringBuilder("Group ").append(group.getName()).append(" members ");
    if (actionType == BulkMembersActionType.DEPROVISION) {
        result.append("de");
    }
    result.append("provision\n\n");
    status.set(result.toString());
    MembershipCond membershipCond = new MembershipCond();
    membershipCond.setGroup(groupKey);
    List<User> users = searchDAO.search(SearchCond.getLeafCond(membershipCond), AnyTypeKind.USER);
    Collection<String> groupResourceKeys = groupDAO.findAllResourceKeys(groupKey);
    status.set("About to " + (actionType == BulkMembersActionType.DEPROVISION ? "de" : "") + "provision " + users.size() + " users from " + groupResourceKeys);
    for (int i = 0; i < users.size() && !interrupt; i++) {
        List<PropagationStatus> statuses = actionType == BulkMembersActionType.DEPROVISION ? userProvisioningManager.deprovision(users.get(i).getKey(), groupResourceKeys, false) : userProvisioningManager.provision(users.get(i).getKey(), true, null, groupResourceKeys, false);
        for (PropagationStatus propagationStatus : statuses) {
            result.append("User ").append(users.get(i).getKey()).append('\t').append("Resource ").append(propagationStatus.getResource()).append('\t').append(propagationStatus.getStatus());
            if (StringUtils.isNotBlank(propagationStatus.getFailureReason())) {
                result.append('\n').append(propagationStatus.getFailureReason()).append('\n');
            }
            result.append("\n");
        }
        result.append("\n");
    }
    if (interrupt) {
        LOG.debug("Group assignment interrupted");
        interrupted = true;
        return result.append("\n*** Group assignment interrupted ***\n").toString();
    }
    membershipCond = new MembershipCond();
    membershipCond.setGroup(groupKey);
    List<AnyObject> anyObjects = searchDAO.search(SearchCond.getLeafCond(membershipCond), AnyTypeKind.ANY_OBJECT);
    status.set("About to " + (actionType == BulkMembersActionType.DEPROVISION ? "de" : "") + "provision " + anyObjects.size() + " any objects from " + groupResourceKeys);
    for (int i = 0; i < anyObjects.size() && !interrupt; i++) {
        List<PropagationStatus> statuses = actionType == BulkMembersActionType.DEPROVISION ? anyObjectProvisioningManager.deprovision(anyObjects.get(i).getKey(), groupResourceKeys, false) : anyObjectProvisioningManager.provision(anyObjects.get(i).getKey(), groupResourceKeys, false);
        for (PropagationStatus propagationStatus : statuses) {
            result.append(anyObjects.get(i).getType().getKey()).append(' ').append(anyObjects.get(i).getKey()).append('\t').append("Resource ").append(propagationStatus.getResource()).append('\t').append(propagationStatus.getStatus());
            if (StringUtils.isNotBlank(propagationStatus.getFailureReason())) {
                result.append('\n').append(propagationStatus.getFailureReason()).append('\n');
            }
            result.append("\n");
        }
        result.append("\n");
    }
    if (interrupt) {
        LOG.debug("Group assignment interrupted");
        interrupted = true;
        result.append("\n*** Group assignment interrupted ***\n");
    }
    return result.toString();
}
Also used : Group(org.apache.syncope.core.persistence.api.entity.group.Group) AnyObject(org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject) User(org.apache.syncope.core.persistence.api.entity.user.User) MembershipCond(org.apache.syncope.core.persistence.api.dao.search.MembershipCond) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus)

Example 27 with AnyObject

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

the class DefaultAnyObjectWorkflowAdapter method doCreate.

@Override
protected WorkflowResult<String> doCreate(final AnyObjectTO anyObjectTO) {
    AnyObject anyObject = entityFactory.newEntity(AnyObject.class);
    dataBinder.create(anyObject, anyObjectTO);
    anyObject = anyObjectDAO.save(anyObject);
    PropagationByResource propByRes = new PropagationByResource();
    propByRes.set(ResourceOperation.CREATE, anyObjectDAO.findAllResourceKeys(anyObject.getKey()));
    return new WorkflowResult<>(anyObject.getKey(), propByRes, "create");
}
Also used : AnyObject(org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject) WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource)

Example 28 with AnyObject

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

the class JPAAnyObjectDAO method findByName.

@Override
public AnyObject findByName(final String name) {
    TypedQuery<AnyObject> query = entityManager().createQuery("SELECT e FROM " + JPAAnyObject.class.getSimpleName() + " e WHERE e.name = :name", AnyObject.class);
    query.setParameter("name", name);
    AnyObject result = null;
    try {
        result = query.getSingleResult();
    } catch (NoResultException e) {
        LOG.debug("No any object found with name {}", name, e);
    }
    return result;
}
Also used : JPAAnyObject(org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAnyObject) JPAAnyObject(org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAnyObject) AnyObject(org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject) NoResultException(javax.persistence.NoResultException)

Example 29 with AnyObject

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

the class RelationshipTypeTest method deleteOnAnyObject.

@Test
public void deleteOnAnyObject() {
    RelationshipType neighborhood = relationshipTypeDAO.find("neighborhood");
    assertNotNull(neighborhood);
    AnyObject anyObject = anyObjectDAO.find("fc6dbc3a-6c07-4965-8781-921e7401a4a5");
    assertNotNull(anyObject);
    assertNotNull(anyObject.getRelationships(neighborhood));
    assertFalse(anyObject.getRelationships(neighborhood).isEmpty());
    relationshipTypeDAO.delete("neighborhood");
    relationshipTypeDAO.flush();
    anyObject = anyObjectDAO.find("fc6dbc3a-6c07-4965-8781-921e7401a4a5");
    assertNotNull(anyObject);
    assertTrue(anyObject.getRelationships().isEmpty());
}
Also used : AnyObject(org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject) RelationshipType(org.apache.syncope.core.persistence.api.entity.RelationshipType) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

AnyObject (org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject)29 Group (org.apache.syncope.core.persistence.api.entity.group.Group)18 User (org.apache.syncope.core.persistence.api.entity.user.User)15 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)11 Test (org.junit.jupiter.api.Test)11 ArrayList (java.util.ArrayList)10 List (java.util.List)9 Autowired (org.springframework.beans.factory.annotation.Autowired)9 Transactional (org.springframework.transaction.annotation.Transactional)9 HashSet (java.util.HashSet)8 Set (java.util.Set)8 Collectors (java.util.stream.Collectors)8 AnyTypeKind (org.apache.syncope.common.lib.types.AnyTypeKind)7 AnyObjectDAO (org.apache.syncope.core.persistence.api.dao.AnyObjectDAO)7 AnyTypeDAO (org.apache.syncope.core.persistence.api.dao.AnyTypeDAO)7 GroupDAO (org.apache.syncope.core.persistence.api.dao.GroupDAO)7 UserDAO (org.apache.syncope.core.persistence.api.dao.UserDAO)7 AnyType (org.apache.syncope.core.persistence.api.entity.AnyType)7 Collections (java.util.Collections)6 SearchCond (org.apache.syncope.core.persistence.api.dao.search.SearchCond)6