use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class DynRealmDataBinderImpl method setDynMembership.
private void setDynMembership(final DynRealm dynRealm, final AnyType anyType, final String dynMembershipFIQL) {
SearchCond dynMembershipCond = SearchCondConverter.convert(dynMembershipFIQL);
if (!dynMembershipCond.isValid()) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidSearchExpression);
sce.getElements().add(dynMembershipFIQL);
throw sce;
}
DynRealmMembership dynMembership;
if (dynRealm.getDynMembership(anyType).isPresent()) {
dynMembership = dynRealm.getDynMembership(anyType).get();
} else {
dynMembership = entityFactory.newEntity(DynRealmMembership.class);
dynMembership.setDynRealm(dynRealm);
dynMembership.setAnyType(anyType);
dynRealm.add(dynMembership);
}
dynMembership.setFIQLCond(dynMembershipFIQL);
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class ReportDataBinderImpl method getReport.
@Override
public void getReport(final Report report, final ReportTO reportTO) {
BeanUtils.copyProperties(reportTO, report, IGNORE_REPORT_PROPERTIES);
ReportTemplate template = reportTemplateDAO.find(reportTO.getTemplate());
if (template == null) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
sce.getElements().add("template");
throw sce;
}
report.setTemplate(template);
reportTO.getReportlets().forEach(reportletKey -> {
Implementation reportlet = implementationDAO.find(reportletKey);
if (reportlet == null) {
LOG.debug("Invalid " + Implementation.class.getSimpleName() + " {}, ignoring...", reportletKey);
} else {
report.add(reportlet);
}
});
// remove all implementations not contained in the TO
report.getReportlets().removeIf(reportlet -> !reportTO.getReportlets().contains(reportlet.getKey()));
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class RealmDataBinderImpl method create.
@Override
public Realm create(final Realm parent, final RealmTO realmTO) {
Realm realm = entityFactory.newEntity(Realm.class);
realm.setName(realmTO.getName());
realm.setParent(parent);
if (realmTO.getPasswordPolicy() != null) {
Policy policy = policyDAO.find(realmTO.getPasswordPolicy());
if (policy instanceof PasswordPolicy) {
realm.setPasswordPolicy((PasswordPolicy) policy);
} else {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPolicy);
sce.getElements().add("Expected " + PasswordPolicy.class.getSimpleName() + ", found " + policy.getClass().getSimpleName());
throw sce;
}
}
if (realmTO.getAccountPolicy() != null) {
Policy policy = policyDAO.find(realmTO.getAccountPolicy());
if (policy instanceof AccountPolicy) {
realm.setAccountPolicy((AccountPolicy) policy);
} else {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPolicy);
sce.getElements().add("Expected " + AccountPolicy.class.getSimpleName() + ", found " + policy.getClass().getSimpleName());
throw sce;
}
}
realmTO.getActions().forEach(logicActionsKey -> {
Implementation logicAction = implementationDAO.find(logicActionsKey);
if (logicAction == null) {
LOG.debug("Invalid " + Implementation.class.getSimpleName() + " {}, ignoring...", logicActionsKey);
} else {
realm.add(logicAction);
}
});
setTemplates(realmTO, realm);
realmTO.getResources().forEach(resourceKey -> {
ExternalResource resource = resourceDAO.find(resourceKey);
if (resource == null) {
LOG.debug("Invalid " + ExternalResource.class.getSimpleName() + " {}, ignoring...", resourceKey);
} else {
realm.add(resource);
}
});
return realm;
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class RealmDataBinderImpl method update.
@Override
public PropagationByResource update(final Realm realm, final RealmTO realmTO) {
realm.setName(realmTO.getName());
realm.setParent(realmTO.getParent() == null ? null : realmDAO.find(realmTO.getParent()));
if (realmTO.getAccountPolicy() == null) {
realm.setAccountPolicy(null);
} else {
Policy policy = policyDAO.find(realmTO.getAccountPolicy());
if (policy instanceof AccountPolicy) {
realm.setAccountPolicy((AccountPolicy) policy);
} else {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPolicy);
sce.getElements().add("Expected " + AccountPolicy.class.getSimpleName() + ", found " + policy.getClass().getSimpleName());
throw sce;
}
}
if (realmTO.getPasswordPolicy() == null) {
realm.setPasswordPolicy(null);
} else {
Policy policy = policyDAO.find(realmTO.getPasswordPolicy());
if (policy instanceof PasswordPolicy) {
realm.setPasswordPolicy((PasswordPolicy) policy);
} else {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPolicy);
sce.getElements().add("Expected " + PasswordPolicy.class.getSimpleName() + ", found " + policy.getClass().getSimpleName());
throw sce;
}
}
realmTO.getActions().forEach(logicActionsKey -> {
Implementation logicActions = implementationDAO.find(logicActionsKey);
if (logicActions == null) {
LOG.debug("Invalid " + Implementation.class.getSimpleName() + " {}, ignoring...", logicActionsKey);
} else {
realm.add(logicActions);
}
});
// remove all implementations not contained in the TO
realm.getActions().removeIf(implementation -> !realmTO.getActions().contains(implementation.getKey()));
setTemplates(realmTO, realm);
PropagationByResource propByRes = new PropagationByResource();
realmTO.getResources().forEach(resourceKey -> {
ExternalResource resource = resourceDAO.find(resourceKey);
if (resource == null) {
LOG.debug("Invalid " + ExternalResource.class.getSimpleName() + " {}, ignoring...", resourceKey);
} else {
realm.add(resource);
propByRes.add(ResourceOperation.CREATE, resource.getKey());
}
});
// remove all resources not contained in the TO
realm.getResources().removeIf(resource -> {
boolean contained = realmTO.getResources().contains(resource.getKey());
if (!contained) {
propByRes.add(ResourceOperation.DELETE, resource.getKey());
}
return !contained;
});
return propByRes;
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class ExecutionsDirectoryPanel method getActions.
@Override
public ActionsPanel<ExecTO> getActions(final IModel<ExecTO> model) {
final ActionsPanel<ExecTO> panel = super.getActions(model);
final ExecTO taskExecutionTO = model.getObject();
panel.add(new ActionLink<ExecTO>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final ExecTO ignore) {
ExecutionsDirectoryPanel.this.getTogglePanel().close(target);
next(new StringResourceModel("execution.view", ExecutionsDirectoryPanel.this, model).getObject(), new ExecMessage(model.getObject().getMessage()), target);
}
}, ActionLink.ActionType.VIEW, StandardEntitlement.TASK_READ);
panel.add(new ActionLink<ExecTO>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final ExecTO ignore) {
ExecutionsDirectoryPanel.this.getTogglePanel().close(target);
try {
restClient.deleteExecution(taskExecutionTO.getKey());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException scce) {
SyncopeConsoleSession.get().error(scce.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ActionLink.ActionType.DELETE, StandardEntitlement.TASK_DELETE, true);
addFurtherAcions(panel, model);
return panel;
}
Aggregations