use of com.evolveum.prism.xml.ns._public.types_3.ObjectType 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.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class PageAccount method savePerformed.
private void savePerformed(AjaxRequestTarget target) {
LOGGER.debug("Saving account changes.");
OperationResult result = new OperationResult(OPERATION_SAVE_ACCOUNT);
try {
WebComponentUtil.revive(accountModel, getPrismContext());
ObjectWrapper wrapper = accountModel.getObject();
ObjectDelta<ShadowType> delta = wrapper.getObjectDelta();
if (delta == null) {
return;
}
if (delta.getPrismContext() == null) {
getPrismContext().adopt(delta);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Account delta computed from form:\n{}", new Object[] { delta.debugDump(3) });
}
if (delta.isEmpty()) {
return;
}
WebComponentUtil.encryptCredentials(delta, true, getMidpointApplication());
Task task = createSimpleTask(OPERATION_SAVE_ACCOUNT);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
deltas.add(delta);
getModelService().executeChanges(deltas, null, task, result);
result.recomputeStatus();
} catch (Exception ex) {
result.recordFatalError("Couldn't save account.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save account", ex);
}
if (!result.isSuccess()) {
showResult(result);
target.add(getFeedbackPanel());
} else {
showResult(result);
redirectBack();
}
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class LensProjectionContext method fromLensProjectionContextType.
public static LensProjectionContext fromLensProjectionContextType(LensProjectionContextType projectionContextType, LensContext lensContext, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException {
String objectTypeClassString = projectionContextType.getObjectTypeClass();
if (StringUtils.isEmpty(objectTypeClassString)) {
throw new SystemException("Object type class is undefined in LensProjectionContextType");
}
ResourceShadowDiscriminator resourceShadowDiscriminator = ResourceShadowDiscriminator.fromResourceShadowDiscriminatorType(projectionContextType.getResourceShadowDiscriminator());
LensProjectionContext projectionContext = new LensProjectionContext(lensContext, resourceShadowDiscriminator);
projectionContext.retrieveFromLensElementContextType(projectionContextType, task, result);
if (projectionContextType.getSyncDelta() != null) {
projectionContext.syncDelta = DeltaConvertor.createObjectDelta(projectionContextType.getSyncDelta(), lensContext.getPrismContext());
} else {
projectionContext.syncDelta = null;
}
ObjectDeltaType secondaryDeltaType = projectionContextType.getSecondaryDelta();
projectionContext.secondaryDelta = secondaryDeltaType != null ? (ObjectDelta) DeltaConvertor.createObjectDelta(secondaryDeltaType, lensContext.getPrismContext()) : null;
ObjectType object = projectionContextType.getObjectNew() != null ? projectionContextType.getObjectNew() : projectionContextType.getObjectOld();
projectionContext.fixProvisioningTypeInDelta(projectionContext.secondaryDelta, object, task, result);
projectionContext.wave = projectionContextType.getWave() != null ? projectionContextType.getWave() : 0;
projectionContext.fullShadow = projectionContextType.isFullShadow() != null ? projectionContextType.isFullShadow() : false;
projectionContext.isAssigned = projectionContextType.isIsAssigned() != null ? projectionContextType.isIsAssigned() : false;
projectionContext.isAssignedOld = projectionContextType.isIsAssignedOld() != null ? projectionContextType.isIsAssignedOld() : false;
projectionContext.isActive = projectionContextType.isIsActive() != null ? projectionContextType.isIsActive() : false;
projectionContext.isLegal = projectionContextType.isIsLegal();
projectionContext.isLegalOld = projectionContextType.isIsLegalOld();
projectionContext.isExists = projectionContextType.isIsExists() != null ? projectionContextType.isIsExists() : false;
projectionContext.synchronizationPolicyDecision = SynchronizationPolicyDecision.fromSynchronizationPolicyDecisionType(projectionContextType.getSynchronizationPolicyDecision());
projectionContext.doReconciliation = projectionContextType.isDoReconciliation() != null ? projectionContextType.isDoReconciliation() : false;
projectionContext.synchronizationSituationDetected = projectionContextType.getSynchronizationSituationDetected();
projectionContext.synchronizationSituationResolved = projectionContextType.getSynchronizationSituationResolved();
projectionContext.accountPasswordPolicy = projectionContextType.getAccountPasswordPolicy();
projectionContext.syncAbsoluteTrigger = projectionContextType.isSyncAbsoluteTrigger();
return projectionContext;
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class LensUtil method checkObjectPolicy.
private static <F extends ObjectType> void checkObjectPolicy(LensFocusContext<F> focusContext, ObjectPolicyConfigurationType objectPolicyConfigurationType) throws SchemaException, PolicyViolationException {
if (objectPolicyConfigurationType == null) {
return;
}
PrismObject<F> focusObjectNew = focusContext.getObjectNew();
ObjectDelta<F> focusDelta = focusContext.getDelta();
for (PropertyConstraintType propertyConstraintType : objectPolicyConfigurationType.getPropertyConstraint()) {
ItemPath itemPath = propertyConstraintType.getPath().getItemPath();
if (BooleanUtils.isTrue(propertyConstraintType.isOidBound())) {
if (focusDelta != null) {
if (focusDelta.isAdd()) {
PrismProperty<Object> propNew = focusObjectNew.findProperty(itemPath);
if (propNew != null) {
// prop delta is OK, but it has to match
if (focusObjectNew.getOid() != null) {
if (!focusObjectNew.getOid().equals(propNew.getRealValue().toString())) {
throw new PolicyViolationException("Cannot set " + itemPath + " to a value different than OID in oid bound mode");
}
}
}
} else {
PropertyDelta<Object> nameDelta = focusDelta.findPropertyDelta(itemPath);
if (nameDelta != null) {
if (nameDelta.isReplace()) {
Collection<PrismPropertyValue<Object>> valuesToReplace = nameDelta.getValuesToReplace();
if (valuesToReplace.size() == 1) {
String stringValue = valuesToReplace.iterator().next().getValue().toString();
if (focusContext.getOid().equals(stringValue)) {
// This is OK. It is most likely a correction made by a recompute.
continue;
}
}
}
throw new PolicyViolationException("Cannot change " + itemPath + " in oid bound mode");
}
}
}
}
}
// Deprecated
if (BooleanUtils.isTrue(objectPolicyConfigurationType.isOidNameBoundMode())) {
if (focusDelta != null) {
if (focusDelta.isAdd()) {
PolyStringType namePolyType = focusObjectNew.asObjectable().getName();
if (namePolyType != null) {
// name delta is OK, but it has to match
if (focusObjectNew.getOid() != null) {
if (!focusObjectNew.getOid().equals(namePolyType.getOrig())) {
throw new PolicyViolationException("Cannot set name to a value different than OID in name-oid bound mode");
}
}
}
} else {
PropertyDelta<Object> nameDelta = focusDelta.findPropertyDelta(FocusType.F_NAME);
if (nameDelta != null) {
throw new PolicyViolationException("Cannot change name in name-oid bound mode");
}
}
}
}
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.
the class Clockwork method triggerReconcileAffected.
private <F extends ObjectType> HookOperationMode triggerReconcileAffected(LensContext<F> context, Task task, OperationResult result) throws SchemaException {
// check applicability
if (!ModelExecuteOptions.isReconcileAffected(context.getOptions())) {
return HookOperationMode.FOREGROUND;
}
if (context.getFocusClass() == null || !RoleType.class.isAssignableFrom(context.getFocusClass())) {
LOGGER.warn("ReconcileAffected requested but not available for {}. Doing nothing.", context.getFocusClass());
return HookOperationMode.FOREGROUND;
}
// check preconditions
if (context.getFocusContext() == null) {
throw new IllegalStateException("No focus context when expected it");
}
PrismObject<RoleType> role = (PrismObject) context.getFocusContext().getObjectAny();
if (role == null) {
throw new IllegalStateException("No role when expected it");
}
// preparing the recompute/reconciliation task
Task reconTask;
if (task.isPersistent()) {
reconTask = task.createSubtask();
} else {
reconTask = task;
}
assert !reconTask.isPersistent();
// creating object query
PrismPropertyDefinition propertyDef = prismContext.getSchemaRegistry().findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY);
PrismReferenceValue referenceValue = new PrismReferenceValue(context.getFocusContext().getOid(), RoleType.COMPLEX_TYPE);
ObjectFilter refFilter = QueryBuilder.queryFor(FocusType.class, prismContext).item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(referenceValue).buildFilter();
SearchFilterType filterType = QueryConvertor.createSearchFilterType(refFilter, prismContext);
QueryType queryType = new QueryType();
queryType.setFilter(filterType);
PrismProperty<QueryType> property = propertyDef.instantiate();
property.setRealValue(queryType);
reconTask.addExtensionProperty(property);
// other parameters
reconTask.setName("Recomputing users after changing role " + role.asObjectable().getName());
reconTask.setBinding(TaskBinding.LOOSE);
reconTask.setInitialExecutionStatus(TaskExecutionStatus.RUNNABLE);
reconTask.setHandlerUri(RecomputeTaskHandler.HANDLER_URI);
reconTask.setCategory(TaskCategory.RECOMPUTATION);
taskManager.switchToBackground(reconTask, result);
result.setBackgroundTaskOid(reconTask.getOid());
result.recordStatus(OperationResultStatus.IN_PROGRESS, "Reconciliation task switched to background");
return HookOperationMode.BACKGROUND;
}
Aggregations