Skip to content

Commit

Permalink
fix(box-connector): Avoid refetching data of deleted items (#3981)
Browse files Browse the repository at this point in the history
* fix(box-connector): Avoid refetching data of deleted items

* fix(box-connector): Add constraints to search request properties

(cherry picked from commit 9fc2d99)
  • Loading branch information
sbuettner committed Feb 11, 2025
1 parent 9648304 commit ed44e21
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
6 changes: 6 additions & 0 deletions connectors/box/element-templates/box-outbound-connector.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@
"id" : "operation.searchQuery",
"label" : "Search query",
"optional" : false,
"constraints" : {
"notEmpty" : true
},
"feel" : "optional",
"group" : "operation",
"binding" : {
Expand All @@ -486,6 +489,9 @@
"description" : "Column for sorting search results",
"optional" : false,
"value" : "modified_at",
"constraints" : {
"notEmpty" : true
},
"feel" : "optional",
"group" : "operation",
"binding" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@
"id" : "operation.searchQuery",
"label" : "Search query",
"optional" : false,
"constraints" : {
"notEmpty" : true
},
"feel" : "optional",
"group" : "operation",
"binding" : {
Expand All @@ -491,6 +494,9 @@
"description" : "Column for sorting search results",
"optional" : false,
"value" : "modified_at",
"constraints" : {
"notEmpty" : true
},
"feel" : "optional",
"group" : "operation",
"binding" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import com.box.sdk.BoxItem;
import com.box.sdk.BoxSearch;
import com.box.sdk.BoxSearchParameters;
import com.box.sdk.IAccessTokenCache;
import com.box.sdk.InMemoryLRUAccessTokenCache;
import io.camunda.connector.api.outbound.OutboundConnectorContext;
import io.camunda.connector.box.model.BoxRequest;
import io.camunda.connector.box.model.BoxRequest.Operation.Search.SortDirection;
Expand Down Expand Up @@ -51,15 +49,17 @@ private static BoxAPIConnection connectToApi(BoxRequest.Authentication authentic
return switch (authentication) {
case BoxRequest.Authentication.DeveloperToken developerToken ->
new BoxAPIConnection(developerToken.accessToken());

case BoxRequest.Authentication.ClientCredentialsUser user ->
BoxCCGAPIConnection.userConnection(user.clientId(), user.clientSecret(), user.userId());

case BoxRequest.Authentication.ClientCredentialsEnterprise enterprise ->
BoxCCGAPIConnection.applicationServiceAccountConnection(
enterprise.clientId(), enterprise.clientSecret(), enterprise.enterpriseId());

case BoxRequest.Authentication.JWTJsonConfig jwtJsonConfig -> {
BoxConfig boxConfig = BoxConfig.readFrom(jwtJsonConfig.jsonConfig());
IAccessTokenCache tokenCache = new InMemoryLRUAccessTokenCache(100);
yield BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(boxConfig, tokenCache);
yield BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(boxConfig);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,14 @@ public static byte[] download(BoxFile file) {
}

public static BoxResult.Item item(BoxFile file) {
return new BoxResult.Item(file.getID(), file.getInfo().getName(), file.getInfo().getType());
return new BoxResult.Item(file.getID(), "file");
}

public static BoxResult.Item item(BoxFolder folder) {
return new BoxResult.Item(
folder.getID(), folder.getInfo().getName(), folder.getInfo().getType());
return new BoxResult.Item(folder.getID(), "folder");
}

public static BoxResult.Item item(BoxItem.Info info) {
return new BoxResult.Item(info.getID(), info.getName(), info.getType());
return new BoxResult.Item(info.getID(), info.getType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,13 @@ record DeleteFile(

@TemplateSubType(id = "search", label = "Search")
record Search(
@TemplateProperty(id = "searchQuery", group = "operation") String query,
@TemplateProperty(id = "searchQuery", group = "operation") @NotBlank String query,
@TemplateProperty(
id = "searchSortColumn",
defaultValue = "modified_at",
description = "Column for sorting search results",
group = "operation")
@NotBlank
String sortColumn,
@TemplateProperty(
id = "searchSortDirection",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public sealed interface BoxResult
permits BoxResult.Download, BoxResult.Generic, BoxResult.Search, BoxResult.Upload {
record Item(String id, String name, String type) {}
record Item(String id, String type) {}

record Download(Item item, Document document) implements BoxResult {}

Expand Down

0 comments on commit ed44e21

Please sign in to comment.