This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch 4_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/4_0_X by this push:
new 6192097cb2 Fixing JPA XMLContentExporter for ARelationship
6192097cb2 is described below
commit 6192097cb24c7cf94cfa779ca3612166aafc2fd7
Author: Francesco Chicchiriccò <[email protected]>
AuthorDate: Fri Sep 12 11:35:33 2025 +0200
Fixing JPA XMLContentExporter for ARelationship
---
.../client/console/wizards/any/Relationships.java | 20 +++-----------------
.../persistence/jpa/content/XMLContentExporter.java | 2 +-
2 files changed, 4 insertions(+), 18 deletions(-)
diff --git
a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/Relationships.java
b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/Relationships.java
index 608130945a..833c1528e5 100644
---
a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/Relationships.java
+++
b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/Relationships.java
@@ -49,7 +49,6 @@ import
org.apache.syncope.client.ui.commons.wizards.any.AnyWrapper;
import org.apache.syncope.client.ui.commons.wizards.any.UserWrapper;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.to.RelatableTO;
import org.apache.syncope.common.lib.to.RelationshipTO;
import org.apache.syncope.common.lib.to.RelationshipTypeTO;
import org.apache.syncope.common.lib.types.AnyEntitlement;
@@ -121,12 +120,11 @@ public class Relationships extends WizardStep implements
ICondition {
Fragment viewFragment = new Fragment("relationships", "viewFragment",
this);
viewFragment.setOutputMarkupId(true);
- List<RelationshipTO> relationships = getCurrentRelationships();
- viewFragment.add(relationships.isEmpty()
+ viewFragment.add(anyTO.getRelationships().isEmpty()
? new Label("relationships", new
Model<>(getString("relationships.empty.list")))
: new RelationshipViewPanel.Builder(pageRef).
setAnyTO(anyTO).
- setRelationships(relationships).
+ setRelationships(anyTO.getRelationships()).
build("relationships"));
ActionsPanel<RelationshipTO> panel = new ActionsPanel<>("actions",
null);
@@ -148,18 +146,6 @@ public class Relationships extends WizardStep implements
ICondition {
return viewFragment;
}
- protected List<RelationshipTO> getCurrentRelationships() {
- return anyTO instanceof RelatableTO relatableTO
- ? relatableTO.getRelationships()
- : List.of();
- }
-
- protected void addNewRelationship(final RelationshipTO relaltionship) {
- if (anyTO instanceof RelatableTO relatableTO) {
- relatableTO.getRelationships().add(relaltionship);
- }
- }
-
@Override
public boolean evaluate() {
return !relationshipTypeRestClient.list().isEmpty();
@@ -270,7 +256,7 @@ public class Relationships extends WizardStep implements
ICondition {
rel.setOtherEndKey(right.getKey());
rel.setOtherEndName(AnyObjectTO.class.cast(right).getName());
- Relationships.this.addNewRelationship(rel);
+ anyTO.getRelationships().add(rel);
Relationships.this.addOrReplace(getViewFragment().setRenderBodyOnly(true));
target.add(Relationships.this);
diff --git
a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java
index 9e63758c99..1dfb232ef1 100644
---
a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java
+++
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java
@@ -161,7 +161,7 @@ public class XMLContentExporter extends
AbstractXMLContentExporter {
}).filter(Objects::nonNull).findFirst().orElse(columnName);
if (Strings.CI.endsWith(name, "_ID")) {
- String left = StringUtils.substringBefore(name, "_");
+ String left = StringUtils.substringBeforeLast(name, "_");
String prefix = attrs.get().filter(attr ->
left.equalsIgnoreCase(attr.getName())).findFirst().
map(Attribute::getName).orElse(left);
name = prefix + "_id";