use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class PageResources method testResourcePerformed.
private void testResourcePerformed(AjaxRequestTarget target, ResourceType resourceType) {
OperationResult result = new OperationResult(OPERATION_TEST_RESOURCE);
// ResourceType resourceType = dto.getValue();
if (StringUtils.isEmpty(resourceType.getOid())) {
result.recordFatalError("Resource oid not defined in request");
}
Task task = createSimpleTask(OPERATION_TEST_RESOURCE);
try {
result = getModelService().testResource(resourceType.getOid(), task);
// ResourceController.updateResourceState(resourceType.getState(),
// result);
// todo de-duplicate code (see the same operation in PageResource)
// this provides some additional tests, namely a test for schema
// handling section
getModelService().getObject(ResourceType.class, resourceType.getOid(), null, task, result);
} catch (Exception ex) {
result.recordFatalError("Failed to test resource connection", ex);
}
// show any (potential) getObject problems
if (result.isSuccess()) {
result.recomputeStatus();
}
// if (!result.isSuccess()) {
showResult(result);
target.add(getFeedbackPanel());
// }
target.add(getResourceTable());
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class ResourceContentPanel method initColumns.
private List<IColumn<SelectableBean<ShadowType>, String>> initColumns() {
List<ColumnTypeDto<String>> columnDefs = Arrays.asList(new ColumnTypeDto<String>("ShadowType.synchronizationSituation", SelectableBean.F_VALUE + ".synchronizationSituation", ShadowType.F_SYNCHRONIZATION_SITUATION.getLocalPart()), new ColumnTypeDto<String>("ShadowType.intent", SelectableBean.F_VALUE + ".intent", ShadowType.F_INTENT.getLocalPart()));
List<IColumn<SelectableBean<ShadowType>, String>> columns = new ArrayList<>();
IColumn<SelectableBean<ShadowType>, String> identifiersColumn = new AbstractColumn<SelectableBean<ShadowType>, String>(createStringResource("pageContentAccounts.identifiers")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ShadowType>>> cellItem, String componentId, IModel<SelectableBean<ShadowType>> rowModel) {
SelectableBean<ShadowType> dto = rowModel.getObject();
RepeatingView repeater = new RepeatingView(componentId);
ShadowType value = dto.getValue();
if (value != null) {
for (ResourceAttribute<?> attr : ShadowUtil.getAllIdentifiers(value)) {
repeater.add(new Label(repeater.newChildId(), attr.getElementName().getLocalPart() + ": " + attr.getRealValue()));
}
}
cellItem.add(repeater);
}
};
columns.add(identifiersColumn);
columns.addAll((Collection) ColumnUtils.createColumns(columnDefs));
ObjectLinkColumn<SelectableBean<ShadowType>> ownerColumn = new ObjectLinkColumn<SelectableBean<ShadowType>>(createStringResource("pageContentAccounts.owner")) {
private static final long serialVersionUID = 1L;
@Override
protected IModel<FocusType> createLinkModel(final IModel<SelectableBean<ShadowType>> rowModel) {
return new AbstractReadOnlyModel<FocusType>() {
private static final long serialVersionUID = 1L;
@Override
public FocusType getObject() {
FocusType owner = loadShadowOwner(rowModel);
if (owner == null) {
return null;
}
return owner;
}
};
}
@Override
public void onClick(AjaxRequestTarget target, IModel<SelectableBean<ShadowType>> rowModel, ObjectType targetObjectType) {
ownerDetailsPerformed(target, (FocusType) targetObjectType);
}
};
columns.add(ownerColumn);
columns.add(new LinkColumn<SelectableBean<ShadowType>>(createStringResource("PageAccounts.accounts.result")) {
private static final long serialVersionUID = 1L;
@Override
protected IModel<String> createLinkModel(final IModel<SelectableBean<ShadowType>> rowModel) {
return new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getResultLabel(rowModel);
}
};
}
@Override
public void onClick(AjaxRequestTarget target, IModel<SelectableBean<ShadowType>> rowModel) {
OperationResultType resultType = getResult(rowModel);
OperationResult result = OperationResult.createOperationResult(resultType);
OperationResultPanel body = new OperationResultPanel(ResourceContentPanel.this.getPageBase().getMainPopupBodyId(), new Model<OpResult>(OpResult.getOpResult(pageBase, result)), getPage());
body.setOutputMarkupId(true);
ResourceContentPanel.this.getPageBase().showMainPopup(body, target);
}
});
return columns;
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class PageAdminResources method loadResource.
protected PrismObject<ResourceType> loadResource(Collection<SelectorOptions<GetOperationOptions>> options) {
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCE);
PrismObject<ResourceType> resource = null;
try {
Task task = createSimpleTask(OPERATION_LOAD_RESOURCE);
LOGGER.trace("getObject(resource) oid={}, options={}", getResourceOid(), options);
resource = getModelService().getObject(ResourceType.class, getResourceOid(), options, task, result);
result.recomputeStatus();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("getObject(resource) result\n:{}", result.debugDump());
}
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get resource", ex);
result.recordFatalError("Couldn't get resource, reason: " + ex.getMessage(), ex);
}
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
if (resource != null) {
showResult(result);
} else {
getSession().error(getString("pageAdminResources.message.cantLoadResource"));
throw new RestartResponseException(PageResources.class);
}
}
return resource;
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class PageAdminResources method deleteSyncTokenPerformed.
protected void deleteSyncTokenPerformed(AjaxRequestTarget target, ResourceType resourceType) {
// ResourceDto dto = model.getObject();
String resourceOid = resourceType.getOid();
String handlerUri = "http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3";
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.setOid(resourceOid);
PrismObject<TaskType> oldTask;
OperationResult result = new OperationResult(OPERATION_DELETE_SYNC_TOKEN);
ObjectQuery query = QueryBuilder.queryFor(TaskType.class, getPrismContext()).item(TaskType.F_OBJECT_REF).ref(resourceOid).and().item(TaskType.F_HANDLER_URI).eq(handlerUri).build();
List<PrismObject<TaskType>> taskList = WebModelServiceUtils.searchObjects(TaskType.class, query, result, this);
if (taskList.size() != 1) {
error(getString("pageResource.message.invalidTaskSearch"));
} else {
oldTask = taskList.get(0);
saveTask(oldTask, result);
}
result.recomputeStatus();
showResult(result);
target.add(getFeedbackPanel());
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class PageConnectorHosts method deleteHostConfirmedPerformed.
private void deleteHostConfirmedPerformed(AjaxRequestTarget target) {
Table hostTable = getConnectorHostTable();
List<SelectableBean<ConnectorHostType>> selected = WebComponentUtil.getSelectedData(hostTable);
OperationResult result = new OperationResult(OPERATION_DELETE_HOSTS);
for (SelectableBean<ConnectorHostType> selectable : selected) {
try {
Task task = createSimpleTask(OPERATION_DELETE_HOSTS);
if (selectable.getValue() != null) {
ObjectDelta<ConnectorHostType> delta = ObjectDelta.createDeleteDelta(ConnectorHostType.class, selectable.getValue().getOid(), getPrismContext());
getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result);
}
} catch (Exception ex) {
result.recordPartialError("Couldn't delete host.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete host", ex);
}
}
result.recomputeStatus();
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS, "The resource(s) have been successfully deleted.");
}
BaseSortableDataProvider provider = (BaseSortableDataProvider) hostTable.getDataTable().getDataProvider();
provider.clearCache();
showResult(result);
target.add(getFeedbackPanel(), (Component) hostTable);
}
Aggregations