Skip to content

Commit

Permalink
MID-2023 - improving navigation in configuration menu. Also, small pr…
Browse files Browse the repository at this point in the history
…ofiling code cleanup.
  • Loading branch information
Erik Suta committed Oct 1, 2014
1 parent 4aaaa4d commit 71c16b0
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 185 deletions.
Expand Up @@ -178,6 +178,7 @@ private MenuBarItem createConfigurationItems() {
configuration.addMenuItem(new MenuItem(null));
configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.configuration"), true, null, null));
configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.basic"), PageSystemConfiguration.class));
configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.logging"), PageSystemConfigurationLogging.class));
// configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.security"), PageDashboard.class));
configuration.addMenuItem(new MenuItem(null));
configuration.addMenuItem(new MenuItem(createStringResource("PageAdmin.menu.top.configuration.development"), true, null, null));
Expand Down
Expand Up @@ -27,4 +27,7 @@ public class PageAdminConfiguration extends PageAdmin {
public static final String AUTH_CONFIGURATION_ALL = AuthorizationConstants.NS_AUTHORIZATION + "#configurationAll";
public static final String AUTH_CONFIGURATION_ALL_LABEL = "PageAdminConfiguration.auth.configurationAll.label";
public static final String AUTH_CONFIGURATION_ALL_DESCRIPTION = "PageAdminConfiguration.auth.configurationAll.description";

protected static final int CONFIGURATION_TAB_BASIC = 0;
protected static final int CONFIGURATION_TAB_LOGGING = 1;
}
Expand Up @@ -96,7 +96,6 @@ protected SystemConfigurationDto load() {
}
};


initLayout();
}

Expand Down Expand Up @@ -151,7 +150,11 @@ public WebMarkupContainer getPanel(String panelId) {
}
});

mainForm.add(new TabbedPanel(ID_TAB_PANEL, tabs));
TabbedPanel tabPanel = new TabbedPanel(ID_TAB_PANEL, tabs);
tabPanel.setOutputMarkupId(true);
tabPanel.setSelectedTab(getTabIndex());

mainForm.add(tabPanel);

initButtons(mainForm);
}
Expand Down Expand Up @@ -243,6 +246,10 @@ private LoggingConfigurationType createLoggingConfiguration(LoggingDto dto) {
return configuration;
}

public TabbedPanel getTabPanel(){
return (TabbedPanel)get(ID_MAIN_FORM + ":" + ID_TAB_PANEL);
}

private ClassLoggerConfigurationType createCustomClassLogger(String name, LoggingLevelType level, String appender) {
ClassLoggerConfigurationType type = new ClassLoggerConfigurationType();
type.setPackage(name);
Expand Down Expand Up @@ -358,10 +365,14 @@ private void savePerformed(AjaxRequestTarget target) {

showResultInSession(result);
target.add(getFeedbackPanel());
resetPerformed(target);
resetPerformed();
}

private void saveObjectPolicies(SystemConfigurationType systemConfig){
if(systemConfigPanel == null){
return;
}

List<ObjectPolicyConfigurationTypeDto> configList = systemConfigPanel.getModel().getObject().getObjectPolicyList();
List<ObjectPolicyConfigurationType> confList = new ArrayList<>();

Expand Down Expand Up @@ -405,7 +416,7 @@ private SystemConfigurationType saveNotificationConfiguration(SystemConfiguratio
MailConfigurationType mailConfig;
MailServerConfigurationType mailServerConfig;

if(systemConfigPanel.getModel().getObject().getNotificationConfig() != null){
if(systemConfigPanel != null && systemConfigPanel.getModel().getObject().getNotificationConfig() != null){
dto = systemConfigPanel.getModel().getObject().getNotificationConfig();

if(config.getNotificationConfiguration() != null){
Expand Down Expand Up @@ -501,12 +512,23 @@ private SystemConfigurationType saveLogging(AjaxRequestTarget target, SystemConf
return config;
}

private void resetPerformed(AjaxRequestTarget target) {
private void resetPerformed() {
model.reset();
setResponsePage(PageSystemConfiguration.class);

setResponsePage(new PageSystemConfiguration(){

@Override
public int getTabIndex(){
return PageSystemConfiguration.this.getTabPanel().getSelectedTab();
}
});
}

private void cancelPerformed(AjaxRequestTarget target) {
resetPerformed(target);
resetPerformed();
}

public int getTabIndex(){
return CONFIGURATION_TAB_BASIC;
}
}
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2010-2013 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.page.admin.configuration;

import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.web.application.AuthorizationAction;
import com.evolveum.midpoint.web.application.PageDescriptor;

/**
* @author shood
* */

@PageDescriptor(url = {"/admin/config", "/admin/config/logging"}, action = {
@AuthorizationAction(actionUri = PageAdminConfiguration.AUTH_CONFIGURATION_ALL,
label = PageAdminConfiguration.AUTH_CONFIGURATION_ALL_LABEL,
description = PageAdminConfiguration.AUTH_CONFIGURATION_ALL_DESCRIPTION),
@AuthorizationAction(actionUri = AuthorizationConstants.NS_AUTHORIZATION + "#configSystemConfiguration",
label = "PageSystemConfiguration.auth.configSystemConfiguration.label",
description = "PageSystemConfiguration.auth.configSystemConfiguration.description")})
public class PageSystemConfigurationLogging extends PageAdminConfiguration{

public PageSystemConfigurationLogging(){
setResponsePage(new PageSystemConfiguration(){

@Override
public int getTabIndex(){
return CONFIGURATION_TAB_LOGGING;
}

});
}

}
Expand Up @@ -130,7 +130,7 @@ private List<PrismObject<OrgType>> loadOrgRoots() {
Task task = createSimpleTask(OPERATION_LOAD_ORG_UNIT);
OperationResult result = new OperationResult(OPERATION_LOAD_ORG_UNIT);

List<PrismObject<OrgType>> list = null;
List<PrismObject<OrgType>> list = new ArrayList<>();
try {
ObjectQuery query = ObjectQueryUtil.createRootOrgQuery(getPrismContext());
list = getModelService().searchObjects(OrgType.class, query, null, task, result);
Expand Down
Expand Up @@ -23,7 +23,6 @@

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.DecimalFormat;

Expand All @@ -45,14 +44,11 @@
*/
public class MidPointProfilingServletFilter implements Filter {

/* Class Variables */
private static final Trace LOGGER = TraceManager.getTrace(MidPointProfilingServletFilter.class);
private static DecimalFormat df = new DecimalFormat("0.00");

/* Attributes */
protected FilterConfig config;

/* Behavior */
@Override
public void destroy() {
}
Expand All @@ -73,30 +69,23 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha

if(request instanceof HttpServletRequest){
String uri = ((HttpServletRequest)request).getRequestURI();
//String info = ((HttpServletRequest)request).getMethod();
//String sessionId = ((HttpServletRequest)request).getRequestedSessionId();
//if(uri.startsWith("/midpoint/admin")){
// LOGGER.trace(info + " " + uri + " " + sessionId + " " + df.format(((double)elapsedTime)/1000000) + " (ms).");
//}

if(uri.startsWith("/midpoint/admin")){
prepareRequestProfilingEvent(request, elapsedTime, uri);
}
}
} else {
chain.doFilter(request, response);
}
} //doFilter
}

/*
* Prepares profiling event from captured servlet request
* */
private void prepareRequestProfilingEvent(ServletRequest request, long elapsed, String uri){
String info = ((HttpServletRequest)request).getMethod();
String sessionId = ((HttpServletRequest)request).getRequestedSessionId();

ProfilingDataLog event = new ProfilingDataLog(info, uri, sessionId, elapsed, System.currentTimeMillis());
ProfilingDataManager.getInstance().prepareRequestProfilingEvent(event);
} //prepareRequestProfilingEvent
}


}
Expand Up @@ -17,82 +17,57 @@
package com.evolveum.midpoint.common;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.DiffUtil;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.aspect.ProfilingDataManager;
import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
*
* On this place, we take care about profilingConfiguration part of midPoint systemConfiguration
*
* @author shood
* */
public class ProfilingConfigurationManager {

/* Class Attributes */
private static final Trace LOGGER = TraceManager.getTrace(ProfilingConfigurationManager.class);
private static final String DOT_CLASS = ProfilingConfigurationManager.class + ".";

private static final String REQUEST_FILTER_LOGGER_CLASS_NAME = "com.evolveum.midpoint.web.util.MidPointProfilingServletFilter";
private static final String SUBSYSTEM_PROFILING_LOGGER = "com.evolveum.midpoint.util.aspect.ProfilingDataManager";
private static final String APPENDER_IDM_PROFILE = "IDM-PROFILE_LOG";

//Subsystems
public static final String SUBSYSTEM_REPOSITORY = "REPOSITORY";
public static final String SUBSYSTEM_TASKMANAGER = "TASKMANAGER";
public static final String SUBSYSTEM_TASK_MANAGER = "TASKMANAGER";
public static final String SUBSYSTEM_PROVISIONING = "PROVISIONING";
public static final String SUBSYSTEM_RESOURCEOBJECTCHANGELISTENER = "RESOURCEOBJECTCHANGELISTENER";
public static final String SUBSYSTEM_RESOURCE_OBJECT_CHANGE_LISTENER = "RESOURCEOBJECTCHANGELISTENER";
public static final String SUBSYSTEM_MODEL = "MODEL";
public static final String SUBSYSTEM_UCF = "UCF";
public static final String SUBSYSTEM_WORKFLOW = "WORKFLOW";
public static final String SUBSYSTEM_WEB = "WEB";

/* Object Attributes */

/* Methods - STATIC */

/**
* In this method, we perform the check of systemConfiguration object, searching for any changes
* related to profilingConfiguration
* */
public static LoggingConfigurationType checkSystemProfilingConfiguration(PrismObject<SystemConfigurationType> systemConfigurationPrism){
SystemConfigurationType systemConfig = systemConfigurationPrism.asObjectable();
ProfilingConfigurationType profilingConfig = systemConfig.getProfilingConfiguration();
boolean isSubsystemConfig = false;
boolean isSubsystemConfig;

if(profilingConfig == null || !profilingConfig.isEnabled())
return systemConfig.getLogging();
else{
isSubsystemConfig = applySubsystemProfiling(systemConfig);
return applyProfilingConfiguration(systemConfigurationPrism, profilingConfig, isSubsystemConfig);
}
} //checkSystemProfilingConfiguration
}

/*
* Checks systemConfig profiling configuration and performs necessary actions
* */
private static LoggingConfigurationType applyProfilingConfiguration(PrismObject<SystemConfigurationType> systemConfigurationPrism, ProfilingConfigurationType profilingConfig, boolean subsystemProfiling){
SystemConfigurationType systemConfig = systemConfigurationPrism.asObjectable();

LoggingConfigurationType loggingConfig = systemConfig.getLogging();

if(loggingConfig != null){
//LOGGER.info("entering profiling config applyProfilingConfiguration()");
if(checkXsdBooleanValue(profilingConfig.isRequestFilter())){
ClassLoggerConfigurationType requestFilterLogger = new ClassLoggerConfigurationType();
requestFilterLogger.setPackage(REQUEST_FILTER_LOGGER_CLASS_NAME);
Expand All @@ -115,24 +90,21 @@ private static LoggingConfigurationType applyProfilingConfiguration(PrismObject<

LOGGER.info("Applying profiling configuration.");
return loggingConfig;
} //applyProfilingConfiguration
}

/*
* Checks for subsystem profiling in system configuration.
* */
private static boolean applySubsystemProfiling(SystemConfigurationType systemConfig){
ProfilingConfigurationType profilingConfig = systemConfig.getProfilingConfiguration();

Map<String, Boolean> profiledSubsystems = new HashMap<String, Boolean>();
Map<String, Boolean> profiledSubsystems = new HashMap<>();
int dumpInterval = 0;
boolean subSystemProfiling = false;
boolean performanceProfiling = false;
boolean requestProfiling = false;
boolean performanceProfiling;
boolean requestProfiling;

profiledSubsystems.put(SUBSYSTEM_PROVISIONING, checkXsdBooleanValue(profilingConfig.isProvisioning()));
profiledSubsystems.put(SUBSYSTEM_REPOSITORY, checkXsdBooleanValue(profilingConfig.isRepository()));
profiledSubsystems.put(SUBSYSTEM_RESOURCEOBJECTCHANGELISTENER, checkXsdBooleanValue(profilingConfig.isResourceObjectChangeListener()));
profiledSubsystems.put(SUBSYSTEM_TASKMANAGER, checkXsdBooleanValue(profilingConfig.isTaskManager()));
profiledSubsystems.put(SUBSYSTEM_RESOURCE_OBJECT_CHANGE_LISTENER, checkXsdBooleanValue(profilingConfig.isResourceObjectChangeListener()));
profiledSubsystems.put(SUBSYSTEM_TASK_MANAGER, checkXsdBooleanValue(profilingConfig.isTaskManager()));
profiledSubsystems.put(SUBSYSTEM_UCF, checkXsdBooleanValue(profilingConfig.isUcf()));
profiledSubsystems.put(SUBSYSTEM_MODEL, checkXsdBooleanValue(profilingConfig.isModel()));
profiledSubsystems.put(SUBSYSTEM_WORKFLOW, checkXsdBooleanValue(profilingConfig.isWorkflow()));
Expand Down Expand Up @@ -160,16 +132,12 @@ private static boolean applySubsystemProfiling(SystemConfigurationType systemCon
ProfilingDataManager.getInstance().configureProfilingDataManager(profiledSubsystems, dumpInterval, subSystemProfiling, performanceProfiling, requestProfiling);
return false;
}
} //applySubsystemProfiling
}

/*
* Check value of Boolean in xsd
* */
private static boolean checkXsdBooleanValue(Boolean value){
if(value == null || !value)
return false;
else
return true;
} //checkXsdBooleanValue

} //ProfilingConfigurationManager
}
}
Expand Up @@ -17,8 +17,6 @@

import java.util.concurrent.atomic.AtomicInteger;

import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
Expand Down Expand Up @@ -106,7 +104,7 @@ public Object proccessWorkflowNdc(ProceedingJoinPoint pjp) throws Throwable {

// This is made public to use in testing
public static String swapSubsystemMark(String subsystemName) {
String prev = (String) MDC.get(MDC_SUBSYSTEM_KEY);
String prev = MDC.get(MDC_SUBSYSTEM_KEY);
if (subsystemName == null) {
MDC.remove(MDC_SUBSYSTEM_KEY);
} else {
Expand Down

0 comments on commit 71c16b0

Please sign in to comment.