Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/support-3.7' into support-3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Apr 12, 2018
2 parents 1cce61b + 7172aec commit aab70d6
Show file tree
Hide file tree
Showing 21 changed files with 770 additions and 66 deletions.
Expand Up @@ -714,8 +714,7 @@ public static void addIncludeOptionsForExportOrView(Collection<SelectorOptions<G
}
}

public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase) {
Task task = pageBase.createSimpleTask("Load admin gui config");
public static boolean isEnableExperimentalFeature(Task task, ModelServiceLocator pageBase) {
OperationResult result = task.getResult();

ModelInteractionService mInteractionService = pageBase.getModelInteractionService();
Expand All @@ -738,4 +737,20 @@ public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase)
return BooleanUtils.isTrue(adminGuiConfig.isEnableExperimentalFeatures());

}

public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase) {
Task task = pageBase.createSimpleTask("Load admin gui config");
return isEnableExperimentalFeature(task, pageBase);

}

public static AccessCertificationConfigurationType getCertificationConfiguration(PageBase pageBase) {
OperationResult result = new OperationResult(WebModelServiceUtils.class.getName() + ".getCertificationConfiguration");
try {
return pageBase.getModelInteractionService().getCertificationConfiguration(result);
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Cannot load certification configuration", t);
return null;
}
}
}
Expand Up @@ -50,6 +50,7 @@
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
Expand Down
Expand Up @@ -51,6 +51,7 @@
import com.evolveum.midpoint.prism.query.ObjectPaging;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.AjaxIconButton;
import com.evolveum.midpoint.web.component.data.BoxedTablePanel;
Expand Down Expand Up @@ -460,8 +461,9 @@ protected void deleteAssignmentPerformed(AjaxRequestTarget target, List<Containe

protected ContainerValueWrapper<AssignmentType> createNewAssignmentContainerValueWrapper(PrismContainerValue<AssignmentType> newAssignment) {
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
Task task = getPageBase().createSimpleTask("Creating new assignment");
ContainerValueWrapper<AssignmentType> valueWrapper = factory.createContainerValueWrapper(getModelObject(), newAssignment,
getModelObject().getObjectStatus(), ValueStatus.ADDED, getModelObject().getPath());
getModelObject().getObjectStatus(), ValueStatus.ADDED, getModelObject().getPath(), task);
valueWrapper.setShowEmpty(true, false);
getModelObject().getValues().add(valueWrapper);
return valueWrapper;
Expand Down
Expand Up @@ -164,7 +164,7 @@ public void computeStripes() {
}
int visibleProperties = 0;

for (ItemWrapper item : properties) {
for (ItemWrapper item : properties) {
if (item.isVisible()) {
visibleProperties++;
}
Expand Down Expand Up @@ -553,24 +553,6 @@ private void addItemDelta(PropertyOrReferenceWrapper itemWrapper, ItemDelta pDel
}
}

public void addNewChildContainerValue(QName path, PageBase pageBase){
ContainerWrapper<C> childContainerWrapper = getContainer().findContainerWrapper(new ItemPath(getPath(), path));
if (childContainerWrapper == null){
return;
}
boolean isSingleValue = childContainerWrapper.getItemDefinition().isSingleValue();
if (isSingleValue){
return;
}
PrismContainerValue<C> newContainerValue = childContainerWrapper.getItem().createNewValue();
ContainerWrapperFactory factory = new ContainerWrapperFactory(pageBase);
ContainerValueWrapper newValueWrapper = factory.createContainerValueWrapper(childContainerWrapper,
newContainerValue, objectStatus,
ValueStatus.ADDED, new ItemPath(path));
newValueWrapper.setShowEmpty(true, false);
childContainerWrapper.getValues().add(newValueWrapper);

}

private Item createItem(PropertyOrReferenceWrapper itemWrapper, ItemDefinition propertyDef) {
List<PrismValue> prismValues = new ArrayList<>();
Expand Down
Expand Up @@ -38,10 +38,12 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.schema.util.ShadowUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.exception.TunnelException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand Down Expand Up @@ -100,13 +102,14 @@ public <C extends Containerable> ContainerWrapper createContainerWrapper(
PrismContainer<C> container,
ContainerStatus objectStatus,
ContainerStatus status,
ItemPath path) {
ItemPath path,
Task task) {

result = new OperationResult(CREATE_PROPERTIES);

ContainerWrapper<C> cWrapper = new ContainerWrapper(container, objectStatus, status, path);

List<ContainerValueWrapper<C>> containerValues = createContainerValues(cWrapper, path);
List<ContainerValueWrapper<C>> containerValues = createContainerValues(cWrapper, path, task);
cWrapper.setProperties(containerValues);
cWrapper.computeStripes();

Expand Down Expand Up @@ -197,45 +200,45 @@ private boolean isEmpty(ValueWrapper shadowAssociationRef) {

}

public <C extends Containerable> ContainerWrapper<C> createContainerWrapper(PrismContainer<C> container, ContainerStatus objectStatus, ContainerStatus status, ItemPath path, boolean readonly) {
public <C extends Containerable> ContainerWrapper<C> createContainerWrapper(PrismContainer<C> container, ContainerStatus objectStatus, ContainerStatus status, ItemPath path, boolean readonly, Task task) {

result = new OperationResult(CREATE_PROPERTIES);

ContainerWrapper<C> cWrapper = new ContainerWrapper<C>(container, objectStatus, status, path, readonly);

List<ContainerValueWrapper<C>> containerValues = createContainerValues(cWrapper, path);
List<ContainerValueWrapper<C>> containerValues = createContainerValues(cWrapper, path, task);
cWrapper.setProperties(containerValues);
cWrapper.computeStripes();


return cWrapper;
}

private <C extends Containerable> List<ContainerValueWrapper<C>> createContainerValues(ContainerWrapper<C> cWrapper, ItemPath path) {
private <C extends Containerable> List<ContainerValueWrapper<C>> createContainerValues(ContainerWrapper<C> cWrapper, ItemPath path, Task task) {
List<ContainerValueWrapper<C>> containerValueWrappers = new ArrayList<>();
PrismContainer<C> container = cWrapper.getItem();

if (container.getValues().isEmpty() && container.isSingleValue()) {
PrismContainerValue<C> pcv = container.createNewValue();
ContainerValueWrapper<C> containerValueWrapper = createContainerValueWrapper(cWrapper, pcv, cWrapper.getObjectStatus(), ValueStatus.ADDED, cWrapper.getPath());
ContainerValueWrapper<C> containerValueWrapper = createContainerValueWrapper(cWrapper, pcv, cWrapper.getObjectStatus(), ValueStatus.ADDED, cWrapper.getPath(), task);

containerValueWrappers.add(containerValueWrapper);
return containerValueWrappers;
}

container.getValues().forEach(pcv -> {
ContainerValueWrapper<C> containerValueWrapper = createContainerValueWrapper(cWrapper, pcv, cWrapper.getObjectStatus(), cWrapper.getStatus() == ContainerStatus.ADDING ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED, pcv.getPath());
ContainerValueWrapper<C> containerValueWrapper = createContainerValueWrapper(cWrapper, pcv, cWrapper.getObjectStatus(), cWrapper.getStatus() == ContainerStatus.ADDING ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED, pcv.getPath(), task);
containerValueWrappers.add(containerValueWrapper);
});


return containerValueWrappers;
}

public <C extends Containerable> ContainerValueWrapper<C> createContainerValueWrapper(ContainerWrapper cWrapper, PrismContainerValue<C> value, ContainerStatus objectStatus, ValueStatus status, ItemPath path){
public <C extends Containerable> ContainerValueWrapper<C> createContainerValueWrapper(ContainerWrapper cWrapper, PrismContainerValue<C> value, ContainerStatus objectStatus, ValueStatus status, ItemPath path, Task task){
ContainerValueWrapper<C> containerValueWrapper = new ContainerValueWrapper<C>(cWrapper, value, objectStatus, status, path);

List<ItemWrapper> properties = createProperties(containerValueWrapper, false);
List<ItemWrapper> properties = createProperties(containerValueWrapper, false, task);
containerValueWrapper.setProperties(properties);

ReferenceWrapper shadowRefWrapper = (ReferenceWrapper) containerValueWrapper.findPropertyWrapper(ShadowAssociationType.F_SHADOW_REF);
Expand All @@ -246,7 +249,7 @@ public <C extends Containerable> ContainerValueWrapper<C> createContainerValueWr
return containerValueWrapper;
}

public <O extends ObjectType, C extends Containerable> List<ItemWrapper> createProperties(ContainerValueWrapper<C> cWrapper, boolean onlyEmpty) {
public <O extends ObjectType, C extends Containerable> List<ItemWrapper> createProperties(ContainerValueWrapper<C> cWrapper, boolean onlyEmpty, Task task) {

result = new OperationResult(CREATE_PROPERTIES);

Expand All @@ -271,14 +274,20 @@ public <O extends ObjectType, C extends Containerable> List<ItemWrapper> createP
return;
}

if (itemDef.isExperimental() && !WebModelServiceUtils.isEnableExperimentalFeature(modelServiceLocator)) {
if (itemDef.isExperimental() && !WebModelServiceUtils.isEnableExperimentalFeature(task, modelServiceLocator)) {
LOGGER.trace("Skipping creating wrapper for {} because it is experimental a experimental features are not enabled.", itemDef.getName());
return;
}

LOGGER.trace("Creating wrapper for {}", itemDef);
try {
createPropertyOrReferenceWrapper(itemDef, cWrapper, propertyOrReferenceWrappers, onlyEmpty, cWrapper.getPath());
createContainerWrapper(itemDef, cWrapper, containerWrappers, onlyEmpty);
createContainerWrapper(itemDef, cWrapper, containerWrappers, onlyEmpty, task);
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "something strange happenned: " + e.getMessage(), e);
System.out.println(e.getMessage());
throw new TunnelException(e);
}

});

Expand Down Expand Up @@ -309,16 +318,47 @@ private <C extends Containerable> void createPropertyOrReferenceWrapper(ItemDefi
}


private <C extends Containerable> void createContainerWrapper(ItemDefinition itemDef, ContainerValueWrapper<C> cWrapper, List<ContainerWrapper<C>> properties, boolean onlyEmpty) {
private <C extends Containerable> void createContainerWrapper(ItemDefinition itemDef, ContainerValueWrapper<C> cWrapper,
List<ContainerWrapper<C>> properties, boolean onlyEmpty, Task task){


if (itemDef instanceof PrismContainerDefinition) {

if (cWrapper.isMain() && !ObjectType.F_EXTENSION.equals(itemDef.getName()) && !ObjectType.F_METADATA.equals(itemDef.getName())) {
return;
}

ContainerWrapper<C> subContainerWrapper = createContainerWrapper((PrismContainerDefinition<C>) itemDef, cWrapper, onlyEmpty);

ContainerWrapper<C> subContainerWrapper;
// if (((PrismContainerDefinition) itemDef).getCompileTimeClass() != null
// && ((PrismContainerDefinition) itemDef).getCompileTimeClass().equals(ResourceObjectAssociationType.class)){
// if (!ConstructionType.class.equals(cWrapper.getDefinition().getCompileTimeClass())){
// return;
// }
// ConstructionType construction = (ConstructionType)cWrapper.getContainerValue().getValue();
// Task task = modelServiceLocator.createSimpleTask("Load resource ref");
// PrismObject<ResourceType> resource = WebModelServiceUtils.loadObject(construction.getResourceRef(),
// modelServiceLocator, task, result);
//
// result.computeStatusIfUnknown();
// if (!result.isAcceptable()) {
// LOGGER.error("Cannot find resource referenced from shadow. {}", result.getMessage());
// result.recordPartialError("Could not find resource referenced from shadow.");
// return;
// }
// try {
// PrismContainer<ResourceObjectAssociationType> assocContainer = cWrapper.getContainer().getItem()
// .findOrCreateContainer(ConstructionType.F_ASSOCIATION);
// subContainerWrapper = createAssociationWrapper(resource, construction.getKind(), construction.getIntent() , assocContainer,
// cWrapper.getObjectStatus(), assocContainer == null ? ContainerStatus.ADDING : ContainerStatus.MODIFYING,
// new ItemPath(ConstructionType.F_ASSOCIATION));
// } catch (SchemaException ex){
// LOGGER.error("Cannot create association container wrapper for construction.", ex);
// return;
// }
//
// } else {
subContainerWrapper = createContainerWrapper((PrismContainerDefinition<C>) itemDef, cWrapper, onlyEmpty, task);
// }

if (subContainerWrapper == null) {
return;
Expand Down Expand Up @@ -406,7 +446,7 @@ private <C extends Containerable> ReferenceWrapper createReferenceWrapper(PrismR
}

private <C extends Containerable> ContainerWrapper<C> createContainerWrapper(PrismContainerDefinition<C> def,
ContainerValueWrapper<C> cWrapper, boolean onlyEmpty) {
ContainerValueWrapper<C> cWrapper, boolean onlyEmpty, Task task) {

PrismContainerValue<C> containerValue = cWrapper.getContainerValue();

Expand Down Expand Up @@ -437,9 +477,9 @@ private <C extends Containerable> ContainerWrapper<C> createContainerWrapper(Pri
return null;
}
return createContainerWrapper(newContainer, cWrapper.getObjectStatus(), ContainerStatus.ADDING,
cWrapper.getPath().append(new ItemPath(newContainer.getElementName())));
cWrapper.getPath().append(new ItemPath(newContainer.getElementName())), task);
}
return createContainerWrapper(container, cWrapper.getObjectStatus(), cWrapper.getStatus() == ValueStatus.ADDED ? ContainerStatus.ADDING: ContainerStatus.MODIFYING, container.getPath());
return createContainerWrapper(container, cWrapper.getObjectStatus(), cWrapper.getStatus() == ValueStatus.ADDED ? ContainerStatus.ADDING: ContainerStatus.MODIFYING, container.getPath(), task);
}

private <C extends Containerable> boolean isItemReadOnly(ItemDefinition def, ContainerValueWrapper<C> cWrapper) {
Expand Down

0 comments on commit aab70d6

Please sign in to comment.