Skip to content

Conversation

@yashmeet29
Copy link
Collaborator

@yashmeet29 yashmeet29 commented Oct 22, 2025

Describe your changes

This PR fixes copyAttachments API for Projection Entities. Earlier copyAttachments() was working only for non-projection entities and was failing for projection entities with 401 "Not authorized to send event 'DRAFT_NEW' to ". I raised this issue with CAP team and as per the suggestion I have incorporated this fix.

Any documentation

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I follow Java Development Guidelines for SAP
  • I have tested the functionality on my cloud environment.
  • I have provided sufficient automated/ unit tests for the code.
  • I have increased or maintained the test coverage.
  • I have ran integration tests on my cloud environment.
  • I have validated blackduck portal for any vulnerability after my commit.

Upload Screenshots/lists of the scenarios tested

  • I have Uploaded Screenshots or added lists of the scenarios tested in description

Single tenant Integration Test: https://github.com/cap-java/sdm/actions/runs/18746444994
Multi tenant Integration Test: https://github.com/cap-java/sdm/actions/runs/18748340988

pom.xml Outdated

<properties>
<revision>1.5.1-SNAPSHOT</revision>
<revision>1.0.0-RC1</revision>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls change this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// Find the parent entity
Optional<CdsEntity> optionalParentEntity = model.findEntity(parentEntity);
if (optionalParentEntity.isEmpty()) {
throw new ServiceException("Unable to find parent entity: " + parentEntity);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we put this in constants file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, added it in constants file.

// Find the target attachment entity
Optional<CdsEntity> attachmentEntity = model.findEntity(targetEntityName);
if (attachmentEntity.isEmpty()) {
throw new ServiceException("Unable to find target attachment entity: " + targetEntityName);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add constant in SDMConstants file

optionalParentEntity.get().findElement(compositionName);
if (compositionElement.isEmpty() || !compositionElement.get().getType().isAssociation()) {
throw new ServiceException(
"Unable to find composition '" + compositionName + "' in entity: " + parentEntity);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, added it in constants file.

String[] facetParts = input.facet().split("\\.");
if (facetParts.length < 3) {
throw new IllegalArgumentException(
"Invalid facet format. Expected: Service.Entity.Composition, got: " + input.facet());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add to constants

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, added it in constants file.


CopyAttachmentsResult copyResult =
copyAttachmentsToSDM(
context, objectIds, folderId, repositoryId, sdmCredentials, isSystemUser, folderExists);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add all these method parameters to a model class because its not good practice to have more than 4 parameters

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


String upIdKey = resolveUpIdKey(context, parentEntity, compositionName);
createDraftEntries(
attachmentsMetadata,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add all these method parameters to a model class because its not good practice to have more than 4 parameters

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

pom.xml Outdated

<properties>
<revision>1.5.1-SNAPSHOT</revision>
<revision>1.0.0-RC1</revision>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert once testing is over

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@yashmeet29 yashmeet29 merged commit dde83af into develop Oct 24, 2025
8 checks passed
@yashmeet29 yashmeet29 deleted the copyAttachmentsFixForProjectionEntities branch October 24, 2025 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants