Skip to content

Commit

Permalink
Accesses metadata enabled by default + test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Feb 13, 2023
1 parent fde178c commit f607e5e
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010-2019 Evolveum and contributors
* Copyright (C) 2010-2023 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.schema.util;

import org.apache.commons.lang3.StringUtils;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.xml.ns._public.common.common_3.InternalsConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleManagementConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;

import org.apache.commons.lang3.StringUtils;

public class SystemConfigurationTypeUtil {

public static boolean isExperimentalCodeEnabled(SystemConfigurationType config) {
Expand All @@ -30,7 +31,7 @@ public static void setEnableExperimentalCode(SystemConfigurationType s, Boolean
}
} else {
if (s.getInternals() == null) {
s.setInternals(new InternalsConfigurationType()); // hopefully prismContext etc is correctly set
s.setInternals(new InternalsConfigurationType()); // hopefully prismContext etc is correctly set
}
s.getInternals().setEnableExperimentalCode(enableExperimentalCode);
}
Expand Down Expand Up @@ -70,4 +71,16 @@ public static String getPublicHttpUrlPattern(SystemConfigurationType sysconfig,
return null;
}
}

public static boolean isAccessesMetadataEnabled(SystemConfigurationType sysconfig) {
boolean defaultValue = true;
if (sysconfig == null) {
return defaultValue;
}
RoleManagementConfigurationType roleManagement = sysconfig.getRoleManagement();
if (roleManagement == null) {
return defaultValue;
}
return Boolean.TRUE.equals(roleManagement.isAccessesMetadataEnabled());
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2010-2022 Evolveum and contributors
~ Copyright (C) 2010-2023 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<!--suppress XmlUnusedNamespaceDeclaration -->
<xsd:schema targetNamespace="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:tns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
Expand Down Expand Up @@ -14207,12 +14208,14 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<!-- TODO fix names, consult - experimental? -->
<xsd:element name="accessesMetadataEnabled" type="xsd:boolean" minOccurs="0" default="false">
<xsd:element name="accessesMetadataEnabled" type="xsd:boolean" minOccurs="0" default="true">
<xsd:annotation>
<xsd:documentation>
Global switch that enables accesses metadata processing for assignment holders.
That stores not only indirect assignments but also the details how it appeared on the object.
Global switch that enables/disables accesses metadata processing for assignment holders.
When enabled assignment holder object stores not only indirect assignments (roleMembershipRef)
but also the details how it appeared on the object.

This is enabled by default.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.7</a:since>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import com.evolveum.midpoint.schema.util.ConstructionTypeUtil;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.schema.util.SchemaDebugUtil;
import com.evolveum.midpoint.schema.util.SystemConfigurationTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.EqualsChecker;
import com.evolveum.midpoint.util.MiscUtil;
Expand Down Expand Up @@ -1024,14 +1025,8 @@ private void addRoleReferences(Collection<PrismReferenceValue> shouldBeRoleRefs,

// If sysconfig enables accesses value metadata, we will add them.
SystemConfigurationType sysconfig = systemObjectCache.getSystemConfigurationBean(operationResult);
if (sysconfig == null) {
return; // unlikely
}
RoleManagementConfigurationType roleManagement = sysconfig.getRoleManagement();
if (roleManagement == null || !Boolean.TRUE.equals(roleManagement.isAccessesMetadataEnabled())) {
// TODO enable by default after fixing failing model tests
// if (roleManagement != null && Boolean.FALSE.equals(roleManagement.isAccessesMetadataEnabled())) {
return; // not enabled
if (!SystemConfigurationTypeUtil.isAccessesMetadataEnabled(sysconfig)) {
return;
}

for (PrismReferenceValue roleRef : shouldBeRoleRefs) {
Expand Down

0 comments on commit f607e5e

Please sign in to comment.