Skip to content

Commit

Permalink
Merge pull request #36 from ao508/spring-boot-2.3.3
Browse files Browse the repository at this point in the history
Update spring boot to 2.3.3.RELEASE
  • Loading branch information
ao508 authored Feb 16, 2021
2 parents 4897a6b + 6e73016 commit 15a6a00
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 200 deletions.
247 changes: 122 additions & 125 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,128 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Session Service</name>
<description>RESTful API to cBioPortal/cbioportal sessions in MongoDB.</description>
<url>https://github.com/cBioPortal/session-service/</url>
<groupId>org.cbioportal.session_service</groupId>
<artifactId>session_service</artifactId>
<version>0.3.0</version>
<packaging>${packaging.type}</packaging>

<!-- inherit defaults from spring boot -->
<parent>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Session Service</name>
<description>RESTful API to cBioPortal/cbioportal sessions in MongoDB.</description>
<url>https://github.com/cBioPortal/session-service/</url>
<groupId>org.cbioportal.session_service</groupId>
<artifactId>session_service</artifactId>
<version>0.4.0</version>
<packaging>${packaging.type}</packaging>
<!-- inherit defaults from spring boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
</parent>
<profiles>
<profile>
<id>war</id>
<properties>
<packaging.type>war</packaging.type>
</properties>
</profile>
<profile>
<id>jar</id>
<!-- Set activeByDefault to jar profile for jitpack to work -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<packaging.type>jar</packaging.type>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.13.Final</version>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>

<profiles>
<profile>
<id>war</id>
<properties>
<packaging.type>war</packaging.type>
</properties>
</profile>
<profile>
<id>jar</id>
<!-- Set activeByDefault to jar profile for jitpack to work -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<packaging.type>jar</packaging.type>
</properties>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
<version>1.7.5</version>
</dependency>
</dependencies>

<properties>
<java.version>1.8</java.version>
</properties>


<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>model</classifier>
<includes>
<include>org/cbioportal/session_service/domain/**</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>model</classifier>
<includes>
<include>org/cbioportal/session_service/domain/**</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.data.mongodb.core.mapping.event.ValidatingMongoEventListener;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.context.annotation.Bean;
Expand Down
20 changes: 9 additions & 11 deletions src/main/java/org/cbioportal/session_service/domain/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,17 @@

package org.cbioportal.session_service.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonView;
import com.mongodb.BasicDBObject;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.springframework.data.annotation.Id;
import org.springframework.util.DigestUtils;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonView;
import com.mongodb.util.JSON; // save as JSON, not String of JSON

/**
* @author Manda Wilson
* @author Manda Wilson
*/
@JsonInclude(Include.NON_NULL)
public class Session {
Expand All @@ -59,7 +57,7 @@ public class Session {
private String source;
@NotNull
private SessionType type;


@JsonView(Session.Views.IdOnly.class)
public String getId() {
Expand All @@ -72,12 +70,12 @@ public String getChecksum() {

public void setData(Object data) {
if(data instanceof String) {
this.data = JSON.parse((String)data);
this.data = BasicDBObject.parse((String)data);
} else {
this.data = data;
this.data = data;
}
// JSON.serialize it so that formatting is the same if we test later
this.checksum = DigestUtils.md5DigestAsHex(JSON.serialize(this.data).getBytes());
this.checksum = DigestUtils.md5DigestAsHex(((BasicDBObject)this.data).toString().getBytes());
}

@JsonView(Session.Views.Full.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public interface SessionRepositoryCustom {

List<Session> findBySourceAndType(String source, SessionType type);

int deleteBySourceAndTypeAndId(String source, SessionType type, String id);
long deleteBySourceAndTypeAndId(String source, SessionType type, String id);

List<Session> findBySourceAndTypeAndQuery(String source, SessionType type, String query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@

package org.cbioportal.session_service.domain.internal;

import org.bson.Document;
import org.cbioportal.session_service.domain.Session;
import org.cbioportal.session_service.domain.SessionType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;

import com.mongodb.DBObject;
import com.mongodb.BasicDBObject;
import org.springframework.data.mongodb.core.index.CompoundIndexDefinition;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.BasicQuery;
Expand All @@ -61,10 +60,10 @@ public class SessionRepositoryImpl implements SessionRepositoryCustom {
public void saveSession(Session session) {
if (!this.mongoTemplate.collectionExists(session.getType().toString())) {
this.mongoTemplate.createCollection(session.getType().toString());
DBObject indexKeys = new BasicDBObject();
indexKeys.put("source", 1);
indexKeys.put("type", 1);
indexKeys.put("checksum", 1);
Document indexKeys = new Document();
indexKeys.append("source", 1);
indexKeys.append("type", 1);
indexKeys.append("checksum", 1);
this.mongoTemplate.indexOps(session.getType().toString()).ensureIndex(
new CompoundIndexDefinition(indexKeys).unique());
}
Expand Down Expand Up @@ -93,10 +92,10 @@ public List<Session> findBySourceAndType(String source, SessionType type) {
Session.class, type.toString());
}

public int deleteBySourceAndTypeAndId(String source, SessionType type, String id) {
public long deleteBySourceAndTypeAndId(String source, SessionType type, String id) {
return this.mongoTemplate.remove(
new Query(Criteria.where("source").is(source).and("type").is(type).and("id").is(id)),
Session.class, type.toString()).getN();
Session.class, type.toString()).getDeletedCount();
}

public List<Session> findBySourceAndTypeAndQuery(String source, SessionType type, String query) {
Expand Down
Loading

0 comments on commit 15a6a00

Please sign in to comment.