use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class ObjectChangesExecutorImpl method executeChangesSync.
private Collection<ObjectDeltaOperation<? extends ObjectType>> executeChangesSync(Collection<ObjectDelta<? extends ObjectType>> deltas, ModelExecuteOptions options, Task task, OperationResult result) {
try {
MidPointApplication application = MidPointApplication.get();
ModelService service = application.getModel();
Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = service.executeChanges(deltas, options, task, result);
result.computeStatusIfUnknown();
return executedDeltas;
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Error executing changes", e);
if (!result.isFatalError()) {
// just to be sure the exception is recorded into the result
result.recordFatalError(e.getMessage(), e);
}
}
return null;
}
use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class PageDebugView method savePerformed.
public void savePerformed(AjaxRequestTarget target) {
if (StringUtils.isEmpty(objectViewDtoModel.getObject().getXml())) {
error(getString("pageDebugView.message.cantSaveEmpty"));
target.add(getFeedbackPanel());
return;
}
Task task = createSimpleTask(OPERATION_SAVE_OBJECT);
OperationResult result = task.getResult();
try {
PrismObject<? extends ObjectType> oldObject = objectViewDtoModel.getObject().getObject();
oldObject.revive(getPrismContext());
Holder<? extends ObjectType> objectHolder = new Holder<>(null);
validateObject(result, (Holder) objectHolder);
if (result.isAcceptable()) {
PrismObject<? extends ObjectType> newObject = objectHolder.getValue().asPrismObject();
ObjectDelta<? extends ObjectType> delta = oldObject.diff((PrismObject) newObject, EquivalenceStrategy.LITERAL);
if (delta.getPrismContext() == null) {
LOGGER.warn("No prism context in delta {} after diff, adding it", delta);
delta.revive(getPrismContext());
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Delta to be applied:\n{}", delta.debugDump());
}
// quick fix for now (MID-1910), maybe it should be somewhere in objectViewModel..
// if (isReport(oldObject)){
// ReportTypeUtil.applyConfigurationDefinition((PrismObject)newObject, delta, getPrismContext());
// }
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscUtil.createCollection(delta);
ModelExecuteOptions options = ModelExecuteOptions.create(getPrismContext());
if (isTrue(DebugViewOptions.ID_SAVE_AS_RAW)) {
options.raw(true);
}
if (isTrue(DebugViewOptions.ID_REEVALUATE_SEARCH_FILTERS)) {
options.reevaluateSearchFilters(true);
}
if (!isTrue(DebugViewOptions.ID_ENCRYPT)) {
options.noCrypt(true);
}
getModelService().executeChanges(deltas, options, task, result);
result.computeStatus();
}
} catch (Exception ex) {
result.recordFatalError(getString("WebModelUtils.couldntSaveObject"), ex);
}
if (result.isError()) {
showResult(result);
target.add(getFeedbackPanel());
} else {
showResult(result);
// to handle returning back to list objects page instead of edit object page
if (getBreadcrumbs().size() >= 3) {
redirectBack(3);
} else {
redirectBack();
}
}
}
use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class InternalsLoggedInUsersPanel method initLayout.
private void initLayout() {
MainObjectListPanel<F> table = new MainObjectListPanel(ID_TABLE, FocusType.class, null) {
@Override
protected void objectDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
if (WebComponentUtil.hasDetailsPage(object.getClass())) {
PageParameters parameters = new PageParameters();
parameters.add(OnePageParameterEncoder.PARAMETER, object.getOid());
getPageBase().navigateToNext(WebComponentUtil.getObjectDetailsPage(object.getClass()), parameters);
}
}
@Override
protected List<IColumn<SelectableBean<F>, String>> createDefaultColumns() {
return InternalsLoggedInUsersPanel.this.initColumns();
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return initInlineMenu();
}
@Override
protected UserProfileStorage.TableId getTableId() {
return null;
}
@Override
protected ISelectableDataProvider<UserSessionManagementType, SelectableBean<F>> createProvider() {
LoadableModel<List<UserSessionManagementType>> principals = new LoadableModel<List<UserSessionManagementType>>(true) {
@Override
protected List<UserSessionManagementType> load() {
return loadLoggedInPrincipals();
}
};
return new SelectableListDataProvider<SelectableBean<F>, UserSessionManagementType>(InternalsLoggedInUsersPanel.this, principals) {
@Override
protected SelectableBean<F> createObjectWrapper(UserSessionManagementType principal) {
SelectableBeanImpl<F> user = new SelectableBeanImpl<>((F) principal.getFocus());
user.setActiveSessions(principal.getActiveSessions());
user.setNodes(principal.getNode());
return user;
}
};
}
@Override
protected boolean isCreateNewObjectEnabled() {
return false;
}
@Override
protected List<Component> createToolbarButtonsList(String buttonId) {
return new ArrayList<>();
}
@Override
protected boolean enableSavePageSize() {
return false;
}
};
add(table);
}
use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class ObjectLinkColumn method populateItem.
@Override
public void populateItem(Item<ICellPopulator<T>> cellItem, String componentId, final IModel<T> rowModel) {
IModel<ObjectType> superModel = createLinkModel(rowModel);
final ObjectType targetObjectType = superModel.getObject();
IModel<String> nameModel = new PropertyModel<>(superModel, FocusType.F_NAME.getLocalPart() + ".orig");
cellItem.add(new AjaxLinkPanel(componentId, nameModel) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ObjectLinkColumn.this.onClick(target, rowModel, targetObjectType);
}
@Override
public boolean isEnabled() {
return ObjectLinkColumn.this.isEnabled(rowModel);
}
});
}
use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class ReferenceAutocomplete method getIterator.
@Override
public Iterator<ObjectReferenceType> getIterator(String input) {
FormComponent<ObjectReferenceType> inputField = getBaseFormComponent();
String realInput = StringUtils.isEmpty(input) ? (!inputField.hasRawInput() ? inputField.getValue() : inputField.getRawInput()) : input;
if (StringUtils.isEmpty(realInput)) {
return Collections.emptyIterator();
}
Class<ObjectType> type = getReferenceTargetObjectType();
ObjectQuery query = pageBase.getPrismContext().queryFor(type).item(ObjectType.F_NAME).containsPoly(realInput).matchingNorm().build();
query.setPaging(pageBase.getPrismContext().queryFactory().createPaging(0, getMaxRowsCount()));
List<PrismObject<ObjectType>> objectsList = WebModelServiceUtils.searchObjects(type, query, new OperationResult("searchObjects"), pageBase);
return ObjectTypeUtil.objectListToReferences(objectsList).iterator();
}
Aggregations