use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class NotificationTaskDirectoryPanel method getActions.
@Override
public ActionsPanel<NotificationTaskTO> getActions(final IModel<NotificationTaskTO> model) {
final ActionsPanel<NotificationTaskTO> panel = super.getActions(model);
final NotificationTaskTO taskTO = model.getObject();
panel.add(new ActionLink<NotificationTaskTO>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final NotificationTaskTO modelObject) {
viewTask(taskTO, target);
}
}, ActionLink.ActionType.VIEW, StandardEntitlement.TASK_READ);
panel.add(new ActionLink<NotificationTaskTO>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final NotificationTaskTO modelObject) {
viewMailBody(MailTemplateFormat.TEXT, taskTO.getTextBody(), target);
}
}, ActionLink.ActionType.TEXT, StandardEntitlement.TASK_READ);
panel.add(new ActionLink<NotificationTaskTO>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final NotificationTaskTO modelObject) {
viewMailBody(MailTemplateFormat.HTML, taskTO.getHtmlBody(), target);
}
}, ActionLink.ActionType.HTML, StandardEntitlement.TASK_READ);
panel.add(new ActionLink<NotificationTaskTO>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final NotificationTaskTO modelObject) {
try {
restClient.startExecution(taskTO.getKey(), null);
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
LOG.error("While running {}", taskTO.getKey(), e);
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ActionLink.ActionType.EXECUTE, StandardEntitlement.TASK_EXECUTE);
panel.add(new ActionLink<NotificationTaskTO>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final NotificationTaskTO modelObject) {
try {
restClient.delete(TaskType.NOTIFICATION, taskTO.getKey());
updateResultTable(target);
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While deleting {}", taskTO.getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ActionLink.ActionType.DELETE, StandardEntitlement.TASK_DELETE, true);
return panel;
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class SchedTaskDirectoryPanel method getActions.
@Override
public ActionsPanel<T> getActions(final IModel<T> model) {
final ActionsPanel<T> panel = super.getActions(model);
final T taskTO = model.getObject();
panel.add(new ActionLink<T>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final T ignore) {
SchedTaskDirectoryPanel.this.getTogglePanel().close(target);
viewTask(taskTO, target);
}
}, ActionLink.ActionType.VIEW, StandardEntitlement.TASK_READ);
panel.add(new ActionLink<T>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final T ignore) {
SchedTaskDirectoryPanel.this.getTogglePanel().close(target);
send(SchedTaskDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(restClient.readTask(taskType, model.getObject().getKey()), target).setResourceModel(new StringResourceModel("inner.task.edit", SchedTaskDirectoryPanel.this, Model.of(Pair.of(ActionLink.ActionType.EDIT, model.getObject())))));
}
}, ActionLink.ActionType.EDIT, StandardEntitlement.TASK_UPDATE);
panel.add(new ActionLink<T>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final T ignore) {
SchedTaskDirectoryPanel.this.getTogglePanel().close(target);
final T clone = SerializationUtils.clone(model.getObject());
clone.setKey(null);
send(SchedTaskDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(clone, target).setResourceModel(new StringResourceModel("inner.task.clone", SchedTaskDirectoryPanel.this, Model.of(Pair.of(ActionLink.ActionType.CLONE, model.getObject())))));
}
}, ActionLink.ActionType.CLONE, StandardEntitlement.TASK_CREATE);
panel.add(new ActionLink<T>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final T ignore) {
SchedTaskDirectoryPanel.this.getTogglePanel().close(target);
startAt.setExecutionDetail(model.getObject().getKey(), model.getObject().getName(), target);
startAt.toggle(target, true);
}
}, ActionLink.ActionType.EXECUTE, StandardEntitlement.TASK_EXECUTE);
addFurtherActions(panel, model);
panel.add(new ActionLink<T>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final T ignore) {
try {
restClient.delete(taskType, taskTO.getKey());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
SchedTaskDirectoryPanel.this.getTogglePanel().close(target);
} catch (SyncopeClientException e) {
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
LOG.error("While deleting propagation task {}", taskTO.getKey(), e);
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ActionLink.ActionType.DELETE, StandardEntitlement.TASK_DELETE, true);
return panel;
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class ResourceLogic method setLatestSyncToken.
@PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_UPDATE + "')")
public void setLatestSyncToken(final String key, final String anyTypeKey) {
ExternalResource resource = resourceDAO.authFind(key);
if (resource == null) {
throw new NotFoundException("Resource '" + key + "'");
}
Connector connector;
try {
connector = connFactory.getConnector(resource);
} catch (Exception e) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidConnInstance);
sce.getElements().add(e.getMessage());
throw sce;
}
if (SyncopeConstants.REALM_ANYTYPE.equals(anyTypeKey)) {
if (resource.getOrgUnit() == null) {
throw new NotFoundException("Realm provision not enabled for Resource '" + key + "'");
}
resource.getOrgUnit().setSyncToken(connector.getLatestSyncToken(resource.getOrgUnit().getObjectClass()));
} else {
AnyType anyType = anyTypeDAO.find(anyTypeKey);
if (anyType == null) {
throw new NotFoundException("AnyType '" + anyTypeKey + "'");
}
Optional<? extends Provision> provision = resource.getProvision(anyType);
if (!provision.isPresent()) {
throw new NotFoundException("Provision for AnyType '" + anyTypeKey + "' in Resource '" + key + "'");
}
provision.get().setSyncToken(connector.getLatestSyncToken(provision.get().getObjectClass()));
}
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.RESOURCE_UPDATE), resource.getConnector().getAdminRealm().getFullPath());
securityChecks(effectiveRealms, resource.getConnector().getAdminRealm().getFullPath(), resource.getKey());
resourceDAO.save(resource);
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class TaskLogic method read.
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_READ + "')")
@Transactional(readOnly = true)
public <T extends TaskTO> T read(final TaskType type, final String key, final boolean details) {
Task task = taskDAO.find(key);
if (task == null) {
throw new NotFoundException("Task " + key);
}
TaskUtils taskUtils = taskUtilsFactory.getInstance(task);
if (type != null && taskUtils.getType() != type) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
sce.getElements().add("Found " + type + ", expected " + taskUtils.getType());
throw sce;
}
return binder.getTaskTO(task, taskUtilsFactory.getInstance(task), details);
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class LoggerLogic method throwInvalidLogger.
private void throwInvalidLogger(final LoggerType type) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidLogger);
sce.getElements().add("Expected " + type.name());
throw sce;
}
Aggregations