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();
}
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");
}
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;
}
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());
}
Aggregations