Skip to content

Commit 9119adc

Browse files
authored
feat: add canNonOwnersViewCollaborators flag to Folder (#1288)
1 parent f6c37ce commit 9119adc

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

src/intTest/java/com/box/sdk/BoxFolderIT.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,32 @@ public void updateFolderInfoSucceeds() {
262262
}
263263
}
264264

265+
@Test
266+
public void updateCanNonOwnersViewCollaboratorsSucceeds() {
267+
BoxAPIConnection api = jwtApiForServiceAccount();
268+
BoxFolder rootFolder = getUniqueFolder(api);
269+
final String name = "[updateCanNonOwnersViewCollaboratorsSucceeds] Child Folder";
270+
BoxFolder childFolder = null;
271+
272+
try {
273+
BoxFolder.Info info = rootFolder.createFolder(name);
274+
childFolder = info.getResource();
275+
boolean getCanNonOwnersViewCollaborators = childFolder.getInfo("can_non_owners_view_collaborators")
276+
.getCanNonOwnersViewCollaborators();
277+
// need to set both
278+
info.setCanNonOwnersViewCollaborators(!getCanNonOwnersViewCollaborators);
279+
info.setCanNonOwnersInvite(!getCanNonOwnersViewCollaborators);
280+
childFolder.updateInfo(info);
281+
282+
assertThat(info.getCanNonOwnersViewCollaborators(), equalTo(!getCanNonOwnersViewCollaborators));
283+
assertThat(info.getCanNonOwnersInvite(), equalTo(!getCanNonOwnersViewCollaborators));
284+
} finally {
285+
this.deleteFolder(childFolder);
286+
assertThat(rootFolder,
287+
not(hasItem(Matchers.<BoxItem.Info>hasProperty("ID", equalTo(childFolder.getID())))));
288+
}
289+
}
290+
265291
@Test
266292
public void copyFolderToSameDestinationWithNewNameSucceeds() {
267293
BoxAPIConnection api = jwtApiForServiceAccount();

src/main/java/com/box/sdk/BoxFolder.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class BoxFolder extends BoxItem implements Iterable<BoxItem.Info> {
4343
"item_status", "item_collection", "sync_state", "has_collaborations", "permissions", "tags",
4444
"can_non_owners_invite", "collections", "watermark_info", "metadata", "is_externally_owned",
4545
"is_collaboration_restricted_to_enterprise", "allowed_shared_link_access_levels", "allowed_invitee_roles",
46-
"is_accessible_via_shared_link"
46+
"is_accessible_via_shared_link", "can_non_owners_view_collaborators"
4747
};
4848
/**
4949
* Create Folder URL Template.
@@ -1467,6 +1467,7 @@ public class Info extends BoxItem.Info {
14671467
private BoxClassification classification;
14681468

14691469
private boolean isAccessibleViaSharedLink;
1470+
private boolean canNonOwnersViewCollaborators;
14701471

14711472
/**
14721473
* Constructs an empty Info object.
@@ -1668,6 +1669,29 @@ public boolean getIsAccessibleViaSharedLink() {
16681669
return this.isAccessibleViaSharedLink;
16691670
}
16701671

1672+
/**
1673+
* Returns the flag indicating if collaborators who are not owners of this folder
1674+
* are restricted from viewing other collaborations on this folder.
1675+
*
1676+
* @return boolean flag indicating if collaborators who are not owners of this folder
1677+
* are restricted from viewing other collaborations on this folder.
1678+
*/
1679+
public boolean getCanNonOwnersViewCollaborators() {
1680+
return this.canNonOwnersViewCollaborators;
1681+
}
1682+
1683+
/**
1684+
* Sets whether collaborators who are not owners of this folder
1685+
* are restricted from viewing other collaborations on this folder.
1686+
*
1687+
* @param canNonOwnersViewCollaborators indicates if collaborators who are not owners of this folder
1688+
* are restricted from viewing other collaborations on this folderr.
1689+
*/
1690+
public void setCanNonOwnersViewCollaborators(boolean canNonOwnersViewCollaborators) {
1691+
this.canNonOwnersViewCollaborators = canNonOwnersViewCollaborators;
1692+
this.addPendingChange("can_non_owners_view_collaborators", canNonOwnersViewCollaborators);
1693+
}
1694+
16711695

16721696
@Override
16731697
public BoxFolder getResource() {
@@ -1729,6 +1753,9 @@ protected void parseJSONMember(JsonObject.Member member) {
17291753
case "is_accessible_via_shared_link":
17301754
this.isAccessibleViaSharedLink = value.asBoolean();
17311755
break;
1756+
case "can_non_owners_view_collaborators":
1757+
this.canNonOwnersViewCollaborators = value.asBoolean();
1758+
break;
17321759
default:
17331760
break;
17341761
}

src/test/Fixtures/BoxFolder/GetFolderInfo200.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,6 @@
116116
"can_set_share_access": true,
117117
"can_share": true,
118118
"can_upload": true
119-
}
119+
},
120+
"can_non_owners_view_collaborators": true
120121
}

src/test/java/com/box/sdk/BoxFolderTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ public void testGetFolderInfoSucceeds() {
553553
assertEquals(classificationDefinition, info.getClassification().getDefinition());
554554
assertEquals(classificationName, info.getClassification().getName());
555555
assertTrue(info.getIsAccessibleViaSharedLink());
556+
assertTrue(info.getCanNonOwnersViewCollaborators());
556557
}
557558

558559
@Test

0 commit comments

Comments
 (0)