Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Dec 10, 2018
2 parents 63f87ad + 12d521f commit f8e988a
Show file tree
Hide file tree
Showing 52 changed files with 1,805 additions and 905 deletions.
30 changes: 7 additions & 23 deletions .travis.yml
@@ -1,6 +1,5 @@
sudo: required
dist: trusty
language: java
os: windows
language: shell

#skips default install - see script bellow
install: true
Expand All @@ -10,28 +9,13 @@ cache:
- $HOME/.m2

before_install:
#- wget http://ftp.wayne.edu/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip
- wget https://archive.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.zip
- unzip -qq apache-maven-3.5.0-bin.zip
- export M2_HOME=$PWD/apache-maven-3.5.0
- export PATH=$M2_HOME/bin:$PATH
- choco install maven
- export MAVEN_OPTS='-Xmx6g'
- RefreshEnv.cmd
- export JAVA_HOME=`find "/c/Program Files/Java" -name jdk1.8.*`

# custom script is used so build and tests are done in one mvn command, separating it (as Travis does by default) leads to problem with ConnId (notably DummyResource)
script: mvn clean install
script: mvn -B clean install

addons:
hostname: localhost # workaround for short hostname
#apt:
#packages:
#- oracle-java8-installer # install newest JDK8

env:
global:
- MALLOC_ARENA_MAX=2

jdk:
#- openjdk7
#- oraclejdk7
- oraclejdk8
- openjdk8
hostname: localhost # workaround for short hostname
Expand Up @@ -20,6 +20,7 @@
import java.util.stream.Collectors;

import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
Expand Down Expand Up @@ -644,9 +645,9 @@ public StringResourceModel createStringResource(String resourceKey, Object... ob
protected abstract List<InlineMenuItem> createInlineMenu();

protected void addCustomActions(@NotNull List<InlineMenuItem> actionsList, SerializableSupplier<Collection<? extends ObjectType>> objectsSupplier) {
GuiObjectListViewType guiObjectListViewType = getGuiObjectListViewType();
if (guiObjectListViewType != null && !guiObjectListViewType.getAction().isEmpty()) {
actionsList.addAll(WebComponentUtil.createMenuItemsFromActions(guiObjectListViewType.getAction(),
CompiledObjectCollectionView guiObjectListViewType = getGuiObjectListViewType();
if (guiObjectListViewType != null && !guiObjectListViewType.getActions().isEmpty()) {
actionsList.addAll(WebComponentUtil.createMenuItemsFromActions(guiObjectListViewType.getActions(),
OPERATION_LOAD_CUSTOM_MENU_ITEMS, parentPage, objectsSupplier));
}
}
Expand All @@ -656,23 +657,12 @@ public void addPerformed(AjaxRequestTarget target, List<O> selected) {
}

private List<GuiObjectColumnType> getGuiObjectColumnTypeList(){
GuiObjectListViewType guiObjectListViewType = getGuiObjectListViewType();
return guiObjectListViewType != null ? guiObjectListViewType.getColumn() : null;
}

private GuiObjectListViewType getGuiObjectListViewType(){
AdminGuiConfigurationType adminGuiConfig = parentPage.getPrincipal().getAdminGuiConfiguration();
if (adminGuiConfig != null && adminGuiConfig.getObjectLists() != null &&
adminGuiConfig.getObjectLists().getObjectList() != null){
for (GuiObjectListViewType object : adminGuiConfig.getObjectLists().getObjectList()){
if (object.getType() != null &&
!type.getClassDefinition().getSimpleName().equals(object.getType().getLocalPart())){
continue;
}
return object;
}
}
return null;
CompiledObjectCollectionView guiObjectListViewType = getGuiObjectListViewType();
return guiObjectListViewType != null ? guiObjectListViewType.getColumns() : null;
}

private CompiledObjectCollectionView getGuiObjectListViewType(){
return parentPage.getCompiledUserProfile().findObjectCollectionView(type.getTypeQName(), null);
}

private boolean isCustomColumnsListConfigured(){
Expand Down
Expand Up @@ -21,6 +21,7 @@
import org.apache.wicket.util.resource.IResourceStream;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.model.api.authentication.CompiledUserProfile;
import com.evolveum.midpoint.web.component.AbstractAjaxDownloadBehavior;
import com.evolveum.midpoint.web.component.AjaxIconButton;

Expand Down Expand Up @@ -93,8 +94,7 @@ public String getFileName() {
public void onClick(AjaxRequestTarget target) {
long exportSizeLimit = -1;
try {
AdminGuiConfigurationType adminGuiConfig = getPageBase().getModelInteractionService().getAdminGuiConfiguration(null,
new OperationResult(OPERATION_GET_EXPORT_SIZE_LIMIT));
CompiledUserProfile adminGuiConfig = getPageBase().getCompiledUserProfile();
if (adminGuiConfig.getDefaultExportSettings() != null && adminGuiConfig.getDefaultExportSettings().getSizeLimit() != null) {
exportSizeLimit = adminGuiConfig.getDefaultExportSettings().getSizeLimit();
}
Expand Down
Expand Up @@ -31,6 +31,9 @@
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.model.api.*;
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView;
import com.evolveum.midpoint.model.api.authentication.CompiledUserProfile;
import com.evolveum.midpoint.model.api.authentication.MidPointUserProfilePrincipal;
import com.evolveum.midpoint.model.api.expr.MidpointFunctions;
import com.evolveum.midpoint.model.api.validator.ResourceValidator;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
Expand Down Expand Up @@ -313,7 +316,7 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {
private LoadableModel<Integer> certWorkItemCountModel;

// No need to store this in the session. Retrieval is cheap.
private transient AdminGuiConfigurationType adminGuiConfiguration;
private transient CompiledUserProfile compiledUserProfile;

// No need for this to store in session. It is used only during single init and render.
private transient Task pageTask;
Expand Down Expand Up @@ -572,25 +575,26 @@ protected ModelDiagnosticService getModelDiagnosticService() {
public CacheDispatcher getCacheDispatcher() {
return cacheDispatcher;
}

@NotNull
@Override
public AdminGuiConfigurationType getAdminGuiConfiguration() {
if (adminGuiConfiguration == null) {
Task task = createSimpleTask(PageBase.DOT_CLASS + "getAdminGuiConfiguration");
public CompiledUserProfile getCompiledUserProfile() {
// TODO: may need to always go to ModelInteractionService to make sure the setting is up to date
if (compiledUserProfile == null) {
Task task = createSimpleTask(PageBase.DOT_CLASS + "getCompiledUserProfile");
try {
adminGuiConfiguration = modelInteractionService.getAdminGuiConfiguration(task, task.getResult());
compiledUserProfile = modelInteractionService.getCompiledUserProfile(task, task.getResult());
} catch (ObjectNotFoundException | SchemaException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Cannot retrieve admin GUI configuration", e);
LoggingUtils.logUnexpectedException(LOGGER, "Cannot retrieve compiled user profile", e);
if (InternalsConfig.nonCriticalExceptionsAreFatal()) {
throw new SystemException("Cannot retrieve admin GUI configuration: " + e.getMessage(), e);
throw new SystemException("Cannot retrieve compiled user profile: " + e.getMessage(), e);
} else {
// Just return empty admin GUI config, so the GUI can go on (and the problem may get fixed)
return new AdminGuiConfigurationType();
return new CompiledUserProfile();
}
}
}
return adminGuiConfiguration;
return compiledUserProfile;
}

@Override
Expand Down Expand Up @@ -648,7 +652,7 @@ public MidpointFormValidatorRegistry getFormValidatorRegistry() {
return formValidatorRegistry;
}

public MidPointPrincipal getPrincipal() {
public MidPointUserProfilePrincipal getPrincipal() {
return SecurityUtils.getPrincipalUser();
}

Expand Down Expand Up @@ -1312,7 +1316,7 @@ public OpResult showResult(OperationResult result, String errorMessageKey, boole
}

private OperationResult executeResultScriptHook(OperationResult result) {
AdminGuiConfigurationType adminGuiConfiguration = getAdminGuiConfiguration();
CompiledUserProfile adminGuiConfiguration = getCompiledUserProfile();
if (adminGuiConfiguration.getFeedbackMessagesHook() == null) {
return result;
}
Expand Down Expand Up @@ -1894,8 +1898,8 @@ private void createSelfServiceMenu(SideBarMenuItem menu) {
}

private void createAdditionalMenu(SideBarMenuItem menu) {
AdminGuiConfigurationType adminGuiConfig = loadAdminGuiConfiguration();
List<RichHyperlinkType> menuList = adminGuiConfig.getAdditionalMenuLink();
CompiledUserProfile userProfile = getCompiledUserProfile();
List<RichHyperlinkType> menuList = userProfile.getAdditionalMenuLink();

Map<String, Class> urlClassMap = DescriptorLoader.getUrlClassMap();
if (menuList != null && menuList.size() > 0 && urlClassMap != null && urlClassMap.size() > 0) {
Expand Down Expand Up @@ -2072,19 +2076,20 @@ private MainMenuItem createServicesItems() {
}

private void addUsersViewMenuItems(List<MenuItem> menu) {
List<GuiObjectListViewType> objectListViews = getObjectViewsList();
if (objectListViews == null) {
List<CompiledObjectCollectionView> objectViews = getCompiledUserProfile().findAllApplicableObjectCollectionViews(UserType.COMPLEX_TYPE);
if (objectViews == null) {
return;
}
objectListViews.forEach(objectListView -> {
objectViews.forEach(objectView -> {
//objectlistView.getType() might be null - from documentation:
// It may not be present in case that the type is defined in a referenced object colleciton.

if (objectListView.getType() != null && !QNameUtil.match(objectListView.getType(), UserType.COMPLEX_TYPE)) {
return;
}

ObjectReferenceType collectionRef = objectListView.getCollectionRef();
CollectionSpecificationType collection = objectView.getCollection();
if (collection == null) {
return;
}

ObjectReferenceType collectionRef = collection.getCollectionRef();
if (collectionRef == null) {
return;
}
Expand All @@ -2105,7 +2110,7 @@ private void addUsersViewMenuItems(List<MenuItem> menu) {
if (!QNameUtil.match(collectionValue.getType(), UserType.COMPLEX_TYPE)) {
return;
}
DisplayType viewDisplayType = objectListView.getDisplay();
DisplayType viewDisplayType = objectView.getDisplay();

PageParameters pageParameters = new PageParameters();
pageParameters.add(PageUsersView.PARAMETER_OBJECT_COLLECTION_TYPE_OID, collectionValue.getOid());
Expand All @@ -2118,14 +2123,6 @@ private void addUsersViewMenuItems(List<MenuItem> menu) {
});
}

private List<GuiObjectListViewType> getObjectViewsList() {
GuiObjectListViewsType objectListViews = getAdminGuiConfiguration().getObjectLists();
if (objectListViews == null) {
return null;
}
return objectListViews.getObjectList();
}

public PrismObject<UserType> loadUserSelf() {
Task task = createSimpleTask(OPERATION_LOAD_USER);
OperationResult result = task.getResult();
Expand Down Expand Up @@ -2155,27 +2152,6 @@ public boolean isEnabled() {
};
}

@NotNull
public AdminGuiConfigurationType loadAdminGuiConfiguration() {
MidPointPrincipal user = SecurityUtils.getPrincipalUser();
AdminGuiConfigurationType adminGuiConfig = new AdminGuiConfigurationType();
if (user == null) {
return adminGuiConfig;
} else {
OperationResult result = new OperationResult(OPERATION_GET_SYSTEM_CONFIG);
Task task = createSimpleTask(OPERATION_GET_SYSTEM_CONFIG);
try {
adminGuiConfig = getModelInteractionService().getAdminGuiConfiguration(task, result);
LOGGER.trace("Admin GUI config: {}", adminGuiConfig);
result.recordSuccess();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load system configuration", ex);
result.recordFatalError(createStringResource("PageBase.message.loadAdminGuiConfiguration.fatalError").getString(), ex);
}
return adminGuiConfig;
}
}

public DeploymentInformationType loadDeploymentInformationType() {
DeploymentInformationType deploymentInformationType = null;
OperationResult result = new OperationResult(OPERATION_GET_DEPLOYMENT_INFORMATION);
Expand Down Expand Up @@ -2305,11 +2281,11 @@ public void redirectBackToBreadcrumb(Breadcrumb breadcrumb) {
protected void setTimeZone(PageBase page) {
PrismObject<UserType> user = loadUserSelf();
String timeZone = null;
MidPointPrincipal principal = SecurityUtils.getPrincipalUser();
MidPointUserProfilePrincipal principal = SecurityUtils.getPrincipalUser();
if (user != null && user.asObjectable().getTimezone() != null) {
timeZone = user.asObjectable().getTimezone();
} else if (principal != null && principal.getAdminGuiConfiguration() != null) {
timeZone = principal.getAdminGuiConfiguration().getDefaultTimezone();
} else if (principal != null && principal.getCompiledUserProfile() != null) {
timeZone = principal.getCompiledUserProfile().getDefaultTimezone();
}
if (timeZone != null) {
WebSession.get().getClientInfo().getProperties().
Expand Down Expand Up @@ -2421,7 +2397,7 @@ private boolean isFooterVisible() {
}

protected String determineDataLanguage() {
AdminGuiConfigurationType config = loadAdminGuiConfiguration();
CompiledUserProfile config = getCompiledUserProfile();
if (config.getPreferredDataLanguage() != null) {
if (PrismContext.LANG_JSON.equals(config.getPreferredDataLanguage())) {
return PrismContext.LANG_JSON;
Expand Down
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017 Evolveum
* Copyright (c) 2017-2018 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,9 +16,8 @@
package com.evolveum.midpoint.gui.api.util;

import com.evolveum.midpoint.gui.api.GuiFeature;
import com.evolveum.midpoint.schema.util.AdminGuiConfigTypeUtil;
import com.evolveum.midpoint.model.api.authentication.CompiledUserProfile;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AdminGuiConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserInterfaceElementVisibilityType;

/**
Expand All @@ -31,14 +30,14 @@ public class FeatureVisibleEnableBehaviour extends VisibleEnableBehaviour {

UserInterfaceElementVisibilityType visibility;

public FeatureVisibleEnableBehaviour(GuiFeature feature, AdminGuiConfigurationType adminGuiConfig) {
public FeatureVisibleEnableBehaviour(GuiFeature feature, CompiledUserProfile userProfile) {
super();
visibility = AdminGuiConfigTypeUtil.getFeatureVisibility(adminGuiConfig, feature.getUri());
visibility = userProfile.getFeatureVisibility(feature.getUri());
}

@Override
public boolean isVisible() {
return AdminGuiConfigTypeUtil.isVisible(visibility, this::isVisibleAutomatic);
return CompiledUserProfile.isVisible(visibility, this::isVisibleAutomatic);
}

/**
Expand Down
Expand Up @@ -18,6 +18,7 @@

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.model.api.ModelInteractionService;
import com.evolveum.midpoint.model.api.authentication.CompiledUserProfile;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
Expand Down Expand Up @@ -79,9 +80,9 @@ public boolean isVisible() {
SecurityUtils.getPrincipalUser().getUser().asPrismObject(), getTaskManager());
OperationResult result = task.getResult();

AdminGuiConfigurationType config;
CompiledUserProfile config;
try {
config = getModelInteractionService().getAdminGuiConfiguration(task, result);
config = getModelInteractionService().getCompiledUserProfile(task, result);
} catch (ObjectNotFoundException | SchemaException e) {
throw new SystemException("Cannot load GUI configuration: " + e.getMessage(), e);
}
Expand Down Expand Up @@ -113,7 +114,7 @@ public boolean isVisible() {
return false;
}

private List<ObjectFormType> findObjectForm(AdminGuiConfigurationType config, PrismObject<O> object) {
private List<ObjectFormType> findObjectForm(CompiledUserProfile config, PrismObject<O> object) {
List<ObjectFormType> result = new ArrayList<>();

if (config == null || config.getObjectForms() == null) {
Expand Down
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2016-2017 Evolveum
* Copyright (c) 2016-2018 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 @@ -18,6 +18,7 @@
import com.evolveum.midpoint.common.LocalizationService;
import com.evolveum.midpoint.model.api.ModelInteractionService;
import com.evolveum.midpoint.model.api.ModelService;
import com.evolveum.midpoint.model.api.authentication.CompiledUserProfile;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.repo.common.ObjectResolver;
import com.evolveum.midpoint.repo.common.expression.ExpressionFactory;
Expand Down Expand Up @@ -65,14 +66,15 @@ public interface ModelServiceLocator {
ExpressionFactory getExpressionFactory();

/**
* Returns adminGuiConfiguraiton applicable to currently logged-in user.
* Returns currently applicable user profile, compiled for efficient use in the user interface.
* applicable to currently logged-in user.
* Strictly speaking, this can be retrieved from modelInteractionService.
* But having a separate function for that allows to get rid of
* task and result parameters. And more importantly: this allows to
* cache adminGuiConfig in the page (in case many components need it).
*/
@NotNull
AdminGuiConfigurationType getAdminGuiConfiguration();
CompiledUserProfile getCompiledUserProfile();

default ObjectResolver getModelObjectResolver() {
return null;
Expand Down

0 comments on commit f8e988a

Please sign in to comment.