use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ModerationDatabaseHandler method createRequest.
public RequestStatus createRequest(License license, User user) {
License dblicense;
try {
dblicense = licenseDatabaseHandler.getLicenseForOrganisation(license.getId(), user.getDepartment());
} catch (SW360Exception e) {
log.error("Could not get original license from database. Could not generate moderation request.", e);
return RequestStatus.FAILURE;
}
// Define moderators
Set<String> moderators = getLicenseModerators(user.getDepartment());
ModerationRequest request = createStubRequest(user, false, license.getId(), moderators);
// Set meta-data
request.setDocumentType(DocumentType.LICENSE);
request.setDocumentName(SW360Utils.printName(license));
// Fill the request
ModerationRequestGenerator generator = new LicenseModerationRequestGenerator();
request = generator.setAdditionsAndDeletions(request, license, dblicense);
addOrUpdate(request, user);
return RequestStatus.SENT_TO_MODERATOR;
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ProjectHandlerTest method testUpdateProject2_2.
@Test
public void testUpdateProject2_2() throws Exception {
Project project2 = handler.getProjectById("P2", user2);
project2.setName("Project2new");
project2.setBusinessUnit("AB CD EF");
RequestStatus status = handler.updateProject(project2, user2);
assertEquals(RequestStatus.SUCCESS, status);
assertEquals("Project2new", handler.getProjectById("P2", user2).getName());
assertEquals("AB CD EF", handler.getProjectById("P2", user2).getBusinessUnit());
assertEquals(2, handler.getMyProjects(user1.getEmail()).size());
assertEquals(1, handler.getMyProjects(user2.getEmail()).size());
assertEquals(1, handler.getMyProjects(user3.getEmail()).size());
assertEquals(3, handler.getAccessibleProjectsSummary(user1).size());
assertEquals(1, handler.getAccessibleProjectsSummary(user2).size());
assertEquals(3, handler.getAccessibleProjectsSummary(user3).size());
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ProjectHandlerTest method testDeleteProject3_3.
@Test(expected = Exception.class)
public void testDeleteProject3_3() throws Exception {
RequestStatus status = handler.deleteProject("P3", user3);
assertEquals(RequestStatus.SUCCESS, status);
assertEquals(2, handler.getMyProjects(user1.getEmail()).size());
assertEquals(1, handler.getMyProjects(user2.getEmail()).size());
assertEquals(0, handler.getMyProjects(user3.getEmail()).size());
assertEquals(2, handler.getAccessibleProjectsSummary(user1).size());
assertEquals(1, handler.getAccessibleProjectsSummary(user2).size());
assertEquals(1, handler.getAccessibleProjectsSummary(user3).size());
boolean deleted = (handler.getProjectById("P3", user3) == null);
assertEquals(true, deleted);
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ProjectHandlerTest method testDeleteProject1_1.
// ////////////////////////////////////////////////////////////////////////////////////
@Test(expected = Exception.class)
public void testDeleteProject1_1() throws Exception {
RequestStatus status = handler.deleteProject("P1", user1);
assertEquals(RequestStatus.SUCCESS, status);
assertEquals(1, handler.getMyProjects(user1.getEmail()).size());
assertEquals(1, handler.getMyProjects(user2.getEmail()).size());
assertEquals(1, handler.getMyProjects(user3.getEmail()).size());
assertEquals(2, handler.getAccessibleProjectsSummary(user1).size());
assertEquals(1, handler.getAccessibleProjectsSummary(user2).size());
assertEquals(1, handler.getAccessibleProjectsSummary(user3).size());
boolean deleted = (handler.getProjectById("P1", user1) == null);
assertEquals(true, deleted);
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ProjectHandlerTest method testUpdateProject3_3.
@Test
public void testUpdateProject3_3() throws Exception {
Project project3 = handler.getProjectById("P3", user3);
project3.setName("Project3new");
project3.setBusinessUnit("AB CD FE");
RequestStatus status = handler.updateProject(project3, user3);
assertEquals(RequestStatus.SUCCESS, status);
assertEquals("Project3new", handler.getProjectById("P3", user3).getName());
assertEquals("AB CD FE", handler.getProjectById("P3", user3).getBusinessUnit());
assertEquals(2, handler.getMyProjects(user1.getEmail()).size());
assertEquals(1, handler.getMyProjects(user2.getEmail()).size());
assertEquals(1, handler.getMyProjects(user3.getEmail()).size());
assertEquals(2, handler.getAccessibleProjectsSummary(user1).size());
assertEquals(2, handler.getAccessibleProjectsSummary(user2).size());
assertEquals(2, handler.getAccessibleProjectsSummary(user3).size());
}
Aggregations