Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/performance…
Browse files Browse the repository at this point in the history
…-stable
  • Loading branch information
1azyman committed Apr 5, 2018
2 parents 95bbcb0 + 557f266 commit 8c1c315
Show file tree
Hide file tree
Showing 13 changed files with 372 additions and 48 deletions.
5 changes: 3 additions & 2 deletions build-system/pom.xml
Expand Up @@ -49,7 +49,7 @@
<commons.lang.version>2.6</commons.lang.version>
<commons.lang3.version>3.7</commons.lang3.version>
<commons.cli>1.2</commons.cli>
<cxf.version>3.2.1</cxf.version>
<cxf.version>3.2.4</cxf.version>
<cxf-xjc.version>3.2.0</cxf-xjc.version>
<wss4j.version>2.2.0</wss4j.version>
<dbunit.version>2.4.7</dbunit.version>
Expand All @@ -63,7 +63,8 @@
<selenium.version>1.0.1</selenium.version>
<slf4j.version>1.7.25</slf4j.version>
<logback.version>1.2.3</logback.version>
<spring.boot.version>1.5.8.e1</spring.boot.version>
<spring.boot.version>1.5.8.e1</spring.boot.version> <!-- can be replaced by a stock version;
ideally after https://github.com/spring-projects/spring-boot/issues/11367 is resolved but it should be OK even before that -->
<spring.version>4.3.14.RELEASE</spring.version>
<spring.security.version>4.2.4.RELEASE</spring.security.version>
<cas.client.version>3.5.0</cas.client.version>
Expand Down
Expand Up @@ -231,6 +231,25 @@ public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentTyp
}
});

columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>(createStringResource("AssignmentType.tenant")){
private static final long serialVersionUID = 1L;

@Override
public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId,
final IModel<ContainerValueWrapper<AssignmentType>> rowModel) {
item.add(new Label(componentId, getTenantLabelModel(rowModel.getObject())));
}
});
columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>(createStringResource("AssignmentType.orgReferenceShorten")){
private static final long serialVersionUID = 1L;

@Override
public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId,
final IModel<ContainerValueWrapper<AssignmentType>> rowModel) {
item.add(new Label(componentId, getOrgRefLabelModel(rowModel.getObject())));
}
});

return columns;
}

Expand Down Expand Up @@ -308,30 +327,6 @@ protected AbstractAssignmentDetailsPanel createDetailsPanel(String idAssignmentD
return new AbstractRoleAssignmentDetailsPanel(ID_ASSIGNMENT_DETAILS, form, model);
}

@Override
protected List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initBasicColumns() {
List<IColumn<ContainerValueWrapper<AssignmentType>, String>> columns = super.initBasicColumns();
columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>(createStringResource("AssignmentType.tenant")){
private static final long serialVersionUID = 1L;

@Override
public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId,
final IModel<ContainerValueWrapper<AssignmentType>> rowModel) {
item.add(new Label(componentId, getTenantLabelModel(rowModel.getObject())));
}
});
columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>(createStringResource("AssignmentType.orgReferenceShorten")){
private static final long serialVersionUID = 1L;

@Override
public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId,
final IModel<ContainerValueWrapper<AssignmentType>> rowModel) {
item.add(new Label(componentId, getOrgRefLabelModel(rowModel.getObject())));
}
});
return columns;
}

private IModel<String> getTenantLabelModel(ContainerValueWrapper<AssignmentType> assignmentContainer){
if (assignmentContainer == null || assignmentContainer.getContainerValue() == null){
return Model.of("");
Expand Down
Expand Up @@ -224,7 +224,7 @@ protected AssignmentsTabStorage getAssignmentsStorage() {

protected abstract ObjectQuery createObjectQuery();

protected List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initBasicColumns() {
private List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initBasicColumns() {
List<IColumn<ContainerValueWrapper<AssignmentType>, String>> columns = new ArrayList<>();

columns.add(new CheckBoxHeaderColumn<>());
Expand Down
@@ -1,19 +1,33 @@
package com.evolveum.midpoint.web.component.assignment;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.query.AndFilter;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectPaging;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.session.AssignmentsTabStorage;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.web.util.ExpressionUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import javax.jws.WebParam;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand All @@ -24,6 +38,9 @@ public class InducedEntitlementsPanel extends InducementsPanel{

private static final long serialVersionUID = 1L;

private static final Trace LOGGER = TraceManager.getTrace(InducedEntitlementsPanel.class);
private static final String DOT_CLASS = InducedEntitlementsPanel.class.getName() + ".";
private static final String OPERATION_LOAD_SHADOW_DISPLAY_NAME = DOT_CLASS + "loadShadowDisplayName";

public InducedEntitlementsPanel(String id, IModel<ContainerWrapper<AssignmentType>> inducementContainerWrapperModel){
super(id, inducementContainerWrapperModel);
Expand All @@ -49,6 +66,40 @@ private AssignmentsTabStorage getInducedEntitlementsTabStorage(){
return getParentPage().getSessionStorage().getInducedEntitlementsTabStorage();
}

@Override
protected List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initColumns() {
List<IColumn<ContainerValueWrapper<AssignmentType>, String>> columns = new ArrayList<>();
columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>(createStringResource("ConstructionType.kind")){
private static final long serialVersionUID = 1L;

@Override
public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId,
final IModel<ContainerValueWrapper<AssignmentType>> rowModel) {
item.add(new Label(componentId, getKindLabelModel(rowModel.getObject())));
}
});
columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>(createStringResource("ConstructionType.intent")){
private static final long serialVersionUID = 1L;

@Override
public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId,
final IModel<ContainerValueWrapper<AssignmentType>> rowModel) {
item.add(new Label(componentId, getIntentLabelModel(rowModel.getObject())));
}
});
columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>(createStringResource("ConstructionType.association")){
private static final long serialVersionUID = 1L;

@Override
public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId,
final IModel<ContainerValueWrapper<AssignmentType>> rowModel) {
item.add(new Label(componentId, getAssociationLabelModel(rowModel.getObject())));
}
});

return columns;
}

@Override
protected ObjectQuery createObjectQuery() {
ObjectQuery query = super.createObjectQuery();
Expand Down Expand Up @@ -91,4 +142,84 @@ protected boolean isRelationVisible() {
protected List<ObjectTypes> getObjectTypesList(){
return Arrays.asList(ObjectTypes.RESOURCE);
}

private IModel<String> getKindLabelModel(ContainerValueWrapper<AssignmentType> assignmentWrapper){
if (assignmentWrapper == null){
return Model.of("");
}
AssignmentType assignment = assignmentWrapper.getContainerValue().asContainerable();
ConstructionType construction = assignment.getConstruction();
if (construction == null || construction.getKind() == null){
return Model.of("");
}
return WebComponentUtil.createLocalizedModelForEnum(construction.getKind(), InducedEntitlementsPanel.this);

}

private IModel<String> getIntentLabelModel(ContainerValueWrapper<AssignmentType> assignmentWrapper){
if (assignmentWrapper == null){
return Model.of("");
}
AssignmentType assignment = assignmentWrapper.getContainerValue().asContainerable();
ConstructionType construction = assignment.getConstruction();
if (construction == null || construction.getIntent() == null){
return Model.of("");
}
return Model.of(construction.getIntent());

}

private IModel<String> getAssociationLabelModel(ContainerValueWrapper<AssignmentType> assignmentWrapper){
if (assignmentWrapper == null){
return Model.of("");
}
AssignmentType assignment = assignmentWrapper.getContainerValue().asContainerable();
ConstructionType construction = assignment.getConstruction();
if (construction == null || construction.getAssociation() == null){
return Model.of("");
}
StringBuilder sb = new StringBuilder();
for (ResourceObjectAssociationType association : construction.getAssociation()){
if (association.getOutbound() == null || association.getOutbound().getExpression() == null){
continue;
}
ObjectReferenceType shadowRefValue = ExpressionUtil.getShadowRefValue(association.getOutbound().getExpression());
if (shadowRefValue == null || StringUtils.isEmpty(shadowRefValue.getOid())){
continue;
}
String shadowDisplayName = WebComponentUtil.getDisplayNameOrName(shadowRefValue, getPageBase(), OPERATION_LOAD_SHADOW_DISPLAY_NAME);
if (sb.length() == 0){
sb.append(createStringResource("ExpressionValuePanel.shadowRefValueTitle").getString() + ":");
}
if (StringUtils.isNotEmpty(shadowDisplayName)){
sb.append("\n");
sb.append(shadowDisplayName);
}
}
return Model.of(sb.toString());

}

@Override
protected List<ContainerValueWrapper<AssignmentType>> postSearch(List<ContainerValueWrapper<AssignmentType>> assignments) {
//TODO fix post search filtering
List<ContainerValueWrapper<AssignmentType>> filteredAssignments = new ArrayList<>();
assignments.forEach(assignmentWrapper -> {
AssignmentType assignment = assignmentWrapper.getContainerValue().asContainerable();
if (assignment.getConstruction() != null && assignment.getConstruction().getAssociation() != null){
List<ResourceObjectAssociationType> associations = assignment.getConstruction().getAssociation();
associations.forEach(association -> {
if (association.getOutbound() != null && association.getOutbound().getExpression() != null){
ObjectReferenceType shadowRef = ExpressionUtil.getShadowRefValue(association.getOutbound().getExpression());
if (shadowRef != null || (shadowRef == null && ValueStatus.ADDED.equals(assignmentWrapper.getStatus()))){
filteredAssignments.add(assignmentWrapper);
return;
}
}
});
}
});
// return filteredAssignments;
return assignments;
}
}
Expand Up @@ -60,7 +60,7 @@ public SelectableRowItem(String id, int index, IModel<T> model) {
@Override
protected Item<IColumn<T, String>> newCellItem(String id, int index, IModel<IColumn<T, String>> model) {
Item item = super.newCellItem(id, index, model);
item.add(new AttributeModifier("style", "max-width: 250px; word-wrap: break-word;"));
item.add(new AttributeModifier("style", "word-wrap: break-word;"));
return item;
}

Expand Down
Expand Up @@ -358,6 +358,7 @@ public abstract class SchemaConstants {

public static final QName MODEL_EXTENSION_OBJECT_TYPE = new QName(NS_MODEL_EXTENSION, "objectType");
public static final QName MODEL_EXTENSION_OBJECT_QUERY = new QName(NS_MODEL_EXTENSION, "objectQuery");
public static final QName MODEL_EXTENSION_SEARCH_OPTIONS = new QName(NS_MODEL_EXTENSION, "searchOptions");
public static final QName MODEL_EXTENSION_ITERATION_METHOD = new QName(NS_MODEL_EXTENSION, "iterationMethod");
public static final QName MODEL_EXTENSION_OBJECT_DELTA = new QName(NS_MODEL_EXTENSION, "objectDelta");
public static final QName MODEL_EXTENSION_WORKER_THREADS = new QName(NS_MODEL_EXTENSION, "workerThreads");
Expand Down
Expand Up @@ -141,6 +141,20 @@
</xsd:annotation>
</xsd:element>

<xsd:element name="searchOptions" type="c:SelectorQualifiedGetOptionsType">
<xsd:annotation>
<xsd:documentation>
Options to be used for object search (if supported by particular task handler).
</xsd:documentation>
<xsd:appinfo>
<a:displayName>Search options</a:displayName>
<!--<a:displayOrder>120</a:displayOrder>-->
<a:minOccurs>0</a:minOccurs>
<a:maxOccurs>1</a:maxOccurs>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

<xsd:element name="objectType" type="xsd:QName">
<xsd:annotation>
<xsd:documentation>
Expand Down
Expand Up @@ -94,7 +94,9 @@ protected ObjectQuery createQuery(ObjectIntegrityCheckResultHandler handler, Tas
protected Collection<SelectorOptions<GetOperationOptions>> createSearchOptions(
ObjectIntegrityCheckResultHandler resultHandler,
TaskRunResult runResult, Task coordinatorTask, OperationResult opResult) {
return SelectorOptions.createCollection(GetOperationOptions.createAttachDiagData());
Collection<SelectorOptions<GetOperationOptions>> optionsFromTask = createSearchOptionsFromTask(resultHandler,
runResult, coordinatorTask, opResult);
return SelectorOptions.updateRootOptions(optionsFromTask, opt -> opt.setAttachDiagData(true), GetOperationOptions::new);
}

@Override
Expand Down
Expand Up @@ -149,6 +149,10 @@ public boolean isCategoryType(EventCategoryType eventCategoryType) {
return eventCategoryType == EventCategoryType.MODEL_EVENT;
}

public ObjectDelta<?> getFocusPrimaryDelta() {
return getFocusContext() != null ? getFocusContext().getPrimaryDelta() : null;
}

public List<ObjectDelta<FocusType>> getFocusDeltas() {
List<ObjectDelta<FocusType>> retval = new ArrayList<>();
Class c = modelContext.getFocusClass();
Expand Down
Expand Up @@ -40,6 +40,8 @@

import java.util.List;

import static java.util.Collections.singletonList;

/**
* @author mederly
*/
Expand Down Expand Up @@ -76,23 +78,38 @@ protected boolean checkApplicability(Event event, GeneralNotifierType generalNot
LOGGER.trace("Operation was not successful, exiting.");
return false;
}
return getPasswordFromEvent((ModelEvent) event) != null; // logging is done in the called method
}

ModelEvent modelEvent = (ModelEvent) event;
private String getPasswordFromEvent(ModelEvent modelEvent) {
if (modelEvent.getFocusDeltas().isEmpty()) {
LOGGER.trace("No user deltas in event, exiting.");
return false;
return null;
}
if (getPasswordFromDeltas(modelEvent.getFocusDeltas()) != null) {
LOGGER.trace("Found password in user delta(s), continuing.");
return true;
String password = getPasswordFromDeltas(modelEvent.getFocusDeltas());
if (password != null) {
LOGGER.trace("Found password in user executed delta(s), continuing.");
return password;
}
//noinspection unchecked
ObjectDelta<FocusType> focusPrimaryDelta = (ObjectDelta) modelEvent.getFocusPrimaryDelta();
if (focusPrimaryDelta == null) {
LOGGER.trace("No password in executed delta(s) and no primary delta, exiting.");
return null;
}
password = getPasswordFromDeltas(singletonList(focusPrimaryDelta));
if (password != null) {
LOGGER.trace("Found password in user primary delta, continuing.");
return password;
} else {
LOGGER.trace("No password in user delta(s), exiting.");
return false;
LOGGER.trace("No password in executed delta(s) nor in primary delta, exiting.");
return null;
}
}

private String getPasswordFromDeltas(List<ObjectDelta<FocusType>> deltas) {
try {
//noinspection unchecked
return midpointFunctions.getPlaintextUserPasswordFromDeltas((List) deltas);
} catch (EncryptionException e) {
LoggingUtils.logException(LOGGER, "Couldn't decrypt password from user deltas: {}", e, DebugUtil.debugDump(deltas));
Expand All @@ -107,15 +124,12 @@ protected String getSubject(Event event, GeneralNotifierType generalNotifierType

@Override
protected String getBody(Event event, GeneralNotifierType generalNotifierType, String transport, Task task, OperationResult result) {

ModelEvent modelEvent = (ModelEvent) event;
List<ObjectDelta<FocusType>> deltas = modelEvent.getFocusDeltas();
return "Password for user " + notificationsUtil.getObjectType(event.getRequestee(), false, result).getName() + " is: " + getPasswordFromDeltas(deltas);
return "Password for user " + notificationsUtil.getObjectType(event.getRequestee(), false, result).getName()
+ " is: " + getPasswordFromEvent((ModelEvent) event);
}

@Override
protected Trace getLogger() {
return LOGGER;
}

}

0 comments on commit 8c1c315

Please sign in to comment.