-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PAYM-2967 Added contentservices dependency to ingest payment templates
- Loading branch information
Goutama Bhat
committed
Feb 24, 2022
1 parent
faede23
commit 2cd6b1a
Showing
19 changed files
with
414 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
.../com/backbase/ct/bbfuel/client/contentservices/ContentServicesPresentationRestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.backbase.ct.bbfuel.client.contentservices; | ||
|
||
import com.backbase.ct.bbfuel.client.common.RestClient; | ||
import com.backbase.ct.bbfuel.config.BbFuelConfiguration; | ||
import com.backbase.dbs.contentservices.client.v2.model.Repository; | ||
import io.restassured.http.ContentType; | ||
import java.io.File; | ||
import java.util.List; | ||
import javax.annotation.PostConstruct; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ContentServicesPresentationRestClient extends RestClient { | ||
|
||
private final BbFuelConfiguration config; | ||
|
||
private static final String ENDPOINT_REPOSITORY_CREATE = "/repositories"; | ||
private static final String ENDPOINT_REPOSITORY_UPLOAD = "/repositories/{repositoryId}/upload"; | ||
private static final String PATH_PARAM_REPOSITORY_ID = "repositoryId"; | ||
private static final String QUERY_PARAM_NAME = "name"; | ||
private static final String QUERY_PARAM_TARGET_PATH = "targetPath"; | ||
|
||
@PostConstruct | ||
public void init() { | ||
setBaseUri(config.getPlatform().getGateway()); | ||
setInitialPath(String.format("%s/%s", config.getDbsServiceNames().getContentservices(), CLIENT_API)); | ||
} | ||
|
||
public void createRepositories(List<Repository> repositories) { | ||
requestSpec() | ||
.contentType(ContentType.JSON) | ||
.body(repositories) | ||
.post(ENDPOINT_REPOSITORY_CREATE); | ||
} | ||
|
||
public void uploadTemplate(String repositoryId, String name, String targetPath, File template) { | ||
requestSpec() | ||
.pathParam(PATH_PARAM_REPOSITORY_ID, repositoryId) | ||
.queryParam(QUERY_PARAM_NAME, name) | ||
.queryParam(QUERY_PARAM_TARGET_PATH, targetPath) | ||
.multiPart(template) | ||
.post(ENDPOINT_REPOSITORY_UPLOAD); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/com/backbase/ct/bbfuel/configurator/ContentServicesConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.backbase.ct.bbfuel.configurator; | ||
|
||
import static com.backbase.ct.bbfuel.data.ContentServicesDataGenerator.createRepositories; | ||
|
||
import com.backbase.ct.bbfuel.client.common.LoginRestClient; | ||
import com.backbase.ct.bbfuel.client.contentservices.ContentServicesPresentationRestClient; | ||
import java.io.File; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class ContentServicesConfigurator { | ||
|
||
private final ContentServicesPresentationRestClient contentServicesPresentationRestClient; | ||
private final LoginRestClient loginRestClient; | ||
|
||
@SuppressWarnings("squid:S1075") | ||
public void ingestContentForPayments() { | ||
|
||
final String repositoryId = "payments"; | ||
final String targetPath = "/templates"; | ||
final File paymentTemplate = new File("src/main/resources/data/content/paymentTemplate.hbs"); | ||
|
||
log.info("Uploading template {} to repository {}", paymentTemplate.getName(), repositoryId); | ||
|
||
loginRestClient.loginBankAdmin(); | ||
|
||
// create repository in content services | ||
contentServicesPresentationRestClient.createRepositories(createRepositories(repositoryId)); | ||
|
||
// upload template file as content to repository | ||
contentServicesPresentationRestClient.uploadTemplate(repositoryId, paymentTemplate.getName(), targetPath, paymentTemplate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/com/backbase/ct/bbfuel/data/ContentServicesDataGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.backbase.ct.bbfuel.data; | ||
|
||
import com.backbase.dbs.contentservices.client.v2.model.AntivirusScanTrigger; | ||
import com.backbase.dbs.contentservices.client.v2.model.Repository; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class ContentServicesDataGenerator { | ||
|
||
private ContentServicesDataGenerator() { | ||
} | ||
|
||
public static List<Repository> createRepositories(String... repositoryIds) { | ||
return Arrays.stream(repositoryIds) | ||
.map(repositoryId -> | ||
new Repository() | ||
.repositoryId(repositoryId) | ||
.name(repositoryId) | ||
.description(String.format("Repository for %s", repositoryId)) | ||
.implementation("DB") | ||
.versioningEnabled(false) | ||
.isPrivate(false) | ||
.antivirusScanTrigger(AntivirusScanTrigger.NONE)) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.