Skip to content

Commit

Permalink
Fix exception on missing class name in custom object
Browse files Browse the repository at this point in the history
  • Loading branch information
lojzatran committed Jan 18, 2024
1 parent 0d12c98 commit f83b16b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ Example:
##### Download

```bash
docker pull commercetools/commercetools-project-sync:5.4.5
docker pull commercetools/commercetools-project-sync:5.4.6
```
##### Run

Expand All @@ -222,14 +222,14 @@ docker run \
-e TARGET_PROJECT_KEY=xxxx \
-e TARGET_CLIENT_ID=xxxx \
-e TARGET_CLIENT_SECRET=xxxx \
commercetools/commercetools-project-sync:5.4.5 -s all
commercetools/commercetools-project-sync:5.4.6 -s all
```


### Examples
- To run the all sync modules from a source project to a target project
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s all
docker run commercetools/commercetools-project-sync:5.4.6 -s all
```
This will run the following sync modules in the given order:
1. `Type` Sync and `ProductType` Sync and `States` Sync and `TaxCategory` Sync and `CustomObject` Sync in parallel.
Expand All @@ -239,70 +239,70 @@ commercetools/commercetools-project-sync:5.4.5 -s all

- To run the type sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s types
docker run commercetools/commercetools-project-sync:5.4.6 -s types
```

- To run the productType sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s productTypes
docker run commercetools/commercetools-project-sync:5.4.6 -s productTypes
```

- To run the states sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s states
docker run commercetools/commercetools-project-sync:5.4.6 -s states
```
- To run the taxCategory sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s taxCategories
docker run commercetools/commercetools-project-sync:5.4.6 -s taxCategories
```

- To run the category sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s categories
docker run commercetools/commercetools-project-sync:5.4.6 -s categories
```

- To run the product sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s products
docker run commercetools/commercetools-project-sync:5.4.6 -s products
```

- To run the cartDiscount sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s cartDiscounts
docker run commercetools/commercetools-project-sync:5.4.6 -s cartDiscounts
```

- To run the inventoryEntry sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s inventoryEntries
docker run commercetools/commercetools-project-sync:5.4.6 -s inventoryEntries
```

- To run the customObject sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s customObjects
docker run commercetools/commercetools-project-sync:5.4.6 -s customObjects
```

- To run the customer sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s customers
docker run commercetools/commercetools-project-sync:5.4.6 -s customers
```

- To run the shoppingList sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s shoppingLists
docker run commercetools/commercetools-project-sync:5.4.6 -s shoppingLists
```
- To run both products and shoppingList sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s products shoppingLists
docker run commercetools/commercetools-project-sync:5.4.6 -s products shoppingLists
```

- To run type, productType and shoppingList sync
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s types productTypes shoppingLists
docker run commercetools/commercetools-project-sync:5.4.6 -s types productTypes shoppingLists
```

- To run all sync modules using a runner name
```bash
docker run commercetools/commercetools-project-sync:5.4.5 -s all -r myRunnerName
docker run commercetools/commercetools-project-sync:5.4.6 -s all -r myRunnerName
```

## Scopes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ public BaseSyncStatistics deserialize(JsonParser jsonParser, DeserializationCont
final ObjectMapper mapper = (ObjectMapper) jsonParser.getCodec();
final JsonNode syncStatisticsNode = mapper.readTree(jsonParser);
try {
final String syncStatisticsClassName =
syncStatisticsNode.get("syncStatisticsClassName").asText();
final JsonNode syncStatisticsClassNameJsonNode =
syncStatisticsNode.get("syncStatisticsClassName");
if (syncStatisticsClassNameJsonNode == null) {
throw new ClassNotFoundException();
}
final String syncStatisticsClassName = syncStatisticsClassNameJsonNode.asText();
final Class<? extends BaseSyncStatistics> c =
Class.forName(syncStatisticsClassName).asSubclass(BaseSyncStatistics.class);
return mapper.treeToValue(syncStatisticsNode, c);
Expand Down

0 comments on commit f83b16b

Please sign in to comment.