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
katkav committed Sep 11, 2018
2 parents 6e3b4bf + a7d010f commit db90f50
Show file tree
Hide file tree
Showing 15 changed files with 214 additions and 96 deletions.
9 changes: 9 additions & 0 deletions gui/admin-gui/pom.xml
Expand Up @@ -145,6 +145,15 @@
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
Expand Down
Expand Up @@ -22,6 +22,7 @@
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.TabbedPanel;
import com.evolveum.midpoint.web.component.dialog.Popupable;
import com.evolveum.midpoint.web.component.util.EnableBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand Down Expand Up @@ -107,14 +108,7 @@ public void onClick(AjaxRequestTarget target) {
}
};
addButton.add(AttributeAppender.append("title", getAddButtonTitleModel()));
addButton.add(new VisibleEnableBehaviour(){
private static final long serialVersionUID = 1L;

@Override
public boolean isEnabled(){
return isAssignButtonEnabled();
}
});
addButton.add(new EnableBehaviour(() -> isAssignButtonEnabled()));
addButton.setOutputMarkupId(true);
form.add(addButton);
}
Expand Down Expand Up @@ -289,7 +283,8 @@ private int getTabPanelSelectedCount(WebMarkupContainer panel){
}

private void tabLabelPanelUpdate(AjaxRequestTarget target){
target.add(AssignmentPopup.this);
getTabbedPanel().reloadCountLabels(target);
target.add(get(ID_FORM).get(ID_ASSIGN_BUTTON));
}

private TabbedPanel getTabbedPanel(){
Expand Down
Expand Up @@ -16,6 +16,7 @@
package com.evolveum.midpoint.gui.api.component;

import com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.query.InOidFilter;
Expand All @@ -32,13 +33,16 @@
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.TabbedPanel;
import com.evolveum.midpoint.web.component.dialog.Popupable;
import com.evolveum.midpoint.web.component.util.EnableBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.StringResourceModel;

import javax.xml.namespace.QName;
Expand Down Expand Up @@ -100,19 +104,34 @@ public void onClick(AjaxRequestTarget target) {

@Override
public void onClick(AjaxRequestTarget target) {
tabs.forEach(panelTab -> {
boolean orgPanelProcessed = false;
for (ITab panelTab : tabs){
WebMarkupContainer tabPanel = ((CountablePanelTab)panelTab).getPanel();
if (tabPanel == null){
return;
continue;
}

MemberPopupTabPanel memberPanel = (MemberPopupTabPanel) tabPanel;
executeMemberOperation(memberPanel.getObjectType().getTypeQName(), createInOidQuery(memberPanel.getSelectedObjectsList()),
if (memberPanel.getObjectType().equals(ObjectTypes.ORG) && orgPanelProcessed){
continue;
}
List<ObjectType> selectedObjects = memberPanel.getObjectType().equals(ObjectTypes.ORG) ? memberPanel.getPreselectedObjects() :
memberPanel.getSelectedObjectsList();

if (selectedObjects == null || selectedObjects.size() == 0){
continue;
}
executeMemberOperation(memberPanel.getObjectType().getTypeQName(),
createInOidQuery(selectedObjects),
memberPanel.prepareDelta(), target);
});
if (memberPanel.getObjectType().equals(ObjectTypes.ORG)){
orgPanelProcessed = true;
}
}
ChooseMemberPopup.this.getPageBase().hideMainPopup(target);
}
};
addButton.add(AttributeAppender.append("title", getAddButtonTitleModel()));
addButton.add(new EnableBehaviour(() -> isAddButtonEnabled()));
addButton.setOutputMarkupId(true);
form.add(addButton);
}
Expand Down Expand Up @@ -304,7 +323,9 @@ protected int getTabPanelSelectedCount(WebMarkupContainer panel){
}

protected void tabLabelPanelUpdate(AjaxRequestTarget target){
target.add(getTabbedPanel());
getTabbedPanel().reloadCountLabels(target);
target.add(get(ID_FORM).get(ID_ADD_BUTTON));

}

private TabbedPanel getTabbedPanel(){
Expand All @@ -320,6 +341,30 @@ protected ObjectQuery createInOidQuery(List<ObjectType> selectedObjectsList){
return ObjectQuery.createObjectQuery(InOidFilter.createInOid(oids));
}

private IModel<String> getAddButtonTitleModel(){
return new LoadableModel<String>(true) {
@Override
protected String load() {
return !isAddButtonEnabled() ? createStringResource("AssignmentPopup.addButtonTitle").getString() : "";
}
};
}

private boolean isAddButtonEnabled(){
TabbedPanel tabbedPanel = getTabbedPanel();
List<ITab> tabs = (List<ITab>) tabbedPanel.getTabs().getObject();
for (ITab tab : tabs){
WebMarkupContainer memberPanel = ((CountablePanelTab)tab).getPanel();
if (memberPanel == null){
continue;
}
if (((MemberPopupTabPanel) memberPanel).getSelectedObjectsList().size() > 0) {
return true;
}
}
return false;
}

protected void executeMemberOperation(QName type, ObjectQuery memberQuery,
ObjectDelta delta, AjaxRequestTarget target) {

Expand Down
Expand Up @@ -74,7 +74,7 @@ private List<QName> getSupportedRelations() {
protected Map<String, AssignmentType> getSelectedAssignmentsMap(){
Map<String, AssignmentType> assignmentsMap = new HashedMap();

List<F> selectedObjects = getSelectedObjectsList();
List<F> selectedObjects = getObjectType().equals(ObjectTypes.ORG) ? getPreselectedObjects() : getSelectedObjectsList();
QName relation = getRelationValue();
selectedObjects.forEach(selectedObject -> {
assignmentsMap.put(selectedObject.getOid(), ObjectTypeUtil.createAssignmentTo(selectedObject, relation));
Expand Down
Expand Up @@ -19,7 +19,7 @@
import java.io.File;
import java.lang.management.ManagementFactory;
import java.time.Duration;
import java.util.EnumSet;
import java.util.Arrays;

import javax.servlet.DispatcherType;

Expand All @@ -31,9 +31,16 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.Banner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet.WebMvcEndpointManagementContextConfiguration;
import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagementContextAutoConfiguration;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
Expand All @@ -55,6 +62,7 @@
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.Session;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
Expand Down Expand Up @@ -109,7 +117,13 @@
PropertyPlaceholderAutoConfiguration.class,
SecurityFilterAutoConfiguration.class,
MultipartAutoConfiguration.class,
HttpEncodingAutoConfiguration.class
HttpEncodingAutoConfiguration.class,
EndpointAutoConfiguration.class,
WebEndpointAutoConfiguration.class,
WebMvcEndpointManagementContextConfiguration.class,
ServletManagementContextAutoConfiguration.class,
HealthEndpointAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class
})
@SpringBootConfiguration
public class MidPointSpringApplication extends SpringBootServletInitializer {
Expand Down Expand Up @@ -213,15 +227,15 @@ public FilterRegistrationBean<DelegatingFilterProxy> springSecurityFilterChain()
registration.addUrlPatterns("/*");
return registration;
}

@Bean
public FilterRegistrationBean<WroFilter> webResourceOptimizer(WroFilter wroFilter) {
FilterRegistrationBean<WroFilter> registration = new FilterRegistrationBean<>();
registration.setFilter(wroFilter);
registration.addUrlPatterns("/wro/*");
return registration;
}

@Bean
public ServletRegistrationBean<CXFServlet> cxfServlet() {
ServletRegistrationBean<CXFServlet> registration = new ServletRegistrationBean<>();
Expand Down
Expand Up @@ -108,6 +108,8 @@ public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/less/**");

web.ignoring().antMatchers("/wicket/resource/**");

web.ignoring().antMatchers("/actuator/**");
}

@Override
Expand Down
Expand Up @@ -19,6 +19,7 @@
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
Expand All @@ -37,6 +38,7 @@
import com.evolveum.midpoint.gui.api.model.CountModelProvider;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -49,6 +51,8 @@ public class TabbedPanel<T extends ITab> extends Panel {
* id used for child panels
*/
public static final String TAB_PANEL_ID = "panel";
public static final String ID_TABS_CONTAINER = "tabs-container";
public static final String ID_TABS = "tabs";
public static final String RIGHT_SIDE_TAB_ITEM_ID = "rightSideTabItem";
public static final String RIGHT_SIDE_TAB_ID = "rightSideTab";

Expand Down Expand Up @@ -106,11 +110,11 @@ public Integer getObject() {
}
};

WebMarkupContainer tabsContainer = newTabsContainer("tabs-container");
WebMarkupContainer tabsContainer = newTabsContainer(ID_TABS_CONTAINER);
add(tabsContainer);

// add the loop used to generate tab names
tabsContainer.add(new Loop("tabs", tabCount) {
tabsContainer.add(new Loop(ID_TABS, tabCount) {
private static final long serialVersionUID = 1L;

@Override
Expand All @@ -131,6 +135,7 @@ protected void populateItem(final LoopItem item) {
}
Label countLabel = new Label(ID_COUNT, countModel);
countLabel.setVisible(countModel != null);
countLabel.setOutputMarkupId(true);
countLabel.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -492,4 +497,15 @@ protected void onTabChange(int index) {}
public interface RightSideItemProvider extends Serializable {
Component createRightSideItem(String id);
}

public void reloadCountLabels(AjaxRequestTarget target){
Loop tabbedPanel = ((Loop)get(ID_TABS_CONTAINER).get(ID_TABS));
int tabsCount = tabbedPanel.getIterations();
for (int i = 0; i < tabsCount; i++){
Component countLabel = tabbedPanel.get(Integer.toString(i)).get(ID_LINK).get(ID_COUNT);
if (countLabel != null) {
target.add(countLabel);
}
}
}
}
Expand Up @@ -135,7 +135,7 @@ public boolean isVisible() {

}

private boolean hasAnyProperty() {
public boolean hasAnyProperty() {
for(ItemWrapper item : getModelObject().getItems()) {
if(item instanceof PropertyOrReferenceWrapper) {
return true;
Expand Down
Expand Up @@ -250,6 +250,10 @@ public String getObject() {
if(((ContainerValueWrapper)item.getModelObject()).getContainer() !=null && ((ContainerValueWrapper)item.getModelObject()).getContainer().isShowOnTopLevel()) {
item.add(AttributeModifier.append("class", "top-level-prism-container"));
}

if(!containerPanel.hasAnyProperty()) {
item.add(AttributeModifier.append("style", " border-top: none; padding-top: 0px; "));
}

}

Expand Down
Expand Up @@ -20,6 +20,7 @@
import com.evolveum.midpoint.util.aspect.ProfilingDataManager;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import org.apache.catalina.connector.ClientAbortException;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -68,7 +69,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
try {
chain.doFilter(request, response);
} catch (IOException | ServletException | RuntimeException | Error e) {
LOGGER.debug("Encountered exception: {}: {}", e.getClass().getName(), e.getMessage(), e);
logException(e);
throw e;
}

Expand All @@ -85,7 +86,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
try {
chain.doFilter(request, response);
} catch (IOException | ServletException | RuntimeException | Error e) {
LOGGER.debug("Encountered exception: {}: {}", e.getClass().getName(), e.getMessage(), e);
logException(e);
throw e;
}
}
Expand All @@ -99,5 +100,15 @@ private void prepareRequestProfilingEvent(ServletRequest request, long elapsed,
ProfilingDataManager.getInstance().prepareRequestProfilingEvent(event);
}

private void logException(Throwable t) throws IOException, ServletException {
if (t instanceof ClientAbortException) {
if (LOGGER.isDebugEnabled()) {
// client abort exceptions are quite OK as they are not an application/server problem
LOGGER.debug("Encountered exception: {}: {}", t.getClass().getName(), t.getMessage(), t);
}
return;
}

LOGGER.error("Encountered exception: {}: {}", t.getClass().getName(), t.getMessage(), t);
}
}
12 changes: 11 additions & 1 deletion gui/admin-gui/src/main/resources/application.yml
Expand Up @@ -46,4 +46,14 @@ auth:
# enable-csrf: false # default for midpoint is true

# more properties with default values can be found here:
# https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
# https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

management:
endpoint:
health:
enabled: true


#logging:
# level:
# org.springframework: TRACE

0 comments on commit db90f50

Please sign in to comment.