Skip to content

Commit

Permalink
PAYM-2967 Added contentservices dependency to ingest payment templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Goutama Bhat committed Feb 24, 2022
1 parent faede23 commit 2cd6b1a
Show file tree
Hide file tree
Showing 19 changed files with 414 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ bb-fuel is a Backbase DBS data loader tool for test and demo data. It can ingest
- Bill Pay
- Account Statements
- Positive Pay
- Contents

It is based on REST and relies on DBS service specs.

Expand Down
10 changes: 10 additions & 0 deletions docs/CAPABILITY_DATA_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,13 @@ backbase:
approval:
enabled: false
```

## Contentservices setup

- If the property `ingest.content.for.payments` is set to `true` then payments content is ingested into contentservices.
- The contentservices should be configured with below configuration to support the payments content upload.
```
contentservices:
whitelist:
allowedContentTypes: application/octet-stream,text/html,image/svg+xml
```
2 changes: 2 additions & 0 deletions jenkins/bb-fuel-minimal.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pipeline {
booleanParam(name: 'INGEST_CONTACTS', defaultValue: false, description: 'Ingest contacts per user')
booleanParam(name: 'INGEST_NOTIFICATIONS', defaultValue: false, description: 'Ingest notifications on global target group')
booleanParam(name: 'INGEST_PAYMENTS', defaultValue: false, description: 'Ingest payments per user')
booleanParam(name: 'INGEST_CONTENT_FOR_PAYMENTS', defaultValue: false, description: 'Ingest content for payments')
booleanParam(name: 'INGEST_MESSAGES', defaultValue: false, description: 'Ingest messages per user')
booleanParam(name: 'INGEST_ACTIONS', defaultValue: false, description: 'Ingest actions per user')
booleanParam(name: 'INGEST_BILLPAY', defaultValue: false, description: 'Enrol users into Bill Pay')
Expand Down Expand Up @@ -78,6 +79,7 @@ pipeline {
"-Dingest.contacts=${params.INGEST_CONTACTS} " +
"-Dingest.notifications=${params.INGEST_NOTIFICATIONS} " +
"-Dingest.payments=${params.INGEST_PAYMENTS} " +
"-Dingest.content.for.payments=${params.INGEST_CONTENT_FOR_PAYMENTS} " +
"-Dingest.messages=${params.INGEST_MESSAGES} " +
"-Dingest.actions=${params.INGEST_ACTIONS} " +
"-Dingest.billpay=${params.INGEST_BILLPAY} " +
Expand Down
2 changes: 2 additions & 0 deletions jenkins/bb-fuel.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pipeline {
booleanParam(name: 'INGEST_CONTACTS', defaultValue: false, description: 'Ingest contacts per user')
booleanParam(name: 'INGEST_NOTIFICATIONS', defaultValue: false, description: 'Ingest notifications on global target group')
booleanParam(name: 'INGEST_PAYMENTS', defaultValue: false, description: 'Ingest payments per user')
booleanParam(name: 'INGEST_CONTENT_FOR_PAYMENTS', defaultValue: false, description: 'Ingest content for payments')
booleanParam(name: 'INGEST_MESSAGES', defaultValue: false, description: 'Ingest messages per user')
booleanParam(name: 'INGEST_ACTIONS', defaultValue: false, description: 'Ingest actions per user')
booleanParam(name: 'INGEST_BILLPAY', defaultValue: false, description: 'Enrol users into Bill Pay')
Expand Down Expand Up @@ -82,6 +83,7 @@ pipeline {
"-Dingest.contacts=${params.INGEST_CONTACTS} " +
"-Dingest.notifications=${params.INGEST_NOTIFICATIONS} " +
"-Dingest.payments=${params.INGEST_PAYMENTS} " +
"-Dingest.content.for.payments=${params.INGEST_CONTENT_FOR_PAYMENTS} " +
"-Dingest.messages=${params.INGEST_MESSAGES} " +
"-Dingest.actions=${params.INGEST_ACTIONS} " +
"-Dingest.billpay=${params.INGEST_BILLPAY} " +
Expand Down
27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<arrangement-integration-outbound-link-account-api.version>2.1.1</arrangement-integration-outbound-link-account-api.version>
<arrangement-integration-outbound-origination-api.version>1.0.3</arrangement-integration-outbound-origination-api.version>
<arrangement-integration-inbound-api.version>2.4.1</arrangement-integration-inbound-api.version>
<contentservices-client-api.version>2.6.0</contentservices-client-api.version>

</properties>

Expand Down Expand Up @@ -442,6 +443,18 @@
<fromFile>arrangement-integration-inbound-api-v${arrangement-integration-inbound-api.version}.yaml</fromFile>
</configuration>
</execution>

<execution>
<id>download-contentservices-client-api-spec</id>
<goals>
<goal>download-single</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<url>https://repo.backbase.com/specs/contentservices</url>
<fromFile>contentservices-client-api-v${contentservices-client-api.version}.yaml</fromFile>
</configuration>
</execution>
</executions>
</plugin>

Expand Down Expand Up @@ -584,6 +597,20 @@
</configOptions>
</configuration>
</execution>

<execution>
<id>generate-contentservices-client-code</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${api.target}/contentservices-client-api-v${contentservices-client-api.version}.yaml</inputSpec>
<configOptions>
<apiPackage>com.backbase.dbs.contentservices.client.v2</apiPackage>
<modelPackage>com.backbase.dbs.contentservices.client.v2.model</modelPackage>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>

Expand Down
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);
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/backbase/ct/bbfuel/config/DbsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,9 @@ public class DbsConfig {
* URI to positivePay.
*/
private String positivePay;

/**
* URI to contentServices.
*/
private String contentservices;
}
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ private CommonConstants() {
public static final String PROPERTY_INGEST_APPROVALS_FOR_NOTIFICATIONS = "ingest.approvals.for.notifications";
public static final String PROPERTY_INGEST_APPROVALS_FOR_BATCHES = "ingest.approvals.for.batches";
public static final String PROPERTY_INGEST_LIMITS = "ingest.limits";
public static final String PROPERTY_INGEST_CONTENT_FOR_PAYMENTS = "ingest.content.for.payments";
public static final String PROPERTY_CONTACTS_MIN = "contacts.min";
public static final String PROPERTY_CONTACTS_MAX = "contacts.max";
public static final String PROPERTY_CONTACTS_ACCOUNT_TYPES = "contacts.account.types";
Expand Down
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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static com.backbase.ct.bbfuel.data.CommonConstants.PROPERTY_INGEST_BILLPAY;
import static com.backbase.ct.bbfuel.data.CommonConstants.PROPERTY_INGEST_BILLPAY_ACCOUNTS;
import static com.backbase.ct.bbfuel.data.CommonConstants.PROPERTY_INGEST_CONTACTS;
import static com.backbase.ct.bbfuel.data.CommonConstants.PROPERTY_INGEST_CONTENT_FOR_PAYMENTS;
import static com.backbase.ct.bbfuel.data.CommonConstants.PROPERTY_INGEST_LIMITS;
import static com.backbase.ct.bbfuel.data.CommonConstants.PROPERTY_INGEST_MESSAGES;
import static com.backbase.ct.bbfuel.data.CommonConstants.PROPERTY_INGEST_NOTIFICATIONS;
Expand All @@ -29,6 +30,7 @@
import com.backbase.ct.bbfuel.configurator.ApprovalsConfigurator;
import com.backbase.ct.bbfuel.configurator.BillPayConfigurator;
import com.backbase.ct.bbfuel.configurator.ContactsConfigurator;
import com.backbase.ct.bbfuel.configurator.ContentServicesConfigurator;
import com.backbase.ct.bbfuel.configurator.LimitsConfigurator;
import com.backbase.ct.bbfuel.configurator.MessagesConfigurator;
import com.backbase.ct.bbfuel.configurator.NotificationsConfigurator;
Expand Down Expand Up @@ -79,6 +81,7 @@ public class CapabilitiesDataSetup extends BaseSetup {
private final UserPresentationRestClient userPresentationRestClient;
private final PocketTailorActuatorClient pocketTailorActuatorClient;
private final TransactionsConfigurator transactionsConfigurator;
private final ContentServicesConfigurator contentServicesConfigurator;

/**
* Ingest data with services of projects APPR, PO, LIM, NOT, CON, MC, ACT, BPAY and Pockets.
Expand All @@ -97,6 +100,7 @@ public void initiate() {
this.ingestPockets();
this.ingestAccountStatementForSelectedUser();
this.ingestPositivePayChecksForSelectedUser();
this.ingestContents();
}

private void ingestApprovals() {
Expand Down Expand Up @@ -293,5 +297,11 @@ private void ingestPositivePayChecksForSelectedUser() {
.forEach(this.positivePayConfigurator::ingestPositivePayChecks);
}
}

private void ingestContents() {
if (this.globalProperties.getBoolean(PROPERTY_INGEST_CONTENT_FOR_PAYMENTS)) {
this.contentServicesConfigurator.ingestContentForPayments();
}
}
}

4 changes: 3 additions & 1 deletion src/main/resources/application-baas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ bb-fuel:
accountStatement: https://app.${environment.name}.${environment.domain}/accountstatementsintegration/service-api
pockets: http://app.${environment.name}.${environment.domain}/api/pocket-tailor/client-api
pocketsArrangements: http://app.${environment.name}.${environment.domain}/arrangementoutboundoriginationmock/service-api
contentservices: https://app.${environment.name}.${environment.domain}/api/contentservices/client-api
dbs-service-names:
accessgroup: access-control
actions: action
Expand All @@ -30,4 +31,5 @@ bb-fuel:
payments: payment-order-service
pfm: transaction-category-collector
user: user-manager
products: arrangement-manager
products: arrangement-manager
contentservices: contentservices
4 changes: 3 additions & 1 deletion src/main/resources/application-k8s-3ang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bb-fuel:
accountStatement: http://accountstatementsintegration.${environment.name}.${environment.domain}/account-statement-integration-service/service-api
pockets: http://edge.${environment.name}.${environment.domain}/api/pocket-tailor/client-api
pocketsArrangements: http://arrangementoutboundoriginationmock.${environment.name}.${environment.domain}/service-api
contentservices: http://edge.${environment.name}.${environment.domain}/api/contentservices/client-api
dbs-service-names:
accessgroup: accessgroup-presentation-service
actions: actionrecipes-presentation-service
Expand All @@ -33,4 +34,5 @@ bb-fuel:
payments: payment-order-presentation-service
pfm: categories-management-presentation-service
user: user-presentation-service
products: product-summary-presentation-service
products: product-summary-presentation-service
contentservices: contentservices
2 changes: 2 additions & 0 deletions src/main/resources/application-k8s-beta-https.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bb-fuel:
accountStatement: https://accountstatementsintegration-${environment.name}.${environment.domain}/service-api
pockets: https://edge.${environment.name}-${environment.domain}/api/pocket-tailor/client-api
pocketsArrangements: https://arrangementoutboundoriginationmock-${environment.name}.${environment.domain}/service-api
contentservices: https://edge.${environment.name}.${environment.domain}/api/contentservices/client-api
dbs-service-names:
accessgroup: access-control
actions: action
Expand All @@ -35,3 +36,4 @@ bb-fuel:
user: user-manager
products: arrangement-manager
positivePay: positive-pay-check
contentservices: contentservices
2 changes: 2 additions & 0 deletions src/main/resources/application-k8s-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bb-fuel:
accountStatement: http://accountstatementsintegration.${environment.name}.${environment.domain}/service-api
pockets: http://edge.${environment.name}.${environment.domain}/api/pocket-tailor/client-api
pocketsArrangements: http://arrangementoutboundoriginationmock.${environment.name}.${environment.domain}/service-api
contentservices: http://edge.${environment.name}.${environment.domain}/api/contentservices/client-api
dbs-service-names:
accessgroup: access-control
actions: action
Expand All @@ -35,3 +36,4 @@ bb-fuel:
user: user-manager
products: arrangement-manager
positivePay: positive-pay-check
contentservices: contentservices
2 changes: 2 additions & 0 deletions src/main/resources/application-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bb-fuel:
accountStatement: http://accountstatementsintegration.${environment.name}.${environment.domain}/service-api
pockets: http://edge.${environment.name}.${environment.domain}/api/pocket-tailor/client-api
pocketsArrangements: http://arrangementoutboundoriginationmock.${environment.name}.${environment.domain}/service-api
contentservices: http://edge.${environment.name}.${environment.domain}/api/contentservices/client-api
dbs-service-names:
accessgroup: accessgroup-presentation-service
actions: actionrecipes-presentation-service
Expand All @@ -35,3 +36,4 @@ bb-fuel:
user: user-presentation-service
products: product-summary-presentation-service
positivePay: positive-pay-check
contentservices: contentservices
2 changes: 2 additions & 0 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ bb-fuel:
user: http://localhost:8086/user-manager/integration-api
accountStatement: http://localhost:8085/account-statement-integration-service/service-api
pockets: http://localhost:8087/pocket-tailor/client-api
contentservices: http://localhost:8006/contentservices/client-api
dbs-service-names:
accessgroup: access-control
actions: action-service
Expand All @@ -32,3 +33,4 @@ bb-fuel:
user: user-manager
products: arrangement-manager
positivePay: positive-pay-check
contentservices: contentservices
4 changes: 3 additions & 1 deletion src/main/resources/data.properties
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ actions.max=2
# Ingest billpay
ingest.billpay=false
ingest.billpay.accounts=false
# ingest pockets
# Ingest pockets
ingest.pockets=false
# Ingest contents
ingest.content.for.payments=false
# the way pocket is mapped to the core system, either ONE_TO_ONE or ONE_TO_MANY
pocket.mapping.mode=ONE_TO_MANY
# Number of accountStatements
Expand Down
Loading

0 comments on commit 2cd6b1a

Please sign in to comment.