Skip to content
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
31 changes: 17 additions & 14 deletions doc/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,26 +646,30 @@ Create a Shared Link
--------------------

A shared link for a file can be generated by calling
[`createSharedLink(BoxSharedLink.Access accessLevel, Date unshareDate, BoxSharedLink.Permissions permissions)`][create-shared-link].
[`createSharedLink(BoxSharedLinkRequest sharedLinkRequest)`][create-shared-link].

<!-- sample put_files_id add_shared_link -->
```java
// Optionally we can calculate and set the date when shared link will automatically be disabled
final long ONE_WEEK_MILLIS = 1000 * 60 * 60 * 24 * 7;
long unsharedTimestamp = System.currentTimeMillis() + ONE_WEEK_MILLIS;
Date unsharedDate = new Date(unsharedTimestamp);

BoxFile file = new BoxFile(api, "id");
BoxSharedLink.Permissions permissions = new BoxSharedLink.Permissions();
permissions.setCanDownload(true);
permissions.setCanPreview(true);
Date unshareDate = new Date();
BoxSharedLink sharedLink = file.createSharedLink(BoxSharedLink.Access.OPEN, null, permissions);
BoxSharedLinkRequest sharedLinkRequest = new BoxSharedLinkRequest()
.access(OPEN)
.permissions(true, true)
.unsharedDate(unsharedDate);
BoxSharedLink sharedLink = file.createSharedLink(sharedLinkRequest);
```

A set of shared link access level constants are available through the SDK for convenience:
* `BoxSharedLink.Access.OPEN`
* `BoxSharedLink.Access.COLLABORATORS`
* `BoxSharedLink.Access.COMPANY`
* `BoxSharedLink.Access.DEFAULT`
* `accessLevels.DISABLED`

[create-shared-link]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFile.html#createSharedLink-com.box.sdk.BoxSharedLink.Access-java.util.Date-com.box.sdk.BoxSharedLink.Permissions-
[create-shared-link]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFile.html#createSharedLink-com.box.sdk.sharedlink.BoxSharedLinkRequest-

Get a Shared Link
-----------------
Expand All @@ -687,16 +691,15 @@ Update a Shared Link
--------------------

A shared link for a file can be updated by calling the same method as used when creating a shared link,
[`createSharedLink(BoxSharedLink.Access accessLevel, Date unshareDate, BoxSharedLink.Permissions permissions)`][create-shared-link].
[`createSharedLink(BoxSharedLinkRequest sharedLinkRequest)`][create-shared-link].

<!-- sample put_files_id update_shared_link -->
```java
BoxFile file = new BoxFile(api, "id");
BoxSharedLink.Permissions permissions = new BoxSharedLink.Permissions();
permissions.setCanDownload(true);
permissions.setCanPreview(true);
Date unshareDate = new Date();
BoxSharedLink sharedLink = file.createSharedLink(BoxSharedLink.Access.OPEN, null, permissions);
BoxSharedLinkRequest sharedLinkRequest = new BoxSharedLinkRequest()
.access(OPEN)
.permissions(true, true);
BoxSharedLink sharedLink = file.createSharedLink(sharedLinkRequest);
```

Remove a Shared Link
Expand Down
32 changes: 18 additions & 14 deletions doc/folders.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,26 +313,30 @@ Create a Shared Link
--------------------

A shared link for a folder can be generated by calling
[`createSharedLink(BoxSharedLink.Access accessLevel, Date unshareDate, BoxSharedLink.Permissions permissions)`][create-shared-link].
[`createSharedLink(BoxSharedLinkRequest sharedLinkRequest)`][create-shared-link].

<!-- sample put_folders_id add_shared_link -->
```java
// Optionally we can calculate and set the date when shared link will automatically be disabled
final long ONE_WEEK_MILLIS = 1000 * 60 * 60 * 24 * 7;
long unsharedTimestamp = System.currentTimeMillis() + ONE_WEEK_MILLIS;
Date unsharedDate = new Date(unsharedTimestamp);

BoxFolder folder = new BoxFolder(api, "id");
BoxSharedLink.Permissions permissions = new BoxSharedLink.Permissions();
permissions.setCanDownload(true);
permissions.setCanPreview(true);
Date unshareDate = new Date();
BoxSharedLink sharedLink = folder.createSharedLink(BoxSharedLink.Access.OPEN, null, permissions);
BoxSharedLinkRequest sharedLinkRequest = new BoxSharedLinkRequest()
.access(OPEN)
.permissions(true, true)
.unsharedDate(unsharedDate);
BoxSharedLink sharedLink = folder.createSharedLink(sharedLinkRequest);
```

A set of shared link access level constants are available through the SDK for convenience:
* `BoxSharedLink.Access.OPEN`
* `BoxSharedLink.Access.COLLABORATORS`
* `BoxSharedLink.Access.COMPANY`
* `BoxSharedLink.Access.DEFAULT`
* `accessLevels.DISABLED`

[create-shared-link]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFolder.html#createSharedLink-com.box.sdk.BoxSharedLink.Access-java.util.Date-com.box.sdk.BoxSharedLink.Permissions-
[create-shared-link]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxFolder.html#createSharedLink-com.box.sdk.sharedlink.BoxSharedLinkRequest-

Get a Shared Link
-----------------
Expand All @@ -354,16 +358,16 @@ Update a Shared Link
--------------------

A shared link for a folder can be updated by calling the same method as used when creating a shared link,
[`createSharedLink(BoxSharedLink.Access accessLevel, Date unshareDate, BoxSharedLink.Permissions permissions)`][create-shared-link].
[`createSharedLink(BoxSharedLinkRequest sharedLinkRequest)`][create-shared-link].

<!-- sample put_folders_id update_shared_link -->
```java
BoxFolder folder = new BoxFolder(api, "id");
BoxSharedLink.Permissions permissions = new BoxSharedLink.Permissions();
permissions.setCanDownload(true);
permissions.setCanPreview(true);
Date unshareDate = new Date();
BoxSharedLink sharedLink = folder.createSharedLink(BoxSharedLink.Access.OPEN, null, permissions);
BoxSharedLinkRequest sharedLinkRequest = new BoxSharedLinkRequest()
.access(OPEN)
.permissions(true, true);

BoxSharedLink sharedLink = folder.createSharedLink(sharedLinkRequest);
```

Remove a Shared Link
Expand Down
15 changes: 11 additions & 4 deletions doc/weblinks.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,23 @@ Create a Shared Link
--------------------

You can create a shared link for a web link by calling the
[`createSharedLink(BoxSharedLink.Access accessLevel, Date expirationDate, BoxSharedLink.Permissions permissions)`][create-shared-link]
[`createSharedLink(BoxSharedLinkWithoutPermissionsRequest sharedLinkRequest)`][create-shared-link]
method.

```java
// Optionally we can calculate and set the date when shared link will automatically be disabled
final long ONE_WEEK_MILLIS = 1000 * 60 * 60 * 24 * 7;
long unsharedTimestamp = System.currentTimeMillis() + ONE_WEEK_MILLIS;
Date unsharedDate = new Date(unsharedTimestamp);

BoxWebLink webLink = new BoxWebLink(api, "id");
SharedLink link = webLink.createSharedLink(BoxSharedLink.Access.OPEN, null,
permissions);
BoxSharedLinkWithoutPermissionsRequest sharedLinkRequest = new BoxSharedLinkWithoutPermissionsRequest()
.access(OPEN)
.unsharedDate(unsharedDate);
BoxSharedLink sharedLink = webLink.createSharedLink(sharedLinkRequest);
```

[create-shared-link]: https://box.github.io/box-java-sdk/javadoc/com/box/sdk/BoxWebLink.html#createSharedLink-com.box.sdk.BoxSharedLink.Access-java.util.Date-com.box.sdk.BoxSharedLink.Permissions-
[create-shared-link]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxWebLink.html#createSharedLink-com.box.sdk.sharedlink.BoxSharedLinkWithoutPermissionsRequest-

Remove a Shared Link
--------------------
Expand Down