Skip to content

Refactor USS setfacl input creation with controlled factory methods#481

Merged
frankgiordano merged 4 commits intomainfrom
aclmod
May 1, 2026
Merged

Refactor USS setfacl input creation with controlled factory methods#481
frankgiordano merged 4 commits intomainfrom
aclmod

Conversation

@frankgiordano
Copy link
Copy Markdown
Collaborator

Summary

Refactored USS setfacl input creation to use a controlled factory pattern instead of exposing direct builder usage.

This change introduces SetAclInputFactory as the public creation path for UssSetAclInputData, ensuring only valid setfacl keyword combinations are created.

Changes

  • Added SetAclInputFactory for creating UssSetAclInputData instances.
  • Added factory methods for supported setfacl operations:
    • createSetInput(...)
    • createModifyInput(...)
    • createDeleteInput(...)
    • createDeleteTypeInput(...)
    • createModifyDeleteInput(...)
  • Updated UssSetAcl methods to use SetAclInputFactory instead of directly using UssSetAclInputData.Builder.
  • Changed UssSetAclInputData.Builder to package-private so external users cannot create invalid ACL input combinations directly.
  • Kept factory defaults aligned with the z/OSMF API behavior:
    • abort = false
    • links = LinkType.FOLLOW
  • Added validation for required ACL operation values.
  • Added validation for links to prevent null values.
  • Added Javadocs for the new factory class and methods.
  • Added unit test coverage for:
    • Factory-created set, modify, delete, delete-type, and modify/delete inputs.
    • Builder behavior from within the same package.
    • UssSetAcl request body generation.
    • URL/body setup and request execution.
    • Constructor and invalid parameter scenarios.

Reason for Change

The previous builder pattern allowed callers to create invalid setfacl input combinations, such as combining set with modify, or delete-type with other ACL operation keywords.

The z/OSMF setfacl API only allows certain combinations:

  • modify and delete may be used together.
  • set cannot be combined with modify, delete, or delete-type.
  • delete-type cannot be combined with set, modify, or delete.

The new factory methods make those valid combinations explicit and prevent misuse by keeping the builder internal to the package.

Testing

Added unit tests to verify:

  • Correct default values are applied.
  • Correct request JSON is generated for each supported setfacl operation.
  • Invalid null or blank values are rejected.
  • UssSetAcl correctly delegates input creation through the factory.
  • The request URL, request body, and request execution are handled as expected.

@frankgiordano frankgiordano self-assigned this May 1, 2026
@frankgiordano frankgiordano added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels May 1, 2026
@frankgiordano
Copy link
Copy Markdown
Collaborator Author

@Ashish-Kumar-Dash fyi see this PR request. Thanks for identifying the issue. The rework is a bit more involved and provides a full solution to the issue.

@frankgiordano frankgiordano merged commit 2112c38 into main May 1, 2026
2 checks passed
@frankgiordano frankgiordano deleted the aclmod branch May 1, 2026 03:23
@Ashish-Kumar-Dash
Copy link
Copy Markdown
Contributor

@Ashish-Kumar-Dash fyi see this PR request. Thanks for identifying the issue. The rework is a bit more involved and provides a full solution to the issue.

That was fast! Nice work for the quick resolution, would've defo taken me a while to come up with the approach

@frankgiordano
Copy link
Copy Markdown
Collaborator Author

@Ashish-Kumar-Dash It is a similar pattern already existing in the project in another place and hence the speed. See https://github.com/zowe/zowe-client-java-sdk/blob/main/src/main/java/zowe/client/sdk/core/ZosConnectionFactory.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants