Skip to content

Commit

Permalink
Merge 6fbbda6 into e95ef35
Browse files Browse the repository at this point in the history
  • Loading branch information
wwelling committed Aug 2, 2018
2 parents e95ef35 + 6fbbda6 commit 2ca4776
Show file tree
Hide file tree
Showing 130 changed files with 4,880 additions and 2,307 deletions.
10 changes: 6 additions & 4 deletions pom.xml
Expand Up @@ -51,7 +51,7 @@
<artifactId>validation</artifactId>
<version>2.0.0-RC5-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>email</artifactId>
Expand All @@ -64,6 +64,11 @@
<version>2.0.0-RC5-SNAPSHOT</version>
</dependency>

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

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand Down Expand Up @@ -125,7 +130,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<quiet>true</quiet>
<instrumentation>
Expand All @@ -145,7 +149,6 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.8</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand All @@ -158,7 +161,6 @@
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
<repoToken></repoToken>
</configuration>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/edu/tamu/app/ProjectApplication.java
Expand Up @@ -9,7 +9,6 @@

/**
* Web server initialization.
*
*/
@EnableScheduling
@SpringBootApplication
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/edu/tamu/app/ProjectInitialization.java
Expand Up @@ -2,10 +2,9 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import edu.tamu.app.model.repo.VersionManagementSoftwareRepo;
import edu.tamu.app.model.repo.RemoteProjectManagerRepo;
import edu.tamu.app.service.registry.ManagementBeanRegistry;

@Component
Expand All @@ -15,12 +14,13 @@ public class ProjectInitialization implements CommandLineRunner {
private ManagementBeanRegistry managementBeanRegistry;

@Autowired
private VersionManagementSoftwareRepo versionManagementSoftwareRepo;
private RemoteProjectManagerRepo remoteProjectManagerRepo;

@Override
public void run(String... args) throws Exception {
versionManagementSoftwareRepo.findAll().forEach(versionManagementSoftware -> {
remoteProjectManagerRepo.findAll().forEach(versionManagementSoftware -> {
managementBeanRegistry.register(versionManagementSoftware);
});
}

}
Expand Up @@ -4,7 +4,7 @@

import org.springframework.stereotype.Service;

import edu.tamu.app.enums.Role;
import edu.tamu.app.model.Role;
import edu.tamu.app.model.User;
import edu.tamu.app.model.repo.UserRepo;
import edu.tamu.weaver.auth.model.Credentials;
Expand All @@ -20,26 +20,7 @@ public synchronized User updateUserByCredentials(Credentials credentials) {

User user = null;

if (!optionalUser.isPresent()) {

Role role = Role.ROLE_USER;

if (credentials.getRole() == null) {
credentials.setRole(role.toString());
}

String shibUin = credentials.getUin();

for (String uin : admins) {
if (uin.equals(shibUin)) {
role = Role.ROLE_ADMIN;
credentials.setRole(role.toString());
}
}

user = userRepo.create(credentials.getUin(), credentials.getEmail(), credentials.getFirstName(), credentials.getLastName(), role);

} else {
if (optionalUser.isPresent()) {
user = optionalUser.get();

boolean changed = false;
Expand All @@ -65,27 +46,44 @@ public synchronized User updateUserByCredentials(Credentials credentials) {
}

if (credentials.getRole() == null) {

user.setRole(Role.valueOf(credentials.getRole()));
user.setRole(getDefaultRole(credentials));
changed = true;
}

if (changed) {
user = userRepo.save(user);
}

} else {
user = userRepo.create(credentials.getUin(), credentials.getEmail(), credentials.getFirstName(), credentials.getLastName(), getDefaultRole(credentials));
}

credentials.setRole(user.getRole().toString());
credentials.setUin(user.getUsername());

return user;

}

@Override
public String getAnonymousRole() {
return Role.ROLE_ANONYMOUS.toString();
}

private Role getDefaultRole(Credentials credentials) {
Role role = Role.ROLE_USER;

if (credentials.getRole() == null) {
credentials.setRole(role.toString());
}

String shibUin = credentials.getUin();

for (String uin : admins) {
if (uin.equals(shibUin)) {
role = Role.ROLE_ADMIN;
credentials.setRole(role.toString());
}
}
return role;
}

}
15 changes: 15 additions & 0 deletions src/main/java/edu/tamu/app/cache/AbstractCache.java
@@ -0,0 +1,15 @@
package edu.tamu.app.cache;

public abstract class AbstractCache<T> implements Cache<T> {

private T cache;

public synchronized T get() {
return cache;
}

public synchronized void set(T cache) {
this.cache = cache;
}

}
14 changes: 14 additions & 0 deletions src/main/java/edu/tamu/app/cache/ActiveSprintsCache.java
@@ -0,0 +1,14 @@
package edu.tamu.app.cache;

import java.util.ArrayList;
import java.util.List;

import edu.tamu.app.cache.model.Sprint;

public class ActiveSprintsCache extends AbstractCache<List<Sprint>> {

public ActiveSprintsCache() {
set(new ArrayList<Sprint>());
}

}
9 changes: 9 additions & 0 deletions src/main/java/edu/tamu/app/cache/Cache.java
@@ -0,0 +1,9 @@
package edu.tamu.app.cache;

public interface Cache<T> {

public T get();

public void set(T cache);

}
15 changes: 15 additions & 0 deletions src/main/java/edu/tamu/app/cache/RemoteProjectsCache.java
@@ -0,0 +1,15 @@
package edu.tamu.app.cache;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import edu.tamu.app.cache.model.RemoteProject;

public class RemoteProjectsCache extends AbstractCache<Map<Long, List<RemoteProject>>> {

public RemoteProjectsCache() {
set(new HashMap<Long, List<RemoteProject>>());
}

}
@@ -0,0 +1,31 @@
package edu.tamu.app.cache.controller;

import static edu.tamu.weaver.response.ApiStatus.SUCCESS;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;

import edu.tamu.app.cache.service.AbstractScheduledCacheService;
import edu.tamu.weaver.response.ApiResponse;

public abstract class AbstractCacheController<S extends AbstractScheduledCacheService<?, ?>> implements CacheController {

@Autowired
private S cacheService;

@GetMapping
@PreAuthorize("hasRole('ANONYMOUS')")
public ApiResponse get() {
return new ApiResponse(SUCCESS, cacheService.get());
}

@GetMapping("/update")
@PreAuthorize("hasRole('MANAGER')")
public ApiResponse update() {
cacheService.update();
cacheService.broadcast();
return new ApiResponse(SUCCESS);
}

}
@@ -0,0 +1,12 @@
package edu.tamu.app.cache.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import edu.tamu.app.cache.service.ActiveSprintsScheduledCacheService;

@RestController
@RequestMapping("/active-sprints")
public class ActiveSprintsCacheController extends AbstractCacheController<ActiveSprintsScheduledCacheService> {

}
11 changes: 11 additions & 0 deletions src/main/java/edu/tamu/app/cache/controller/CacheController.java
@@ -0,0 +1,11 @@
package edu.tamu.app.cache.controller;

import edu.tamu.weaver.response.ApiResponse;

public interface CacheController {

public ApiResponse get();

public ApiResponse update();

}
@@ -0,0 +1,12 @@
package edu.tamu.app.cache.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import edu.tamu.app.cache.service.RemoteProjectsScheduledCacheService;

@RestController
@RequestMapping("/remote-projects")
public class RemoteProjectsCacheController extends AbstractCacheController<RemoteProjectsScheduledCacheService> {

}
88 changes: 88 additions & 0 deletions src/main/java/edu/tamu/app/cache/model/Card.java
@@ -0,0 +1,88 @@
package edu.tamu.app.cache.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

public class Card implements Serializable {

private static final long serialVersionUID = 5692495387386239114L;

private final String id;

private final String number;

private final String type;

private final String status;

private final String name;

@JsonInclude(Include.NON_NULL)
private final String description;

@JsonInclude(Include.NON_NULL)
private final Float estimate;

private final List<Member> assignees;

public Card() {
super();
this.id = "";
this.number = "";
this.type = "";
this.name = "";
this.description = "";
this.status = "";
this.estimate = null;
this.assignees = new ArrayList<Member>();
}

public Card(String id, String number, String type, String name, String description, String status, Float estimate, List<Member> assignees) {
super();
this.id = id;
this.number = number;
this.type = type;
this.name = name;
this.description = description;
this.status = status;
this.estimate = estimate;
this.assignees = assignees;
}

public String getId() {
return id;
}

public String getNumber() {
return number;
}

public String getType() {
return type;
}

public String getName() {
return name;
}

public String getDescription() {
return description;
}

public String getStatus() {
return status;
}

public Float getEstimate() {
return estimate;
}

public List<Member> getAssignees() {
return assignees;
}

}

0 comments on commit 2ca4776

Please sign in to comment.