Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Apr 16, 2019
2 parents 91756b2 + 2e819d2 commit f37f3c0
Show file tree
Hide file tree
Showing 94 changed files with 4,060 additions and 483 deletions.
Expand Up @@ -17,6 +17,7 @@
package com.evolveum.midpoint.gui.api.page;

import com.evolveum.midpoint.audit.api.AuditService;
import com.evolveum.midpoint.common.Clock;
import com.evolveum.midpoint.common.LocalizationService;

import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration;
Expand All @@ -35,6 +36,7 @@
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.interaction.DashboardService;
import com.evolveum.midpoint.model.api.validator.ResourceValidator;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.*;
Expand Down Expand Up @@ -104,8 +106,7 @@
import com.evolveum.midpoint.web.page.admin.certification.PageCertDefinition;
import com.evolveum.midpoint.web.page.admin.certification.PageCertDefinitions;
import com.evolveum.midpoint.web.page.admin.configuration.*;
import com.evolveum.midpoint.web.page.admin.home.PageDashboard;
import com.evolveum.midpoint.web.page.admin.home.PageDashboardAdmin;
import com.evolveum.midpoint.web.page.admin.home.PageDashboardConfigurable;
import com.evolveum.midpoint.web.page.admin.home.PageDashboardInfo;
import com.evolveum.midpoint.web.page.admin.reports.*;
import com.evolveum.midpoint.web.page.admin.resources.*;
Expand All @@ -130,6 +131,7 @@
import com.evolveum.midpoint.web.session.SessionStorage;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.web.util.NewWindowNotifyingBehavior;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.web.util.validation.MidpointFormValidatorRegistry;
import com.evolveum.midpoint.wf.api.WorkflowManager;
import com.evolveum.midpoint.wf.util.QueryUtils;
Expand Down Expand Up @@ -256,6 +258,9 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {

@SpringBean(name = "modelInteractionService")
private ModelInteractionService modelInteractionService;

@SpringBean(name = "dashboardService")
private DashboardService dashboardService;

@SpringBean(name = "modelController")
private TaskService taskService;
Expand Down Expand Up @@ -295,6 +300,9 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {

@SpringBean(name = "accessDecisionManager")
private SecurityEnforcer securityEnforcer;

@SpringBean(name = "clock")
private Clock clock;

@SpringBean
private SecurityContextManager securityContextManager;
Expand Down Expand Up @@ -580,6 +588,11 @@ public SecurityContextManager getSecurityContextManager() {
public ModelInteractionService getModelInteractionService() {
return modelInteractionService;
}

@Override
public DashboardService getDashboardService() {
return dashboardService;
}

protected ModelDiagnosticService getModelDiagnosticService() {
return modelDiagnosticService;
Expand Down Expand Up @@ -1957,7 +1970,27 @@ private MainMenuItem createHomeItems() {
createStringResource("PageAdmin.menu.dashboard"), null);

addMenuItem(item, "PageAdmin.menu.dashboard.info", PageDashboardInfo.class);
addMenuItem(item, "PageAdmin.menu.dashboard.admin", PageDashboardAdmin.class);

OperationResult result = new OperationResult("Search Dashboard");
List<PrismObject<DashboardType>> dashboards = WebModelServiceUtils.searchObjects(DashboardType.class, null, result, this);
if(dashboards != null) {
dashboards.forEach(prismObject -> {
Validate.notNull(prismObject, "PrismObject<Dashboard> is null");
DashboardType dashboard = prismObject.getRealValue();
Validate.notNull(dashboard, "Dashboard object is null");

StringResourceModel label = null;
if(dashboard.getDisplay() != null && dashboard.getDisplay().getLabel() != null) {
label = createStringResource(dashboard.getDisplay().getLabel().getOrig());
} else {
label = createStringResource(dashboard.getName());
}
PageParameters pageParameters = new PageParameters();
pageParameters.add(OnePageParameterEncoder.PARAMETER, dashboard.getOid());
MenuItem menu = new MenuItem(label, "", PageDashboardConfigurable.class, pageParameters, null, null);
item.getItems().add(menu);
});
}

return item;
}
Expand Down Expand Up @@ -2311,15 +2344,19 @@ public void navigateToNext(Class<? extends WebPage> page) {
}

public void navigateToNext(Class<? extends WebPage> pageType, PageParameters params) {
IPageFactory pFactory = Session.get().getPageFactory();
WebPage page = createWebPage(pageType, params);
navigateToNext(page);
}

public WebPage createWebPage(Class<? extends WebPage> pageType, PageParameters params) {
IPageFactory pFactory = Session.get().getPageFactory();
WebPage page;
if (params == null) {
page = pFactory.newPage(pageType);
} else {
page = pFactory.newPage(pageType, params);
}

navigateToNext(page);
return page;
}

public void navigateToNext(WebPage page) {
Expand Down Expand Up @@ -2517,4 +2554,8 @@ public AsyncWebProcessManager getAsyncWebProcessManager() {
public Locale getLocale() {
return getSession().getLocale();
}

public Clock getClock() {
return clock;
}
}
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2016-2018 Evolveum
* Copyright (c) 2016-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 @@ -19,6 +19,7 @@
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.model.api.interaction.DashboardService;
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 @@ -46,6 +47,8 @@ public interface ModelServiceLocator {

ModelInteractionService getModelInteractionService();

DashboardService getDashboardService();

LocalizationService getLocalizationService();

Task createSimpleTask(String operationName);
Expand Down
Expand Up @@ -3468,15 +3468,13 @@ public static <T> List<T> sortDropDownChoices(IModel<? extends List<? extends T>
}

public static String getMidpointCustomSystemName(PageBase pageBase, String defaultSystemNameKey){
OperationResult result = new OperationResult(pageBase.getClass().getSimpleName() + ".loadDeploymentInformation");
try {
SystemConfigurationType systemConfig = pageBase.getModelInteractionService().getSystemConfiguration(result);
DeploymentInformationType deploymentInfo = systemConfig != null ? systemConfig.getDeploymentInformation() : null;
return deploymentInfo != null && StringUtils.isNotEmpty(deploymentInfo.getSystemName()) ? deploymentInfo.getSystemName() : pageBase.createStringResource(defaultSystemNameKey).getString();
} catch (ObjectNotFoundException | SchemaException e){
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load deployment information", e);
result.recordFatalError("Couldn't load deployment information.", e);
}
return pageBase.createStringResource(defaultSystemNameKey).getString();
DeploymentInformationType deploymentInfo = MidPointApplication.get().getDeploymentInfo();
String subscriptionId = deploymentInfo != null ? deploymentInfo.getSubscriptionIdentifier() : null;
if (!isSubscriptionIdCorrect(subscriptionId) ||
SubscriptionType.DEMO_SUBSRIPTION.getSubscriptionType().equals(subscriptionId.substring(0, 2))) {
return pageBase.createStringResource(defaultSystemNameKey).getString();
}
return deploymentInfo != null && StringUtils.isNotEmpty(deploymentInfo.getSystemName()) ?
deploymentInfo.getSystemName() : pageBase.createStringResource(defaultSystemNameKey).getString();
}
}

0 comments on commit f37f3c0

Please sign in to comment.