Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add canNonOwnersViewCollaborators flag to Folder #1288

Merged
merged 1 commit into from
Feb 12, 2025
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
26 changes: 26 additions & 0 deletions src/intTest/java/com/box/sdk/BoxFolderIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,32 @@ public void updateFolderInfoSucceeds() {
}
}

@Test
public void updateCanNonOwnersViewCollaboratorsSucceeds() {
BoxAPIConnection api = jwtApiForServiceAccount();
BoxFolder rootFolder = getUniqueFolder(api);
final String name = "[updateCanNonOwnersViewCollaboratorsSucceeds] Child Folder";
BoxFolder childFolder = null;

try {
BoxFolder.Info info = rootFolder.createFolder(name);
childFolder = info.getResource();
boolean getCanNonOwnersViewCollaborators = childFolder.getInfo("can_non_owners_view_collaborators")
.getCanNonOwnersViewCollaborators();
// need to set both
info.setCanNonOwnersViewCollaborators(!getCanNonOwnersViewCollaborators);
info.setCanNonOwnersInvite(!getCanNonOwnersViewCollaborators);
childFolder.updateInfo(info);

assertThat(info.getCanNonOwnersViewCollaborators(), equalTo(!getCanNonOwnersViewCollaborators));
assertThat(info.getCanNonOwnersInvite(), equalTo(!getCanNonOwnersViewCollaborators));
} finally {
this.deleteFolder(childFolder);
assertThat(rootFolder,
not(hasItem(Matchers.<BoxItem.Info>hasProperty("ID", equalTo(childFolder.getID())))));
}
}

@Test
public void copyFolderToSameDestinationWithNewNameSucceeds() {
BoxAPIConnection api = jwtApiForServiceAccount();
Expand Down
29 changes: 28 additions & 1 deletion src/main/java/com/box/sdk/BoxFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class BoxFolder extends BoxItem implements Iterable<BoxItem.Info> {
"item_status", "item_collection", "sync_state", "has_collaborations", "permissions", "tags",
"can_non_owners_invite", "collections", "watermark_info", "metadata", "is_externally_owned",
"is_collaboration_restricted_to_enterprise", "allowed_shared_link_access_levels", "allowed_invitee_roles",
"is_accessible_via_shared_link"
"is_accessible_via_shared_link", "can_non_owners_view_collaborators"
};
/**
* Create Folder URL Template.
Expand Down Expand Up @@ -1467,6 +1467,7 @@ public class Info extends BoxItem.Info {
private BoxClassification classification;

private boolean isAccessibleViaSharedLink;
private boolean canNonOwnersViewCollaborators;

/**
* Constructs an empty Info object.
Expand Down Expand Up @@ -1668,6 +1669,29 @@ public boolean getIsAccessibleViaSharedLink() {
return this.isAccessibleViaSharedLink;
}

/**
* Returns the flag indicating if collaborators who are not owners of this folder
* are restricted from viewing other collaborations on this folder.
*
* @return boolean flag indicating if collaborators who are not owners of this folder
* are restricted from viewing other collaborations on this folder.
*/
public boolean getCanNonOwnersViewCollaborators() {
return this.canNonOwnersViewCollaborators;
}

/**
* Sets whether collaborators who are not owners of this folder
* are restricted from viewing other collaborations on this folder.
*
* @param canNonOwnersViewCollaborators indicates if collaborators who are not owners of this folder
* are restricted from viewing other collaborations on this folderr.
*/
public void setCanNonOwnersViewCollaborators(boolean canNonOwnersViewCollaborators) {
this.canNonOwnersViewCollaborators = canNonOwnersViewCollaborators;
this.addPendingChange("can_non_owners_view_collaborators", canNonOwnersViewCollaborators);
}


@Override
public BoxFolder getResource() {
Expand Down Expand Up @@ -1729,6 +1753,9 @@ protected void parseJSONMember(JsonObject.Member member) {
case "is_accessible_via_shared_link":
this.isAccessibleViaSharedLink = value.asBoolean();
break;
case "can_non_owners_view_collaborators":
this.canNonOwnersViewCollaborators = value.asBoolean();
break;
default:
break;
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/Fixtures/BoxFolder/GetFolderInfo200.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,6 @@
"can_set_share_access": true,
"can_share": true,
"can_upload": true
}
},
"can_non_owners_view_collaborators": true
}
1 change: 1 addition & 0 deletions src/test/java/com/box/sdk/BoxFolderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ public void testGetFolderInfoSucceeds() {
assertEquals(classificationDefinition, info.getClassification().getDefinition());
assertEquals(classificationName, info.getClassification().getName());
assertTrue(info.getIsAccessibleViaSharedLink());
assertTrue(info.getCanNonOwnersViewCollaborators());
}

@Test
Expand Down
Loading