Skip to content

Commit

Permalink
implementing buttons behavior for details pages
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Aug 25, 2021
1 parent 54573e4 commit 40e9d9b
Show file tree
Hide file tree
Showing 37 changed files with 2,677 additions and 658 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ protected List<CompositedIconButtonDto> load() {
}

private List<CompositedIconButtonDto> newButtonDescription() {
if (getModelObject() == null) {
return null;
}
List<AssignmentObjectRelation> relations = getModelObject().getAssignmentObjectRelation();
if (relations == null) {
return null;
Expand Down Expand Up @@ -183,7 +186,7 @@ protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRe
}
};
form.add(newObjectIcon);
newObjectIcon.add(new VisibleBehaviour(() -> getModelObject().isSelectionVisible()));
newObjectIcon.add(new VisibleBehaviour(() -> getModelObject() != null && getModelObject().isSelectionVisible()));

addOrReplaceTabPanels(form, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.delta.ReferenceDelta;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

Expand All @@ -28,4 +29,6 @@ public interface PrismObjectWrapper<O extends ObjectType> extends PrismContainer
String getOid();

PrismObjectValueWrapper<O> getValue();

void addShadowDelta(ReferenceDelta shadowRefDelta);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ public interface PrismReferenceWrapper<R extends Referencable> extends ItemWrapp

Set<Function<Search, SearchItem>> getSpecialSearchItemFunctions();
void setSpecialSearchItemFunctions(Set<Function<Search, SearchItem>> specialItems);

boolean isOnlyForDeltaComputation();
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import java.util.Locale;

import com.evolveum.midpoint.web.util.validation.MidpointFormValidatorRegistry;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -94,4 +95,6 @@ default ObjectResolver getModelObjectResolver() {
<I extends Item, IW extends ItemWrapper> IW createItemWrapper(I item, ItemStatus status, WrapperContext ctx) throws SchemaException;

<IW extends ItemWrapper, VW extends PrismValueWrapper, PV extends PrismValue> VW createValueWrapper(IW parentWrapper, PV newValue, ValueStatus status, WrapperContext context) throws SchemaException;

MidpointFormValidatorRegistry getFormValidatorRegistry();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.impl.page.admin.ObjectDetailsModels;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.*;
import org.apache.commons.lang3.math.NumberUtils;
Expand Down Expand Up @@ -1572,6 +1574,49 @@ public static void encryptCredentials(ObjectDelta delta, boolean encrypt, MidPoi
}
}

public static void encryptCredentials(ObjectDelta delta, boolean encrypt, ModelServiceLocator serviceLocator) {
if (delta == null || delta.isEmpty()) {
return;
}

PropertyDelta propertyDelta = delta.findPropertyDelta(SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE);
if (propertyDelta == null) {
return;
}

Collection<PrismPropertyValue<ProtectedStringType>> values = propertyDelta
.getValues(ProtectedStringType.class);
for (PrismPropertyValue<ProtectedStringType> value : values) {
ProtectedStringType string = value.getValue();
encryptProtectedString(string, encrypt, serviceLocator);
}
}

public static void encryptProtectedString(ProtectedStringType string, boolean encrypt,
ModelServiceLocator serviceLocator) {
if (string == null) {
return;
}
Protector protector = serviceLocator.getPrismContext().getDefaultProtector();
try {
if (encrypt) {
if (StringUtils.isEmpty(string.getClearValue())) {
return;
}
protector.encrypt(string);
} else {
if (string.getEncryptedDataType() == null) {
return;
}
protector.decrypt(string);
}
} catch (EncryptionException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't encrypt protected string", ex);
} catch (SchemaException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't encrypt/decrypt protected string", e);
}
}

public static void encryptCredentials(PrismObject object, boolean encrypt, MidPointApplication app) {
PrismContainer password = object.findContainer(SchemaConstants.PATH_CREDENTIALS_PASSWORD);
if (password == null) {
Expand All @@ -1589,6 +1634,23 @@ public static void encryptCredentials(PrismObject object, boolean encrypt, MidPo
encryptProtectedString(string, encrypt, app);
}

public static void encryptCredentials(PrismObject object, boolean encrypt, ModelServiceLocator serviceLocator) {
PrismContainer password = object.findContainer(SchemaConstants.PATH_CREDENTIALS_PASSWORD);
if (password == null) {
return;
}
PrismProperty protectedStringProperty = password.findProperty(PasswordType.F_VALUE);
if (protectedStringProperty == null
|| protectedStringProperty.getRealValue(ProtectedStringType.class) == null) {
return;
}

ProtectedStringType string = (ProtectedStringType) protectedStringProperty
.getRealValue(ProtectedStringType.class);

encryptProtectedString(string, encrypt, serviceLocator);
}

public static void encryptProtectedString(ProtectedStringType string, boolean encrypt,
MidPointApplication app) {
if (string == null) {
Expand Down Expand Up @@ -5013,14 +5075,15 @@ public static IModel<String> createMappingDescription(IModel<PrismContainerValue
});
}

public static <T> Panel createPanel(Class<? extends Panel> panelClass, String markupId, IModel<T> model, ContainerPanelConfigurationType panelConfig) {
//TODO
public static <T extends ObjectType> Panel createPanel(Class<? extends Panel> panelClass, String markupId, ObjectDetailsModels<T> objectDetailsModels, ContainerPanelConfigurationType panelConfig) {
if (panelClass == null) {
return null;
}

try {
Constructor constructor = panelClass.getConstructor(String.class, LoadableModel.class, ContainerPanelConfigurationType.class);
Panel panel = (Panel) constructor.newInstance(markupId, model, panelConfig);
Panel panel = (Panel) constructor.newInstance(markupId, objectDetailsModels.getObjectWrapperModel(), panelConfig);
panel.setOutputMarkupId(true);
return panel;
} catch (Throwable e) {
Expand All @@ -5030,7 +5093,7 @@ public static <T> Panel createPanel(Class<? extends Panel> panelClass, String ma

try {
Constructor constructor = panelClass.getConstructor(String.class, IModel.class, ContainerPanelConfigurationType.class);
Panel panel = (Panel) constructor.newInstance(markupId, model, panelConfig);
Panel panel = (Panel) constructor.newInstance(markupId, objectDetailsModels.getObjectWrapperModel(), panelConfig);
panel.setOutputMarkupId(true);
return panel;
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
import com.evolveum.midpoint.gui.impl.prism.wrapper.PrismReferenceValueWrapperImpl;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismReferenceWrapper;
import com.evolveum.midpoint.gui.impl.prism.wrapper.PrismReferenceWrapperImpl;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;

import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -66,7 +69,11 @@ protected PrismReferenceValue createNewValue(PrismReference item) {
protected PrismReferenceWrapper<R> createWrapperInternal(PrismContainerValueWrapper<?> parent, PrismReference item,
ItemStatus status, WrapperContext ctx) {

return new PrismReferenceWrapperImpl<>(parent, item, status);
PrismReferenceWrapperImpl<R> referenceWrapper = new PrismReferenceWrapperImpl<>(parent, item, status);
if (QNameUtil.match(FocusType.F_LINK_REF, item.getElementName())) {
referenceWrapper.setOnlyForDeltaComputation(true);
}
return referenceWrapper;
}


Expand Down

This file was deleted.

0 comments on commit 40e9d9b

Please sign in to comment.