Skip to content

Commit

Permalink
Fixing GUI and sanity after schema cleanup (MID-5052)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Sep 4, 2019
1 parent c9dc845 commit 3c6ad02
Show file tree
Hide file tree
Showing 20 changed files with 124 additions and 261 deletions.
Expand Up @@ -812,13 +812,8 @@ public static boolean isPostAuthenticationEnabled(TaskManager taskManager, Model
}

public static PrismObject<SystemConfigurationType> loadSystemConfigurationAsPrismObject(PageBase pageBase, Task task, OperationResult result) {

Collection<SelectorOptions<GetOperationOptions>> options = pageBase.getOperationOptionsBuilder()
.items(SystemConfigurationType.F_DEFAULT_USER_TEMPLATE_REF, SystemConfigurationType.F_GLOBAL_PASSWORD_POLICY_REF).resolve()
.build();

PrismObject<SystemConfigurationType> systemConfig = loadObject(
SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), options,
SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null,
pageBase, task, result);

return systemConfig;
Expand Down
Expand Up @@ -43,8 +43,11 @@ public boolean match(ItemDefinition<?> def) {
public PrismContainerValueWrapper<ConstructionType> createContainerValueWrapper(PrismContainerWrapper<ConstructionType> objectWrapper, PrismContainerValue<ConstructionType> objectValue, ValueStatus status, WrapperContext context) {
ConstructionValueWrapper constructionValueWrapper = new ConstructionValueWrapper(objectWrapper, objectValue, status);
ConstructionType constructionType = objectValue.asContainerable();
if (constructionType.getResource() != null) {
constructionValueWrapper.setResource(constructionType.getResource().asPrismObject());
if (constructionType.getResourceRef() != null) {
PrismObject resource = constructionType.getResourceRef().asReferenceValue().getObject();
if (resource != null) {
constructionValueWrapper.setResource(resource);
}
return constructionValueWrapper;
}

Expand Down
Expand Up @@ -22,7 +22,6 @@
import javax.annotation.PostConstruct;
import javax.xml.namespace.QName;

import org.slf4j.spi.LocationAwareLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand All @@ -34,8 +33,6 @@
import com.evolveum.midpoint.gui.impl.prism.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismContainerValueWrapperImpl;
import com.evolveum.midpoint.gui.impl.prism.PrismContainerWrapperImpl;
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyPanel;
import com.evolveum.midpoint.gui.impl.prism.PrismValueWrapper;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.ItemDefinition;
Expand All @@ -47,13 +44,6 @@
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExclusionPolicyConstraintType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.HasAssignmentPolicyConstraintType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LocalizableMessageTemplateType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintEnforcementType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintPresentationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.StatePolicyConstraintType;

/**
* @author katka
Expand Down
Expand Up @@ -691,6 +691,11 @@ public <A> A getAnnotation(QName qname) {
public <A> void setAnnotation(QName qname, A value) {
getItemDefinition().setAnnotation(qname, value);
}

@Override
public List<SchemaMigration> getSchemaMigrations() {
return getItemDefinition().getSchemaMigrations();
}

@Override
public void accept(Visitor visitor) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2017 Evolveum
* Copyright (c) 2010-2019 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,28 +16,28 @@

package com.evolveum.midpoint.web.application;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.request.mapper.parameter.IPageParametersEncoder;

import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.util.ClassPathUtil;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.DisplayableValue;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.security.MidPointApplication;
import com.evolveum.midpoint.web.util.ExactMatchMountedMapper;
import com.evolveum.midpoint.xml.ns._public.gui.admin_1.DescriptorType;
import com.evolveum.midpoint.xml.ns._public.gui.admin_1.ObjectFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.request.mapper.parameter.IPageParametersEncoder;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Unmarshaller;
import java.io.InputStream;
import java.util.*;
import java.util.function.Consumer;

/**
* @author lazyman
Expand All @@ -46,13 +46,33 @@ public final class DescriptorLoader implements DebugDumpable {

private static final Trace LOGGER = TraceManager.getTrace(DescriptorLoader.class);

private static final String[] PACKAGES_TO_SCAN = {
"com.evolveum.midpoint.web.page",
"com.evolveum.midpoint.web.page.admin.home",
"com.evolveum.midpoint.web.page.admin.users",
"com.evolveum.midpoint.web.page.admin.services",
"com.evolveum.midpoint.web.page.admin.roles",
"com.evolveum.midpoint.web.page.admin.resources",
"com.evolveum.midpoint.web.page.admin.resources.content",
"com.evolveum.midpoint.web.page.admin.workflow",
"com.evolveum.midpoint.web.page.admin.server",
"com.evolveum.midpoint.web.page.admin.reports",
"com.evolveum.midpoint.web.page.admin.configuration",
"com.evolveum.midpoint.web.page.admin.certification",
"com.evolveum.midpoint.web.page.admin.valuePolicy",
"com.evolveum.midpoint.web.page.admin.cases",
"com.evolveum.midpoint.web.page.admin.archetype",
"com.evolveum.midpoint.web.page.login",
"com.evolveum.midpoint.web.page.error",
"com.evolveum.midpoint.web.page.forgetpassword",
"com.evolveum.midpoint.web.page.self",
"com.evolveum.midpoint.web.component.prism.show"
};

private static Map<String, DisplayableValue<String>[]> actions = new HashMap<>();
private static List<String> permitAllUrls = new ArrayList<>();
private static Map<String, Class> urlClassMap = new HashMap<>();

private String baseFileName = "/descriptor.xml";
private String customFileName = "/descriptor.xml";

public static Map<String, DisplayableValue<String>[]> getActions() {
return actions;
}
Expand All @@ -61,65 +81,32 @@ public static Map<String, Class> getUrlClassMap() {
return urlClassMap;
}

public String getBaseFileName() {
return baseFileName;
}

public void setBaseFileName(String baseFileName) {
this.baseFileName = baseFileName;
}

public String getCustomFileName() {
return customFileName;
}

public void setCustomFileName(String customFileName) {
this.customFileName = customFileName;
}

public static Collection<String> getPermitAllUrls() {
return permitAllUrls;
}

public void loadData(MidPointApplication application) {
LOGGER.debug("Loading data from descriptor files.");

try (InputStream baseInput = DescriptorLoader.class.getResourceAsStream(baseFileName);
InputStream customInput = DescriptorLoader.class.getResourceAsStream(customFileName)) {
if (baseInput == null) {
LOGGER.error("Couldn't find " + baseFileName + " file, can't load application menu and other stuff.");
}

JAXBContext context = JAXBContext.newInstance(ObjectFactory.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
JAXBElement<DescriptorType> element = (JAXBElement) unmarshaller.unmarshal(baseInput);
DescriptorType descriptor = element.getValue();
try {
scanPackagesForPages(application);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("loaded:\n{}", debugDump(1));
}
} catch (InstantiationException | IllegalAccessException e) {
LOGGER.error("Error scanning packages for pages: {}", e.getMessage(), e);
throw new SystemException("Error scanning packages for pages: "+e.getMessage(), e);
}

LOGGER.debug("Loading menu bar from " + baseFileName + " .");
DescriptorType customDescriptor = null;
if (customInput != null) {
element = (JAXBElement) unmarshaller.unmarshal(customInput);
customDescriptor = element.getValue();
}

scanPackagesForPages(descriptor.getPackagesToScan(), application);
if (customDescriptor != null) {
scanPackagesForPages(customDescriptor.getPackagesToScan(), application);
}

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("loaded:\n{}", debugDump(1));
}


} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't process application descriptor", ex);
}
}

private void scanPackagesForPages(List<String> packages, MidPointApplication application)
private void scanPackagesForPages(MidPointApplication application)
throws InstantiationException, IllegalAccessException {

for (String pac : packages) {
for (String pac : PACKAGES_TO_SCAN) {
LOGGER.debug("Scanning package package {} for page annotations", new Object[]{pac});

Set<Class> classes = ClassPathUtil.listClasses(pac);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum
* Copyright (c) 2010-2019 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -115,8 +115,7 @@ public class SearchFactory {
ItemPath.create(ShadowType.F_DEAD),
ItemPath.create(ShadowType.F_INTENT),
ItemPath.create(ShadowType.F_EXISTS),
ItemPath.create(ShadowType.F_SYNCHRONIZATION_SITUATION),
ItemPath.create(ShadowType.F_FAILED_OPERATION_TYPE)
ItemPath.create(ShadowType.F_SYNCHRONIZATION_SITUATION)
));
SEARCHABLE_OBJECTS.put(TaskType.class, Arrays.asList(
ItemPath.create(TaskType.F_TASK_IDENTIFIER),
Expand Down
Expand Up @@ -84,8 +84,9 @@
* @author shood
*/
public class SchemaHandlingStep extends WizardStep {
private static final long serialVersionUID = 1L;

private static final Trace LOGGER = TraceManager.getTrace(SchemaHandlingStep.class);
private static final Trace LOGGER = TraceManager.getTrace(SchemaHandlingStep.class);

private static final String DOT_CLASS = SchemaHandlingStep.class.getName() + ".";
private static final String OPERATION_SAVE_SCHEMA_HANDLING = DOT_CLASS + "saveSchemaHandling";
Expand Down Expand Up @@ -1037,9 +1038,6 @@ private void removeEmptyContainers(@NotNull PrismObject<ResourceType> resourcePr
// we know that we lose description for empty filters ... but such filters (description + no clause) cause problems in prisms
protectedObject.setFilter(null);
}
if (protectedObject.getName() != null || protectedObject.getUid() != null || protectedObject.getFilter() != null) {
newProtectedList.add(protectedObject);
}
}
replace(objectType.getProtected(), newProtectedList);

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2017 Evolveum
* Copyright (c) 2010-2019 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -686,13 +686,6 @@ private void reactionEditPerformed(AjaxRequestTarget target, SynchronizationReac
WebMarkupContainer newContainer = new SynchronizationReactionEditor(ID_THIRD_ROW_CONTAINER, new Model<>(reaction), this, parentPage);
getThirdRowContainer().replaceWith(newContainer);

for (SynchronizationActionType action : reaction.getAction()) {
if (action.getRef() != null) {
warn(getString("SynchronizationStep.message.unsupportedActionFormat"));
break;
}
}

resetSelections(target);
syncDtoModel.getObject().setSelectedReaction(reaction);

Expand Down
Expand Up @@ -98,15 +98,6 @@ public String getObject() {
StringBuilder sb = new StringBuilder();
ResourceObjectPatternType account = item.getModelObject();
sb.append("#").append(item.getIndex()+1).append(" - ");

if (account.getUid() != null) {
sb.append(account.getUid()).append(":");
}

if (account.getName() != null) {
sb.append(account.getName());
}

return sb.toString();
}
});
Expand Down
Expand Up @@ -114,10 +114,6 @@ public String getOutcome() {
return caseInstance.getOutcome();
}

public ObjectDeltaType getObjectChange() {
return caseInstance.getObjectChange();
}

public XMLGregorianCalendar getOpenTimestamp() {
if (caseInstance.getMetadata() != null) {
return caseInstance.getMetadata().getCreateTimestamp();
Expand Down

0 comments on commit 3c6ad02

Please sign in to comment.