Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
*.tar.gz
*.rar

<<<<<<< HEAD
# Resources
src/main/resources

# Properties files
*.properties

=======
>>>>>>> ce793d902e0374fe41c8edd9e05657e1adfc1a66
# IntelliJ
\.idea

Expand All @@ -33,3 +36,4 @@ hs_err_pid*

# ignore any .properties files
*.properties
/.jpb/
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ Team Vanquish Project 2 Implementation
- [ ] Client/Server communication is done with JSON in HTTP request and response bodies.
- [ ] All low-level persistence logic is abstracted away with Hibernate/Spring Data
- [ ] Documentation (all classes and methods have adequate Javadoc comments)
<<<<<<< HEAD
- [ ] All Exceptions are caught and logged to a file/database
=======
- [ ] All VanquishP2.Exceptions are caught and logged to a file/database
>>>>>>> ce793d902e0374fe41c8edd9e05657e1adfc1a66
- [ ] Data useful to the application is retrieved from a third party API
- [ ] Adequate test coverage for the service-layer
- [ ] DevOps CI/CD pipeline is used to build and deploy project to a publicly available remote location
Expand All @@ -32,14 +36,24 @@ the users that like particular artists.
* As a user, I can add or remove songs from a playlist.
* As a user, I can rate a song with a like or dislike.
* As a user, I can look up an album and see what songs are on it.
<<<<<<< HEAD
* As a user, I can look up an artist and see a list of their top 5 songs.
* As a premium user, I can schedule a concert.
* As a premium user, I can cancel a concert.
=======
* As a user, I can look up an artist and see a [limited] list of their songs.
* As a premium user, I can schedule a concert.
* As a premium user, I can cancel a concert.
* As a premium user, I can see a list of liked songs for a user.
>>>>>>> ce793d902e0374fe41c8edd9e05657e1adfc1a66
* As a premium user, I can see a like/dislike ratio for a particular song.

### Bonus Stories
* As a user, I can view a list of users who like the same songs.
<<<<<<< HEAD
* As a premium user, I can see a list of liked songs for a user.
=======
>>>>>>> ce793d902e0374fe41c8edd9e05657e1adfc1a66
* As a premium user, I can see a like/dislike ratio for an entire artist.

## Tech Stack
Expand Down
129 changes: 62 additions & 67 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
Expand All @@ -17,15 +17,44 @@
<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<version>2.5.5</version>
</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>
<version>2.5.5</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
<version>0.0.20131108.vaadin1</version>
<scope>compile</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down Expand Up @@ -54,97 +83,63 @@
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>

<!-- JSON Web Token -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.1</version>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.1</version>
<scope>runtime</scope>
</dependency>

<!-- JSON Web Token -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.1</version>
<scope>runtime</scope>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.2</version>
</dependency>

<!-- Spring Boot JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.5.5</version>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>

<!-- Spring Boot Bean Validation -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<version>2.5.5</version>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>

<!-- Spring Boot Web Server -->
<!-- Mockito -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.5.5</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.0.0</version>
</dependency>

<!-- &lt;!&ndash; Spring Boot Testing &ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-tomcat</artifactId>-->
<!-- <version>2.5.5</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->

<!-- Spring Boot Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.5.5</version>
<scope>test</scope>
</dependency>
<!-- H2 Testing Database -->
<dependency>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
<version>0.0.20131108.vaadin1</version>
<scope>compile</scope>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<!--OK HTTP for sending get requests to third party API-->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

</dependencies>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- <version>2.4.3</version>-->
</plugin>
</plugins>
</build>

</project>
</project>
1 change: 0 additions & 1 deletion src/main/java/Application/DTOs/UserRegistrationDTO.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package Application.DTOs;

import Application.models.Location;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
Expand Down
23 changes: 1 addition & 22 deletions src/main/java/Application/P2Application.java
Original file line number Diff line number Diff line change
@@ -1,39 +1,18 @@
package Application;

import Application.deezer.AlbumSearch;
import Application.deezer.ArtistSearch;
import Application.deezer.TrackSearch;
import Application.models.Album;
import Application.models.Artist;
import Application.models.Track;
import Application.services.ConcertService;
import Application.services.TrackService;
import org.json.JSONException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.PropertySource;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.List;

@SpringBootApplication(scanBasePackages = "Application")
@EntityScan("Application")
@PropertySource(value = "classpath:application.properties")
@EnableTransactionManagement
public class P2Application {

public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(P2Application.class, args);

TrackService service = context.getBean(TrackService.class);
ConcertService service2 = context.getBean(ConcertService.class);

System.out.println("TESTING: TrackSearch for \"kiwi\"");
List<Track> trackList = TrackSearch.searchTracks("kiwi",3);
for(Track track:trackList){
System.out.println(track.toString());
}
SpringApplication.run(P2Application.class, args);
}
}
12 changes: 5 additions & 7 deletions src/main/java/Application/ServletInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(P2Application.class);
}

}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(P2Application.class);
}
}
52 changes: 52 additions & 0 deletions src/main/java/Application/aspects/LoggerAspect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package Application.aspects;

import Application.services.LoggerService;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
* LoggerAspect
* Logs all method calls and exceptions for all classes except filters.
*
* @author Kollier Martin
*/


@Aspect
@Component
public class LoggerAspect {
private final LoggerService loggerService;

public LoggerAspect(LoggerService loggerService) {
this.loggerService = loggerService;
}

@Pointcut("within(Application.*.*) && !within(Application.filters..*) && !within(Application.configs..*)")
public void logAll() {

}

@Around("within(Application.*.*) && !within(Application.filters..*) && !within(Application.configs..*)")
public void logAroundAll(ProceedingJoinPoint joinPoint) throws Throwable {
try {
joinPoint.proceed();
} catch (Exception ignored){

}
}

@AfterThrowing(pointcut = "logAll()", throwing = "e")
public void logMethodException(JoinPoint jp, Throwable e) {
String methodSig = extractMethodSignature(jp);
loggerService.writeLog(String.format("%s was thrown in method %s with message: %s", e.getClass().getSimpleName(), methodSig, e.getMessage()), 3);
}

private String extractMethodSignature(JoinPoint jp) {
return jp.getTarget().getClass().toString() + "." + jp.getSignature().getName();
}
}
20 changes: 20 additions & 0 deletions src/main/java/Application/configs/FilterConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package Application.configs;

import Application.filters.CORSFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Collections;

@Configuration
public class FilterConfig {
@Bean
@SuppressWarnings({"rawtypes, unchecked"})
public FilterRegistrationBean corsRegistrationBean() {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
filterRegistrationBean.setFilter(new CORSFilter());
filterRegistrationBean.setUrlPatterns(Collections.singletonList("/*"));
return filterRegistrationBean;
}
}
Loading