Skip to content

Commit

Permalink
Merge branch 'post-3.7-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Feb 23, 2018
2 parents 11d5abb + 9d3c2b2 commit a1ce5a3
Show file tree
Hide file tree
Showing 62 changed files with 2,264 additions and 398 deletions.
Expand Up @@ -26,11 +26,13 @@
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.*;
import com.evolveum.prism.xml.ns._public.types_3.EvaluationTimeType;

import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.LocaleUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
Expand Down Expand Up @@ -711,4 +713,29 @@ public static void addIncludeOptionsForExportOrView(Collection<SelectorOptions<G
GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
}
}

public static boolean isEnableExperimentalFeature(PageBase pageBase) {
Task task = pageBase.createSimpleTask("Load admin gui config");
OperationResult result = task.getResult();

ModelInteractionService mInteractionService = pageBase.getModelInteractionService();

AdminGuiConfigurationType adminGuiConfig = null;
try {
adminGuiConfig = mInteractionService.getAdminGuiConfiguration(task, result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
} catch (Exception e) {
LoggingUtils.logException(LOGGER, "Cannot load admin gui config", e);
result.recordPartialError("Cannot load admin gui config. Reason: " + e.getLocalizedMessage());

}

if (adminGuiConfig == null) {
return false;
}

return BooleanUtils.isTrue(adminGuiConfig.isEnableExperimentalFeatures());

}
}
Expand Up @@ -23,6 +23,8 @@

import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.util.logging.Trace;
Expand Down Expand Up @@ -80,7 +82,12 @@ private void initLayout() {
}

private List<ItemPath> getVisibleContainers() {
return Arrays.asList(ItemPath.EMPTY_PATH, new ItemPath(AbstractRoleType.F_DATA_PROTECTION), SchemaConstants.PATH_ACTIVATION, SchemaConstants.PATH_PASSWORD);
List<ItemPath> paths = new ArrayList<>();
paths.addAll(Arrays.asList(ItemPath.EMPTY_PATH, SchemaConstants.PATH_ACTIVATION, SchemaConstants.PATH_PASSWORD));
if (WebModelServiceUtils.isEnableExperimentalFeature(getPageBase())) {
paths.add(new ItemPath(AbstractRoleType.F_DATA_PROTECTION));
}
return paths;
}


Expand Down
Expand Up @@ -303,40 +303,44 @@ public String getCount() {
});

authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_ASSIGNMENTS_URL);
tabs.add(
new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.dataProtection"), authorization) {

if (WebModelServiceUtils.isEnableExperimentalFeature(parentPage)) {
tabs.add(new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.dataProtection"), authorization) {

private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;

@Override
public WebMarkupContainer createPanel(String panelId) {
return createFocusDataProtectionTabPanel(panelId, parentPage);
}
@Override
public WebMarkupContainer createPanel(String panelId) {
return createFocusDataProtectionTabPanel(panelId, parentPage);
}

@Override
public String getCount() {
PrismObject<F> focus = getObjectModel().getObject().getObject();
List<AssignmentType> assignments = focus.asObjectable().getAssignment();
int count = 0;
for (AssignmentType assignment : assignments) {
if (assignment.getTargetRef() == null) {
continue;
}
if (QNameUtil.match(assignment.getTargetRef().getType(), OrgType.COMPLEX_TYPE)) {
Task task = parentPage.createSimpleTask("load data protection obejcts");
PrismObject<OrgType> org = WebModelServiceUtils.loadObject(assignment.getTargetRef(), parentPage, task, task.getResult());

if (org != null) {
if (org.asObjectable().getOrgType().contains("access")) {
count++;
}
@Override
public String getCount() {
PrismObject<F> focus = getObjectModel().getObject().getObject();
List<AssignmentType> assignments = focus.asObjectable().getAssignment();
int count = 0;
for (AssignmentType assignment : assignments) {
if (assignment.getTargetRef() == null) {
continue;
}
if (QNameUtil.match(assignment.getTargetRef().getType(), OrgType.COMPLEX_TYPE)) {
Task task = parentPage.createSimpleTask("load data protection obejcts");
PrismObject<OrgType> org = WebModelServiceUtils.loadObject(assignment.getTargetRef(), parentPage,
task, task.getResult());

if (org != null) {
if (org.asObjectable().getOrgType().contains("access")) {
count++;
}
}
}

return String.valueOf(count);
}
});

return String.valueOf(count);
}
});
}


authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_TASKS_URL);
tabs.add(
Expand Down
Expand Up @@ -19,6 +19,7 @@
import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
Expand Down
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~ 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.
-->

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>
<div class="row">
<div class="col-md-6">
<h3><wicket:message key="PageInternals.title.cache"/></h3>

<div class="main-button-bar">
<a class="btn btn-primary" wicket:id="clearCaches"/>
</div>

</div>
</div>
</wicket:panel>
</body>
</html>
@@ -0,0 +1,36 @@
package com.evolveum.midpoint.web.page.admin.configuration;

import org.apache.wicket.ajax.AjaxRequestTarget;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.web.component.AjaxButton;

public class InternalsCachePanel extends BasePanel<Void>{

private static final long serialVersionUID = 1L;

private static final String ID_CLEAR_CACHES_BUTTON = "clearCaches";

public InternalsCachePanel(String id) {
super(id);
}

@Override
protected void onInitialize() {
super.onInitialize();

AjaxButton clearCustomFunctionCache = new AjaxButton(ID_CLEAR_CACHES_BUTTON, createStringResource("InternalsCachePanel.button.clearCaches")) {

private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
getPageBase().getModelInteractionService().clearCaches();
}
};

add(clearCustomFunctionCache);
}


}
Expand Up @@ -135,6 +135,16 @@ public WebMarkupContainer getPanel(String panelId) {
}
});

tabs.add(new AbstractTab(createStringResource("PageInternals.tab.cache")) {

private static final long serialVersionUID = 1L;

@Override
public WebMarkupContainer getPanel(String panelId) {
return initCachePanel(panelId);
}
});

TabbedPanel<ITab> tabPannel = new TabbedPanel<>(ID_TAB_PANEL, tabs);
add(tabPannel);

Expand All @@ -157,7 +167,11 @@ private WebMarkupContainer initTraces(String panelId) {
}

private WebMarkupContainer initCounters(String panelId) {
return new InternalsCountersPanel(panelId);
return new InternalsCountersPanel(panelId);
}

private WebMarkupContainer initCachePanel(String panelId) {
return new InternalsCachePanel(panelId);
}


Expand Down
Expand Up @@ -16,11 +16,13 @@

package com.evolveum.midpoint.web.security;

import org.apache.commons.lang.StringUtils;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.security.web.access.AccessDeniedHandlerImpl;
import org.springframework.security.web.csrf.MissingCsrfTokenException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -55,6 +57,20 @@ private boolean isLoginLogoutRequest(HttpServletRequest req) {
}

String uri = req.getRequestURI();
return "/j_spring_security_logout".equals(uri) || "/spring_security_login".equals(uri);
return createUri(req, "/j_spring_security_logout").equals(uri)
|| createUri(req, "/spring_security_login").equals(uri);
}

private String createUri(HttpServletRequest req, String uri) {
StringBuilder sb = new StringBuilder();

ServletContext ctx = req.getServletContext();
String ctxPath = ctx.getContextPath();
if (StringUtils.isNotEmpty(ctxPath)) {
sb.append(ctxPath);
}
sb.append(uri);

return sb.toString();
}
}
Expand Up @@ -19,6 +19,7 @@
import com.evolveum.midpoint.common.LocalizationService;
import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.MidPointApplicationConfiguration;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.model.api.*;
Expand Down Expand Up @@ -279,6 +280,12 @@ public void updateAjaxAttributes(AbstractDefaultAjaxBehavior behavior, AjaxReque
//descriptor loader, used for customization
new DescriptorLoader().loadData(this);

Map<String, MidPointApplicationConfiguration> map =
applicationContext.getBeansOfType(MidPointApplicationConfiguration.class);
if (map != null) {
map.forEach((key, value) -> value.init(this));
}

// for schrodinger selenide library
initializeSchrodinger();
}
Expand Down
Expand Up @@ -3939,3 +3939,6 @@ CertCampaignStateFilter.REVIEW_STAGE_DONE=Review stage done
CertCampaignStateFilter.IN_REMEDIATION=In remediation
CertCampaignStateFilter.CLOSED=Closed
pageAdminFocus.dataProtection=Data protection
PageInternals.title.cache=Caches
PageInternals.tab.cache=Cache management
InternalsCachePanel.button.clearCaches=Clear caches
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017 Evolveum
* Copyright (c) 2017-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 All @@ -24,7 +24,9 @@ public enum InternalCounters {

RESOURCE_SCHEMA_FETCH_COUNT("resourceSchemaFetchCount", "resource schema fetch count", InternalOperationClasses.REPOSITORY_OPERATIONS),

RESOURCE_REPOSITORY_READ_COUNT("resourceRepositoryReadCount", "resource repository read count", null),
RESOURCE_REPOSITORY_READ_COUNT("resourceRepositoryReadCount", "resource repository read count", InternalOperationClasses.REPOSITORY_OPERATIONS),

RESOURCE_REPOSITORY_MODIFY_COUNT("resourceRepositoryModifyCount", "resource repository modify count", InternalOperationClasses.REPOSITORY_OPERATIONS),

CONNECTOR_INSTANCE_INITIALIZATION_COUNT("connectorInstanceInitializationCount", "connector instance initialization count", InternalOperationClasses.CONNECTOR_OPERATIONS),

Expand Down
Expand Up @@ -65,7 +65,7 @@ public static void recordCount(InternalCounters counter) {
long count = recordCountInternal(counter);
InternalOperationClasses operationClass = counter.getOperationClass();
if (operationClass != null && isTrace(operationClass)) {
traceOperation(operationClass, count);
traceOperation(counter, operationClass, count);
}
}

Expand Down Expand Up @@ -100,12 +100,12 @@ public static void setTrace(InternalOperationClasses operationClass, boolean val
traceMap.put(operationClass, val);
}

private static void traceOperation(InternalOperationClasses operationClass, long counter) {
traceOperation(operationClass.getKey(), null, counter, false);
private static void traceOperation(InternalCounters counter, InternalOperationClasses operationClass, long count) {
traceOperation(counter.getKey() + "["+ operationClass.getKey() +"]", null, count, false);
}

private static void traceOperation(String opName, Supplier<String> paramsSupplier, long counter, boolean traceAndDebug) {
LOGGER.info("MONITOR {} ({})", opName, counter);
private static void traceOperation(String opName, Supplier<String> paramsSupplier, long count, boolean traceAndDebug) {
LOGGER.info("MONITOR {} ({})", opName, count);
if (LOGGER.isDebugEnabled()) {
StackTraceElement[] fullStack = Thread.currentThread().getStackTrace();
String immediateClass = null;
Expand All @@ -129,9 +129,9 @@ private static void traceOperation(String opName, Supplier<String> paramsSupplie
params = paramsSupplier.get();
}
if (traceAndDebug) {
LOGGER.debug("MONITOR {}({}) ({}): {} {}", opName, params, counter, immediateClass, immediateMethod);
LOGGER.debug("MONITOR {}({}) ({}): {} {}", opName, params, count, immediateClass, immediateMethod);
}
LOGGER.trace("MONITOR {}({}) ({}):\n{}", opName, params, counter, sb);
LOGGER.trace("MONITOR {}({}) ({}):\n{}", opName, params, count, sb);
}
}

Expand Down
Expand Up @@ -544,7 +544,7 @@
<xsd:sequence>
<xsd:element name="resetMethod" type="xsd:string" minOccurs="0">
</xsd:element>
<xsd:element name="password" type="xsd:string" minOccurs="0">
<xsd:element name="userEntry" type="xsd:string" minOccurs="0">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
Expand Down

0 comments on commit a1ce5a3

Please sign in to comment.