use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.
the class Realm method customResultBody.
@Override
@SuppressWarnings("unchecked")
protected Panel customResultBody(final String panelId, final RealmTO item, final Serializable result) {
if (!(result instanceof ProvisioningResult)) {
throw new IllegalStateException("Unsupported result type");
}
final MultilevelPanel mlp = new MultilevelPanel(panelId);
add(mlp);
final PropagationStatus syncope = new PropagationStatus();
syncope.setStatus(PropagationTaskExecStatus.SUCCESS);
syncope.setResource(Constants.SYNCOPE);
ArrayList<PropagationStatus> propagations = new ArrayList<>();
propagations.add(syncope);
propagations.addAll(((ProvisioningResult) result).getPropagationStatuses());
ListViewPanel.Builder<PropagationStatus> builder = new ListViewPanel.Builder<PropagationStatus>(PropagationStatus.class, pageRef) {
private static final long serialVersionUID = -6809736686861678498L;
@Override
protected Component getValueComponent(final String key, final PropagationStatus bean) {
if ("afterObj".equalsIgnoreCase(key)) {
ConnObjectTO afterObj = bean.getAfterObj();
String remoteId = afterObj == null || afterObj.getAttrs().isEmpty() || !afterObj.getAttr(ConnIdSpecialName.NAME).isPresent() || afterObj.getAttr(ConnIdSpecialName.NAME).get().getValues() == null || afterObj.getAttr(ConnIdSpecialName.NAME).get().getValues().isEmpty() ? StringUtils.EMPTY : afterObj.getAttr(ConnIdSpecialName.NAME).get().getValues().get(0);
return new Label("field", remoteId);
} else if ("status".equalsIgnoreCase(key)) {
return StatusUtils.getStatusImagePanel("field", bean.getStatus());
} else {
return super.getValueComponent(key, bean);
}
}
};
builder.setItems(propagations);
builder.includes("resource", "afterObj", "status");
builder.withChecks(ListViewPanel.CheckAvailability.NONE);
builder.setReuseItem(false);
builder.addAction(new ActionLink<PropagationStatus>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
protected boolean statusCondition(final PropagationStatus bean) {
return !Constants.SYNCOPE.equals(bean.getResource()) && (PropagationTaskExecStatus.CREATED == bean.getStatus() || PropagationTaskExecStatus.SUCCESS == bean.getStatus());
}
@Override
public void onClick(final AjaxRequestTarget target, final PropagationStatus bean) {
mlp.next(bean.getResource(), new RemoteRealmPanel(bean), target);
}
}, ActionLink.ActionType.VIEW, StandardEntitlement.RESOURCE_GET_CONNOBJECT);
mlp.setFirstLevel(builder.build(MultilevelPanel.FIRST_LEVEL_ID));
return mlp;
}
use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.
the class UserRestClient method reactivate.
public BulkActionResult reactivate(final String etag, final String userKey, final List<StatusBean> statuses) {
StatusPatch statusPatch = StatusUtils.buildStatusPatch(statuses, true);
statusPatch.setKey(userKey);
statusPatch.setType(StatusPatchType.REACTIVATE);
BulkActionResult result;
synchronized (this) {
result = new BulkActionResult();
Map<String, BulkActionResult.Status> res = result.getResults();
UserService service = getService(etag, UserService.class);
@SuppressWarnings("unchecked") ProvisioningResult<UserTO> provisions = (ProvisioningResult<UserTO>) service.status(statusPatch).readEntity(ProvisioningResult.class);
if (statusPatch.isOnSyncope()) {
res.put(StringUtils.capitalize(Constants.SYNCOPE), "active".equalsIgnoreCase(provisions.getEntity().getStatus()) ? BulkActionResult.Status.SUCCESS : BulkActionResult.Status.FAILURE);
}
for (PropagationStatus status : provisions.getPropagationStatuses()) {
res.put(status.getResource(), BulkActionResult.Status.valueOf(status.getStatus().name()));
}
resetClient(UserService.class);
}
return result;
}
use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.
the class GroupLogic method deprovision.
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public ProvisioningResult<GroupTO> deprovision(final String key, final Collection<String> resources, final boolean nullPriorityAsync) {
// security checks
GroupTO group = binder.getGroupTO(key);
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.GROUP_UPDATE), group.getRealm());
securityChecks(effectiveRealms, group.getRealm(), group.getKey());
List<PropagationStatus> statuses = provisioningManager.deprovision(key, resources, nullPriorityAsync);
ProvisioningResult<GroupTO> result = new ProvisioningResult<>();
result.setEntity(binder.getGroupTO(key));
result.getPropagationStatuses().addAll(statuses);
return result;
}
use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.
the class RealmLogic method update.
@PreAuthorize("hasRole('" + StandardEntitlement.REALM_UPDATE + "')")
public ProvisioningResult<RealmTO> update(final RealmTO realmTO) {
Realm realm = realmDAO.findByFullPath(realmTO.getFullPath());
if (realm == null) {
LOG.error("Could not find realm '" + realmTO.getFullPath() + "'");
throw new NotFoundException(realmTO.getFullPath());
}
PropagationByResource propByRes = binder.update(realm, realmTO);
realm = realmDAO.save(realm);
List<PropagationTaskTO> tasks = propagationManager.createTasks(realm, propByRes, null);
PropagationReporter propagationReporter = taskExecutor.execute(tasks, false);
ProvisioningResult<RealmTO> result = new ProvisioningResult<>();
result.setEntity(binder.getRealmTO(realm, true));
result.getPropagationStatuses().addAll(propagationReporter.getStatuses());
return result;
}
use of org.apache.syncope.common.lib.to.ProvisioningResult in project syncope by apache.
the class RealmLogic method create.
@PreAuthorize("hasRole('" + StandardEntitlement.REALM_CREATE + "')")
public ProvisioningResult<RealmTO> create(final String parentPath, final RealmTO realmTO) {
Realm parent;
if (StringUtils.isBlank(realmTO.getParent())) {
parent = realmDAO.findByFullPath(parentPath);
if (parent == null) {
LOG.error("Could not find parent realm " + parentPath);
throw new NotFoundException(parentPath);
}
realmTO.setParent(parent.getFullPath());
} else {
parent = realmDAO.find(realmTO.getParent());
if (parent == null) {
LOG.error("Could not find parent realm " + realmTO.getParent());
throw new NotFoundException(realmTO.getParent());
}
if (!parent.getFullPath().equals(parentPath)) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPath);
sce.getElements().add("Mismatching parent realm: " + parentPath + " Vs " + parent.getFullPath());
throw sce;
}
}
String fullPath = StringUtils.appendIfMissing(parent.getFullPath(), "/") + realmTO.getName();
if (realmDAO.findByFullPath(fullPath) != null) {
throw new DuplicateException(fullPath);
}
Realm realm = realmDAO.save(binder.create(parent, realmTO));
PropagationByResource propByRes = new PropagationByResource();
realm.getResourceKeys().forEach(resource -> {
propByRes.add(ResourceOperation.CREATE, resource);
});
List<PropagationTaskTO> tasks = propagationManager.createTasks(realm, propByRes, null);
PropagationReporter propagationReporter = taskExecutor.execute(tasks, false);
ProvisioningResult<RealmTO> result = new ProvisioningResult<>();
result.setEntity(binder.getRealmTO(realm, true));
result.getPropagationStatuses().addAll(propagationReporter.getStatuses());
return result;
}
Aggregations