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 Jun 4, 2020
2 parents b806ce0 + 41f4a68 commit 37e3f6b
Show file tree
Hide file tree
Showing 106 changed files with 1,441 additions and 2,096 deletions.
4 changes: 2 additions & 2 deletions dist/javadoc/pom.xml
Expand Up @@ -42,8 +42,8 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
29 changes: 10 additions & 19 deletions gui/admin-gui/pom.xml
Expand Up @@ -51,23 +51,21 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
<exclusions>
<!-- Replaced by tomcat-annotations-api -->
<exclusion>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-annotations-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Equivalent of: javax.annotation:javax.annotation-api -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-annotations-api</artifactId>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -593,8 +591,8 @@
<artifactId>annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
Expand All @@ -617,11 +615,9 @@
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.64</version>
</dependency>

<!-- TEST -->

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down Expand Up @@ -741,11 +737,6 @@
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- testing dependencies -->
<dependency>
Expand Down
Expand Up @@ -163,6 +163,11 @@ public void exportPerformed(AjaxRequestTarget target) {
protected void createReportPerformed(String name, SearchFilterType filter, AjaxRequestTarget target) {
CsvDownloadButtonPanel.this.createReportPerformed(name, filter, exportableColumnsIndex, target);
}

@Override
public boolean isVisibleCreateReportOption() {
return CsvDownloadButtonPanel.this.isVisibleCreateReportOption();
}
};
getPageBase().showMainPopup(exportingPanel, target);
}
Expand All @@ -185,4 +190,8 @@ protected void createReportPerformed(String name, SearchFilterType filter, AjaxR

protected abstract void createReportPerformed(String name, SearchFilterType filter, List<Integer> indexOfColumns, AjaxRequestTarget target);

public boolean isVisibleCreateReportOption() {
return true;
}

}
@@ -1,55 +1,52 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
* Copyright (c) 2010-2020 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.web.boot;

import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration;
import com.evolveum.midpoint.gui.impl.factory.panel.TextAreaPanelFactory;
import com.evolveum.midpoint.gui.impl.registry.GuiComponentRegistryImpl;
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import java.lang.management.ManagementFactory;
import java.time.Duration;
import java.util.Collections;

import org.apache.catalina.Context;
import org.apache.catalina.Manager;
import org.apache.catalina.Valve;
import org.apache.catalina.valves.RemoteIpValve;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.embedded.TomcatWebServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryCustomizer;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.Session;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
import org.springframework.stereotype.Component;

import java.lang.management.ManagementFactory;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration;
import com.evolveum.midpoint.gui.impl.factory.panel.TextAreaPanelFactory;
import com.evolveum.midpoint.gui.impl.registry.GuiComponentRegistryImpl;
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;

/**
* Created by Viliam Repan (lazyman).
Expand Down Expand Up @@ -81,7 +78,16 @@
})
@Profile("!test")
@SpringBootConfiguration
@ComponentScan(basePackages = {"com.evolveum.midpoint.web.security.factory", "com.evolveum.midpoint.gui", "com.evolveum.midpoint.gui.api"}, basePackageClasses = {TextAreaPanelFactory.class, GuiComponentRegistryImpl.class})
@ComponentScan(
basePackages = {
"com.evolveum.midpoint.web.security.factory",
"com.evolveum.midpoint.gui",
"com.evolveum.midpoint.gui.api"
},
basePackageClasses = {
TextAreaPanelFactory.class,
GuiComponentRegistryImpl.class
})
@EnableScheduling
public class MidPointSpringApplication extends AbstractSpringBootApplication {

Expand All @@ -105,16 +111,13 @@ public static void main(String[] args) {
System.exit(SpringApplication.exit(applicationContext, () -> 0));

} else {

applicationContext = configureApplication(new SpringApplicationBuilder()).run(args);

if (LOGGER.isDebugEnabled()) {
LOGGER.debug("PID:" + ManagementFactory.getRuntimeMXBean().getName() +
" Application started context:" + applicationContext);
}

}

}

@Override
Expand Down Expand Up @@ -169,39 +172,29 @@ public void invalidExpiredSessions() {

@Component
@EnableConfigurationProperties(ServerProperties.class)
public class ServerCustomization implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {
public class ServerCustomization implements WebServerFactoryCustomizer<MidPointTomcatServletWebServerFactory> {

@Value("${server.servlet.session.timeout}")
private int sessionTimeout;

@Value("${server.servlet.context-path}")
private String servletPath;

@Value("${server.use-forward-headers:false}")
private Boolean useForwardHeaders;

@Value("${server.tomcat.internal-proxies:@null}")
private String internalProxies;

@Value("${server.tomcat.protocol-header:@null}")
private String protocolHeader;

@Value("${server.tomcat.protocol-header-https-value:@null}")
private String protocolHeaderHttpsValue;

@Value("${server.tomcat.port-header:@null}")
private String portHeader;

@Autowired
private ServerProperties serverProperties;

@Autowired
private TaskManager taskManager;

@Override
public void customize(ConfigurableServletWebServerFactory serverFactory) {
@Autowired
private Environment env;

ServletWebServerFactoryCustomizer servletWebServerFactoryCustomizer = new ServletWebServerFactoryCustomizer(serverProperties);
servletWebServerFactoryCustomizer.customize(serverFactory);
@Override
public void customize(MidPointTomcatServletWebServerFactory serverFactory) {
ServletWebServerFactoryCustomizer webServletWebServerFactoryCustomizer = new ServletWebServerFactoryCustomizer(serverProperties);
webServletWebServerFactoryCustomizer.customize(serverFactory);
TomcatWebServerFactoryCustomizer tomcatWebServerFactoryCustomizer = new TomcatWebServerFactoryCustomizer(env, serverProperties);
tomcatWebServerFactoryCustomizer.customize(serverFactory);

serverFactory.addErrorPages(new ErrorPage(HttpStatus.UNAUTHORIZED, "/error/401"));
serverFactory.addErrorPages(new ErrorPage(HttpStatus.FORBIDDEN, "/error/403"));
Expand All @@ -213,48 +206,16 @@ public void customize(ConfigurableServletWebServerFactory serverFactory) {
session.setTimeout(Duration.ofMinutes(sessionTimeout));
serverFactory.setSession(session);

if (serverFactory instanceof TomcatServletWebServerFactory) {
customizeTomcat((TomcatServletWebServerFactory) serverFactory);
}
}

private void customizeTomcat(TomcatServletWebServerFactory tomcatFactory) {
// set tomcat context.
TomcatContextCustomizer contextCustomizer = new TomcatContextCustomizer() {
@Override
public void customize(Context context) {
setTomcatContext(context);
}
};
List<TomcatContextCustomizer> contextCustomizers = new ArrayList<>();
contextCustomizers.add(contextCustomizer);
tomcatFactory.setTomcatContextCustomizers(contextCustomizers);
serverFactory.setTomcatContextCustomizers(
Collections.singleton(MidPointSpringApplication.this::setTomcatContext));

// Tomcat valve used to redirect root URL (/) to real application URL (/midpoint/).
// See comments in TomcatRootValve
Valve rootValve = new TomcatRootValve(servletPath);
tomcatFactory.addEngineValves(rootValve);
serverFactory.addEngineValves(rootValve);

Valve nodeIdHeaderValve = new NodeIdHeaderValve(taskManager);
tomcatFactory.addEngineValves(nodeIdHeaderValve);

if (useForwardHeaders) {
RemoteIpValve remoteIpValve = new RemoteIpValve();
if (StringUtils.isNotEmpty(internalProxies)) {
remoteIpValve.setInternalProxies(internalProxies);
}
if (StringUtils.isNotEmpty(protocolHeader)) {
remoteIpValve.setProtocolHeader(protocolHeader);
}
if (StringUtils.isNotEmpty(protocolHeaderHttpsValue)) {
remoteIpValve.setProtocolHeaderHttpsValue(protocolHeaderHttpsValue);
}
if (StringUtils.isNotEmpty(portHeader)) {
remoteIpValve.setPortHeader(portHeader);
}
tomcatFactory.addEngineValves(remoteIpValve);
}
serverFactory.addEngineValves(nodeIdHeaderValve);
}

}
}
Expand Up @@ -21,6 +21,7 @@
import com.evolveum.midpoint.web.component.message.FeedbackAlerts;
import com.evolveum.midpoint.web.component.search.Search;

import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType;

import org.apache.wicket.Component;
Expand Down Expand Up @@ -165,6 +166,12 @@ public void onClick(AjaxRequestTarget target) {
((PageBase) getPage()).hideMainPopup(target);
}
};
createReport.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isVisibleCreateReportOption();
}
});
panel.add(createReport);
AjaxButton exportSelected = new AjaxButton(ID_EXPORT,
new StringResourceModel("ExportingPopupPanel.exportSelected", this, null)) {
Expand Down Expand Up @@ -218,6 +225,8 @@ public WebMarkupContainer createPanel(String panelId) {
return createTable(panelId, dataTable);
}
});


tabs.add(new PanelTab(getPageBase().createStringResource("ExportingPopupPanel.filter")) {
@Override
public WebMarkupContainer createPanel(String panelId) {
Expand All @@ -228,6 +237,11 @@ public PageBase getPageBase() {
}
};
}

@Override
public boolean isVisible() {
return isVisibleCreateReportOption();
}
});
return tabs;
}
Expand Down Expand Up @@ -364,4 +378,8 @@ public Component getComponent() {
return this;
}

public boolean isVisibleCreateReportOption() {
return true;
}

}
Expand Up @@ -10,9 +10,11 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -189,6 +191,7 @@ private void initSearchItemField(WebMarkupContainer searchItemContainer) {
Component searchItemField = null;
SearchItem<T> item = getModelObject();
IModel<List<DisplayableValue<T>>> choices = null;
PrismObject<LookupTableType> lookupTable = findLookupTable(item.getDefinition());
switch (item.getType()) {
case REFERENCE:
//TODO change probably to another component
Expand Down Expand Up @@ -273,10 +276,13 @@ public DisplayableValue getObject(String id, IModel<? extends List<? extends Dis
}, true);
break;
case TEXT:
searchItemField = new TextPanel<String>(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), "value.value"));
if (lookupTable != null){
searchItemField = (SearchPopupPanel<T>) new TextPopupPanel<T>(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), "value"), lookupTable);
} else {
searchItemField = new TextPanel<String>(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), "value.value"));
}
break;
default:
PrismObject<LookupTableType> lookupTable = findLookupTable(item.getDefinition());
searchItemField = (SearchPopupPanel<T>) new TextPopupPanel<T>(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), "value"), lookupTable);
}
if (searchItemField == null){
Expand Down

0 comments on commit 37e3f6b

Please sign in to comment.