use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class TaskDetails method details.
public void details() {
if (input.parameterNumber() == 0) {
try {
final Map<String, String> details = new LinkedHashMap<>();
final List<TaskTO> notificationTaskTOs = taskSyncopeOperations.list(TaskType.NOTIFICATION.name());
final List<TaskTO> propagationTaskTOs = taskSyncopeOperations.list(TaskType.PROPAGATION.name());
final List<TaskTO> pushTaskTOs = taskSyncopeOperations.list(TaskType.PUSH.name());
final List<TaskTO> scheduledTaskTOs = taskSyncopeOperations.list(TaskType.SCHEDULED.name());
final List<TaskTO> pullTaskTOs = taskSyncopeOperations.list(TaskType.PULL.name());
final List<JobTO> jobTOs = taskSyncopeOperations.listJobs();
final int notificationTaskSize = notificationTaskTOs.size();
final int propagationTaskSize = propagationTaskTOs.size();
final int pushTaskSize = pushTaskTOs.size();
final int scheduledTaskSize = scheduledTaskTOs.size();
final int pullTaskSize = pullTaskTOs.size();
final int jobsSize = jobTOs.size();
long notificationNotExecuted = notificationTaskTOs.stream().filter(notificationTaskTO -> !((NotificationTaskTO) notificationTaskTO).isExecuted()).count();
long propagationNotExecuted = propagationTaskTOs.stream().filter(propagationTaskTO -> ((PropagationTaskTO) propagationTaskTO).getExecutions().isEmpty()).count();
long pushNotExecuted = pushTaskTOs.stream().filter(pushTaskTO -> ((PushTaskTO) pushTaskTO).getExecutions().isEmpty()).count();
long scheduledNotExecuted = scheduledTaskTOs.stream().filter(scheduledTaskTO -> ((SchedTaskTO) scheduledTaskTO).getExecutions().isEmpty()).count();
int pullNotExecuted = 0;
int pullFull = 0;
for (final TaskTO pullTaskTO : pullTaskTOs) {
if (((PullTaskTO) pullTaskTO).getExecutions().isEmpty()) {
pullNotExecuted++;
}
if (((PullTaskTO) pullTaskTO).getPullMode() == PullMode.FULL_RECONCILIATION) {
pullFull++;
}
}
details.put("total number", String.valueOf(notificationTaskSize + propagationTaskSize + pushTaskSize + scheduledTaskSize + pullTaskSize));
details.put("notification tasks", String.valueOf(notificationTaskSize));
details.put("notification tasks not executed", String.valueOf(notificationNotExecuted));
details.put("propagation tasks", String.valueOf(propagationTaskSize));
details.put("propagation tasks not executed", String.valueOf(propagationNotExecuted));
details.put("push tasks", String.valueOf(pushTaskSize));
details.put("push tasks not executed", String.valueOf(pushNotExecuted));
details.put("scheduled tasks", String.valueOf(scheduledTaskSize));
details.put("scheduled tasks not executed", String.valueOf(scheduledNotExecuted));
details.put("pull tasks", String.valueOf(pullTaskSize));
details.put("pull tasks not executed", String.valueOf(pullNotExecuted));
details.put("pull tasks with full reconciliation", String.valueOf(pullFull));
details.put("jobs", String.valueOf(jobsSize));
taskResultManager.printDetails(details);
} catch (final SyncopeClientException ex) {
LOG.error("Error reading details about task", ex);
taskResultManager.genericError(ex.getMessage());
} catch (final IllegalArgumentException ex) {
LOG.error("Error reading details about task", ex);
taskResultManager.typeNotValidError("task", input.firstParameter(), CommandUtils.fromEnumToArray(TaskType.class));
}
} else {
taskResultManager.commandOptionError(DETAILS_HELP_MESSAGE);
}
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class LoggerCreate method create.
public void create() {
if (input.parameterNumber() >= 1) {
final List<LoggerTO> loggerTOs = new ArrayList<>();
boolean failed = false;
for (String parameter : input.getParameters()) {
LoggerTO loggerTO = new LoggerTO();
Pair<String, String> pairParameter = Input.toPairParameter(parameter);
try {
loggerTO.setKey(pairParameter.getKey());
loggerTO.setLevel(LoggerLevel.valueOf(pairParameter.getValue()));
loggerSyncopeOperations.update(loggerTO);
loggerTOs.add(loggerTO);
} catch (WebServiceException | SyncopeClientException | IllegalArgumentException ex) {
LOG.error("Error creating logger", ex);
loggerResultManager.typeNotValidError("logger level", input.firstParameter(), CommandUtils.fromEnumToArray(LoggerLevel.class));
failed = true;
break;
}
}
if (!failed) {
loggerResultManager.fromUpdate(loggerTOs);
}
} else {
loggerResultManager.commandOptionError(CREATE_HELP_MESSAGE);
}
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class TopologyTogglePanel method getResourceFragment.
private Fragment getResourceFragment(final TopologyNode node, final PageReference pageRef) {
Fragment fragment = new Fragment("actions", "resourceActions", this);
AjaxLink<String> delete = new IndicatingOnConfirmAjaxLink<String>("delete", true) {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
resourceRestClient.delete(node.getKey());
target.appendJavaScript(String.format("jsPlumb.remove('%s');", node.getKey()));
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
toggle(target, false);
} catch (SyncopeClientException e) {
LOG.error("While deleting resource {}", node.getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
};
MetaDataRoleAuthorizationStrategy.authorize(delete, RENDER, StandardEntitlement.RESOURCE_DELETE);
fragment.add(delete);
AjaxLink<String> edit = new IndicatingAjaxLink<String>("edit") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
ResourceTO resource = resourceRestClient.read(node.getKey());
ConnInstanceTO connInstance = connectorRestClient.read(resource.getConnector());
IModel<ResourceTO> model = new CompoundPropertyModel<>(resource);
modal.setFormModel(model);
target.add(modal.setContent(new ResourceWizardBuilder(resource, pageRef).build(BaseModal.CONTENT_ID, SyncopeConsoleSession.get().owns(StandardEntitlement.RESOURCE_UPDATE, connInstance.getAdminRealm()) ? AjaxWizard.Mode.EDIT : AjaxWizard.Mode.READONLY)));
modal.header(new Model<>(MessageFormat.format(getString("resource.edit"), node.getKey())));
modal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(edit, RENDER, StandardEntitlement.RESOURCE_READ);
fragment.add(edit);
AjaxLink<String> status = new IndicatingAjaxLink<String>("status") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
ResourceTO modelObject = resourceRestClient.read(node.getKey());
target.add(propTaskModal.setContent(new ResourceStatusModal(propTaskModal, pageRef, modelObject)));
propTaskModal.header(new Model<>(MessageFormat.format(getString("resource.provisioning.status"), node.getKey())));
propTaskModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(status, RENDER, StandardEntitlement.USER_UPDATE);
fragment.add(status);
AjaxLink<String> provision = new IndicatingAjaxLink<String>("provision") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
ResourceTO resource = resourceRestClient.read(node.getKey());
ConnInstanceTO connInstance = connectorRestClient.read(resource.getConnector());
if (SyncopeConsoleSession.get().owns(StandardEntitlement.RESOURCE_UPDATE, connInstance.getAdminRealm())) {
provisionModal.addSubmitButton();
} else {
provisionModal.removeSubmitButton();
}
IModel<ResourceTO> model = new CompoundPropertyModel<>(resource);
provisionModal.setFormModel(model);
target.add(provisionModal.setContent(new ResourceProvisionPanel(provisionModal, resource, connInstance.getAdminRealm(), pageRef)));
provisionModal.header(new Model<>(MessageFormat.format(getString("resource.edit"), node.getKey())));
provisionModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(edit, RENDER, StandardEntitlement.RESOURCE_READ);
fragment.add(provision);
AjaxLink<String> explore = new IndicatingAjaxLink<String>("explore") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
ResourceTO resource = resourceRestClient.read(node.getKey());
target.add(propTaskModal.setContent(new ConnObjects(resource, pageRef)));
propTaskModal.header(new StringResourceModel("resource.explore.list", Model.of(node)));
propTaskModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(explore, RENDER, StandardEntitlement.RESOURCE_LIST_CONNOBJECT);
fragment.add(explore);
AjaxLink<String> propagation = new IndicatingAjaxLink<String>("propagation") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
@SuppressWarnings("unchecked")
public void onClick(final AjaxRequestTarget target) {
target.add(propTaskModal.setContent(new PropagationTasks(propTaskModal, node.getKey(), pageRef)));
propTaskModal.header(new Model<>(MessageFormat.format(getString("task.propagation.list"), node.getKey())));
propTaskModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(propagation, RENDER, StandardEntitlement.TASK_LIST);
fragment.add(propagation);
AjaxLink<String> pull = new IndicatingAjaxLink<String>("pull") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
target.add(schedTaskModal.setContent(new PullTasks(schedTaskModal, pageRef, node.getKey())));
schedTaskModal.header(new Model<>(MessageFormat.format(getString("task.pull.list"), node.getKey())));
schedTaskModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(pull, RENDER, StandardEntitlement.TASK_LIST);
fragment.add(pull);
AjaxLink<String> push = new IndicatingAjaxLink<String>("push") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
target.add(schedTaskModal.setContent(new PushTasks(schedTaskModal, pageRef, node.getKey())));
schedTaskModal.header(new Model<>(MessageFormat.format(getString("task.push.list"), node.getKey())));
schedTaskModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(push, RENDER, StandardEntitlement.TASK_LIST);
fragment.add(push);
AjaxLink<String> history = new IndicatingAjaxLink<String>("history") {
private static final long serialVersionUID = -1876519166660008562L;
@Override
public void onClick(final AjaxRequestTarget target) {
String resourceKey = String.class.cast(node.getKey());
final ResourceTO modelObject = resourceRestClient.read(String.class.cast(node.getKey()));
target.add(historyModal.setContent(new HistoryConfList<>(historyModal, resourceKey, pageRef, modelObject)));
historyModal.header(new Model<>(MessageFormat.format(getString("resource.menu.history"), node.getDisplayName())));
historyModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(history, RENDER, StandardEntitlement.RESOURCE_HISTORY_LIST);
fragment.add(history);
// [SYNCOPE-1161] - Option to clone a resource
AjaxLink<String> clone = new IndicatingOnConfirmAjaxLink<String>("clone", "confirmClone", true) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
ResourceTO resource = resourceRestClient.read(node.getKey());
resource.setKey("Copy of " + resource.getKey());
// reset some resource objects keys
if (resource.getOrgUnit() != null) {
resource.getOrgUnit().setKey(null);
for (ItemTO item : resource.getOrgUnit().getItems()) {
item.setKey(null);
}
}
for (ProvisionTO provision : resource.getProvisions()) {
provision.setKey(null);
if (provision.getMapping() != null) {
for (ItemTO item : provision.getMapping().getItems()) {
item.setKey(null);
}
provision.getMapping().getLinkingItems().clear();
}
provision.getVirSchemas().clear();
}
resourceRestClient.create(resource);
// refresh Topology
send(pageRef.getPage(), Broadcast.DEPTH, new AbstractResourceWizardBuilder.CreateEvent(resource.getKey(), resource.getKey(), TopologyNode.Kind.RESOURCE, resource.getConnector(), target));
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
toggle(target, false);
} catch (SyncopeClientException e) {
LOG.error("While cloning resource {}", node.getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
};
MetaDataRoleAuthorizationStrategy.authorize(clone, RENDER, StandardEntitlement.RESOURCE_CREATE);
fragment.add(clone);
return fragment;
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class TopologyTogglePanel method getConnectorFragment.
private Fragment getConnectorFragment(final TopologyNode node, final PageReference pageRef) {
Fragment fragment = new Fragment("actions", "connectorActions", this);
AjaxLink<String> delete = new IndicatingOnConfirmAjaxLink<String>("delete", true) {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
connectorRestClient.delete(String.class.cast(node.getKey()));
target.appendJavaScript(String.format("jsPlumb.remove('%s');", node.getKey()));
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
toggle(target, false);
} catch (SyncopeClientException e) {
LOG.error("While deleting resource {}", node.getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
};
MetaDataRoleAuthorizationStrategy.authorize(delete, RENDER, StandardEntitlement.CONNECTOR_DELETE);
fragment.add(delete);
AjaxLink<String> create = new IndicatingAjaxLink<String>("create") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
final ResourceTO modelObject = new ResourceTO();
modelObject.setConnector(String.class.cast(node.getKey()));
modelObject.setConnectorDisplayName(node.getDisplayName());
final IModel<ResourceTO> model = new CompoundPropertyModel<>(modelObject);
modal.setFormModel(model);
target.add(modal.setContent(new ResourceWizardBuilder(modelObject, pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE)));
modal.header(new Model<>(MessageFormat.format(getString("resource.new"), node.getKey())));
modal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(create, RENDER, StandardEntitlement.RESOURCE_CREATE);
fragment.add(create);
AjaxLink<String> edit = new IndicatingAjaxLink<String>("edit") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
ConnInstanceTO connInstance = connectorRestClient.read(String.class.cast(node.getKey()));
final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(connInstance);
modal.setFormModel(model);
target.add(modal.setContent(new ConnectorWizardBuilder(connInstance, pageRef).build(BaseModal.CONTENT_ID, SyncopeConsoleSession.get().owns(StandardEntitlement.CONNECTOR_UPDATE, connInstance.getAdminRealm()) ? AjaxWizard.Mode.EDIT : AjaxWizard.Mode.READONLY)));
modal.header(new Model<>(MessageFormat.format(getString("connector.edit"), connInstance.getDisplayName())));
modal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(edit, RENDER, StandardEntitlement.CONNECTOR_READ);
fragment.add(edit);
AjaxLink<String> history = new IndicatingAjaxLink<String>("history") {
private static final long serialVersionUID = -1876519166660008562L;
@Override
public void onClick(final AjaxRequestTarget target) {
String connKey = String.class.cast(node.getKey());
ConnInstanceTO connInstance = connectorRestClient.read(connKey);
target.add(historyModal.setContent(new HistoryConfList<>(historyModal, connKey, pageRef, connInstance)));
historyModal.header(new Model<>(MessageFormat.format(getString("connector.menu.history"), node.getDisplayName())));
historyModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(history, RENDER, StandardEntitlement.CONNECTOR_HISTORY_LIST);
fragment.add(history);
return fragment;
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class AbstractAnyDataBinder method fill.
@SuppressWarnings({ "unchecked", "rawtypes" })
protected PropagationByResource fill(final Any any, final AnyPatch anyPatch, final AnyUtils anyUtils, final SyncopeClientCompositeException scce) {
PropagationByResource propByRes = new PropagationByResource();
// 1. anyTypeClasses
for (StringPatchItem patch : anyPatch.getAuxClasses()) {
AnyTypeClass auxClass = anyTypeClassDAO.find(patch.getValue());
if (auxClass == null) {
LOG.debug("Invalid " + AnyTypeClass.class.getSimpleName() + " {}, ignoring...", patch.getValue());
} else {
switch(patch.getOperation()) {
case ADD_REPLACE:
any.add(auxClass);
break;
case DELETE:
default:
any.getAuxClasses().remove(auxClass);
}
}
}
// 2. resources
for (StringPatchItem patch : anyPatch.getResources()) {
ExternalResource resource = resourceDAO.find(patch.getValue());
if (resource == null) {
LOG.debug("Invalid " + ExternalResource.class.getSimpleName() + " {}, ignoring...", patch.getValue());
} else {
switch(patch.getOperation()) {
case ADD_REPLACE:
propByRes.add(ResourceOperation.CREATE, resource.getKey());
any.add(resource);
break;
case DELETE:
default:
propByRes.add(ResourceOperation.DELETE, resource.getKey());
any.getResources().remove(resource);
}
}
}
Set<ExternalResource> resources = anyUtils.getAllResources(any);
SyncopeClientException invalidValues = SyncopeClientException.build(ClientExceptionType.InvalidValues);
// 3. plain attributes
anyPatch.getPlainAttrs().stream().filter(patch -> patch.getAttrTO() != null).forEach(patch -> {
PlainSchema schema = getPlainSchema(patch.getAttrTO().getSchema());
if (schema == null) {
LOG.debug("Invalid " + PlainSchema.class.getSimpleName() + " {}, ignoring...", patch.getAttrTO().getSchema());
} else {
PlainAttr<?> attr = (PlainAttr<?>) any.getPlainAttr(schema.getKey()).orElse(null);
if (attr == null) {
LOG.debug("No plain attribute found for schema {}", schema);
if (patch.getOperation() == PatchOperation.ADD_REPLACE) {
attr = anyUtils.newPlainAttr();
((PlainAttr) attr).setOwner(any);
attr.setSchema(schema);
any.add(attr);
}
}
if (attr != null) {
processAttrPatch(any, patch, schema, attr, anyUtils, resources, propByRes, invalidValues);
}
}
});
if (!invalidValues.isEmpty()) {
scce.addException(invalidValues);
}
SyncopeClientException requiredValuesMissing = checkMandatory(any, anyUtils);
if (!requiredValuesMissing.isEmpty()) {
scce.addException(requiredValuesMissing);
}
requiredValuesMissing = checkMandatoryOnResources(any, resources);
if (!requiredValuesMissing.isEmpty()) {
scce.addException(requiredValuesMissing);
}
return propByRes;
}
Aggregations