Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
030b9ff
Changes for the ApiDocumenation
AltiusIndia Feb 10, 2021
475249a
Merge branch 'dev' into ApiDocumentation
AltiusIndia Feb 13, 2021
83a9774
Made changes in the files
AltiusIndia Feb 15, 2021
1563905
Merge branch 'dev' into ApiDocumentation
AltiusIndia Feb 19, 2021
e1a6f1e
Merge branch 'QAT-573' into ApiDocumentation
AltiusIndia Feb 19, 2021
00819ab
Updated the getRegionByRealmCountry method
AltiusIndia Feb 19, 2021
08ae69b
Updated the API docs for the new report
AltiusIndia Feb 19, 2021
51ad4d1
Merge branch 'dev' into ApiDocumentation
AltiusIndia Feb 19, 2021
274524a
Merge branch 'dev' into ApiDocumentation
AltiusIndia Mar 25, 2021
64d0982
Updated the ApiDocumentation branch with latest code from dev
AltiusIndia Apr 29, 2021
24800e8
API doc for 4 controllers
Shrutika-Kalbande-Altius May 1, 2021
0b787ef
testing pull request
Shrutika-Kalbande-Altius May 12, 2021
02f30c7
conflicts resolved merged with devNew
Shrutika-Kalbande-Altius Aug 31, 2021
16f4e65
api doc
Shrutika-Kalbande-Altius Sep 24, 2021
d18cdfb
resolve the conflits
shubham-deulkar-altius Sep 24, 2021
d2ed731
added /
Shrutika-Kalbande-Altius Sep 27, 2021
3026ce2
Merge branch 'ApiDocumentation' of https://github.com/AltiusIndia/fas…
Shrutika-Kalbande-Altius Sep 27, 2021
e473505
security file changes
Shrutika-Kalbande-Altius Sep 29, 2021
01875d8
Merge branch 'dev' into ApiDocumentation
shubham-deulkar-altius Sep 30, 2021
e0b3423
nothing
Shrutika-Kalbande-Altius Oct 5, 2021
f606ab2
Merge branch 'ApiDocumentation' of https://github.com/AltiusIndia/fas…
Shrutika-Kalbande-Altius Oct 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<version>2.3.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>cc.altius.FASP.rest.webservice</groupId>
Expand Down Expand Up @@ -100,7 +100,12 @@
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-data-rest</artifactId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-security</artifactId>
<version>1.3.1</version>
</dependency>
<!-- API, java.xml.bind module -->
Expand Down Expand Up @@ -154,6 +159,19 @@
<executable>true</executable>
</configuration>
</plugin>
<!-- <plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>-->
</plugins>
</build>

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/cc/altius/FASP/WebApplication.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
package cc.altius.FASP;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.annotations.servers.Server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;

@OpenAPIDefinition(
info = @Info(
title = "Quantification and Analytics Tool",
description = "API's to access the QAT Server",
license = @License(name = "Apache 2.0", url = "https://foo.bar"),
contact = @Contact(url = "https://www.quantificationanalytics.org", name = "FASP team", email = "HSS_FASP_HQ@ghsc-psm.org")
), servers = @Server(url = "https://www.quantificationanalytics.org", description = "Production server for QAT")
)
@SpringBootApplication
@EnableScheduling
@ComponentScan(basePackages = {"cc.altius.FASP"})
Expand Down
17 changes: 5 additions & 12 deletions src/main/java/cc/altius/FASP/jwt/JWTWebSecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ protected void configure(HttpSecurity httpSecurity) throws Exception {
.exceptionHandling().authenticationEntryPoint(jwtUnAuthorizedResponseAuthenticationEntryPoint).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests()
// .antMatchers("/actuator/info").permitAll()
// .antMatchers("/api/healthArea/**").access("hasRole('ROLE_BF_UPDATE_REALM_MASTER')")
// .antMatchers("/api/organisation/**").access("hasRole('ROLE_BF_UPDATE_REALM_MASTER')")
// .antMatchers("/api/unit/**").access("hasRole('ROLE_BF_UPDATE_APPL_MASTER')")
// .antMatchers(HttpMethod.POST, "/api/realm/**").access("hasAnyRole('ROLE_BF_UPDATE_APPL_MASTER')")
// .antMatchers(HttpMethod.PUT, "/api/realm/**").access("hasAnyRole('ROLE_BF_UPDATE_APPL_MASTER', 'ROLE_BF_UPDATE_REALM_MASTER')")
// .antMatchers("/api/realmCountry/**").access("hasRole('ROLE_BF_UPDATE_REALM_MASTER')")
.anyRequest().authenticated();

httpSecurity
Expand Down Expand Up @@ -109,14 +102,14 @@ public void configure(WebSecurity webSecurity) throws Exception {
.and().ignoring().antMatchers("/browser**")
.and().ignoring().antMatchers("/file**")
.and().ignoring().antMatchers("/file/**")
// .and().ignoring().antMatchers("/v2/api-docs", "/configuration/ui", "/swagger-resources", "/swagger-resources/configuration/security", "/swagger-ui.html**", "/swagger-resources/configuration/ui")
.and().ignoring().antMatchers("/v3/api-docs", "/configuration/ui", "/swagger-resources", "/swagger-resources/configuration/security", "/swagger-ui.html**", "/swagger-resources/configuration/ui")
.and().ignoring().antMatchers("/api/locales/*/**")
.and().ignoring().antMatchers("/api/forgotPassword/**")
.and().ignoring().antMatchers("/api/user/forgotPassword/**")
.and().ignoring().antMatchers("/api/getForgotPasswordToken/**")
.and().ignoring().antMatchers("/api/confirmForgotPasswordToken/**")
.and().ignoring().antMatchers("/api/updatePassword/**")
.and().ignoring().antMatchers("/api/user/confirmForgotPasswordToken/**")
.and().ignoring().antMatchers("/api/user/updatePassword/**")
// .and().ignoring().antMatchers("/api/user/**")
.and().ignoring().antMatchers("/api/updateExpiredPassword/**")
.and().ignoring().antMatchers("/api/user/updateExpiredPassword/**")
.and().ignoring().antMatchers("/exportSupplyPlan/**")
.and().ignoring().antMatchers("/exportProgramData/**")
.and().ignoring().antMatchers("/exportOrderData/**")
Expand Down
124 changes: 103 additions & 21 deletions src/main/java/cc/altius/FASP/rest/controller/BudgetRestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
import cc.altius.FASP.model.ResponseCode;
import cc.altius.FASP.service.BudgetService;
import cc.altius.FASP.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -31,7 +36,7 @@
* @author akil
*/
@RestController
@RequestMapping("/api")
@RequestMapping("/api/budget")
public class BudgetRestController {

private final Logger logger = LoggerFactory.getLogger(this.getClass());
Expand All @@ -40,8 +45,42 @@ public class BudgetRestController {
@Autowired
private UserService userService;

@PostMapping(path = "/budget")
public ResponseEntity postBudget(@RequestBody Budget budget, Authentication auth) {
/**
* API used to get the complete Budget list
*
* @param auth
* @return returns the complete list of Budgets List<Budget>
*/
@GetMapping("/")
@Operation(description = "Returns the complete list of Budgets List<Budget>", summary = "Get Budget list", tags = ("budget"))
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the Budget list")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of Budget list")
public ResponseEntity getBudgetList(Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
return new ResponseEntity(this.budgetService.getBudgetList(curUser), HttpStatus.OK);
} catch (Exception e) {
logger.error("Error while trying to get Budget list", e);
return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
}
}

/**
* API used to add a Budget to the Realm
*
* @param budget Budget object that you want to add to the Realm
* @param auth
* @return returns a Success code if the operation was successful
*/
@PostMapping(path = "/")
@Operation(description = "API used to add a Budget to the Realm", summary = "Add Budget", tags = ("budget"))
@Parameters(
@Parameter(name = "budget", description = "The Budget object that you want to add to the Realm"))
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns a Success code if the operation was successful")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access to add the Budget")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if the some of the underlying data does not match.")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Returns a HttpStatus.INTERNAL_SERVER_ERROR if there was some other error that did not allow the operation to complete")
public ResponseEntity addBudget(@RequestBody Budget budget, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
this.budgetService.addBudget(budget, curUser);
Expand All @@ -58,8 +97,21 @@ public ResponseEntity postBudget(@RequestBody Budget budget, Authentication auth
}
}

@PutMapping(path = "/budget")
public ResponseEntity putBudget(@RequestBody Budget budget, Authentication auth) {
/**
* API used to update a Budget
*
* @param budget Budget object that you want to update
* @param auth
* @return returns a Success code if the operation was successful
*/
@PutMapping(path = "/")
@Operation(description = "API used to update a Budget", summary = "Update Budget", tags = ("budget"))
@Parameters(
@Parameter(name = "budget", description = "The Budget object that you want to update"))
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns a Success code if the operation was successful")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access to add the Budget")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Returns a HttpStatus.INTERNAL_SERVER_ERROR if there was some other error that did not allow the operation to complete")
public ResponseEntity updateBudget(@RequestBody Budget budget, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
int rows = this.budgetService.updateBudget(budget, curUser);
Expand All @@ -73,8 +125,21 @@ public ResponseEntity putBudget(@RequestBody Budget budget, Authentication auth)
}
}

@PostMapping("/budget/programIds")
public ResponseEntity getBudget(@RequestBody String[] programIds, Authentication auth) {
/**
* API used to get the Budget list for a list of Program Ids
*
* @param programIds List of ProgramIds that you want to the list of Budgets
* for
* @param auth
* @return returns the list of Budgets based on Program Ids specified
*/
@PostMapping("/programIds")
@Operation(description = "API used to get the Budget list for a list of Program Ids", summary = "Get Budget list for Program Ids", tags = ("budget"))
@Parameters(
@Parameter(name = "programIds", description = "List of Program Ids that you want to the Budgets for"))
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the Budget list")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of Budget list")
public ResponseEntity getBudgetForProgramIds(@RequestBody String[] programIds, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
return new ResponseEntity(this.budgetService.getBudgetListForProgramIds(programIds, curUser), HttpStatus.OK);
Expand All @@ -84,19 +149,22 @@ public ResponseEntity getBudget(@RequestBody String[] programIds, Authentication
}
}

@GetMapping("/budget")
public ResponseEntity getBudget(Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
return new ResponseEntity(this.budgetService.getBudgetList(curUser), HttpStatus.OK);
} catch (Exception e) {
logger.error("Error while trying to get Budget list", e);
return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
}
}

@GetMapping("/budget/{budgetId}")
public ResponseEntity getBudget(@PathVariable("budgetId") int budgetId, Authentication auth) {
/**
* API used to get the Budget for a specific BudgetId
*
* @param budgetId BudgetId that you want the Budget Object for
* @param auth
* @return returns the list the Budget object based on BudgetId specified
*/
@GetMapping("/{budgetId}")
@Operation(description = "API used to get the Budget for a specific BudgetId", summary = "Get Budget for a BudgetId", tags = ("budget"))
@Parameters(
@Parameter(name = "budgetId", description = "BudgetId that you want to the Budget for"))
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the Budget")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access to the Budget")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if the BudgetId specified does not exist")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of Budget")
public ResponseEntity getBudgetById(@PathVariable("budgetId") int budgetId, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
return new ResponseEntity(this.budgetService.getBudgetById(budgetId, curUser), HttpStatus.OK);
Expand All @@ -112,7 +180,21 @@ public ResponseEntity getBudget(@PathVariable("budgetId") int budgetId, Authenti
}
}

@GetMapping("/budget/realmId/{realmId}")
/**
* API used to get all the Budgets for a specific Realm
*
* @param realmId RealmId that you want the List of Budgets for
* @param auth
* @return returns the list the Budgets based on RealmId specified
*/
@GetMapping("/realmId/{realmId}")
@Operation(description = "API used to get the Budget for a specific BudgetId", summary = "Get Budget for a Realm", tags = ("budget"))
@Parameters(
@Parameter(name = "realmId", description = "RealmId that you want the List of Budgets for"))
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the List of Budgets for that Realm")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access to the Realm")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if the RealmId specified does not exist")
@ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of Budget")
public ResponseEntity getBudgetForRealm(@PathVariable("realmId") int realmId, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
Expand Down
Loading