Skip to content

Commit

Permalink
Merge 0b2cc3b into 4a52a55
Browse files Browse the repository at this point in the history
  • Loading branch information
wwelling committed Jun 26, 2018
2 parents 4a52a55 + 0b2cc3b commit 23f49c8
Show file tree
Hide file tree
Showing 32 changed files with 294 additions and 306 deletions.
3 changes: 0 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<quiet>true</quiet>
<instrumentation>
Expand All @@ -144,7 +143,6 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.8</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand All @@ -157,7 +155,6 @@
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
<repoToken></repoToken>
</configuration>
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/edu/tamu/app/ProjectInitialization.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
package edu.tamu.app;

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

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.enums.ServiceType;
import edu.tamu.app.model.Project;
import edu.tamu.app.model.RemoteProjectManager;
import edu.tamu.app.model.repo.ProjectRepo;
import edu.tamu.app.model.repo.RemoteProjectManagerRepo;
import edu.tamu.app.service.registry.ManagementBeanRegistry;

@Component
public class ProjectInitialization implements CommandLineRunner {

@Autowired
private ProjectRepo projectRepo;

@Autowired
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);
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public synchronized User updateUserByCredentials(Credentials credentials) {
}

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

user.setRole(Role.valueOf(credentials.getRole()));
changed = true;
}
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/edu/tamu/app/controller/ProjectController.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import org.springframework.web.bind.annotation.RestController;

import edu.tamu.app.model.Project;
import edu.tamu.app.model.VersionManagementSoftware;
import edu.tamu.app.model.RemoteProjectManager;
import edu.tamu.app.model.repo.ProjectRepo;
import edu.tamu.app.model.repo.VersionManagementSoftwareRepo;
import edu.tamu.app.model.repo.RemoteProjectManagerRepo;
import edu.tamu.app.model.request.FeatureRequest;
import edu.tamu.app.model.request.TicketRequest;
import edu.tamu.app.service.managing.RemoteProjectManagerBean;
import edu.tamu.app.service.registry.ManagementBeanRegistry;
import edu.tamu.app.service.ticketing.SugarService;
import edu.tamu.app.service.versioning.VersionManagementSoftwareBean;
import edu.tamu.weaver.response.ApiResponse;
import edu.tamu.weaver.validation.aspect.annotation.WeaverValidatedModel;
import edu.tamu.weaver.validation.aspect.annotation.WeaverValidation;
Expand All @@ -44,7 +44,7 @@ public class ProjectController {
private ManagementBeanRegistry managementBeanRegistry;

@Autowired
private VersionManagementSoftwareRepo versionManagementSoftwareRepo;
private RemoteProjectManagerRepo versionManagementSoftwareRepo;

@Autowired
private SugarService sugarService;
Expand Down Expand Up @@ -100,9 +100,9 @@ public ApiResponse pushRequest(HttpServletRequest req, @RequestBody FeatureReque
Optional<Project> project = Optional.ofNullable(projectRepo.findOne(request.getProjectId()));
ApiResponse response;
if (project.isPresent()) {
Optional<VersionManagementSoftware> versionManagementSoftware = Optional.ofNullable(project.get().getVersionManagementSoftware());
Optional<RemoteProjectManager> versionManagementSoftware = Optional.ofNullable(project.get().getRemoteProjectManager());
if (versionManagementSoftware.isPresent()) {
VersionManagementSoftwareBean versionManagementSoftwareBean = (VersionManagementSoftwareBean) managementBeanRegistry.getService(versionManagementSoftware.get().getName());
RemoteProjectManagerBean versionManagementSoftwareBean = (RemoteProjectManagerBean) managementBeanRegistry.getService(versionManagementSoftware.get().getName());
request.setScopeId(project.get().getScopeId());
try {
response = new ApiResponse(SUCCESS, versionManagementSoftwareBean.push(request));
Expand All @@ -121,12 +121,12 @@ public ApiResponse pushRequest(HttpServletRequest req, @RequestBody FeatureReque
@RequestMapping(value = "/{vmsId}/version-projects", method = RequestMethod.GET)
@PreAuthorize("hasRole('MANAGER')")
public ApiResponse getAllVersionProjects(@PathVariable Long vmsId) {
Optional<VersionManagementSoftware> vms = Optional.ofNullable(versionManagementSoftwareRepo.findOne(vmsId));
Optional<RemoteProjectManager> vms = Optional.ofNullable(versionManagementSoftwareRepo.findOne(vmsId));
ApiResponse response;
if (vms.isPresent()) {
VersionManagementSoftwareBean versionManagementSoftwareBean = (VersionManagementSoftwareBean) managementBeanRegistry.getService(vms.get().getName());
RemoteProjectManagerBean versionManagementSoftwareBean = (RemoteProjectManagerBean) managementBeanRegistry.getService(vms.get().getName());
try {
response = new ApiResponse(SUCCESS, versionManagementSoftwareBean.getVersionProjects());
response = new ApiResponse(SUCCESS, versionManagementSoftwareBean.getRemoteProjects());
} catch (Exception e) {
response = new ApiResponse(ERROR, "Error fetching version projects from " + vms.get().getName() + "!");
}
Expand All @@ -139,12 +139,12 @@ public ApiResponse getAllVersionProjects(@PathVariable Long vmsId) {
@RequestMapping(value = "/{vmsId}/version-projects/{scopeId}", method = RequestMethod.GET)
@PreAuthorize("hasRole('MANAGER')")
public ApiResponse getVersionProjectByScopeId(@PathVariable Long vmsId, @PathVariable String scopeId) {
Optional<VersionManagementSoftware> vms = Optional.ofNullable(versionManagementSoftwareRepo.findOne(vmsId));
Optional<RemoteProjectManager> vms = Optional.ofNullable(versionManagementSoftwareRepo.findOne(vmsId));
ApiResponse response;
if (vms.isPresent()) {
VersionManagementSoftwareBean versionManagementSoftwareBean = (VersionManagementSoftwareBean) managementBeanRegistry.getService(vms.get().getName());
RemoteProjectManagerBean versionManagementSoftwareBean = (RemoteProjectManagerBean) managementBeanRegistry.getService(vms.get().getName());
try {
response = new ApiResponse(SUCCESS, versionManagementSoftwareBean.getVersionProjectByScopeId(scopeId));
response = new ApiResponse(SUCCESS, versionManagementSoftwareBean.getRemoteProjectByScopeId(scopeId));
} catch (Exception e) {
response = new ApiResponse(ERROR, "Error fetching version project with scope id " + scopeId + " from " + vms.get().getName() + "!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,56 @@
import org.springframework.web.bind.annotation.RestController;

import edu.tamu.app.enums.ServiceType;
import edu.tamu.app.model.VersionManagementSoftware;
import edu.tamu.app.model.repo.VersionManagementSoftwareRepo;
import edu.tamu.app.model.RemoteProjectManager;
import edu.tamu.app.model.repo.RemoteProjectManagerRepo;
import edu.tamu.weaver.response.ApiResponse;
import edu.tamu.weaver.validation.aspect.annotation.WeaverValidatedModel;
import edu.tamu.weaver.validation.aspect.annotation.WeaverValidation;

@RestController
@RequestMapping("/version-management-software")
public class VersionManagementSoftwareController {
@RequestMapping("/remote-project-manager")
public class RemoteProjectManagerController {

@Autowired
private VersionManagementSoftwareRepo vmsRepo;
private RemoteProjectManagerRepo remoteProjectManagerRepo;

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

@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("hasRole('USER')")
public ApiResponse getAll() {
return new ApiResponse(SUCCESS, vmsRepo.findAll());
return new ApiResponse(SUCCESS, remoteProjectManagerRepo.findAll());
}

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@PreAuthorize("hasRole('USER')")
public ApiResponse getOne(@PathVariable Long id) {
return new ApiResponse(SUCCESS, vmsRepo.findOne(id));
return new ApiResponse(SUCCESS, remoteProjectManagerRepo.findOne(id));
}

@RequestMapping(method = RequestMethod.POST)
@PreAuthorize("hasRole('USER')")
@WeaverValidation(business = { @WeaverValidation.Business(value = CREATE) })
public ApiResponse createVersionManagementSoftware(@WeaverValidatedModel VersionManagementSoftware vms) {
logger.info("Model: " + vms.toString());
logger.info("Creating Version Management Software: " + vms.getName());
return new ApiResponse(SUCCESS, vmsRepo.create(vms));
public ApiResponse createRemoteProjectManager(@WeaverValidatedModel RemoteProjectManager remoteProjectManager) {
logger.info("Model: " + remoteProjectManager.toString());
logger.info("Creating Version Management Software: " + remoteProjectManager.getName());
return new ApiResponse(SUCCESS, remoteProjectManagerRepo.create(remoteProjectManager));
}

@RequestMapping(method = RequestMethod.PUT)
@PreAuthorize("hasRole('USER')")
@WeaverValidation(business = { @WeaverValidation.Business(value = UPDATE) })
public ApiResponse updateVersionManagementSoftware(@WeaverValidatedModel VersionManagementSoftware vms) {
logger.info("Updating Version Management Software: " + vms.getName());
return new ApiResponse(SUCCESS, vmsRepo.update(vms));
public ApiResponse updateRemoteProjectManager(@WeaverValidatedModel RemoteProjectManager remoteProjectManager) {
logger.info("Updating Version Management Software: " + remoteProjectManager.getName());
return new ApiResponse(SUCCESS, remoteProjectManagerRepo.update(remoteProjectManager));
}

@RequestMapping(method = RequestMethod.DELETE)
@PreAuthorize("hasRole('USER')")
@WeaverValidation(business = { @WeaverValidation.Business(value = DELETE) })
public ApiResponse deleteVersionManagementSoftware(@WeaverValidatedModel VersionManagementSoftware vms) {
logger.info("Deleting Version Management Software: " + vms.getName());
vmsRepo.delete(vms);
public ApiResponse deleteRemoteProjectManager(@WeaverValidatedModel RemoteProjectManager remoteProjectManager) {
logger.info("Deleting Version Management Software: " + remoteProjectManager.getName());
remoteProjectManagerRepo.delete(remoteProjectManager);
return new ApiResponse(SUCCESS);
}

Expand Down
28 changes: 9 additions & 19 deletions src/main/java/edu/tamu/app/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

/**
* User Controller
*
*/
@RestController
@RequestMapping("/users")
Expand All @@ -26,13 +25,11 @@ public class UserController {
private UserRepo userRepo;

/**
* Websocket endpoint to request credentials.
* Get credentials.
*
* @param credentials
* @ApiCredentials Credentials
*
* @WeaverCredentials Credentials
* @return ApiResponse
*
*/
@RequestMapping("/credentials")
@PreAuthorize("hasRole('ANONYMOUS')")
Expand All @@ -41,12 +38,9 @@ public ApiResponse credentials(@WeaverCredentials Credentials credentials) {
}

/**
* Returns all users.
* Get all users.
*
* @param user
* @ApiModel AppUser
*
* @return
* @return ApiResponse
*/
@RequestMapping
@PreAuthorize("hasRole('MANAGER')")
Expand All @@ -55,13 +49,11 @@ public ApiResponse allUsers() {
}

/**
* Returns users.
* Update user.
*
* @param user
* @ApiModel AppUser
*
* @RequestBody User
* @return ApiResponse
*
*/
@RequestMapping("/update")
@PreAuthorize("hasRole('MANAGER')")
Expand All @@ -71,13 +63,11 @@ public ApiResponse updateUser(@RequestBody User user) {
}

/**
* Endpoint to delete user.
* Delete user.
*
* @param user
* @ApiModel AppUser
*
* @RequestBody User
* @return ApiResponse
*
*/
@RequestMapping("/delete")
@PreAuthorize("hasRole('MANAGER')")
Expand All @@ -86,4 +76,4 @@ public ApiResponse delete(@RequestBody User user) {
return new ApiResponse(SUCCESS);
}

}
}
18 changes: 9 additions & 9 deletions src/main/java/edu/tamu/app/model/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Project extends ValidatingBaseEntity {

@JsonInclude(Include.NON_NULL)
@ManyToOne(fetch = EAGER, cascade = { DETACH, REFRESH, MERGE }, optional = true)
private VersionManagementSoftware versionManagementSoftware;
private RemoteProjectManager remoteProjectManager;

public Project() {
this.modelValidator = new ProjectValidator();
Expand All @@ -38,13 +38,13 @@ public Project(String name) {
this.name = name;
}

public Project(String name, VersionManagementSoftware versionManagementSoftware) {
public Project(String name, RemoteProjectManager remoteProjectManager) {
this(name);
this.versionManagementSoftware = versionManagementSoftware;
this.remoteProjectManager = remoteProjectManager;
}

public Project(String name, String scopeId, VersionManagementSoftware versionManagementSoftware) {
this(name, versionManagementSoftware);
public Project(String name, String scopeId, RemoteProjectManager remoteProjectManager) {
this(name, remoteProjectManager);
this.scopeId = scopeId;
}

Expand All @@ -64,12 +64,12 @@ public void setScopeId(String scopeId) {
this.scopeId = scopeId;
}

public VersionManagementSoftware getVersionManagementSoftware() {
return versionManagementSoftware;
public RemoteProjectManager getRemoteProjectManager() {
return remoteProjectManager;
}

public void setVersionManagementSoftware(VersionManagementSoftware versionManagementSoftware) {
this.versionManagementSoftware = versionManagementSoftware;
public void setRemoteProjectManager(RemoteProjectManager remoteProjectManager) {
this.remoteProjectManager = remoteProjectManager;
}

}
24 changes: 24 additions & 0 deletions src/main/java/edu/tamu/app/model/RemoteProjectManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package edu.tamu.app.model;

import java.util.Map;

import javax.persistence.Entity;

import edu.tamu.app.enums.ServiceType;

@Entity
public class RemoteProjectManager extends ManagementService {

public RemoteProjectManager() {
super();
}

public RemoteProjectManager(String name, ServiceType type) {
super(name, type);
}

public RemoteProjectManager(String name, ServiceType type, Map<String, String> settings) {
super(name, type, settings);
}

}
2 changes: 1 addition & 1 deletion src/main/java/edu/tamu/app/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,4 @@ public String getPassword() {
return null;
}

}
}
24 changes: 0 additions & 24 deletions src/main/java/edu/tamu/app/model/VersionManagementSoftware.java

This file was deleted.

0 comments on commit 23f49c8

Please sign in to comment.