Skip to content

Commit

Permalink
tomcat crash fix for induced entitlements panel
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed May 24, 2018
1 parent 49efa81 commit 222c72f
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 18 deletions.
@@ -0,0 +1,60 @@
/*
* 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.
*/
package com.evolveum.midpoint.gui.api.component;

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.web.component.dialog.Popupable;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import org.apache.wicket.Component;
import org.apache.wicket.model.StringResourceModel;

import java.util.Collection;
import java.util.List;

/**
* Created by honchar.
*/
public class PopupableObjectListPanel<O extends ObjectType> extends PopupObjectListPanel<O> implements Popupable {

public PopupableObjectListPanel(String id, Class<? extends O> defaultType, Collection<SelectorOptions<GetOperationOptions>> options,
boolean multiselect, PageBase parentPage, List<O> selectedObjectsList) {
super(id, defaultType, options, multiselect, parentPage, selectedObjectsList);
}

@Override
public int getWidth() {
return 900;
}

@Override
public int getHeight() {
return 700;
}

@Override
public StringResourceModel getTitle() {
return createStringResource("ObjectBrowserPanel.chooseObject");
}

@Override
public Component getComponent() {
return this;
}


}
Expand Up @@ -19,7 +19,7 @@
import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition;
import com.evolveum.midpoint.common.refinery.RefinedResourceSchema;
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel;
import com.evolveum.midpoint.gui.api.component.PopupableObjectListPanel;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
Expand All @@ -29,23 +29,19 @@
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.util.ItemPathUtil;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
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.web.component.form.ValueChoosePanel;
import com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel;
import com.evolveum.midpoint.web.component.form.multivalue.MultiValueChoosePanel;
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
import com.evolveum.midpoint.web.component.prism.*;
import com.evolveum.midpoint.web.util.ExpressionUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.*;
Expand Down Expand Up @@ -279,13 +275,10 @@ private List<ObjectReferenceType> getAssociationsShadowRefs(boolean compareName,
}

private void addNewShadowRefValuePerformed(AjaxRequestTarget target, RefinedAssociationDefinition def){
ObjectFilter filter = WebComponentUtil.createAssociationShadowRefFilter(def,
getPageBase().getPrismContext(), resourceModel.getObject().getOid());
Task task = getPageBase().createAnonymousTask("Adding new shadow");
ObjectBrowserPanel<ShadowType> objectBrowserPanel = new ObjectBrowserPanel<ShadowType>(
getPageBase().getMainPopupBodyId(), ShadowType.class, Arrays.asList(ShadowType.COMPLEX_TYPE),
false, getPageBase(),
filter) {
PopupableObjectListPanel<ShadowType> objectBrowserPanel = new PopupableObjectListPanel<ShadowType>(getPageBase().getMainPopupBodyId(),
ShadowType.class, SelectorOptions.createCollection(ItemPath.EMPTY_PATH, GetOperationOptions.createNoFetch()),
false, ConstructionAssociationPanel.this.getPageBase(), null) {

private static final long serialVersionUID = 1L;

@Override
Expand All @@ -303,16 +296,27 @@ protected void onSelectPerformed(AjaxRequestTarget target, ShadowType object) {
ExpressionUtil.createShadowRefEvaluatorValue(newAssociationExpression, object.getOid(),
getPageBase().getPrismContext());
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
Task task = getPageBase().createAnonymousTask("Adding new shadow");
ContainerValueWrapper<ResourceObjectAssociationType> valueWrapper =
factory.createContainerValueWrapper(associationWrapper, newAssociation,
associationWrapper.getObjectStatus(), ValueStatus.ADDED, associationWrapper.getPath(), task);
// valueWrapper.setShowEmpty(true, false);
associationWrapper.getValues().add(valueWrapper);

target.add(ConstructionAssociationPanel.this);
}
target.add(ConstructionAssociationPanel.this); }

@Override
protected ObjectQuery addFilterToContentQuery(ObjectQuery query) {
ObjectFilter filter = WebComponentUtil.createAssociationShadowRefFilter(def,
ConstructionAssociationPanel.this.getPageBase().getPrismContext(), resourceModel.getObject().getOid());
if (query == null) {
query = new ObjectQuery();
}
query.addFilter(filter);
return query;
}
};
objectBrowserPanel.setOutputMarkupId(true);

getPageBase().showMainPopup(objectBrowserPanel, target);

Expand Down
Expand Up @@ -71,17 +71,24 @@ public class GenericMultiValueLabelEditPanel <T extends Serializable> extends Ba
private static final String CLASS_MULTI_VALUE = "multivalue-form";

private boolean isMultiple;
private IModel<String> label;
private String labelSize;
private String textSize;

public GenericMultiValueLabelEditPanel(String id, IModel<List<T>> value, IModel<String> label,
String labelSize, String textSize, boolean isMultiple){
super(id, value);
this.isMultiple = isMultiple;
setOutputMarkupId(true);

initLayout(label, labelSize, textSize);
this.label = label;
this.labelSize = labelSize;
this.textSize = textSize;
}

private void initLayout(final IModel<String> label, final String labelSize, final String textSize){
@Override
protected void onInitialize() {
super.onInitialize();

Label l = new Label(ID_LABEL, label);
l.setVisible(getLabelVisibility());
Expand Down
Expand Up @@ -330,6 +330,7 @@ private String getInducedEntitlementsCount(){
if (association.getOutbound() != null && association.getOutbound().getExpression() != null
&& ExpressionUtil.getShadowRefValue(association.getOutbound().getExpression()) != null){
count++;
break;
}
}
}
Expand Down

0 comments on commit 222c72f

Please sign in to comment.