Skip to content

Commit

Permalink
adding new endpoints and functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Kerwin committed Jun 16, 2021
1 parent 10adc95 commit 30d3cc7
Show file tree
Hide file tree
Showing 19 changed files with 617 additions and 394 deletions.
10 changes: 8 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ apply plugin: 'com.synopsys.integration.solution'
apply plugin: 'io.spring.dependency-management'

dependencies {
implementation 'com.synopsys.integration:integration-common:25.0.0'
implementation('com.synopsys.integration:integration-common:25.0.0') {
exclude group: 'com.flipkart.zjsonpatch', module: 'zjsonpatch'
}

implementation 'org.springframework.boot:spring-boot-starter-web'
implementation('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-json'
}

implementation 'javax.validation:validation-api:2.0.1.Final'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* chitstop
*
* Copyright (c) 2021 Synopsys, Inc.
*
* Use subject to the terms and conditions of the Synopsys End User Software License and Maintenance Agreement. All rights reserved worldwide.
*/
package com.synopsys.integration.chitstop;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ApplicationProperties {
@Value("${stored.tokens.path}")
private String storedTokensPath;

public String getStoredTokensPath() {
return storedTokensPath;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.synopsys.integration.chitstop.exception.GameOverException;
import com.synopsys.integration.chitstop.rest.controller.StringToVmKeyConverter;
import com.synopsys.integration.chitstop.rest.model.VmKey;
import com.synopsys.integration.chitstop.rest.model.VmKeyTypeAdapter;

@SpringBootApplication
public class ChitstopApplication {
public class ChitstopApplication implements WebMvcConfigurer {
private static final Logger logger = LoggerFactory.getLogger(ChitstopApplication.class);

public static void main(String[] args) {
Expand All @@ -35,15 +40,22 @@ public static void main(String[] args) {
}
}

@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new StringToVmKeyConverter());
}

@Bean
public WatchService watchService() throws IOException {
return FileSystems.getDefault().newWatchService();
}

@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper()
.configure(SerializationFeature.INDENT_OUTPUT, true);
public Gson gson() {
return new GsonBuilder()
.setPrettyPrinting()
.registerTypeAdapter(VmKey.class, new VmKeyTypeAdapter())
.create();
}

@Bean
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* chitstop
*
* Copyright (c) 2021 Synopsys, Inc.
*
* Use subject to the terms and conditions of the Synopsys End User Software License and Maintenance Agreement. All rights reserved worldwide.
*/
package com.synopsys.integration.chitstop.rest.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.synopsys.integration.chitstop.rest.model.ApiToken;
import com.synopsys.integration.chitstop.rest.model.VmKey;
import com.synopsys.integration.chitstop.service.ApiTokens;

@RestController
public class ApiTokenController {
private final ApiTokens apiTokens;

@Autowired
public ApiTokenController(ApiTokens apiTokens) {
this.apiTokens = apiTokens;
}

@GetMapping("/puretoken")
public String retrievePure(
@RequestParam(value = "vm") VmKey vmKey,
@RequestParam(value = "username", required = false) String username
) {
return apiTokens.findPure(vmKey, username);
}

@GetMapping("/token")
public ApiToken retrieve(
@RequestParam(value = "vm") VmKey vmKey,
@RequestParam(value = "username", required = false) String username
) {
return apiTokens.find(vmKey, username);
}

@GetMapping("/tokens")
public List<ApiToken> retrieveVmTokens(@RequestParam(value = "vm", required = false) VmKey vmKey) {
return apiTokens.findAll(vmKey);
}

@GetMapping("/report")
public String tokensReport() {
return apiTokens.tokensStatusReport();
}

@PutMapping("/token")
public void store(@RequestBody ApiToken apiToken) {
apiTokens.storeToken(apiToken);
}

@DeleteMapping("/token")
public void clearVmToken(
@RequestParam(value = "vm") VmKey vmKey,
@RequestParam(value = "token") String token
) {
apiTokens.deleteVmToken(vmKey, token);
}

@DeleteMapping("/tokens")
public void clearVmTokens(@RequestParam(value = "vm") VmKey vmKey) {
apiTokens.deleteVmTokens(vmKey);
}

}
Loading

0 comments on commit 30d3cc7

Please sign in to comment.