use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.
the class RestControllerHelper method addEmbeddedUser.
public void addEmbeddedUser(HalResource halResource, User user, String relation) {
User embeddedUser = convertToEmbeddedUser(user);
Resource<User> embeddedUserResource = new Resource<>(embeddedUser);
try {
String userUUID = Base64.getEncoder().encodeToString(user.getEmail().getBytes("utf-8"));
Link userLink = linkTo(UserController.class).slash("api/users/" + userUUID).withSelfRel();
embeddedUserResource.add(userLink);
} catch (Exception e) {
LOGGER.error("cannot create embedded user with email: " + user.getEmail());
}
halResource.addEmbeddedResource(relation, embeddedUserResource);
}
use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.
the class UserSpecTest method before.
@Before
public void before() throws UnsupportedEncodingException {
List<User> userList = new ArrayList<>();
user = new User();
user.setEmail("admin@sw360.org");
user.setId(Base64.getEncoder().encodeToString(user.getEmail().getBytes("utf-8")));
user.setUserGroup(UserGroup.ADMIN);
user.setFullname("John Doe");
user.setGivenname("John");
user.setLastname("Doe");
user.setDepartment("SW360 Administration");
user.setWantsMailNotification(true);
userList.add(user);
given(this.userServiceMock.getUserByEmail("admin@sw360.org")).willReturn(user);
User user2 = new User();
user2.setEmail("jane@sw360.org");
user2.setId(Base64.getEncoder().encodeToString(user.getEmail().getBytes("utf-8")));
user2.setUserGroup(UserGroup.USER);
user2.setFullname("Jane Doe");
user2.setGivenname("Jane");
user2.setLastname("Doe");
user2.setDepartment("SW360 BA");
user2.setWantsMailNotification(false);
userList.add(user2);
given(this.userServiceMock.getAllUsers()).willReturn(userList);
}
use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.
the class ComponentSpecTest method before.
@Before
public void before() throws TException {
List<Component> componentList = new ArrayList<>();
List<Component> componentListByName = new ArrayList<>();
angularComponent = new Component();
angularComponent.setId("17653524");
angularComponent.setName("Angular");
angularComponent.setComponentOwner("John");
angularComponent.setDescription("Angular is a development platform for building mobile and desktop web applications.");
angularComponent.setCreatedOn("2016-12-15");
angularComponent.setCreatedBy("admin@sw360.org");
angularComponent.setComponentType(ComponentType.OSS);
angularComponent.setVendorNames(new HashSet<>(Collections.singletonList("Google")));
angularComponent.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "john@sw360.org")));
angularComponent.setOwnerAccountingUnit("4822");
angularComponent.setOwnerCountry("DE");
angularComponent.setOwnerGroup("AA BB 123 GHV2-DE");
angularComponent.setCategories(ImmutableSet.of("java", "javascript", "sql"));
angularComponent.setLanguages(ImmutableSet.of("EN", "DE"));
angularComponent.setOperatingSystems(ImmutableSet.of("Windows", "Linux"));
componentList.add(angularComponent);
componentListByName.add(angularComponent);
Component springComponent = new Component();
springComponent.setId("678dstzd8");
springComponent.setName("Spring Framework");
springComponent.setComponentOwner("Jane");
springComponent.setDescription("The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications.");
springComponent.setCreatedOn("2016-12-18");
springComponent.setCreatedBy("jane@sw360.org");
springComponent.setComponentType(ComponentType.OSS);
springComponent.setVendorNames(new HashSet<>(Collections.singletonList("Pivotal")));
springComponent.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
springComponent.setOwnerAccountingUnit("5661");
springComponent.setOwnerCountry("FR");
springComponent.setOwnerGroup("SIM-KA12");
springComponent.setCategories(ImmutableSet.of("jdbc", "java"));
springComponent.setLanguages(ImmutableSet.of("EN", "DE"));
springComponent.setOperatingSystems(ImmutableSet.of("Windows", "Linux"));
componentList.add(springComponent);
when(this.componentServiceMock.createComponent(anyObject(), anyObject())).then(invocation -> {
springComponent.setType("component");
springComponent.setCreatedOn("2016-12-20");
springComponent.setModerators(null);
springComponent.setVendorNames(null);
return springComponent;
});
given(this.componentServiceMock.getComponentsForUser(anyObject())).willReturn(componentList);
given(this.componentServiceMock.getComponentForUserById(eq("17653524"), anyObject())).willReturn(angularComponent);
given(this.componentServiceMock.searchComponentByName(eq(angularComponent.getName()))).willReturn(componentListByName);
User user = new User();
user.setId("admin@sw360.org");
user.setEmail("admin@sw360.org");
user.setFullname("John Doe");
user.setDepartment("sw360");
given(this.userServiceMock.getUserByEmail("admin@sw360.org")).willReturn(user);
List<Release> releaseList = new ArrayList<>();
Release release = new Release();
release.setId("3765276512");
release.setName("Angular 2.3.0");
release.setCpeid("cpe:/a:Google:Angular:2.3.0:");
release.setReleaseDate("2016-12-07");
release.setVersion("2.3.0");
release.setCreatedOn("2016-12-18");
release.setCreatedBy("admin@sw360.org");
release.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
release.setComponentId(springComponent.getId());
releaseList.add(release);
Release release2 = new Release();
release2.setId("3765276512");
release2.setName("Angular 2.3.1");
release2.setCpeid("cpe:/a:Google:Angular:2.3.1:");
release2.setReleaseDate("2016-12-15");
release2.setVersion("2.3.1");
release2.setCreatedOn("2016-12-18");
release2.setCreatedBy("admin@sw360.org");
release2.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
release2.setComponentId(springComponent.getId());
releaseList.add(release2);
angularComponent.setReleases(releaseList);
}
use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.
the class ProjectController method getVulnerabilitiesOfReleases.
@RequestMapping(value = PROJECTS_URL + "/{id}/vulnerabilities", method = RequestMethod.GET)
public ResponseEntity<Resources<Resource<VulnerabilityDTO>>> getVulnerabilitiesOfReleases(@PathVariable("id") String id, OAuth2Authentication oAuth2Authentication) {
final User sw360User = restControllerHelper.getSw360UserFromAuthentication(oAuth2Authentication);
final List<VulnerabilityDTO> allVulnerabilityDTOs = vulnerabilityService.getVulnerabilitiesByProjectId(id, sw360User);
final List<Resource<VulnerabilityDTO>> vulnerabilityResources = new ArrayList<>();
for (final VulnerabilityDTO vulnerabilityDTO : allVulnerabilityDTOs) {
final Resource<VulnerabilityDTO> vulnerabilityDTOResource = new Resource<>(vulnerabilityDTO);
vulnerabilityResources.add(vulnerabilityDTOResource);
}
final Resources<Resource<VulnerabilityDTO>> resources = new Resources<>(vulnerabilityResources);
return new ResponseEntity<>(resources, HttpStatus.OK);
}
use of org.eclipse.sw360.datahandler.thrift.users.User in project sw360portal by sw360.
the class Sw360ProjectService method deleteProject.
public RequestStatus deleteProject(Project project, User sw360User) throws TException {
ProjectService.Iface sw360ProjectClient = getThriftProjectClient();
RequestStatus requestStatus = sw360ProjectClient.deleteProject(project.getId(), sw360User);
if (requestStatus != RequestStatus.SUCCESS) {
throw new RuntimeException("sw360 project with name '" + project.getName() + " cannot be deleted.");
}
return requestStatus;
}
Aggregations