Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/hikari
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Mar 6, 2018
2 parents 5b13bba + 34805d9 commit d517a43
Show file tree
Hide file tree
Showing 63 changed files with 1,501 additions and 937 deletions.
Expand Up @@ -18,7 +18,6 @@
import java.util.*;

import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
Expand All @@ -32,7 +31,6 @@
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.StringResourceModel;

import com.evolveum.midpoint.gui.api.model.LoadableModel;
Expand Down
Expand Up @@ -26,7 +26,6 @@
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails;
import com.evolveum.midpoint.web.page.login.PageLogin;
import com.evolveum.midpoint.web.security.MidPointApplication;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
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,8 @@
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.Valve;
import org.apache.commons.lang.StringUtils;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.apache.wicket.Application;
Expand All @@ -37,6 +39,7 @@
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.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 +86,7 @@
"classpath:ctx-webapp.xml"
})
@ImportAutoConfiguration(classes = {
EmbeddedServletContainerAutoConfiguration.class,
EmbeddedTomcatAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
Expand Down Expand Up @@ -248,6 +251,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);
}

}
Expand Up @@ -19,23 +19,15 @@
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.web.component.input.ExpressionValuePanel;
import com.evolveum.midpoint.web.component.input.QNameEditorPanel;
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.prism.PrismContainerValueHeaderPanel;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

import javax.xml.namespace.QName;
import java.util.List;

/**
* Created by honchar
*/
Expand Down
Expand Up @@ -31,21 +31,15 @@
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ItemWrapper;
import com.evolveum.midpoint.web.component.prism.ValueWrapper;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import sun.security.provider.SHA;

import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.List;

Expand Down

0 comments on commit d517a43

Please sign in to comment.