Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.stream.Collectors;
import org.apache.syncope.client.console.rest.ResourceRestClient;
import org.apache.syncope.common.lib.to.ResourceTO;
import org.apache.syncope.common.lib.types.AnyTypeKind;

public class IdMExternalResourceProvider implements ExternalResourceProvider {

Expand All @@ -34,7 +35,18 @@ public IdMExternalResourceProvider(final ResourceRestClient resourceRestClient)
}

@Override
public List<String> get() {
return resourceRestClient.list().stream().map(ResourceTO::getKey).collect(Collectors.toList());
public List<String> get(final String anyType) {
return resourceRestClient.list().stream().
filter(r -> AnyTypeKind.GROUP.name().equals(anyType) || r.getProvision(anyType).isPresent()).
map(ResourceTO::getKey).
collect(Collectors.toList());
}

@Override
public List<String> getForRealms() {
return resourceRestClient.list().stream().
filter(r -> r.getOrgUnit() != null).
map(ResourceTO::getKey).
collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public <T extends AnyTO> Resources(final AnyWrapper<T> modelObject) {
public boolean evaluate() {
if (SyncopeWebApplication.get().getSecuritySettings().
getAuthorizationStrategy().isActionAuthorized(this, RENDER)) {
available.setObject(SyncopeWebApplication.get().getResourceProvider().get());

available.setObject(SyncopeWebApplication.get().getResourceProvider().get(anyTO.getType()));
return !available.getObject().isEmpty();
} else {
return false;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,20 @@ public abstract class AbstractAnyFormLayout<A extends AnyTO, F extends AnyForm<A

private static final long serialVersionUID = -6061683026789976508L;

private boolean relationships = true;

private final List<String> whichPlainAttrs = new ArrayList<>();

private final List<String> whichDerAttrs = new ArrayList<>();

public boolean isRelationships() {
return relationships;
}

public void setRelationships(final boolean relationships) {
this.relationships = relationships;
}

public List<String> getWhichPlainAttrs() {
return whichPlainAttrs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ public abstract class AbstractResources extends WizardStep implements ICondition

private static final long serialVersionUID = 552437609667518888L;

protected final AnyTO anyTO;

protected final ListModel<String> available;

public <T extends AnyTO> AbstractResources(final AnyWrapper<T> modelObject) {
final T entityTO = modelObject.getInnerObject();
anyTO = modelObject.getInnerObject();

if (modelObject instanceof UserWrapper
&& UserWrapper.class.cast(modelObject).getPreviousUserTO() != null
if (modelObject instanceof UserWrapper userWrapper
&& userWrapper.getPreviousUserTO() != null
&& !modelObject.getInnerObject().getResources().equals(
UserWrapper.class.cast(modelObject).getPreviousUserTO().getResources())) {
userWrapper.getPreviousUserTO().getResources())) {

add(new LabelInfo("changed", StringUtils.EMPTY));
} else {
Expand All @@ -52,19 +54,19 @@ public <T extends AnyTO> AbstractResources(final AnyWrapper<T> modelObject) {
this.setOutputMarkupId(true);
this.available = new ListModel<>(List.of());

add(new AjaxPalettePanel.Builder<String>().build("resources", new PropertyModel<>(entityTO, "resources") {
add(new AjaxPalettePanel.Builder<String>().build("resources", new PropertyModel<>(anyTO, "resources") {

private static final long serialVersionUID = 3799387950428254072L;

@Override
public List<String> getObject() {
return new ArrayList<>(entityTO.getResources());
return new ArrayList<>(anyTO.getResources());
}

@Override
public void setObject(final List<String> object) {
entityTO.getResources().clear();
entityTO.getResources().addAll(object);
anyTO.getResources().clear();
anyTO.getResources().addAll(object);
}
}, available).hideLabel().setOutputMarkupId(true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
import java.io.Serializable;
import java.util.List;

@FunctionalInterface
public interface ExternalResourceProvider extends Serializable {

List<String> get();
List<String> get(String anyType);

List<String> getForRealms();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ public class IdRepoExternalResourceProvider implements ExternalResourceProvider
private static final long serialVersionUID = 3002474783308961295L;

@Override
public List<String> get() {
public List<String> get(final String anyType) {
return List.of();
}

@Override
public List<String> getForRealms() {
return List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public class UserFormLayoutInfo extends AbstractAnyFormLayout<UserTO, UserForm>

private boolean roles = true;

private boolean relationships = true;

@Override
protected Class<? extends UserForm> getDefaultFormClass() {
return UserWizardBuilder.class;
Expand All @@ -53,12 +51,4 @@ public boolean isRoles() {
public void setRoles(final boolean roles) {
this.roles = roles;
}

public boolean isRelationships() {
return relationships;
}

public void setRelationships(final boolean relationships) {
this.relationships = relationships;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected List<String> load() {

@Override
protected List<String> load() {
return SyncopeWebApplication.get().getResourceProvider().get();
return SyncopeWebApplication.get().getResourceProvider().getForRealms();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.syncope.client.ui.commons.Constants;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.to.AnyTO;
import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.syncope.common.lib.to.RelationshipTO;
import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.common.lib.types.AnyEntitlement;
Expand Down Expand Up @@ -56,8 +57,15 @@ private RelationshipViewPanel(
final AnyTO anyTO,
final boolean reuseItem,
final boolean wizardInModal) {

super(id, wizardInModal);
addInnerObject(getHeader());

WebMarkupContainer header = new WebMarkupContainer("header");
header.add(new Label("header_left_end", getString("left.end")));
header.add(new Label("header_relationship", new ResourceModel("relationship")));
header.add(new Label("header_right_end", new ResourceModel("right.end")));
addInnerObject(header);

relationshipsList = new ListView<>("relationships", relationships) {

private static final long serialVersionUID = 4983556433071042668L;
Expand Down Expand Up @@ -101,9 +109,8 @@ protected void onEvent(final AjaxRequestTarget target) {
if (togglePanel == null) {
relationshipItem.add(action);
} else {
relationshipItem.add(new ActionsPanel<>("action", new Model<>(relationshipTO))
.setVisible(false)
.setEnabled(false));
relationshipItem.add(new ActionsPanel<>("action", new Model<>(relationshipTO)).
setVisible(false).setEnabled(false));
}
}
};
Expand All @@ -112,25 +119,20 @@ protected void onEvent(final AjaxRequestTarget target) {
relationshipsList.setRenderBodyOnly(true);

addInnerObject(relationshipsList);

}

private WebMarkupContainer getHeader() {
WebMarkupContainer headerContainer = new WebMarkupContainer("header");
headerContainer.add(new Label("header_left_end", getString("left.end")));
headerContainer.add(new Label("header_relationship", new ResourceModel("relationship")));
headerContainer.add(new Label("header_right_end", new ResourceModel("right.end")));
return headerContainer;
}

private void buildRowLabels(
private static void buildRowLabels(
final ListItem<RelationshipTO> row,
final RelationshipTO relationshipTO,
final AnyTO anyTO) {

boolean isLeftRelation = relationshipTO.getEnd() == RelationshipTO.End.LEFT;
String anyName = anyTO instanceof UserTO
? UserTO.class.cast(anyTO).getUsername()
: AnyObjectTO.class.cast(anyTO).getName();

String anyName = anyTO instanceof UserTO userTO
? userTO.getUsername()
: anyTO instanceof GroupTO groupTO
? groupTO.getName()
: AnyObjectTO.class.cast(anyTO).getName();

row.add(new Label("relationship", relationshipTO.getType()));
Label leftEnd = new Label("left_end", isLeftRelation
Expand All @@ -149,7 +151,7 @@ private void buildRowLabels(
row.add(leftEnd, rightEnd);
}

private void setBold(final Label... labels) {
private static void setBold(final Label... labels) {
for (Label label : labels) {
label.add(new AttributeModifier("style", "font-weight: bold;"));
}
Expand All @@ -176,7 +178,6 @@ public RelationshipViewPanel.Builder setAnyTO(final AnyTO anyTO) {
return this;
}


public RelationshipViewPanel.Builder setRelationships(final List<RelationshipTO> relationships) {
this.relationships = relationships;
return this;
Expand Down Expand Up @@ -204,8 +205,5 @@ public RelationshipViewPanel.Builder setReuseItem(final boolean reuseItem) {
protected WizardMgtPanel<RelationshipTO> newInstance(final String id, final boolean wizardInModal) {
return new RelationshipViewPanel(id, relationships, anyTO, reuseItem, wizardInModal);
}

}

}

Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public abstract class AbstractSearchPanel extends Panel {

protected final AnyTypeKind typeKind;

protected final String type;
protected final String anyType;

public abstract static class Builder<T extends AbstractSearchPanel> implements Serializable {

Expand Down Expand Up @@ -150,7 +150,7 @@ protected AbstractSearchPanel(

this.model = builder.model;
this.typeKind = kind;
this.type = type;
this.anyType = type;

setOutputMarkupId(true);

Expand Down Expand Up @@ -233,8 +233,8 @@ public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
protected abstract String getFIQLQueryTarget();

protected void updateFIQL(final AjaxRequestTarget target, final String fiql) {
model.setObject(SearchUtils.getSearchClauses(
fiql.replaceAll(SearchUtils.getTypeConditionPattern(type).pattern(), "")));
model.setObject(SearchUtils.getSearchClauses(fiql.replaceAll(SearchUtils.getTypeConditionPattern(anyType).
pattern(), "")));
target.add(searchFormContainer);
}

Expand Down Expand Up @@ -275,17 +275,17 @@ protected List<String> load() {

@Override
protected List<String> load() {
return SyncopeWebApplication.get().getResourceProvider().get();
return SyncopeWebApplication.get().getResourceProvider().get(anyType);
}
};
}

public IModel<List<SearchClause>> getModel() {
return this.model;
return model;
}

public String getBackObjectType() {
return this.type;
public String getAnyType() {
return anyType;
}

public Map<String, PlainSchemaTO> getAvailableSchemaTypes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ protected AnyObjectSearchPanel(final String id, final AnyTypeKind kind, final St

@Override
protected AbstractFiqlSearchConditionBuilder<?, ?, ?> getSearchConditionBuilder() {
return SyncopeClient.getAnyObjectSearchConditionBuilder(type);
return SyncopeClient.getAnyObjectSearchConditionBuilder(anyType);
}

@Override
protected String getFIQLQueryTarget() {
return type;
return anyType;
}

@Override
Expand Down Expand Up @@ -121,8 +121,8 @@ protected List<String> load() {

@Override
protected Map<String, PlainSchemaTO> load() {
return schemaRestClient.<PlainSchemaTO>getSchemas(SchemaType.PLAIN, null, anyTypeRestClient.read(type).
getClasses().toArray(String[]::new)).
return schemaRestClient.<PlainSchemaTO>getSchemas(
SchemaType.PLAIN, null, anyTypeRestClient.read(anyType).getClasses().toArray(String[]::new)).
stream().collect(Collectors.toMap(SchemaTO::getKey, Function.identity()));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected List<String> load() {
@Override
protected Map<String, PlainSchemaTO> load() {
return schemaRestClient.<PlainSchemaTO>getSchemas(
SchemaType.PLAIN, null, anyTypeRestClient.read(type).getClasses().toArray(String[]::new)).
SchemaType.PLAIN, null, anyTypeRestClient.read(anyType).getClasses().toArray(String[]::new)).
stream().collect(Collectors.toMap(SchemaTO::getKey, Function.identity()));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ public static String buildFIQL(

switch (clause.getType()) {
case GROUP_MEMBER:
if (builder instanceof GroupFiqlSearchConditionBuilder) {
if (builder instanceof final GroupFiqlSearchConditionBuilder gbuilder) {
switch (clause.getComparator()) {
case EQUALS:
condition = ((GroupFiqlSearchConditionBuilder) builder).withMembers(value);
condition = gbuilder.withMembers(value);
break;

case NOT_EQUALS:
condition = ((GroupFiqlSearchConditionBuilder) builder).withoutMembers(value);
condition = gbuilder.withoutMembers(value);
break;

default:
Expand All @@ -265,14 +265,14 @@ public static String buildFIQL(
if (StringUtils.isNotBlank(clause.getProperty())) {
String groupKey = clause.getProperty();

if (builder instanceof final UserFiqlSearchConditionBuilder conditionBuilder) {
if (builder instanceof final UserFiqlSearchConditionBuilder ubuilder) {
condition = clause.getComparator() == SearchClause.Comparator.EQUALS
? conditionBuilder.inGroups(groupKey)
: conditionBuilder.notInGroups(groupKey);
} else {
? ubuilder.inGroups(groupKey)
: ubuilder.notInGroups(groupKey);
} else if (builder instanceof final AnyObjectFiqlSearchConditionBuilder abuilder) {
condition = clause.getComparator() == SearchClause.Comparator.EQUALS
? ((AnyObjectFiqlSearchConditionBuilder) builder).inGroups(groupKey)
: ((AnyObjectFiqlSearchConditionBuilder) builder).notInGroups(groupKey);
? abuilder.inGroups(groupKey)
: abuilder.notInGroups(groupKey);
}
}
break;
Expand Down
Loading
Loading