Skip to content

Commit

Permalink
optimizing imports
Browse files Browse the repository at this point in the history
  • Loading branch information
AWerbrouck committed May 23, 2024
1 parent 3f4949d commit 5ff90d1
Show file tree
Hide file tree
Showing 66 changed files with 197 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@

import jakarta.servlet.http.HttpServletRequest;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.http.MethodNotSupportedException;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.server.MethodNotAllowedException;
import org.springframework.web.servlet.NoHandlerFoundException;
import org.springframework.web.servlet.resource.NoResourceFoundException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.StringUtils;
import org.springframework.web.filter.OncePerRequestFilter;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.interfaces.RSAPublicKey;
import java.util.ArrayList;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.StringUtils;
import org.springframework.web.filter.OncePerRequestFilter;

/**
* This class extends OncePerRequestFilter to provide a filter that decodes and verifies JWT tokens.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.ugent.pidgeon.auth;

import com.ugent.pidgeon.postgre.models.types.UserRole;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
import com.ugent.pidgeon.postgre.repository.UserRepository;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;


/**
* This class is a Spring component that implements the HandlerInterceptor interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.core.convert.converter.Converter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.ugent.pidgeon.config;

import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.core.io.ClassPathResource;

import javax.annotation.PostConstruct;

/**
* We check if the application-secrets.properties file exists. If it does not exist, we throw an exception.
*/
Expand Down
3 changes: 1 addition & 2 deletions backend/app/src/main/java/com/ugent/pidgeon/model/Auth.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.ugent.pidgeon.model;

import com.ugent.pidgeon.postgre.models.UserEntity;
import java.util.Collection;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.util.Assert;

import java.util.Collection;
import com.ugent.pidgeon.model.User;
public class Auth extends AbstractAuthenticationToken {
private static final long serialVersionUID = 620L;

Expand Down
2 changes: 0 additions & 2 deletions backend/app/src/main/java/com/ugent/pidgeon/model/User.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.ugent.pidgeon.model;

import java.util.List;

public class User {

public String name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package com.ugent.pidgeon.model.submissionTesting;

import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.core.command.PullImageResultCallback;
import com.ugent.pidgeon.util.DockerClientInstance;

public class AddDockerModel {

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.ugent.pidgeon.model.submissionTesting;

import java.util.List;

public interface DockerOutput {
public boolean isAllowed();
public String getFeedbackAsString();
boolean isAllowed();
String getFeedbackAsString();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.util.List;

public class DockerTemplateTestOutput implements DockerOutput{
private List<DockerSubtestResult> subtestResults;
private boolean allowed;
private final List<DockerSubtestResult> subtestResults;
private final boolean allowed;

public List<DockerSubtestResult> getSubtestResults() {
return subtestResults;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package com.ugent.pidgeon.model.submissionTesting;

import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
Expand Down Expand Up @@ -170,7 +176,7 @@ public SubmissionResult checkSubmission(ZipFile file) throws IOException {
}
// return true if all items in template are in the zip
for (int i = 0; i < requiredItemsContained.size(); i++) {
if (requiredItemsContained.get(i) == false) {
if (!requiredItemsContained.get(i)) {
filesMissing.add(requiredFiles.get(i).name);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.ugent.pidgeon.postgre.models;

import jakarta.persistence.*;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.OffsetDateTime;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.ugent.pidgeon.postgre.models;

import com.ugent.pidgeon.postgre.models.types.CourseRelation;
import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.Table;

@Entity
@IdClass(CourseUserId.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.ugent.pidgeon.postgre.models;

import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

@Entity
@Table(name = "files")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.ugent.pidgeon.postgre.models;

import jakarta.persistence.*;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.OffsetDateTime;

@Entity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.ugent.pidgeon.postgre.models;

import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

@Entity
@Table(name="groups")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.ugent.pidgeon.postgre.models;

import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.Table;

@Entity
@IdClass(GroupFeedbackId.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.ugent.pidgeon.postgre.models;

import jakarta.persistence.*;

import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.Table;

@Entity
@IdClass(GroupUserId.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.time.OffsetDateTime;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.logging.Logger;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.ugent.pidgeon.postgre.models;

import jakarta.persistence.*;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.OffsetDateTime;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.ugent.pidgeon.postgre.models;

import com.ugent.pidgeon.postgre.models.types.DockerTestType;
import com.ugent.pidgeon.postgre.models.types.DockerTestState;
import jakarta.persistence.*;

import com.ugent.pidgeon.postgre.models.types.DockerTestType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.OffsetDateTime;

@Entity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.ugent.pidgeon.postgre.models;

import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

@Entity
@Table(name = "tests")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@


import com.ugent.pidgeon.postgre.models.types.UserRole;
import jakarta.persistence.*;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.OffsetDateTime;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.ugent.pidgeon.postgre.repository;

import com.fasterxml.jackson.annotation.OptBoolean;
import com.ugent.pidgeon.postgre.models.CourseUserEntity;
import com.ugent.pidgeon.postgre.models.CourseUserId;
import com.ugent.pidgeon.postgre.models.types.CourseRelation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface CourseUserRepository extends JpaRepository<CourseUserEntity, CourseUserId> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.ugent.pidgeon.postgre.repository;

import com.ugent.pidgeon.postgre.models.GroupClusterEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface GroupClusterRepository extends JpaRepository<GroupClusterEntity, Long> {
List<GroupClusterEntity> findByCourseId(long courseId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import com.ugent.pidgeon.postgre.models.GroupFeedbackEntity;
import com.ugent.pidgeon.postgre.models.GroupFeedbackId;
import com.ugent.pidgeon.postgre.models.SubmissionEntity;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface GroupFeedbackRepository extends JpaRepository<GroupFeedbackEntity, GroupFeedbackId> {

@Query(value = "SELECT * FROM group_feedback WHERE group_id = ?1 AND project_id = ?2", nativeQuery = true)
Expand Down
Loading

0 comments on commit 5ff90d1

Please sign in to comment.