diff --git a/api-audit/src/main/java/com/capitalone/dashboard/rest/AuditResultController.java b/api-audit/src/main/java/com/capitalone/dashboard/rest/AuditResultController.java new file mode 100644 index 0000000000..11f684f685 --- /dev/null +++ b/api-audit/src/main/java/com/capitalone/dashboard/rest/AuditResultController.java @@ -0,0 +1,91 @@ +package com.capitalone.dashboard.rest; + +import com.capitalone.dashboard.model.AuditResult; +import com.capitalone.dashboard.model.AuditType; +import com.capitalone.dashboard.service.AuditResultService; +import org.bson.types.ObjectId; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.RequestMapping; + +import javax.validation.Valid; + +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; + +@RestController +public class AuditResultController { + + private final AuditResultService auditResultService; + + @Autowired + public AuditResultController(AuditResultService auditResultService) { + this.auditResultService = auditResultService; + } + + @RequestMapping(value = "/auditresult/dashboard/all/pages", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAuditResultsAll(Pageable pageable) { + Iterable auditResults = auditResultService.getAuditResultsAll(pageable); + return ResponseEntity.ok().body(auditResults); + } + + @RequestMapping(value = "/auditresult/dashboard/audittype/{auditType}/pages", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAuditResultsByAuditType(@Valid @PathVariable AuditType auditType, Pageable pageable) { + Iterable auditResults = auditResultService.getAuditResultsByAuditType(auditType, pageable); + return ResponseEntity.ok().body(auditResults); + } + + @RequestMapping(value = "/auditresult/dashboard/title/{title}", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAuditResultsByDBoardTitle(@Valid @PathVariable String title) { + Iterable auditResults = auditResultService.getAuditResultsByDBoardTitle(title); + return ResponseEntity.ok().body(auditResults); + } + + @RequestMapping(value = "/auditresult/dashboard/title/{title}/audittype/{auditType}", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAuditResultsByDBoardTitleAndAuditType(@Valid @PathVariable String title, + @Valid @PathVariable AuditType auditType) { + Iterable auditResults = auditResultService.getAuditResultsByDBoardTitleAndAuditType(title, auditType); + return ResponseEntity.ok().body(auditResults); + } + + @RequestMapping(value = "/auditresult/dashboard/product/{configItemBusServName}/component/{configItemBusAppName}", + method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAuditResultsByServAndAppNames(@Valid @PathVariable String configItemBusServName, + @Valid @PathVariable String configItemBusAppName) { + Iterable auditResults = auditResultService.getAuditResultsByServAndAppNames(configItemBusServName, + configItemBusAppName); + return ResponseEntity.ok().body(auditResults); + } + + @RequestMapping(value = "/auditresult/dashboard/product/{configItemBusServName}/component/{configItemBusAppName}/audittype/{auditType}", + method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAuditResultsByServAndAppNamesAndAuditType(@Valid @PathVariable String configItemBusServName, + @Valid @PathVariable String configItemBusAppName, + @Valid @PathVariable AuditType auditType) { + Iterable auditResults = auditResultService.getAuditResultsByServAndAppNamesAndAuditType(configItemBusServName, + configItemBusAppName, auditType); + return ResponseEntity.ok().body(auditResults); + } + + @RequestMapping(value = "/auditresult/lob/{lineOfBusiness}/audittype/{auditType}/pages", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAuditResultsByLineOfBusAndAuditType(@Valid @PathVariable String lineOfBusiness, + @Valid @PathVariable AuditType auditType, Pageable pageable) { + Iterable auditResults = auditResultService.getAuditResultsByLineOfBusAndAuditType(lineOfBusiness, auditType, pageable); + return ResponseEntity.ok().body(auditResults); + } + + @RequestMapping(value = "/auditresult/lob/{lineOfBusiness}/pages", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAuditResultsByLineOfBus(@Valid @PathVariable String lineOfBusiness, Pageable pageable) { + Iterable auditResults = auditResultService.getAuditResultsByLineOfBus(lineOfBusiness, pageable); + return ResponseEntity.ok().body(auditResults); + } + + @RequestMapping(value = "/auditresult/{id}", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity getAuditResult(@Valid @PathVariable ObjectId id) { + AuditResult auditResult = auditResultService.getAuditResult(id); + return ResponseEntity.ok().body(auditResult); + } +} diff --git a/api-audit/src/main/java/com/capitalone/dashboard/service/AuditResultService.java b/api-audit/src/main/java/com/capitalone/dashboard/service/AuditResultService.java new file mode 100644 index 0000000000..8ab308795b --- /dev/null +++ b/api-audit/src/main/java/com/capitalone/dashboard/service/AuditResultService.java @@ -0,0 +1,28 @@ +package com.capitalone.dashboard.service; + +import com.capitalone.dashboard.model.AuditResult; +import com.capitalone.dashboard.model.AuditType; +import org.bson.types.ObjectId; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface AuditResultService { + + AuditResult getAuditResult(ObjectId id); + + Page getAuditResultsAll(Pageable pageable); + + Page getAuditResultsByAuditType(AuditType auditType, Pageable pageable); + + Iterable getAuditResultsByDBoardTitle(String title); + + Iterable getAuditResultsByDBoardTitleAndAuditType(String title, AuditType auditType); + + Iterable getAuditResultsByServAndAppNames(String configItemBusServName, String configItemBusAppName); + + Iterable getAuditResultsByServAndAppNamesAndAuditType(String configItemBusServName, String configItemBusAppName, AuditType auditType); + + Page getAuditResultsByLineOfBusAndAuditType(String lineOfBusiness, AuditType auditType, Pageable pageable); + + Page getAuditResultsByLineOfBus(String lineOfBusiness, Pageable pageable); +} diff --git a/api-audit/src/main/java/com/capitalone/dashboard/service/AuditResultServiceImpl.java b/api-audit/src/main/java/com/capitalone/dashboard/service/AuditResultServiceImpl.java new file mode 100644 index 0000000000..82ca3fcf96 --- /dev/null +++ b/api-audit/src/main/java/com/capitalone/dashboard/service/AuditResultServiceImpl.java @@ -0,0 +1,67 @@ +package com.capitalone.dashboard.service; + +import com.capitalone.dashboard.model.AuditResult; +import com.capitalone.dashboard.model.AuditType; +import com.capitalone.dashboard.repository.AuditResultRepository; +import org.bson.types.ObjectId; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Component; + +@Component +public class AuditResultServiceImpl implements AuditResultService{ + + @Autowired + private AuditResultRepository auditResultRepository; + + @Autowired + public AuditResultServiceImpl(AuditResultRepository auditResultRepository){ + this.auditResultRepository = auditResultRepository; + } + + @Override + public AuditResult getAuditResult(ObjectId id){ + return auditResultRepository.findById(id); + } + + @Override + public Page getAuditResultsAll(Pageable pageable) { + return auditResultRepository.findAll(pageable); + } + + @Override + public Page getAuditResultsByAuditType(AuditType auditType, Pageable pageable) { + return auditResultRepository.findByAuditType(auditType, pageable); + } + + @Override + public Iterable getAuditResultsByDBoardTitle(String dashboardTitle){ + return auditResultRepository.findByDashboardTitle(dashboardTitle); + } + + @Override + public Iterable getAuditResultsByDBoardTitleAndAuditType(String title, AuditType auditType) { + return auditResultRepository.findByDashboardTitleAndAuditType(title, auditType); + } + + @Override + public Iterable getAuditResultsByServAndAppNames(String configItemBusServName, String configItemBusAppName) { + return auditResultRepository.findByConfigItemBusServNameAndConfigItemBusAppName(configItemBusServName, configItemBusAppName); + } + + @Override + public Iterable getAuditResultsByServAndAppNamesAndAuditType(String configItemBusServName, String configItemBusAppName, AuditType auditType) { + return auditResultRepository.findByConfigItemBusServNameAndConfigItemBusAppNameAndAuditType(configItemBusServName, configItemBusAppName, auditType); + } + + @Override + public Page getAuditResultsByLineOfBusAndAuditType(String lineOfBus, AuditType auditType, Pageable pageable) { + return auditResultRepository.findByLineOfBusinessAndAuditType(lineOfBus, auditType, pageable); + } + + @Override + public Page getAuditResultsByLineOfBus(String lineOfBus, Pageable pageable) { + return auditResultRepository.findByLineOfBusiness(lineOfBus, pageable); + } +} diff --git a/collectors/audit/nfrr/README.md b/collectors/audit/nfrr/README.md new file mode 100644 index 0000000000..f58d2a1464 --- /dev/null +++ b/collectors/audit/nfrr/README.md @@ -0,0 +1 @@ +The README is in the [gh-pages](https://github.com/capitalone/Hygieia/blob/gh-pages/pages/hygieia/collectors/audit/nfrr-audit.md) branch. Please update it there. diff --git a/collectors/audit/nfrr/docker/Dockerfile b/collectors/audit/nfrr/docker/Dockerfile new file mode 100644 index 0000000000..f063939b67 --- /dev/null +++ b/collectors/audit/nfrr/docker/Dockerfile @@ -0,0 +1,19 @@ + +FROM docker.io/openjdk:8-jre + +MAINTAINER Hygieia@capitalone.com + +RUN mkdir /hygieia /hygieia/config + +COPY *.jar /hygieia/ +COPY properties-builder.sh /hygieia/ + +WORKDIR /hygieia + +VOLUME ["/hygieia/logs"] + +ENV PROP_FILE /hygieia/config/application.properties + +CMD ./properties-builder.sh && \ + java -jar nfrr-audit-collector*.jar --spring.config.location=$PROP_FILE + diff --git a/collectors/audit/nfrr/docker/properties-builder.sh b/collectors/audit/nfrr/docker/properties-builder.sh new file mode 100755 index 0000000000..36bb3b5285 --- /dev/null +++ b/collectors/audit/nfrr/docker/properties-builder.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +if [ "$SKIP_PROPERTIES_BUILDER" = true ]; then + echo "Skipping properties builder" + exit 0 +fi + +# mongo container provides the HOST/PORT +# api container provided DB Name, ID & PWD + +if [ "$TEST_SCRIPT" != "" ] +then + #for testing locally + PROP_FILE=application.properties +else + PROP_FILE=config/hygieia-nfrr-audit-collector.properties +fi + +if [ "$MONGO_PORT" != "" ]; then + # Sample: MONGO_PORT=tcp://172.17.0.20:27017 + MONGODB_HOST=`echo $MONGO_PORT|sed 's;.*://\([^:]*\):\(.*\);\1;'` + MONGODB_PORT=`echo $MONGO_PORT|sed 's;.*://\([^:]*\):\(.*\);\2;'` +else + env + echo "ERROR: MONGO_PORT not defined" + exit 1 +fi + +echo "MONGODB_HOST: $MONGODB_HOST" +echo "MONGODB_PORT: $MONGODB_PORT" + +cat > $PROP_FILE <> $PROP_FILE <> $PROP_FILE <