Skip to content

Commit

Permalink
Update Box Java SDK to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
wadimw committed Oct 3, 2023
1 parent 5fbd960 commit 1407f1d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
<dependency>
<groupId>com.box</groupId>
<artifactId>box-java-sdk</artifactId>
<version>2.1.1</version>
<version>4.6.0</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected BoxAPIConnection createBoxAPIConnection() throws BoxSDKServiceExceptio
BoxSDKServiceConfig boxSDKServiceConfig = boxSDKServiceConfigProvider.getConfig();
JWTEncryptionPreferences encryptionPref = boxSDKJWTProvider.getJWTEncryptionPreferences(boxSDKServiceConfig);

return BoxDeveloperEditionAPIConnection.getAppUserConnection(
return BoxDeveloperEditionAPIConnection.getUserConnection(
boxSDKServiceConfig.getAppUserId(),
boxSDKServiceConfig.getClientId(),
boxSDKServiceConfig.getClientSecret(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.box.sdk.BoxFolder;
import com.box.sdk.BoxItem;
import com.box.sdk.BoxSharedLink;
import com.box.sdk.sharedlink.BoxSharedLinkRequest;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -89,7 +90,7 @@ public BoxFolder createSharedFolder(String folderName, String parentId) throws B
BoxFolder createFolder = createFolder(folderName, parentId);

try {
createFolder.createSharedLink(BoxSharedLink.Access.OPEN, null, null);
createFolder.createSharedLink(new BoxSharedLinkRequest().access(BoxSharedLink.Access.OPEN));
return createFolder;
} catch (BoxAPIException e) {
throw new BoxSDKServiceException("Can't create shared link for directory: " + createFolder.getID(), e);
Expand Down Expand Up @@ -157,7 +158,7 @@ public BoxFile uploadFile(String folderId, String filename, String filecontent)
logger.debug("Uploaded new file, id: " + uploadFile.getID() + ", name: " + filename);
} else {
logger.debug("Upload a new version of file named: {} to folder: {}", filename, folderId);
uploadFile.uploadVersion(IOUtils.toInputStream(filecontent, StandardCharsets.UTF_8));
uploadFile.uploadNewVersion(IOUtils.toInputStream(filecontent, StandardCharsets.UTF_8));

logger.debug("Uploaded new version of file, id: " + uploadFile.getID() + ", name: " + filename);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.box.sdk.BoxFolder;
import com.box.sdk.BoxSharedLink;
import com.box.sdk.BoxUser;
import com.box.sdk.sharedlink.BoxSharedLinkRequest;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -215,7 +216,7 @@ private void validateConfig(BoxSDKServiceConfigEntity boxSDKServiceConfig, @Pare
try {
BoxAPIConnection apiConnection = boxAPIConnectionProvider.getConnection();
BoxFolder mojitoFolder = new BoxFolder(apiConnection, boxSDKServiceConfig.getRootFolderId());
BoxSharedLink sharedLink = mojitoFolder.createSharedLink(BoxSharedLink.Access.COLLABORATORS, null, null);
BoxSharedLink sharedLink = mojitoFolder.createSharedLink(new BoxSharedLinkRequest().access(BoxSharedLink.Access.COLLABORATORS));

boxSDKServiceConfig.setRootFolderUrl(sharedLink.getURL());
boxSDKServiceConfig.setValidated(true);
Expand Down

0 comments on commit 1407f1d

Please sign in to comment.