Skip to content

Commit bcd24fa

Browse files
handling copy of invalid properties
1 parent 453ccb8 commit bcd24fa

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMCustomServiceHandler.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.io.IOException;
2323
import java.util.ArrayList;
2424
import java.util.HashMap;
25-
import java.util.HashSet;
2625
import java.util.List;
2726
import java.util.Map;
2827
import java.util.Optional;
@@ -104,13 +103,25 @@ public void copyAttachments(AttachmentCopyEventContext context) throws IOExcepti
104103
.toString()));
105104
}
106105

107-
Set<String> customPropertiesInSDM = new HashSet<>(customPropertyDefinitions.values());
108-
String upID = context.getUpId();
109-
String folderName = upID + "__" + compositionName;
110106
String repositoryId = SDMConstants.REPOSITORY_ID;
111107
Boolean isSystemUser = context.getSystemUser();
112-
113108
SDMCredentials sdmCredentials = tokenHandler.getSDMCredentials();
109+
110+
// Fetch secondary types and valid secondary properties from SDM
111+
List<String> secondaryTypes =
112+
sdmService.getSecondaryTypes(repositoryId, sdmCredentials, isSystemUser);
113+
List<String> validSecondaryProperties =
114+
sdmService.getValidSecondaryProperties(
115+
secondaryTypes, sdmCredentials, repositoryId, isSystemUser);
116+
117+
// Filter custom properties to only include those that are valid in SDM
118+
Set<String> customPropertiesInSDM =
119+
customPropertyDefinitions.values().stream()
120+
.filter(validSecondaryProperties::contains)
121+
.collect(Collectors.toSet());
122+
123+
String upID = context.getUpId();
124+
String folderName = upID + "__" + compositionName;
114125
// Check if folder exists before trying to create it
115126
boolean folderExists =
116127
sdmService.getFolderIdByPath(folderName, repositoryId, sdmCredentials, isSystemUser)

0 commit comments

Comments
 (0)