Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/mid-7053
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 28, 2021
2 parents 957cfec + e7d77e0 commit 89a1858
Show file tree
Hide file tree
Showing 236 changed files with 3,396 additions and 2,412 deletions.
13 changes: 2 additions & 11 deletions config/initial-objects/024-archetype-operation-request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,10 @@
<cssClass>fa fa-circle-o</cssClass>
</icon>
</display>
<displayOrder>1</displayOrder>
<panelType>operationRequestCase</panelType>
<type>c:CaseType</type>
</panel>
<panel>
<identifier>operationRequestCase</identifier>
<display>
<label>Operation request</label>
<icon>
<cssClass>fa fa-circle-o</cssClass>
</icon>
</display>
<panelType>operationRequestCase</panelType>
<type>c:CaseType</type>
<default>true</default>
</panel>
</objectDetails>
</adminGuiConfiguration>
Expand Down
2 changes: 2 additions & 0 deletions config/initial-objects/025-archetype-approval-case.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
<cssClass>fa fa-circle-o</cssClass>
</icon>
</display>
<displayOrder>1</displayOrder>
<panelType>approvalCase</panelType>
<type>c:CaseType</type>
<default>true</default>
</panel>
</objectDetails>
</adminGuiConfiguration>
Expand Down
58 changes: 36 additions & 22 deletions dist/src/main/bin/midpoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ JAVA_def_trustStoreType="jceks"

USE_NOHUP="true"

ENV_MAP_PREFIX="MP_SET_"

######################

set -eu
Expand Down Expand Up @@ -76,10 +78,12 @@ fi
[ "${MP_MEM_MAX:-}" != "" ] && JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-Xmx[^[:space:]]*//") -Xmx${MP_MEM_MAX}"
[ "${MP_MEM_INIT:-}" != "" ] && JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-Xms[^[:space:]]*//") -Xms${MP_MEM_INIT}"

###### Backward compatibility for ENV variables ####

[ "${REPO_PORT:-}" != "" ] && db_port=${REPO_PORT}
if [ "${REPO_DATABASE_TYPE:-}" != "" ]
then
JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-Dmidpoint.repository.database=[^[:space:]]*//") -Dmidpoint.repository.database=${REPO_DATABASE_TYPE}"
export ${ENV_MAP_PREFIX}midpoint_repository_database="${REPO_DATABASE_TYPE}"
[ "${db_port:-}" == "default" ] && db_port=""
case ${REPO_DATABASE_TYPE} in
h2)
Expand Down Expand Up @@ -120,33 +124,43 @@ then
fi
;;
esac
if [ "${REPO_URL:-}" != "" ]
then
JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-Dmidpoint.repository.jdbcUrl=[^[:space:]]*//") -Dmidpoint.repository.jdbcUrl=${REPO_URL}"
else
JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-Dmidpoint.repository.jdbcUrl=[^[:space:]]*//") -Dmidpoint.repository.jdbcUrl=${db_prefix}${REPO_HOST:-localhost}:${db_port}${db_path}"
fi
[ "${REPO_URL:-}" = "" ] && export ${ENV_MAP_PREFIX}midpoint_repository_jdbcUrl="${db_prefix}${REPO_HOST:-localhost}:${db_port}${db_path}"
fi
[ "${REPO_USER:-}" != "" ] && JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-Dmidpoint.repository.jdbcUsername=[^[:space:]]*//") -Dmidpoint.repository.jdbcUsername=${REPO_USER}"
[ "${REPO_PASSWORD_FILE:-}" != "" ] && JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-Dmidpoint.repository.jdbcPassword_FILE=[^[:space:]]*//") -Dmidpoint.repository.jdbcPassword_FILE=${REPO_PASSWORD_FILE}"
[ "${REPO_MISSING_SCHEMA_ACTION:-}" != "" ] && JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-Dmidpoint.repository.missingSchemaAction=[^[:space:]]*//") -Dmidpoint.repository.missingSchemaAction=${REPO_MISSING_SCHEMA_ACTION}"
[ "${REPO_UPGRADEABLE_SCHEMA_ACTION:-}" != "" ] && JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-Dmidpoint.repository.upgradeableSchemaAction=[^[:space:]]*//") -Dmidpoint.repository.upgradeableSchemaAction=${REPO_UPGRADEABLE_SCHEMA_ACTION}"
[ "${REPO_SCHEMA_VARIANT:-}" != "" ] && JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-Dmidpoint.repository.schemaVariant=[^[:space:]]*//") -Dmidpoint.repository.schemaVariant=${REPO_SCHEMA_VARIANT}"
[ "${REPO_SCHEMA_VERSION_IF_MISSING:-}" != "" ] && JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-Dmidpoint.repository.schemaVersionIfMissing=[^[:space:]]*//") -Dmidpoint.repository.schemaVersionIfMissing=${REPO_SCHEMA_VERSION_IF_MISSING}"

[ "${MP_KEYSTORE_PASSWORD_FILE:-}" != "" ] && JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-Dmidpoint.keystore.keyStorePassword_FILE=[^[:space:]]*//") -Dmidpoint.keystore.keyStorePassword_FILE=${MP_KEYSTORE_PASSWORD_FILE}"

if [ -e /.dockerenv ]
then
JAVA_OPTS="${JAVA_OPTS:-} -Dmidpoint.repository.hibernateHbm2ddl=none"
JAVA_OPTS="${JAVA_OPTS:-} -Dmidpoint.repository.initializationFailTimeout=60000"
[ "${REPO_URL:-}" != "" ] && export ${ENV_MAP_PREFIX}midpoint_repository_jdbcUrl="${REPO_URL}"
[ "${REPO_USER:-}" != "" ] && export ${ENV_MAP_PREFIX}midpoint_repository_jdbcUsername="${REPO_USER}"
[ "${REPO_PASSWORD_FILE:-}" != "" ] && export ${ENV_MAP_PREFIX}midpoint_repository_jdbcPassword_FILE="${REPO_PASSWORD_FILE}"
[ "${REPO_MISSING_SCHEMA_ACTION:-}" != "" ] && export ${ENV_MAP_PREFIX}midpoint_repository_missingSchemaAction="${REPO_MISSING_SCHEMA_ACTION}"
[ "${REPO_UPGRADEABLE_SCHEMA_ACTION:-}" != "" ] && export ${ENV_MAP_PREFIX}midpoint_repository_upgradeableSchemaAction="${REPO_UPGRADEABLE_SCHEMA_ACTION}"
[ "${REPO_SCHEMA_VARIANT:-}" != "" ] && export ${ENV_MAP_PREFIX}midpoint_repository_schemaVariant="${REPO_SCHEMA_VARIANT}"
[ "${REPO_SCHEMA_VERSION_IF_MISSING:-}" != "" ] && export ${ENV_MAP_PREFIX}midpoint_repository_schemaVersionIfMissing="${REPO_SCHEMA_VERSION_IF_MISSING}"

JAVA_OPTS="${JAVA_OPTS:-} -Dfile.encoding=UTF8"
JAVA_OPTS="${JAVA_OPTS:-} -Dmidpoint.logging.alt.enabled=true"
fi
[ "${MP_KEYSTORE_PASSWORD_FILE:-}" != "" ] && export ${ENV_MAP_PREFIX}midpoint_keystore_keyStorePassword_FILE="${MP_KEYSTORE_PASSWORD_FILE}"

#############################

###### ENV Variables mapping ######

while read line
do
_to_process="${line:${#ENV_MAP_PREFIX}}"
_key="$(echo -n "${_to_process}" | cut -d = -f 1 | sed "s/_/./g")"
_val="$(echo -n "${_to_process}" | cut -d = -f 2-)"

### exception for *_FILE key name ###
[ "${_key: -5}" = ".FILE" ] && _key="${_key::$(( ${#_key} - 5 ))}_FILE"
###

if [ "${_key:0:1}" = "." ]
then
JAVA_OPTS="${JAVA_OPTS:-} -D${_key:1}=${_val}"
else
JAVA_OPTS="$(echo ${JAVA_OPTS:-} | sed "s/-D${_key}=[^[:space:]]*//") -D${_key}=${_val}"
fi
done < <(env | grep "^${ENV_MAP_PREFIX}")

###################################

# Check for the default JAVA_OPTS values. In case the specific key is already set the value is kept untouched.
# To prevent Xms to be set pass the --Xms to JAVA_OPTS (double dash).
# To prevent Xmx to be set pass the --Xmx to JAVA_OPTS (double dash).
Expand Down
6 changes: 3 additions & 3 deletions gui/admin-gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<artifactId>ojdbc11</artifactId>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -901,7 +901,7 @@
</exclude>
<exclude>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<artifactId>ojdbc11</artifactId>
</exclude>
</excludes>
-->
Expand Down Expand Up @@ -943,7 +943,7 @@
<!-- note how the archive is treated as a normal file directory -->
<directory>${project.build.directory}/midpoint-executable.war/WEB-INF/lib-provided</directory>
<includes>
<include>ojdbc8-*.jar</include>
<include>ojdbc11-*.jar</include>
<include>ucp-*.jar</include>
<include>oraclepki-*.jar</include>
<include>osdt_cert-*.jar</include>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.*;
import javax.annotation.PostConstruct;

import com.evolveum.midpoint.gui.api.prism.ItemStatus;
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView;
import com.evolveum.midpoint.prism.polystring.PolyString;

import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
Expand Down Expand Up @@ -46,7 +46,7 @@ public class DefaultGuiConfigurationCompiler implements GuiProfileCompilable {
@Autowired private PrismContext prismContext;
@Autowired private AdminGuiConfigurationMergeManager adminGuiConfigurationMergeManager;

private static final String[] PACKAGES_TO_SCAN = {
private static final String[] PANEL_PACKAGES_TO_SCAN = {
"com.evolveum.midpoint.web.component.objectdetails", //Old panels
"com.evolveum.midpoint.web.component.assignment", //Assignments
"com.evolveum.midpoint.gui.impl.page.admin",
Expand All @@ -68,6 +68,20 @@ public class DefaultGuiConfigurationCompiler implements GuiProfileCompilable {
"com.evolveum.midpoint.gui.impl.page.admin.report.component"
};

private static final String[] COLLECTION_PACKAGES_TO_SCAN = {
"com.evolveum.midpoint.web.page.admin.users",
"com.evolveum.midpoint.web.page.admin.services",
"com.evolveum.midpoint.web.page.admin.tasks",
"com.evolveum.midpoint.web.page.admin.roles",
"com.evolveum.midpoint.web.page.admin.resources",
"com.evolveum.midpoint.web.page.admin.reports",
"com.evolveum.midpoint.web.page.admin.orgs",
"com.evolveum.midpoint.web.page.admin.objectTemplate",
"com.evolveum.midpoint.web.page.admin.objectCollection",
"com.evolveum.midpoint.web.page.admin.cases",
"com.evolveum.midpoint.web.page.admin.archetype"
};

private final Map<String, Class<? extends Panel>> panelsMap = new HashMap<>();

private final Map<String, SimpleCounter> countersMap = new HashMap<>();
Expand All @@ -92,22 +106,111 @@ public SimpleCounter findCounter(String idenifier) {
public void postProcess(CompiledGuiProfile compiledGuiProfile) {
experimentalFeaturesEnabled = compiledGuiProfile.isEnableExperimentalFeatures();

Set<Class<?>> classes = collectClasses();
Set<Class<?>> classes = collectPackagesClasses();

fillInPanelsMap(classes);
fillInCountersMap(classes);

compileDefaultDetailsPages(classes, compiledGuiProfile);
mergeCollectionViewsWithDefault(compiledGuiProfile);
processShadowPanels(classes, compiledGuiProfile);

}

private void compileDefaultDetailsPages(Set<Class<?>> classes, CompiledGuiProfile compiledGuiProfile) {
GuiObjectDetailsSetType defaultDetailsPages = compileDefaultGuiObjectDetailsSetType(classes);
List<GuiObjectDetailsPageType> detailsPages = defaultDetailsPages.getObjectDetailsPage();
for (GuiObjectDetailsPageType defaultDetailsPage : detailsPages) {

//objects
GuiObjectDetailsPageType compiledPageType = compiledGuiProfile.findObjectDetailsConfiguration(defaultDetailsPage.getType());
GuiObjectDetailsPageType mergedDetailsPage = adminGuiConfigurationMergeManager.mergeObjectDetailsPageConfiguration(defaultDetailsPage, compiledPageType);

if (compiledGuiProfile.getObjectDetails() == null) {
compiledGuiProfile.setObjectDetails(new GuiObjectDetailsSetType(prismContext));
}
compiledGuiProfile.getObjectDetails().getObjectDetailsPage().removeIf(p -> QNameUtil.match(p.getType(), defaultDetailsPage.getType()));
compiledGuiProfile.getObjectDetails().getObjectDetailsPage().add(mergedDetailsPage.cloneWithoutId());
}
}

private void mergeCollectionViewsWithDefault(CompiledGuiProfile compiledGuiProfile) {
Set<Class<?>> classes = collectCollectionClasses();
List<CompiledObjectCollectionView> defaultCollectionViews = compileDefaultCollectionViews(classes);

for (CompiledObjectCollectionView defaultCollectionView : defaultCollectionViews) {
CompiledObjectCollectionView compiledObjectCollectionView = compiledGuiProfile.findObjectCollectionView(defaultCollectionView.getContainerType(), defaultCollectionView.getViewIdentifier());
if (compiledObjectCollectionView == null) {
compiledGuiProfile.getObjectCollectionViews().add(defaultCollectionView);
continue;
}
mergeCollectionViews(compiledObjectCollectionView, defaultCollectionView);
}

}

private void mergeCollectionViews(CompiledObjectCollectionView compiledObjectCollectionView, CompiledObjectCollectionView defaulCollectionView) {
DisplayType displayType = adminGuiConfigurationMergeManager.mergeDisplayType(compiledObjectCollectionView.getDisplay(), defaulCollectionView.getDisplay());
compiledObjectCollectionView.setDisplay(displayType);

if (compiledObjectCollectionView.getApplicableForOperation() == null) {
compiledObjectCollectionView.setApplicableForOperation(defaulCollectionView.getApplicableForOperation());
}
}

private List<CompiledObjectCollectionView> compileDefaultCollectionViews(Set<Class<?>> classes) {
List<CompiledObjectCollectionView> compiledObjectCollectionViews = new ArrayList<>();
for (Class<?> clazz : classes) {
CollectionInstance collectionInstance = clazz.getAnnotation(CollectionInstance.class);
if (collectionInstance == null) {
continue;
}
ObjectTypes objectType = ObjectTypes.getObjectType(collectionInstance.applicableForType());
CompiledObjectCollectionView defaultCollectionView = new CompiledObjectCollectionView(objectType.getTypeQName(), collectionInstance.identifier());
defaultCollectionView.setDisplay(createDisplayType(collectionInstance.display()));
compiledObjectCollectionViews.add(defaultCollectionView);
defaultCollectionView.setDefaultView(true);

if (collectionInstance.applicableForOperation().length == 1) {
defaultCollectionView.setApplicableForOperation(collectionInstance.applicableForOperation()[0]);
}
}
return compiledObjectCollectionViews;
}

private void processShadowPanels(Set<Class<?>> classes, CompiledGuiProfile compiledGuiProfile) {
List<ContainerPanelConfigurationType> shadowPanels = new ArrayList<>();
for (Class<?> clazz : classes) {
PanelInstance instance = clazz.getAnnotation(PanelInstance.class);
if (instance == null) {
continue;
}
if (!instance.applicableForType().equals(ShadowType.class)) {
continue;
}

if (compiledGuiProfile.getObjectDetails() == null) {
compiledGuiProfile.setObjectDetails(new GuiObjectDetailsSetType());
}
ContainerPanelConfigurationType shadowPanel = compileContainerPanelConfiguration(clazz, ShadowType.class, classes, instance);
shadowPanels.add(shadowPanel);
}

if (compiledGuiProfile.getObjectDetails() == null) {
compiledGuiProfile.setObjectDetails(new GuiObjectDetailsSetType(prismContext));
}

if (compiledGuiProfile.getObjectDetails().getShadowDetailsPage().isEmpty()) {
compiledGuiProfile.getObjectDetails().getShadowDetailsPage().add(new GuiShadowDetailsPageType());
}

for (GuiShadowDetailsPageType shadowDetailsPage : compiledGuiProfile.getObjectDetails().getShadowDetailsPage()) {
List<ContainerPanelConfigurationType> mergedPanels = adminGuiConfigurationMergeManager.mergeContainerPanelConfigurationType(shadowPanels, shadowDetailsPage.getPanel());
shadowDetailsPage.getPanel().clear();
shadowDetailsPage.getPanel().addAll(mergedPanels);
}
}

private void fillInPanelsMap(Set<Class<?>> classes) {
for (Class<?> clazz : classes) {
PanelType panelType = clazz.getAnnotation(PanelType.class);
Expand Down Expand Up @@ -153,6 +256,9 @@ private GuiObjectDetailsSetType compileDefaultGuiObjectDetailsSetType(Set<Class<
GuiObjectDetailsSetType guiObjectDetailsSetType = new GuiObjectDetailsSetType();
for (ObjectTypes objectType : ObjectTypes.values()) {
GuiObjectDetailsPageType detailsPageType = compileDefaultGuiObjectDetailsPage(objectType, scannedClasses);
if (QNameUtil.match(detailsPageType.getType(), ShadowType.COMPLEX_TYPE)) {
continue;
}
guiObjectDetailsSetType.getObjectDetailsPage().add(detailsPageType);
}
return guiObjectDetailsSetType;
Expand Down Expand Up @@ -199,9 +305,17 @@ private List<ContainerPanelConfigurationType> getPanelsFor(Class<? extends Objec
return panels;
}

private Set<Class<?>> collectClasses() {
private Set<Class<?>> collectPackagesClasses() {
return collectClasses(PANEL_PACKAGES_TO_SCAN);
}

private Set<Class<?>> collectCollectionClasses() {
return collectClasses(COLLECTION_PACKAGES_TO_SCAN);
}

private Set<Class<?>> collectClasses(String[] packagesToScan) {
Set<Class<?>> allClasses = new HashSet<>();
for (String packageToScan : PACKAGES_TO_SCAN) {
for (String packageToScan : packagesToScan) {
Set<Class<?>> classes = ClassPathUtil.listClasses(packageToScan);
allClasses.addAll(classes);
}
Expand All @@ -220,8 +334,8 @@ private boolean isNotApplicableFor(Class<? extends ObjectType> objectType, Panel
return true;
}

if (panelInstance.notApplicableFor() != null && !panelInstance.notApplicableFor().equals(SystemConfigurationType.class)) {
return panelInstance.notApplicableFor().isAssignableFrom(objectType);
if (panelInstance.excludeTypes() != null && panelInstance.excludeTypes().length > 0) {
return Arrays.stream(panelInstance.excludeTypes()).anyMatch(o -> o.equals(objectType));
}

return !panelInstance.applicableForType().isAssignableFrom(objectType);
Expand Down Expand Up @@ -282,6 +396,7 @@ private void compileDefaultContainerSpecification(PanelType panelType, Container
ItemPathType path = prismContext.itemPathParser().asItemPathType(panelType.defaultContainerPath());
defaultContainer.setPath(path);
}
defaultContainer.setDisplayOrder(10);
config.getContainer().add(defaultContainer);
}

Expand Down Expand Up @@ -318,11 +433,16 @@ private List<ContainerPanelConfigurationType> processChildren(Set<Class<?>> clas

private DisplayType createDisplayType(PanelDisplay display) {
DisplayType displayType = new DisplayType();
PolyStringTranslationType translationType = new PolyStringTranslationType();
translationType.setKey(display.label());
PolyString polyString = new PolyString(null, null, translationType);
displayType.setLabel(new PolyStringType(polyString));
displayType.setLabel(createPolyStringType(display.label()));
displayType.setSingularLabel(createPolyStringType(display.singularLabel()));
displayType.setIcon(new IconType().cssClass(display.icon()));
return displayType;
}

private PolyStringType createPolyStringType(String key) {
PolyStringTranslationType translationType = new PolyStringTranslationType();
translationType.setKey(key);
PolyString polyString = new PolyString(null, null, translationType);
return new PolyStringType(polyString);
}
}

0 comments on commit 89a1858

Please sign in to comment.