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
KaterynaHonchar committed Dec 10, 2020
2 parents 96741a2 + d6b7692 commit 872707e
Show file tree
Hide file tree
Showing 26 changed files with 606 additions and 251 deletions.
Expand Up @@ -299,9 +299,6 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {

private boolean initialized = false;

// private LoadableModel<Integer> workItemCountModel;
// private LoadableModel<Integer> certWorkItemCountModel;

// No need to store this in the session. Retrieval is cheap.
private transient CompiledGuiProfile compiledGuiProfile;

Expand All @@ -321,9 +318,6 @@ public PageBase(PageParameters parameters) {
MidPointAuthWebSession.getSession().setClientCustomization();

add(new NewWindowNotifyingBehavior());

initializeModel();

}

@Override
Expand All @@ -344,58 +338,6 @@ protected void onConfigure() {
createBreadcrumb();
}

private void initializeModel() {
// workItemCountModel = new LoadableModel<Integer>() {
// private static final long serialVersionUID = 1L;
//
// @Override
// protected Integer load() {
// try {
// Task task = createSimpleTask(OPERATION_LOAD_WORK_ITEM_COUNT);
// S_FilterEntryOrEmpty q = getPrismContext().queryFor(CaseWorkItemType.class);
// ObjectQuery query = QueryUtils.filterForAssignees(q, getPrincipal(),
// OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS, getRelationRegistry())
// .and()
// .item(CaseWorkItemType.F_CLOSE_TIMESTAMP)
// .isNull()
// .build();
// return getModelService().countContainers(CaseWorkItemType.class, query, null, task, task.getResult());
// } catch (Exception e) {
// LoggingUtils.logExceptionAsWarning(LOGGER, "Couldn't load work item count", e);
// return null;
// }
// }
// };
// certWorkItemCountModel = new LoadableModel<Integer>() {
// private static final long serialVersionUID = 1L;
//
// @Override
// protected Integer load() {
// try {
// AccessCertificationService acs = getCertificationService();
// Task task = createSimpleTask(OPERATION_LOAD_CERT_WORK_ITEM_COUNT);
// OperationResult result = task.getResult();
// return acs.countOpenWorkItems(getPrismContext().queryFactory().createQuery(), true, null, task, result);
// } catch (Exception e) {
// LoggingUtils.logExceptionAsWarning(LOGGER, "Couldn't load certification work item count", e);
// return null;
// }
// }
// };
}

// public void resetWorkItemCountModel() {
// if (workItemCountModel != null) {
// workItemCountModel.reset();
// }
// }
//
// public void resetCertWorkItemCountModel() {
// if (certWorkItemCountModel != null) {
// certWorkItemCountModel.reset();
// }
// }

protected void createBreadcrumb() {
BreadcrumbPageClass bc = new BreadcrumbPageClass(new IModel<String>() {
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -609,17 +551,7 @@ public <O extends ObjectType> boolean isAuthorized(ModelAuthorizationAction acti
}
}

// // TODO reconsider this method
// public boolean isFullyAuthorized() {
// try {
// return isAuthorized(AuthorizationConstants.AUTZ_ALL_URL);
// } catch (Throwable t) {
// LoggingUtils.logUnexpectedException(LOGGER, "Couldn't check the authorization", t);
// return false;
// }
// }

public <O extends ObjectType, T extends ObjectType> boolean isAuthorized(String operationUrl) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
public boolean isAuthorized(String operationUrl) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
return isAuthorized(operationUrl, null, null, null, null, null);
}

Expand Down Expand Up @@ -718,27 +650,6 @@ public MidpointConfiguration getMidpointConfiguration() {
return midpointConfiguration;
}

// @Override
// public void renderHead(IHeaderResponse response) {
// super.renderHead(response);
//
// String skinCssString = CLASS_DEFAULT_SKIN;
// DeploymentInformationType info = MidPointApplication.get().getDeploymentInfo();
// if (info != null && StringUtils.isNotEmpty(info.getSkin())) {
// skinCssString = info.getSkin();
// }
//
// String skinCssPath = String.format("../../../../../../webjars/AdminLTE/2.4.18/dist/css/skins/%s.min.css", skinCssString);
// response.render(CssHeaderItem.forReference(
// new CssResourceReference(
// PageBase.class, skinCssPath)
// )
// );
//
// // this attaches jquery.js as first header item, which is used in our scripts.
// CoreLibrariesContributor.contribute(getApplication(), response);
// }

@Override
protected void onBeforeRender() {
super.onBeforeRender();
Expand All @@ -760,7 +671,6 @@ private void initHeaderLayout(WebMarkupContainer container) {
container.add(rightMenu);

LocalePanel locale = new LocalePanel(ID_LOCALE);
// locale.add(createUserStatusBehaviour(false));
container.add(locale);
}

Expand Down Expand Up @@ -1036,15 +946,6 @@ public String getObject() {

initDebugBarLayout();

// SideBarMenuPanel sidebarMenu = new SideBarMenuPanel(ID_SIDEBAR_MENU, new LoadableModel<List<SideBarMenuItem>>(false) {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// protected List<SideBarMenuItem> load() {
// return createMenuItems();
// }
// });
LeftMenuPanel sidebarMenu = new LeftMenuPanel(ID_SIDEBAR_MENU);
sidebarMenu.add(createUserStatusBehaviour());
add(sidebarMenu);
Expand Down Expand Up @@ -1730,12 +1631,8 @@ public void redirectBackToBreadcrumb(Breadcrumb breadcrumb) {
}

protected void setTimeZone(PageBase page) {
// PrismObject<? extends FocusType> focus = loadFocusSelf();
String timeZone = null;
GuiProfiledPrincipal principal = SecurityUtils.getPrincipalUser();
// if (focus != null && focus.asObjectable().getTimezone() != null) {
// timeZone = focus.asObjectable().getTimezone();
// } else
if (principal != null && principal.getCompiledGuiProfile() != null) {
timeZone = principal.getCompiledGuiProfile().getDefaultTimezone();
}
Expand Down
Expand Up @@ -8,6 +8,9 @@

import javax.annotation.PostConstruct;

import com.evolveum.midpoint.gui.api.Validatable;

import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.markup.html.panel.Panel;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -41,10 +44,20 @@ protected Panel getPanel(PrismPropertyPanelContext<SearchFilterType> panelCtx) {
return new SearchFilterConfigurationPanel(
panelCtx.getComponentId(), panelCtx.getRealValueModel(), containerWrapper);
}
return new AceEditorPanel(
AceEditorPanel panel = new AceEditorPanel(
panelCtx.getComponentId(),
null,
new SearchFilterTypeModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()),
10);
return panel;
}

@Override
public void configure(PrismPropertyPanelContext<SearchFilterType> panelCtx, org.apache.wicket.Component component) {
if (!(component instanceof AceEditorPanel)) {
super.configure(panelCtx, component);
return;
}
panelCtx.getFeedback().setFilter(new ComponentFeedbackMessageFilter(((AceEditorPanel) component).getEditor()));
}
}
Expand Up @@ -13,9 +13,13 @@
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.Session;
import org.apache.wicket.model.IComponentAssignedModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.IWrapModel;

public class SearchFilterTypeModel implements IModel<String> {
public class SearchFilterTypeModel implements IComponentAssignedModel<String> {

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

Expand Down Expand Up @@ -45,11 +49,9 @@ public String getObject() {

return pageBase.getPrismContext().xmlSerializer().serializeRealValue(value);
} catch (SchemaException e) {
// TODO handle!!!!
LoggingUtils.logUnexpectedException(LOGGER, "Cannot serialize filter", e);
// getSession().error("Cannot serialize filter");
throw new IllegalStateException("Cannot serialize filter: " + e.getMessage() + ". For more details, please, see midpoint log");
}
return null;
}

@Override
Expand All @@ -62,10 +64,47 @@ public void setObject(String object) {
SearchFilterType filter = pageBase.getPrismContext().parserFor(object).parseRealValue(SearchFilterType.class);
baseModel.setObject(filter);
} catch (SchemaException e) {
// TODO handle!!!!
LoggingUtils.logUnexpectedException(LOGGER, "Cannot parse filter", e);
// getSession().error("Cannot parse filter");
throw new IllegalStateException("Cannot parse filter: " + e.getMessage() + ". For more details, please, see midpoint log");
}

}

@Override
public IWrapModel<String> wrapOnAssignment(Component component) {
return new SearchFilterWrapperModel(component);
}

class SearchFilterWrapperModel implements IWrapModel<String> {

private Component component;

public SearchFilterWrapperModel(Component component) {
this.component = component;
}

@Override
public IModel<?> getWrappedModel() {
return SearchFilterTypeModel.this;
}

@Override
public String getObject() {
try {
return SearchFilterTypeModel.this.getObject();
} catch (Throwable e) {
component.error(e.getMessage());
}
return null;
}

@Override
public void setObject(String object) {
try {
SearchFilterTypeModel.this.setObject(object);
} catch (Throwable e) {
component.error(e.getMessage());
}
}
}
}
Expand Up @@ -72,7 +72,10 @@ public abstract class PrismValueWrapperImpl<T> implements PrismValueWrapper<T> {

if (parent.isSingleValue()) {
if (newValue.isEmpty()) {
delta.addValueToDelete(oldValue.clone());
// if old value is empty, nothing to do.
if (!oldValue.isEmpty()) {
delta.addValueToDelete(oldValue.clone());
}
} else {
delta.addValueToReplace(getNewValueWithMetadataApplied());
}
Expand Down
Expand Up @@ -6,9 +6,10 @@
*/
package com.evolveum.midpoint.gui;

import java.io.File;

import org.javasimon.Split;
import org.javasimon.Stopwatch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
Expand All @@ -18,12 +19,11 @@
import com.evolveum.midpoint.gui.impl.component.menu.LeftMenuPanel;
import com.evolveum.midpoint.gui.test.TestMidPointSpringApplication;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.repo.sql.testing.TestQueryListener;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.statistics.AbstractStatisticsPrinter;
import com.evolveum.midpoint.schema.statistics.OperationsPerformanceInformationUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.tools.testng.PerformanceTestMixin;
import com.evolveum.midpoint.tools.testng.PerformanceTestMethodMixin;
import com.evolveum.midpoint.util.statistics.OperationsPerformanceMonitor;
import com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest;
import com.evolveum.midpoint.web.page.admin.home.PageDashboardInfo;
Expand All @@ -34,27 +34,21 @@
import com.evolveum.midpoint.web.page.self.PageSelfCredentials;
import com.evolveum.midpoint.web.page.self.PageSelfDashboard;
import com.evolveum.midpoint.web.page.self.PageUserSelfProfile;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import java.io.File;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AdminGuiConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationsPerformanceInformationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType;

@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@ActiveProfiles("test")
@SpringBootTest(classes = TestMidPointSpringApplication.class)
public class MidScaleGuiTest extends AbstractInitializedGuiIntegrationTest implements PerformanceTestMixin {
public class MidScaleGuiTest extends AbstractInitializedGuiIntegrationTest implements PerformanceTestMethodMixin {

private static final String TEST_DIR = "./src/test/resources/midScale";

private static final File FILE_ORG_STRUCT = new File(TEST_DIR, "org-struct.xml");
private static final File FILE_USERS = new File(TEST_DIR, "users.xml");

@Autowired TestQueryListener queryListener;

@BeforeMethod
public void reportBeforeTest() {
queryListener.clear();
}

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
Expand All @@ -70,7 +64,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
ItemPath.create(SystemConfigurationType.F_ADMIN_GUI_CONFIGURATION, AdminGuiConfigurationType.F_ENABLE_EXPERIMENTAL_FEATURES),
initTask, initResult, true);


}

@BeforeMethod
Expand Down Expand Up @@ -102,16 +95,14 @@ public void test040PageRequestRole() {
runTestFor(PageAssignmentShoppingCart.class, "requestRole", "Request a role");
}


@Test
public void test110PageDashboard() {
displayTestTitle(getTestName());
runTestFor(PageDashboardInfo.class, "dashboard", "Info Dashboard");
}

private void runTestFor(Class pageToRender, String stopwathName, String stopwatchDescription) {
OperationsPerformanceMonitor.INSTANCE.clearGlobalPerformanceInformation();
Stopwatch stopwatch = stopwatch(stopwathName, stopwatchDescription);
private void runTestFor(Class pageToRender, String stopwatchName, String stopwatchDescription) {
Stopwatch stopwatch = stopwatch(stopwatchName, stopwatchDescription);
for (int i = 0; i < 1; i++) {
try (Split ignored = stopwatch.start()) {
queryListener.start();
Expand All @@ -130,7 +121,6 @@ private void runTestFor(Class pageToRender, String stopwathName, String stopwatc
new AbstractStatisticsPrinter.Options(AbstractStatisticsPrinter.Format.TEXT, AbstractStatisticsPrinter.SortBy.TIME), null, null));
}


@Test
public void test210listUsers() {
logger.info(getTestName());
Expand All @@ -153,7 +143,6 @@ public void test310orgTree() throws Exception {
@Test(enabled = false) // doesn't work because of getPageBase usages
public void test200sidebarMenu() {
logger.info(getTestName());
OperationsPerformanceMonitor.INSTANCE.clearGlobalPerformanceInformation();
Stopwatch stopwatch = stopwatch("sidebar", "sidebar perf");
try (Split ignored = stopwatch.start()) {
queryListener.start();
Expand Down
Expand Up @@ -27,10 +27,10 @@
import com.evolveum.midpoint.prism.PrismParser;
import com.evolveum.midpoint.prism.PrismSerializer;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.tools.testng.PerformanceTestMixin;
import com.evolveum.midpoint.tools.testng.PerformanceTestClassMixin;
import com.evolveum.midpoint.util.exception.SchemaException;

public class PerfTestCodecObject extends AbstractSchemaTest implements PerformanceTestMixin {
public class PerfTestCodecObject extends AbstractSchemaTest implements PerformanceTestClassMixin {

static final List<String> FORMAT = ImmutableList.of("xml", "json", "yaml");
static final List<String> NS = ImmutableList.of("no-ns", "ns");
Expand Down

0 comments on commit 872707e

Please sign in to comment.