Skip to content

Commit

Permalink
Merge branch 'master' into keystore-perf
Browse files Browse the repository at this point in the history
  • Loading branch information
SavvasMisaghMoayyed committed Mar 5, 2018
2 parents cbf5986 + d7aafcc commit cbef297
Show file tree
Hide file tree
Showing 96 changed files with 2,246 additions and 1,040 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Expand Up @@ -15,7 +15,7 @@ before_install:
- unzip -qq apache-maven-3.5.0-bin.zip
- export M2_HOME=$PWD/apache-maven-3.5.0
- export PATH=$M2_HOME/bin:$PATH
- export MAVEN_OPTS='-Xmx4g'
- export MAVEN_OPTS='-Xmx6g'

# 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
Expand All @@ -26,6 +26,10 @@ addons:
#packages:
#- oracle-java8-installer # install newest JDK8

env:
global:
- MALLOC_ARENA_MAX=2

jdk:
#- openjdk7
#- oraclejdk7
Expand Down
Expand Up @@ -103,7 +103,9 @@ public void checkInputValue(AutoCompleteTextField input, AjaxRequestTarget targe
if (input.getInput() == null || input.getInput().trim().equals("")){
model.setObject(input.getInput());
}
if (getIterator(input.getInput()).hasNext() && getIterator(input.getInput()).next() instanceof String) {
if (!getIterator(input.getInput()).hasNext()) {
updateFeedbackPanel(input, true, target);
} else {
Iterator<String> lookupTableValuesIterator = (Iterator<String>) getIterator(input.getInput());

String value = input.getInput();
Expand Down
Expand Up @@ -408,6 +408,14 @@ public static <T extends ObjectType> IModel<ObjectWrapper<T>> adopt(
return objectWrapperModel;
}

public static void safeResultCleanup(OperationResult result, Trace logger) {
try {
result.cleanupResultDeeply();
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(logger, "Couldn't clean up the operation result", t);
}
}

public enum Channel {
// TODO: move this to schema component
LIVE_SYNC(SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI),
Expand Down
@@ -0,0 +1,64 @@
/**
* Copyright (c) 2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.web.boot;

import javax.servlet.Servlet;

import org.apache.catalina.startup.Tomcat;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration.BeanPostProcessorsRegistrar;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.Ordered;

import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;

/**
* Custom configuration (factory) for embedded tomcat factory.
* This is necessary, as the tomcat factory is hacking tomcat setup.
* @see MidPointTomcatEmbeddedServletContainerFactory
*
* @author semancik
*/
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@Configuration
@ConditionalOnWebApplication
@Import(BeanPostProcessorsRegistrar.class)
public class EmbeddedTomcatAutoConfiguration {

private static final Trace LOGGER = TraceManager.getTrace(EmbeddedTomcatAutoConfiguration.class);

@Configuration
@ConditionalOnClass({ Servlet.class, Tomcat.class })
@ConditionalOnMissingBean(value = EmbeddedServletContainerFactory.class, search = SearchStrategy.CURRENT)
public static class EmbeddedTomcat {

@Bean
public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() {
return new MidPointTomcatEmbeddedServletContainerFactory();
}

}

}
Expand Up @@ -21,6 +21,12 @@
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.util.MidPointProfilingServletFilter;

import org.apache.catalina.Context;
import org.apache.catalina.Pipeline;
import org.apache.catalina.Valve;
import org.apache.catalina.Wrapper;
import org.apache.catalina.connector.Connector;
import org.apache.commons.lang.StringUtils;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.apache.wicket.Application;
Expand All @@ -37,6 +43,9 @@
import org.springframework.boot.autoconfigure.web.*;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
Expand Down Expand Up @@ -83,7 +92,7 @@
"classpath:ctx-webapp.xml"
})
@ImportAutoConfiguration(classes = {
EmbeddedServletContainerAutoConfiguration.class,
EmbeddedTomcatAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
Expand Down Expand Up @@ -248,6 +257,17 @@ public void customize(ConfigurableEmbeddedServletContainer container) {
"/error"));

container.setSessionTimeout(sessionTimeout, TimeUnit.MINUTES);

if (container instanceof TomcatEmbeddedServletContainerFactory) {
customizeTomcat((TomcatEmbeddedServletContainerFactory) container);
}
}

private void customizeTomcat(TomcatEmbeddedServletContainerFactory tomcatFactory) {
// Tomcat valve used to redirect root URL (/) to real application URL (/midpoint/).
// See comments in TomcatRootValve
Valve rootValve = new TomcatRootValve();
tomcatFactory.addEngineValves(rootValve);
}
}
}
@@ -0,0 +1,52 @@
/**
11 * Copyright (c) 2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.web.boot;

import org.apache.catalina.startup.Tomcat;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;

import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;

/**
* Custom tomcat factory that used to hack embedded Tomcat setup.
* There seem to be no cleaner way to get to actual configured Tomcat instance.
*
* @author semancik
*/
public class MidPointTomcatEmbeddedServletContainerFactory extends TomcatEmbeddedServletContainerFactory {

private static final Trace LOGGER = TraceManager.getTrace(MidPointTomcatEmbeddedServletContainerFactory.class);

@Override
protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(Tomcat tomcat) {

// We are setting up fake context here. This context does not really do anything.
// But it is "mapped" to the root URL (/ ... or rather "" in Tomcat parlance).
// This fake context is necessary. If there is no context at all then
// CoyoteAdapter will not execute any Valves and returns 404 immediately.
// So without this the TomcatRootValve will not work.

RootRootContext rootRootContext = new RootRootContext();
tomcat.getHost().addChild(rootRootContext);

return super.getTomcatEmbeddedServletContainer(tomcat);
}



}
@@ -0,0 +1,45 @@
/**
* Copyright (c) 2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.web.boot;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.core.StandardContext;

/**
* Fake root context. This context does not really do anything.
* But it is "mapped" to the root URL (/ ... or rather "" in Tomcat parlance).
* This fake context is necessary. If there is no context at all then
* CoyoteAdapter will not execute any Valves and returns 404 immediately.
* So without this the TomcatRootValve will not work.
*
* @author semancik
*/
public class RootRootContext extends StandardContext {

public RootRootContext() {
super();
setPath(""); // this means "/"
setDisplayName("RootRoot");
}

// HAck
@Override
public void resourcesStart() throws LifecycleException {
super.resourcesStart();
setConfigured(true);
}

}
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.web.boot;

import java.io.IOException;

import javax.servlet.ServletException;

import org.apache.catalina.Context;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.valves.ValveBase;

import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;

/**
* Tomcat valve used to redirect root (/) URL to real application (/midpoint/).
* This is needed in Spring boot deployment. Entire midPoint app is deployed
* under http://.../midpoint/ URL root. But we want users to use http://.../
* as well to access the application.
*
* This could not be done with midPoint servlets or servlet filters. The entire
* midPoint application is under /midpoint/, so the application won't even receive
* requests to root URL. We need to use dirty Tomcat-specific tricks for this.
*
* @author semancik
*
*/
public class TomcatRootValve extends ValveBase {

private static final Trace LOGGER = TraceManager.getTrace(TomcatRootValve.class);

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {

Context context = request.getContext();
if (context instanceof RootRootContext) {
String uri = request.getDecodedRequestURI();
if (uri.endsWith("favicon.ico")) {
LOGGER.trace("Redirecting favicon request to real application (URI={})", request.getDecodedRequestURI());
response.sendRedirect("/midpoint/favicon.ico");
return;
} else {
LOGGER.trace("Redirecting request to real application root (URI={})", request.getDecodedRequestURI());
response.sendRedirect("/midpoint/");
return;
}
}

getNext().invoke(request, response);
}

}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2017 Evolveum
* Copyright (c) 2010-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 Down Expand Up @@ -41,8 +41,9 @@
* @author lazyman
*/
public class CheckBoxHeaderColumn<T extends Serializable> extends CheckBoxColumn<T> {
private static final long serialVersionUID = 1L;

private static final Trace LOGGER = TraceManager.getTrace(CheckBoxHeaderColumn.class);
private static final Trace LOGGER = TraceManager.getTrace(CheckBoxHeaderColumn.class);

public CheckBoxHeaderColumn() {
super(null);
Expand Down Expand Up @@ -79,7 +80,7 @@ public boolean isVisible() {

@Override
public String getCssClass() {
return "icon";
return "check";
}

protected boolean isCheckboxVisible(){
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-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 Down

0 comments on commit cbef297

Please sign in to comment.