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
katkav committed Jun 26, 2018
2 parents 20824f7 + 6468454 commit 3a3955c
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 116 deletions.
18 changes: 10 additions & 8 deletions dist/src/main/bin/ninja.sh
Expand Up @@ -37,15 +37,17 @@ cd "$PRGDIR/.." >/dev/null

cd "$SCRIPT_PATH/.."

if [ ! -d var ] ; then
echo "ERROR: midpoint.home directory desn't exist"
exit 1
else
MIDPOINT_HOME=$(cd "$SCRIPT_PATH../var"; pwd)
# honor MIDPOINT_HOME variable if it exists!
if [ -z "$MIDPOINT_HOME" ]; then
if [ ! -d var ] ; then
echo "ERROR: midpoint.home directory desn't exist"
exit 1
else
MIDPOINT_HOME=$(cd "$SCRIPT_PATH../var"; pwd)
fi

[ -z "$MIDPOINT_HOME" ] && MIDPOINT_HOME=`cd "$SCRIPT_PATH../var" >/dev/null; pwd`
fi

[ -z "$MIDPOINT_HOME" ] && MIDPOINT_HOME=`cd "$SCRIPT_PATH../var" >/dev/null; pwd`

#cd "$SCRIPT_PATH../lib"

if [ ! -f lib/ninja.jar ] ; then
Expand Down
Expand Up @@ -41,15 +41,13 @@
/**
* Created by honchar.
*/
public abstract class AbstractAssignmentPopupTabPanel<O extends ObjectType> extends BasePanel {
public abstract class AbstractAssignmentPopupTabPanel<O extends ObjectType> extends BasePanel<O> {

private static final long serialVersionUID = 1L;

private static final String ID_OBJECT_LIST_PANEL = "objectListPanel";

private static final String DOT_CLASS = AbstractAssignmentPopupTabPanel.class.getName();
private static final Trace LOGGER = TraceManager.getTrace(AbstractAssignmentPopupTabPanel.class);
private static final String OPERATION_LOAD_ASSIGNABLE_ROLES = DOT_CLASS + "loadAssignableRoles";

private ObjectTypes type;
protected List<O> selectedObjects;
Expand Down Expand Up @@ -91,29 +89,7 @@ protected IModel<Boolean> getCheckBoxEnableModel(IModel<SelectableBean<O>> rowMo

@Override
protected ObjectQuery addFilterToContentQuery(ObjectQuery query) {
LOGGER.debug("Loading roles which the current user has right to assign");
Task task = AbstractAssignmentPopupTabPanel.this.getPageBase().createSimpleTask(OPERATION_LOAD_ASSIGNABLE_ROLES);
OperationResult result = task.getResult();
ObjectFilter filter = null;
try {
ModelInteractionService mis = AbstractAssignmentPopupTabPanel.this.getPageBase().getModelInteractionService();
RoleSelectionSpecification roleSpec =
mis.getAssignableRoleSpecification(SecurityUtils.getPrincipalUser().getUser().asPrismObject(), task, result);
filter = roleSpec.getFilter();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load available roles", ex);
result.recordFatalError("Couldn't load available roles", ex);
} finally {
result.recomputeStatus();
}
if (!result.isSuccess() && !result.isHandledError()) {
AbstractAssignmentPopupTabPanel.this.getPageBase().showResult(result);
}
if (query == null){
query = new ObjectQuery();
}
query.addFilter(filter);
return query;
return AbstractAssignmentPopupTabPanel.this.addFilterToContentQuery(query);
}

};
Expand All @@ -128,9 +104,7 @@ public boolean isVisible(){
return listPanel;
}

protected PopupObjectListPanel getObjectListPanel(){
return (PopupObjectListPanel)get(ID_OBJECT_LIST_PANEL);
}
protected abstract void initParametersPanel();

protected List getSelectedObjectsList(){
PopupObjectListPanel objectListPanel = getObjectListPanel();
Expand All @@ -140,17 +114,23 @@ protected List getSelectedObjectsList(){
return objectListPanel.getSelectedObjects();
}

protected PopupObjectListPanel getObjectListPanel(){
return (PopupObjectListPanel)get(ID_OBJECT_LIST_PANEL);
}

protected void onSelectionPerformed(AjaxRequestTarget target){}

protected IModel<Boolean> getObjectSelectCheckBoxEnableModel(IModel<SelectableBean<O>> rowModel){
return Model.of(true);
}

protected ObjectQuery addFilterToContentQuery(ObjectQuery query){
return query;
}

protected abstract List<AssignmentType> getSelectedAssignmentsList();

protected boolean isObjectListPanelVisible(){
return true;
}

protected abstract void initParametersPanel();

protected void onSelectionPerformed(AjaxRequestTarget target){}
}
Expand Up @@ -3,8 +3,6 @@
import com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.TabbedPanel;
import com.evolveum.midpoint.web.component.dialog.Popupable;
Expand All @@ -17,14 +15,13 @@
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.StringResourceModel;

import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.List;

/**
* Created by honchar.
*/
public class AssignmentPopup<O extends ObjectType> extends BasePanel implements Popupable{
public class AssignmentPopup extends BasePanel implements Popupable{
private static final long serialVersionUID = 1L;

private static final String ID_TABS_PANEL = "tabsPanel";
Expand Down Expand Up @@ -231,14 +228,14 @@ private int getTabPanelSelectedCount(WebMarkupContainer panel){
return 0;
}

private TabbedPanel getTabbedPanel(){
return (TabbedPanel) get(ID_FORM).get(ID_TABS_PANEL);
}

private void tabLabelPanelUpdate(AjaxRequestTarget target){
target.add(getTabbedPanel());
}

private TabbedPanel getTabbedPanel(){
return (TabbedPanel) get(ID_FORM).get(ID_TABS_PANEL);
}

protected void addPerformed(AjaxRequestTarget target, List newAssignmentsList) {
getPageBase().hideMainPopup(target);
}
Expand Down
Expand Up @@ -16,19 +16,25 @@
package com.evolveum.midpoint.gui.api.component;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.model.api.ModelInteractionService;
import com.evolveum.midpoint.model.api.RoleSelectionSpecification;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.assignment.RelationTypes;
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior;
import com.evolveum.midpoint.web.security.SecurityUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import javax.xml.namespace.QName;
Expand All @@ -47,6 +53,7 @@ public class FocusTypeAssignmentPopupTabPanel<F extends FocusType> extends Abstr

private static final String DOT_CLASS = FocusTypeAssignmentPopupTabPanel.class.getName();
private static final Trace LOGGER = TraceManager.getTrace(FocusTypeAssignmentPopupTabPanel.class);
private static final String OPERATION_LOAD_ASSIGNABLE_ROLES = DOT_CLASS + "loadAssignableRoles";

public FocusTypeAssignmentPopupTabPanel(String id, ObjectTypes type){
this(id, type, new ArrayList<>());
Expand All @@ -71,10 +78,6 @@ protected void initParametersPanel(){
relationContainer.add(relationSelector);
}

private DropDownChoicePanel getRelationDropDown(){
return (DropDownChoicePanel)get(ID_RELATION_CONTAINER).get(ID_RELATION);
}

@Override
protected List<AssignmentType> getSelectedAssignmentsList(){
List<AssignmentType> assignmentList = new ArrayList<>();
Expand All @@ -95,4 +98,35 @@ public QName getRelationValue(){
}
return relation.getRelation();
}

private DropDownChoicePanel getRelationDropDown(){
return (DropDownChoicePanel)get(ID_RELATION_CONTAINER).get(ID_RELATION);
}

@Override
protected ObjectQuery addFilterToContentQuery(ObjectQuery query){
LOGGER.debug("Loading roles which the current user has right to assign");
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_ASSIGNABLE_ROLES);
OperationResult result = task.getResult();
ObjectFilter filter = null;
try {
ModelInteractionService mis = getPageBase().getModelInteractionService();
RoleSelectionSpecification roleSpec =
mis.getAssignableRoleSpecification(SecurityUtils.getPrincipalUser().getUser().asPrismObject(), task, result);
filter = roleSpec.getFilter();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load available roles", ex);
result.recordFatalError("Couldn't load available roles", ex);
} finally {
result.recomputeStatus();
}
if (!result.isSuccess() && !result.isHandledError()) {
getPageBase().showResult(result);
}
if (query == null){
query = new ObjectQuery();
}
query.addFilter(filter);
return query;
}
}
Expand Up @@ -19,6 +19,7 @@
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.page.admin.orgs.OrgTreeAssignablePanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.IModel;
Expand Down Expand Up @@ -46,26 +47,8 @@ public OrgTypeAssignmentPopupTabPanel(String id, boolean isOrgTreeView, List<Org
@Override
protected void onInitialize() {
super.onInitialize();
IModel<List<OrgType>> selectedOrgsModel = new IModel<List<OrgType>>() {
private static final long serialVersionUID = 1L;

@Override
public List<OrgType> getObject() {
return selectedObjects;
}

@Override
public void setObject(List<OrgType> orgTypes) {
selectedObjects = orgTypes;
}

@Override
public void detach() {

}
};
OrgTreeAssignablePanel orgTreePanel = new OrgTreeAssignablePanel(
ID_ORG_TREE_VIEW_PANEL, true, getPageBase(), selectedOrgsModel) {
ID_ORG_TREE_VIEW_PANEL, true, getPageBase(), selectedObjects) {
private static final long serialVersionUID = 1L;

@Override
Expand Down Expand Up @@ -121,6 +104,12 @@ protected List getSelectedObjectsList(){
}
}

@Override
protected List<AssignmentType> getSelectedAssignmentsList(){
isOrgTreeView = true;
return super.getSelectedAssignmentsList();
}

protected void onOrgTreeCheckBoxSelectionPerformed(AjaxRequestTarget target){}

public boolean isOrgTreeView(){
Expand Down
Expand Up @@ -57,7 +57,8 @@ public class ResourceTypeAssignmentPopupTabPanel extends AbstractAssignmentPopup
private static final String ID_INTENT = "intent";

private LoadableModel<List<String>> intentValues;
private String intentValue = "";
private String intentValue;
private ShadowKindType kindValue;

private static final String DOT_CLASS = ResourceTypeAssignmentPopupTabPanel.class.getName();
private static final Trace LOGGER = TraceManager.getTrace(ResourceTypeAssignmentPopupTabPanel.class);
Expand All @@ -75,8 +76,8 @@ protected void initParametersPanel(){
add(kindContainer);

DropDownChoicePanel<ShadowKindType> kindSelector = WebComponentUtil.createEnumPanel(ShadowKindType.class, ID_KIND,
WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), Model.of(ShadowKindType.ACCOUNT),
ResourceTypeAssignmentPopupTabPanel.this, false);
WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), Model.of(),
ResourceTypeAssignmentPopupTabPanel.this, true);
kindSelector.setOutputMarkupId(true);
kindSelector.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
Expand All @@ -103,24 +104,7 @@ public boolean isEnabled(){
add(intentContainer);

DropDownChoicePanel<String> intentSelector = new DropDownChoicePanel<String>(ID_INTENT,
new IModel<String>() {
private static final long serialVersionUID = 1L;

@Override
public String getObject() {
return intentValue;
}

@Override
public void setObject(String s) {
intentValue = s;
}

@Override
public void detach() {

}
}, intentValues);
Model.of(), intentValues, true);
intentSelector.getBaseFormComponent().add(new VisibleEnableBehaviour(){
private static final long serialVersionUID = 1L;

Expand All @@ -136,14 +120,6 @@ public boolean isEnabled(){

}

private DropDownChoicePanel getIntentDropDown(){
return (DropDownChoicePanel)get(ID_INTENT_CONTAINER).get(ID_INTENT);
}

private DropDownChoicePanel<ShadowKindType> getKindDropDown(){
return (DropDownChoicePanel<ShadowKindType>)get(ID_KIND_CONTAINER).get(ID_KIND);
}

private void initModels(){
intentValues = new LoadableModel<List<String>>(true) {
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -180,14 +156,6 @@ protected List<String> load() {
};
}

public String getIntentValue(){
return intentValue;
}

public ShadowKindType getKindValue(){
return getKindDropDown().getModel().getObject();
}

@Override
protected List<AssignmentType> getSelectedAssignmentsList(){
List<AssignmentType> assignmentList = new ArrayList<>();
Expand All @@ -201,6 +169,24 @@ protected List<AssignmentType> getSelectedAssignmentsList(){
return assignmentList;
}

public ShadowKindType getKindValue(){
DropDownChoicePanel<ShadowKindType> kindDropDown = getKindDropDown();
return kindDropDown.getModel() != null ? kindDropDown.getModel().getObject() : null;
}

public String getIntentValue(){
DropDownChoicePanel<String> intentDropDown = getIntentDropDown();
return intentDropDown.getModel() != null ? intentDropDown.getModel().getObject() : null;
}

private DropDownChoicePanel<String> getIntentDropDown(){
return (DropDownChoicePanel<String>)get(ID_INTENT_CONTAINER).get(ID_INTENT);
}

private DropDownChoicePanel<ShadowKindType> getKindDropDown(){
return (DropDownChoicePanel<ShadowKindType>)get(ID_KIND_CONTAINER).get(ID_KIND);
}

@Override
protected void onSelectionPerformed(AjaxRequestTarget target){
target.add(getObjectListPanel());
Expand Down

0 comments on commit 3a3955c

Please sign in to comment.