Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint 42 upgrade weaver webservice 2.1.1 rc7 #43

Merged
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
aaa0959
WIP - modification for CatalogSerice pending
rmathew1011 Apr 19, 2022
8492366
WIP - added the interface WebMvcConfigurer
rmathew1011 Apr 19, 2022
51dd7f1
Wip - modified the assert statements
rmathew1011 Apr 20, 2022
cdcd23f
map detail properties file was renamed following the kebab case conv…
rmathew1011 Apr 21, 2022
22c471b
Tests are passing
rmathew1011 Apr 21, 2022
88225ca
Modified build catalog configuration return type
rmathew1011 Apr 22, 2022
bda173d
WIP Dockerfile
rmathew1011 Apr 22, 2022
dd5a44d
WIP - edited build file
rmathew1011 Apr 22, 2022
5a45fef
WIP - edited build file2
rmathew1011 Apr 22, 2022
3f5ac1b
WIP - removed coveralls from build file
rmathew1011 Apr 22, 2022
02cd60a
Commented the war packaging and modified Dockerfile
rmathew1011 Apr 26, 2022
3f46841
WIP - code review resolutions
rmathew1011 Apr 26, 2022
5c90c85
Code review changes made to pom
rmathew1011 Apr 26, 2022
bbf4665
Added get() to findBtId()
rmathew1011 Apr 27, 2022
79ffba0
Merge branch 'sprint_42_upgrade_weaver_webservice_2.1.1-rc7' of githu…
rmathew1011 Apr 27, 2022
8106843
Removed spring-boot-properties-migrator dependency
rmathew1011 Apr 27, 2022
178a48c
Removing catalina.home variable from properties
rmathew1011 Apr 27, 2022
424b298
Edited the test properties file as per Code Review Suggestion (Kevin)
rmathew1011 Apr 27, 2022
717da30
Removed formatting related changes
rmathew1011 Apr 27, 2022
6936f2d
Formatting removed
rmathew1011 Apr 27, 2022
4e52f83
Reverted formatting
rmathew1011 Apr 27, 2022
dced472
Added new line
rmathew1011 Apr 27, 2022
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
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
- name: "Setup Java"
uses: actions/setup-java@v1
with:
java-version: 1.11
java-version: 11

- name: "Maven Test"
run: mvn clean test jacoco:report -DdryRun=true

37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM maven:3-openjdk-11-slim as maven

# copy pom.xml
COPY pom.xml pom.xml

# copy src files
COPY src src

# build
RUN mvn package

# final base image
FROM openjdk:11-jre-slim

# set deployment directory
WORKDIR /GIFMButtonService

# copy over the built artifact from the maven image
COPY --from=maven /target/ROOT.jar /GIFMButtonService/ROOT.jar

#Settings
ENV SERVER_PORT='9000'
ENV SPRING_SQL_INIT_PLATFORM='h2'
ENV SPRING_DATASOURCE_DRIVERCLASSNAME='org.h2.Driver'
ENV SPRING_DATASOURCE_URL='jdbc:h2:mem:AZ;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE'
ENV SPRING_JPA_DATABASEPLATFORM='org.hibernate.dialect.H2Dialect'
ENV SPRING_JPA_HIBERNATE_DDLAUTO='create-drop'
ENV SPRING_DATASOURCE_USERNAME='spring'
ENV SPRING_DATASOURCE_PASSWORD='spring'


#expose port
EXPOSE ${SERVER_PORT}

#run java command
CMD java -jar /GIFMButtonService/ROOT.jar

35 changes: 25 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@
<parent>
<groupId>edu.tamu.weaver</groupId>
<artifactId>webservice-parent</artifactId>
<version>2.0.2</version>
<version>2.1.1-RC8</version>
</parent>

<properties>
<start-class>edu.tamu.app.WebServerInit</start-class>
<java.version>11</java.version>
</properties>

<packaging>war</packaging>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>auth</artifactId>
<version>2.0.2</version>
<version>2.1.1-RC8</version>
</dependency>

<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>token-provider</artifactId>
<version>2.0.2</version>
<version>2.1.1-RC8</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>

<dependency>
Expand All @@ -55,10 +55,15 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>

<dependency>
Expand All @@ -76,19 +81,29 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<version>3.2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<release>11</release>
<release>${java.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/tamu/app/WebServerInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;

/**
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/edu/tamu/app/config/AppWebMvcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;

import edu.tamu.app.model.User;
import edu.tamu.app.model.repo.UserRepo;
import edu.tamu.weaver.auth.resolver.WeaverCredentialsArgumentResolver;
import edu.tamu.weaver.auth.resolver.WeaverUserArgumentResolver;
import edu.tamu.weaver.validation.resolver.WeaverValidatedModelMethodProcessor;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@EnableWebMvc
@Configuration
@EntityScan(basePackages = { "edu.tamu.app.model" })
@EnableJpaRepositories(basePackages = { "edu.tamu.app.model.repo" })
@PropertySource("classpath:buttons.properties")
public class AppWebMvcConfig extends WebMvcConfigurerAdapter {
public class AppWebMvcConfig implements WebMvcConfigurer {

@Value("${app.security.allow-access}")
private String[] hosts;
Expand Down Expand Up @@ -59,7 +59,6 @@ public ConfigurableMimeFileTypeMap configurableMimeFileTypeMap() {
return new ConfigurableMimeFileTypeMap();
}

@Override
public void addCorsMappings(CorsRegistry registry) {
// @formatter:off
registry.addMapping("/**")
Expand All @@ -71,7 +70,6 @@ public void addCorsMappings(CorsRegistry registry) {
// @formatter:on
}

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(new WeaverValidatedModelMethodProcessor(converters));
argumentResolvers.add(new WeaverCredentialsArgumentResolver());
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/edu/tamu/app/config/AppWebSocketConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketTransportRegistration;

/**
Expand All @@ -14,7 +14,7 @@
*/
@Configuration
@EnableWebSocketMessageBroker
public class AppWebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
public class AppWebSocketConfig implements WebSocketMessageBrokerConfigurer {

/**
* {@inheritDoc}
Expand Down Expand Up @@ -49,7 +49,7 @@ public void configureWebSocketTransport(WebSocketTransportRegistration registrat
*/
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/connect").setAllowedOrigins("*").withSockJS();
registry.addEndpoint("/connect").setAllowedOriginPatterns("*").withSockJS();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ButtonManagementController {
@RequestMapping("/all")
@PreAuthorize("hasRole('ADMIN')")
public ApiResponse getAll() {
return new ApiResponse(SUCCESS,persistedButtonRepo.findAll(new Sort(Sort.Direction.ASC, "name")));
return new ApiResponse(SUCCESS, persistedButtonRepo.findAll(Sort.by(Sort.Direction.ASC, "name")));
}

@RequestMapping("/create")
Expand All @@ -37,7 +37,7 @@ public ApiResponse create(@RequestBody PersistedButton button) {
@RequestMapping("/{id}")
@PreAuthorize("hasRole('ADMIN')")
public ApiResponse getButton(@PathVariable Long id) {
return new ApiResponse(SUCCESS, persistedButtonRepo.findOne(id));
return new ApiResponse(SUCCESS, persistedButtonRepo.findById(id).get());
}

@RequestMapping("/update")
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/edu/tamu/app/service/CatalogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ protected void buildCatalogConfigurations() {
final JsonNode catalogsJson = objectMapper.readTree(new FileInputStream(catalogsRaw.getFile()));
catalogsJson.get("catalogs").fieldNames().forEachRemaining(catalogName -> {
try {
catalogConfigurations.put(catalogName, objectMapper.readValue(catalogsJson.get("catalogs").get(catalogName).toString(), new TypeReference<HashMap<String, Object>>() {}));
catalogConfigurations.put(catalogName,
objectMapper.readValue(catalogsJson.get("catalogs").get(catalogName).toString(),
new TypeReference<HashMap<String, String>>() {
}));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/edu/tamu/app/service/MapService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
*/

@Service
@ConfigurationProperties("mapDetails")
@PropertySource("classpath:mapDetails.properties")
@ConfigurationProperties("map-details")
@PropertySource("classpath:map-details.properties")
public class MapService {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Value("#{'${mapDetails.stackMap}'.split(';')}")
@Value("#{'${map-details.stack-map}'.split(';')}")
private List<String> stackMapLocations;

@Value("#{'${mapDetails.bypassCodes}'.split(';')}")
@Value("#{'${map-details.bypass-codes}'.split(';')}")
private List<String> bypassCodes;

@Value("${mapDetails.defaultMapLink}")
@Value("${map-details.default-map-link}")
private String defaultMapLink;

public final Map<String, String> mapLinks = new HashMap<String,String>();
Expand Down
17 changes: 12 additions & 5 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
server.port: 9001
server.contextPath:
security.basic.enabled: false

# Bean overriding is necessary for TokenAuthorizationFilter.
spring.main.allow-bean-definition-overriding: true
# Circular bean dependency between appWebMvcConfig and userRepoImpl.
spring.main.allow-circular-references: true

spring.profiles.active: production
spring.datasource.username: spring
spring.datasource.password: spring

# H2
spring.datasource.platform: h2
spring.sql.init.platform: h2
spring.datasource.url: jdbc:h2:mem:AZ;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.driverClassName: org.h2.Driver
spring.jpa.database-platform: org.hibernate.dialect.H2Dialect
# PostgrSQL
#spring.datasource.platform: postgresql
#spring.sql.init.platform: postgresql
#spring.datasource.url: jdbc:postgresql://localhost:5432/catalog_service
#spring.datasource.driverClassName: org.postgresql.Driver
#spring.jpa.database-platform: org.hibernate.dialect.PostgreSQLDialect
Expand All @@ -24,14 +31,14 @@ logging.level.edu.tamu.app.service.GetItForMeService: INFO
logging.level.org.springframework:INFO
logging.level.ro.isdc.wro: INFO
logging.encoder.pattern: "%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"
logging.file: ${catalina.home}/logs/application.log
logging.file.name: ${catalina.home}/logs/application.log
logging.rolling.pattern: ${catalina.home}/logs/application-%d{yyyy-MM-dd}.%i.log
logging.rolling.file-size: 5MB
logging.rolling.threshold-level: ALL
app.whitelist: 127.0.0.1
################################################################
# edu.tamu.weaver.auth.service.UserCredentialsService
app.authority.admins: 123456789, 990000081, 523008230, 512004707, 613001223, 402001311, 709005486
app.authority.admins: 123456789, 990000081, 523008230, 512004707, 613001223, 402001311, 709005486, 724001395
################################################################
################################################################
# spring-boot actuator endpoint: health set to true
Expand Down Expand Up @@ -61,7 +68,7 @@ app.security.secret: verysecretsecret
################################################################
################################################################
# edu.tamu.weaver.filter.CorsFilter
app.security.allow-access: http://localhost,http://localhost:8080, http://localhost:9000
app.security.allow-access: http://localhost,http://localhost:8080, http://localhost:9000, http://localhost:9001
################################################################
################################################################
# edu.tamu.weaver.email.config.WeaverEmailConfig
Expand Down
Loading