Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed May 26, 2017
2 parents e9f7f33 + 3766e28 commit 1e0cd21
Show file tree
Hide file tree
Showing 16 changed files with 306 additions and 167 deletions.
Expand Up @@ -19,6 +19,14 @@
import java.util.ArrayList;
import java.util.List;

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.web.component.prism.ContainerStatus;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.page.admin.users.PageUser;
import com.evolveum.midpoint.web.page.self.PageSelfProfile;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -62,22 +70,22 @@ public class PasswordPanel extends InputPanel {
private boolean passwordInputVisble;

public PasswordPanel(String id, IModel<ProtectedStringType> model) {
this(id, model, false, false);
this(id, model, false);
}

public PasswordPanel(String id, IModel<ProtectedStringType> model, boolean isReadOnly, boolean showRemoveButton) {
public PasswordPanel(String id, IModel<ProtectedStringType> model, boolean isReadOnly) {
super(id);
this.passwordInputVisble = model.getObject() == null;
initLayout(model, isReadOnly, showRemoveButton);
initLayout(model, isReadOnly);
}

public PasswordPanel(String id, IModel<ProtectedStringType> model, boolean isReadOnly, boolean isInputVisible, boolean showRemoveButton) {
public PasswordPanel(String id, IModel<ProtectedStringType> model, boolean isReadOnly, boolean isInputVisible) {
super(id);
this.passwordInputVisble = isInputVisible;
initLayout(model, isReadOnly, showRemoveButton);
initLayout(model, isReadOnly);
}

private void initLayout(final IModel<ProtectedStringType> model, final boolean isReadOnly, boolean showRemoveButton) {
private void initLayout(final IModel<ProtectedStringType> model, final boolean isReadOnly) {
setOutputMarkupId(true);
final WebMarkupContainer inputContainer = new WebMarkupContainer(ID_INPUT_CONTAINER) {
@Override
Expand Down Expand Up @@ -165,7 +173,18 @@ public void onClick(AjaxRequestTarget target) {

@Override
public boolean isVisible() {
return showRemoveButton;
PageBase pageBase = (PageBase)getPage();
if (pageBase == null){
return false;
}
if (pageBase instanceof PageSelfProfile){
return false;
}
if (pageBase instanceof PageUser
&& model.getObject() != null && !model.getObject().isEmpty()){
return true;
}
return false;
}
});
removePassword.setBody(new ResourceModel("passwordPanel.passwordRemove"));
Expand Down
Expand Up @@ -18,11 +18,7 @@

import java.util.List;

import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.web.component.assignment.MetadataPanel;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.cxf.common.util.StringUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
Expand All @@ -37,10 +33,13 @@
import org.apache.wicket.request.resource.ResourceReference;

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;

import javax.xml.namespace.QName;
import com.evolveum.midpoint.web.component.assignment.MetadataPanel;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

/**
* @author lazyman
Expand Down
Expand Up @@ -440,18 +440,8 @@ private Panel createTypedInputComponent(String id) {
panel = new DatePanel(id, new PropertyModel<XMLGregorianCalendar>(valueWrapperModel, baseExpression));

} else if (ProtectedStringType.COMPLEX_TYPE.equals(valueType)) {
boolean showRemovePasswordButton = true;
if (pageBase instanceof PageUser &&
((PageUser) pageBase).getObjectWrapper().getObject() != null &&
((PageUser) pageBase).getObjectWrapper().getObject().getOid() != null &&
((PageUser) pageBase).getObjectWrapper().getObject().getOid().equals(SecurityUtils.getPrincipalUser().getOid())) {
showRemovePasswordButton = false;
} else if (valueWrapperModel.getObject().getStatus() == ValueStatus.ADDED) {
// it has no sense to show remove button while adding a new value..
showRemovePasswordButton = false;
}
panel = new PasswordPanel(id, new PropertyModel<ProtectedStringType>(valueWrapperModel, baseExpression),
valueWrapperModel.getObject().isReadonly(), showRemovePasswordButton);
valueWrapperModel.getObject().isReadonly());
} else if (DOMUtil.XSD_BOOLEAN.equals(valueType)) {
panel = new TriStateComboPanel(id, new PropertyModel<Boolean>(valueWrapperModel, baseExpression));

Expand Down
Expand Up @@ -19,6 +19,7 @@
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.prism.PrismReferenceValue;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.web.component.DateLabelComponent;
Expand All @@ -34,7 +35,9 @@
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.web.util.TooltipBehavior;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.*;
import org.apache.wicket.markup.html.basic.Label;
Expand Down Expand Up @@ -234,9 +237,29 @@ public void onClick(AjaxRequestTarget target, IModel<WorkItemDto> rowModel) {
WorkItemDto dto = rowModel.getObject();
dispatchToObjectDetailsPage(dto.getTargetRef(), getPageBase(), false);
}

@Override
public void populateItem(Item<ICellPopulator<WorkItemDto>> cellItem, String componentId,
final IModel<WorkItemDto> rowModel) {
super.populateItem(cellItem, componentId, rowModel);
Component c = cellItem.get(componentId);
c.add(new AttributeAppender("title", rowModel.getObject().getTargetRef() != null ?
rowModel.getObject().getTargetRef().asReferenceValue().getObject().asObjectable().getDescription() : ""));
}
};
}

private String getTargetObjectDescription(IModel<WorkItemDto> rowModel){
if (rowModel == null || rowModel.getObject() == null ||
rowModel.getObject().getTargetRef() == null) {
return "";
}
PrismReferenceValue refVal = rowModel.getObject().getTargetRef().asReferenceValue();
return refVal.getObject() != null ?
refVal.getObject().asObjectable().getDescription() : "";

}

public IColumn<WorkItemDto, String> createTypeIconColumn(final boolean object) { // true = object, false = target
return new IconColumn<WorkItemDto>(createStringResource("")) {
@Override
Expand Down
Expand Up @@ -351,8 +351,7 @@ public boolean isVisible() {
private void createPasswordPanel(WebMarkupContainer staticRegistrationForm) {
// ProtectedStringType initialPassword = null;
PasswordPanel password = new PasswordPanel(ID_PASSWORD,
new PropertyModel<ProtectedStringType>(userModel, "credentials.password.value"), false, true,
false);
new PropertyModel<ProtectedStringType>(userModel, "credentials.password.value"), false, true);
password.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
password.getBaseFormComponent().setRequired(true);
staticRegistrationForm.add(password);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -361,7 +361,7 @@ public <T> boolean contains(ResourceAttribute<T> attr) {

public static ResourceAttributeContainer convertFromContainer(PrismContainer<?> origAttrContainer,
ObjectClassComplexTypeDefinition objectClassDefinition) throws SchemaException {
if (origAttrContainer == null) {
if (origAttrContainer == null || origAttrContainer.getValue() == null) {
return null;
}
QName elementName = origAttrContainer.getElementName();
Expand Down
Expand Up @@ -112,32 +112,34 @@ private static void joinForms(ObjectFormsType objectForms, ObjectFormType newFor
}

private static boolean isTheSameObjectForm(ObjectFormType oldForm, ObjectFormType newForm){
if (oldForm.getType().equals(newForm.getType())){
if (!oldForm.getType().equals(newForm.getType())){
return false;
}
if (oldForm.getFormSpecification() == null || newForm.getFormSpecification() == null){
return true;
}
String oldFormPanelUri = oldForm.getFormSpecification().getPanelUri();
String newFormPanelUri = newForm.getFormSpecification().getPanelUri();
if (oldFormPanelUri != null && oldFormPanelUri.equals(newFormPanelUri)){
if (oldForm.isIncludeDefaultForms() != null &&
newForm.isIncludeDefaultForms() != null){
return true;
}
if (oldForm.getFormSpecification() == null && newForm.getFormSpecification() == null) {
String oldFormPanelUri = oldForm.getFormSpecification().getPanelUri();
String newFormPanelUri = newForm.getFormSpecification().getPanelUri();
if (oldFormPanelUri != null && oldFormPanelUri.equals(newFormPanelUri)) {
return true;
}

String oldFormPanelClass = oldForm.getFormSpecification().getPanelClass();
String newFormPanelClass = newForm.getFormSpecification().getPanelClass();
if (oldFormPanelClass != null && oldFormPanelClass.equals(newFormPanelClass)){
return true;
}
String oldFormPanelClass = oldForm.getFormSpecification().getPanelClass();
String newFormPanelClass = newForm.getFormSpecification().getPanelClass();
if (oldFormPanelClass != null && oldFormPanelClass.equals(newFormPanelClass)) {
return true;
}

String oldFormRefOid = oldForm.getFormSpecification().getFormRef() == null ?
null : oldForm.getFormSpecification().getFormRef().getOid();
String newFormRefOid = newForm.getFormSpecification().getFormRef() == null ?
null : newForm.getFormSpecification().getFormRef().getOid();
if (oldFormRefOid != null && oldFormRefOid.equals(newFormRefOid)){
return true;
String oldFormRefOid = oldForm.getFormSpecification().getFormRef() == null ?
null : oldForm.getFormSpecification().getFormRef().getOid();
String newFormRefOid = newForm.getFormSpecification().getFormRef() == null ?
null : newForm.getFormSpecification().getFormRef().getOid();
if (oldFormRefOid != null && oldFormRefOid.equals(newFormRefOid)) {
return true;
}
}

return false;
}

Expand Down
Expand Up @@ -244,6 +244,10 @@ public PrismObject<SystemConfigurationType> getSystemConfiguration(OperationResu

public <O extends ObjectType, R extends ObjectType> PrismObject<R> searchOrgTreeWidthFirstReference(PrismObject<O> object,
Function<PrismObject<OrgType>, ObjectReferenceType> function, String shortDesc, Task task, OperationResult result) throws SchemaException {
if (object == null) {
LOGGER.trace("No object provided. Cannost find security policy specific for an object.");
return null;
}
PrismReference orgRef = object.findReference(ObjectType.F_PARENT_ORG_REF);
if (orgRef == null) {
return null;
Expand Down

0 comments on commit 1e0cd21

Please sign in to comment.