Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/new-system-configuration-page'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Aug 10, 2018
2 parents 1b9943e + f1d459a commit c94c05f
Show file tree
Hide file tree
Showing 92 changed files with 6,103 additions and 1,173 deletions.
Expand Up @@ -160,5 +160,7 @@ public class GuiStyleConstants {
public static final String CLASS_POLICY_RULES_ICON_COLORED = "fa fa-balance-scale"; //TODO

public static final String CLASS_VALUE_POLICY_ICON = "fa fa-asterisk";


public static final String CLASS_SYSTEM_CONFIGURATION_ICON = "fa fa-cog";
public static final String CLASS_SYSTEM_CONFIGURATION_ICON_COLORED = CLASS_SYSTEM_CONFIGURATION_ICON + " object-shadow-color";
}
Expand Up @@ -26,20 +26,28 @@
import org.apache.wicket.model.PropertyModel;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.gui.impl.page.admin.configuration.component.ObjectPolicyConfigurationTabPanel;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;

public class DisplayNamePanel<C extends Containerable> extends BasePanel<C>{

private static final long serialVersionUID = 1L;

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

private final static String ID_TYPE_IMAGE = "typeImage";
private final static String ID_DISPLAY_NAME = "displayName";
Expand All @@ -59,7 +67,7 @@ private void initLayout() {
typeImage.setOutputMarkupId(true);
typeImage.add(AttributeModifier.append("class", createImageModel()));
add(typeImage);

Label name = new Label(ID_DISPLAY_NAME, createHeaderModel());
name.setOutputMarkupId(true);
add(name);
Expand All @@ -79,8 +87,19 @@ private void initLayout() {
kindIntent.setOutputMarkupId(true);
kindIntent.add(new VisibleBehaviour(() -> isKindIntentVisible(kindIntentLabelModel)));
add(kindIntent);

add(new Label(ID_DESCRIPTION, new PropertyModel<String>(getModel(), ObjectType.F_DESCRIPTION.getLocalPart())));

if(getModel().getObject().asPrismContainerValue().contains(ObjectType.F_DESCRIPTION)) {
add(new Label(ID_DESCRIPTION, new PropertyModel<String>(getModel(), ObjectType.F_DESCRIPTION.getLocalPart())));
} else {
add(new Label(ID_DESCRIPTION, Model.of("")));
}
}

private boolean isObjectPolicyConfigurationType() {
if(QNameUtil.match(ObjectPolicyConfigurationType.COMPLEX_TYPE, getModelObject().asPrismContainerValue().getComplexTypeDefinition().getTypeName())) {
return true;
}
return false;
}

private String createImageModel() {
Expand All @@ -103,6 +122,17 @@ private IModel<String> createHeaderModel() {
if (ObjectType.class.isAssignableFrom(getModelObject().getClass())) {
return Model.of(WebComponentUtil.getEffectiveName((ObjectType) getModelObject(), AbstractRoleType.F_DISPLAY_NAME));
}
if (isObjectPolicyConfigurationType()) {
QName typeValue = WebComponentUtil.getValue(getModel().getObject().asPrismContainerValue(), ObjectPolicyConfigurationType.F_TYPE, QName.class);
ObjectReferenceType objectTemplate = ((ObjectPolicyConfigurationType)getModel().getObject()).getObjectTemplateRef();
if(objectTemplate == null){
return Model.of("");
}
String objectTemplateNameValue = objectTemplate.getTargetName().toString();
StringBuilder sb = new StringBuilder();
sb.append(typeValue.getLocalPart()).append(" - ").append(objectTemplateNameValue);
return Model.of(sb.toString());
}
PrismProperty<String> name = getModelObject().asPrismContainerValue().findProperty(ObjectType.F_NAME);
if (name == null || name.isEmpty()) {
return Model.of("");
Expand Down
Expand Up @@ -24,6 +24,8 @@
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.IAutoCompleteRenderer;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.StringAutoCompleteRenderer;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.time.Duration;
Expand All @@ -42,14 +44,18 @@ public abstract class AutoCompleteTextPanel<T> extends AbstractAutoCompletePanel
private static final long serialVersionUID = 1L;

private static final String ID_INPUT = "input";

public AutoCompleteTextPanel(String id, final IModel<T> model, Class<T> type) {
super(id);

public AutoCompleteTextPanel(String id, final IModel<T> model, Class<T> type) {
this(id, model, type, StringAutoCompleteRenderer.INSTANCE);
}

public AutoCompleteTextPanel(String id, final IModel<T> model, Class<T> type, IAutoCompleteRenderer<T> renderer) {
super(id);

AutoCompleteSettings autoCompleteSettings = createAutoCompleteSettings();

// this has to be copied because the AutoCompleteTextField dies if renderer=null
final AutoCompleteTextField<T> input = new AutoCompleteTextField<T>(ID_INPUT, model, type, autoCompleteSettings) {
final AutoCompleteTextField<T> input = new AutoCompleteTextField<T>(ID_INPUT, model, type, renderer, autoCompleteSettings) {
private static final long serialVersionUID = 1L;

@Override
Expand Down
Expand Up @@ -70,7 +70,7 @@ public String getObject() {
}
});
}

public abstract boolean isOn();

}
Expand Up @@ -1501,7 +1501,40 @@ private void createConfigurationMenu(SideBarMenuItem item) {
PageDebugView.class, null, createVisibleDisabledBehaviorForEditMenu(PageDebugView.class));
debugs.getItems().add(menu);

addMainMenuItem(item, "fa fa-cog", "PageAdmin.menu.top.configuration.basic.new", PageSystemConfigurationNew.class);
MainMenuItem systemItemNew = addMainMenuItem(item, "fa fa-cog", "PageAdmin.menu.top.configuration.basic.new", PageSystemConfigurationNew.class);

addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.basic",
PageSystemConfigurationNew.CONFIGURATION_TAB_BASIC);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.objectPolicy",
PageSystemConfigurationNew.CONFIGURATION_TAB_OBJECT_POLICY);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.globalPolicyRule",
PageSystemConfigurationNew.CONFIGURATION_TAB_GLOBAL_POLICY_RULE);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.globalAccountSynchronization",
PageSystemConfigurationNew.CONFIGURATION_TAB_GLOBAL_ACCOUNT_SYNCHRONIZATION);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.cleanupPolicy",
PageSystemConfigurationNew.CONFIGURATION_TAB_CLEANUP_POLICY);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.notifications",
PageSystemConfigurationNew.CONFIGURATION_TAB_NOTIFICATION);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.logging",
PageSystemConfigurationNew.CONFIGURATION_TAB_LOGGING);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.profiling",
PageSystemConfigurationNew.CONFIGURATION_TAB_PROFILING);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.adminGui",
PageSystemConfigurationNew.CONFIGURATION_TAB_ADMIN_GUI);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.workflow",
PageSystemConfigurationNew.CONFIGURATION_TAB_WORKFLOW);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.roleManagement",
PageSystemConfigurationNew.CONFIGURATION_TAB_ROLE_MANAGEMENT);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.internals",
PageSystemConfigurationNew.CONFIGURATION_TAB_INTERNALS);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.deploymentInformation",
PageSystemConfigurationNew.CONFIGURATION_TAB_DEPLOYMENT_INFORMATION);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.accessCertification",
PageSystemConfigurationNew.CONFIGURATION_TAB_ACCESS_CERTIFICATION);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.infrastructure",
PageSystemConfigurationNew.CONFIGURATION_TAB_INFRASTRUCTURE);
addSystemMenuItemNew(systemItemNew, "PageAdmin.menu.top.configuration.fullTextSearch",
PageSystemConfigurationNew.CONFIGURATION_TAB_FULL_TEXT_SEARCH);

MainMenuItem systemItem = addMainMenuItem(item, "fa fa-cog", "PageAdmin.menu.top.configuration.basic", null);

Expand Down Expand Up @@ -1543,6 +1576,24 @@ public boolean isMenuActive(WebPage page) {
};
mainItem.getItems().add(menu);
}

private void addSystemMenuItemNew(MainMenuItem mainItem, String key, int tabIndex) {
PageParameters params = new PageParameters();
params.add(PageSystemConfigurationNew.SELECTED_TAB_INDEX, tabIndex);
MenuItem menu = new MenuItem(createStringResource(key), PageSystemConfigurationNew.class, params, null) {

@Override
public boolean isMenuActive(WebPage page) {
if (!PageSystemConfigurationNew.class.equals(page.getClass())) {
return false;
}

int index = getSelectedTabForConfiguration(page);
return tabIndex == index ? true : false;
}
};
mainItem.getItems().add(menu);
}

private MainMenuItem addMainMenuItem(SideBarMenuItem item, String icon, String key, Class<? extends PageBase> page) {
MainMenuItem mainItem = new MainMenuItem(icon, createStringResource(key), page);
Expand Down
Expand Up @@ -99,6 +99,7 @@
import com.evolveum.midpoint.gui.api.model.NonEmptyModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.DefaultReferencableImpl;
import com.evolveum.midpoint.prism.Objectable;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerValue;
Expand Down Expand Up @@ -275,6 +276,21 @@ public static String getReferencedObjectDisplayNamesAndNames(List<ObjectReferenc
.map(ref -> emptyIfNull(getDisplayNameAndName(ref)) + (showTypes ? (" (" + emptyIfNull(getTypeLocalized(ref)) + ")") : ""))
.collect(Collectors.joining(", "));
}

public static String getReferencedObjectDisplayNamesAndNames(DefaultReferencableImpl ref, boolean showTypes) {
String name = ref.getTargetName() == null ? "" : ref.getTargetName().getOrig();
StringBuilder sb = new StringBuilder(name);
if(showTypes) {
sb.append(" (");
ObjectTypes type = ObjectTypes.getObjectTypeFromTypeQName(ref.getType());
ObjectTypeGuiDescriptor descriptor = ObjectTypeGuiDescriptor.getDescriptor(type);
if (descriptor == null) {
return null;
}
sb.append(emptyIfNull(createStringResourceStatic(null, descriptor.getLocalizationKey()).getString())).append(")");
}
return sb.toString();
}

public static void addAjaxOnUpdateBehavior(WebMarkupContainer container) {
container.visitChildren(new IVisitor<Component, Object>() {
Expand Down Expand Up @@ -1463,6 +1479,10 @@ public static <T extends ObjectType> String createDefaultColoredIcon(QName objec
return GuiStyleConstants.CLASS_OBJECT_SHADOW_ICON_COLORED;
} else if (QNameUtil.match(PolicyRuleType.COMPLEX_TYPE, objectType)) {
return GuiStyleConstants.CLASS_POLICY_RULES_ICON_COLORED;
} else if (QNameUtil.match(ObjectPolicyConfigurationType.COMPLEX_TYPE, objectType)) {
return GuiStyleConstants.CLASS_SYSTEM_CONFIGURATION_ICON_COLORED;
} else if (QNameUtil.match(GlobalPolicyRuleType.COMPLEX_TYPE, objectType)) {
return GuiStyleConstants.CLASS_SYSTEM_CONFIGURATION_ICON_COLORED;
} else {
return "";
}
Expand Down Expand Up @@ -1494,6 +1514,8 @@ public static <T extends ObjectType> String createDefaultBlackIcon(QName objectT
return GuiStyleConstants.CLASS_OBJECT_SHADOW_ICON;
} else if (QNameUtil.match(PolicyRuleType.COMPLEX_TYPE, objectType)) {
return GuiStyleConstants.CLASS_POLICY_RULES_ICON;
} else if (QNameUtil.match(SystemConfigurationType.COMPLEX_TYPE, objectType)) {
return GuiStyleConstants.CLASS_SYSTEM_CONFIGURATION_ICON;
} else {
return "";
}
Expand Down
Expand Up @@ -26,6 +26,10 @@
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.component.prism.ContainerStatus;
import com.evolveum.midpoint.web.component.prism.ObjectWrapper;
import com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory;
import com.evolveum.midpoint.web.page.error.PageError;
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 Expand Up @@ -81,6 +85,7 @@ public class WebModelServiceUtils {
private static final String OPERATION_COUNT_OBJECT = DOT_CLASS + "countObjects";
private static final String OPERATION_ASSUME_POWER_OF_ATTORNEY = DOT_CLASS + "assumePowerOfAttorney";
private static final String OPERATION_DROP_POWER_OF_ATTORNEY = DOT_CLASS + "dropPowerOfAttorney";
private static final String OPERATION_GET_SYSTEM_CONFIG = DOT_CLASS + "getSystemConfiguration";

public static String resolveReferenceName(ObjectReferenceType ref, PageBase page) {
Task task = page.createSimpleTask(WebModelServiceUtils.class.getName() + ".resolveReferenceName");
Expand Down Expand Up @@ -798,4 +803,36 @@ public static boolean isPostAuthenticationEnabled(TaskManager taskManager, Model
}
return false;
}

public static ObjectWrapper<SystemConfigurationType> loadSystemConfigurationAsObjectWrapper(PageBase pageBase) {
Task task = pageBase.createSimpleTask(OPERATION_GET_SYSTEM_CONFIG);
OperationResult result = new OperationResult(OPERATION_GET_SYSTEM_CONFIG);

Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(
GetOperationOptions.createResolve(), SystemConfigurationType.F_DEFAULT_USER_TEMPLATE,
SystemConfigurationType.F_GLOBAL_PASSWORD_POLICY);

ObjectWrapper<SystemConfigurationType> wrapper = null;
try {
PrismObject<SystemConfigurationType> systemConfig = loadObject(
SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), options,
pageBase, task, result);

ObjectWrapperFactory owf = new ObjectWrapperFactory(pageBase);

wrapper = owf.createObjectWrapper("adminPage.systemConfiguration", null, systemConfig, ContainerStatus.MODIFYING, task);

result.recordSuccess();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load system configuration", ex);
result.recordFatalError("Couldn't load system configuration.", ex);
}

if (!WebComponentUtil.isSuccessOrHandledError(result) || wrapper == null) {
pageBase.showResult(result, false);
throw pageBase.getRestartResponseException(PageError.class);
}

return wrapper;
}
}
@@ -0,0 +1,25 @@
<!--
~ 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 wicket:id="displayName"/>
<div class="container-fluid prism-object" wicket:id="basicPanel" />
<div wicket:id="specificContainersPanel" />
</wicket:panel>
</body>
</html>

0 comments on commit c94c05f

Please sign in to comment.