Search in sources :

Example 31 with RequestStatus

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;
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest) License(org.eclipse.sw360.datahandler.thrift.licenses.License) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception)

Example 32 with RequestStatus

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());
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) Test(org.junit.Test)

Example 33 with RequestStatus

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);
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) Test(org.junit.Test)

Example 34 with RequestStatus

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);
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) Test(org.junit.Test)

Example 35 with RequestStatus

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());
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) Test(org.junit.Test)

Aggregations

RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)52 TException (org.apache.thrift.TException)27 User (org.eclipse.sw360.datahandler.thrift.users.User)24 Test (org.junit.Test)16 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)13 UsedAsLiferayAction (org.eclipse.sw360.portal.common.UsedAsLiferayAction)10 ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)5 TestUtils.assertTestString (org.eclipse.sw360.datahandler.TestUtils.assertTestString)4 AddDocumentRequestStatus (org.eclipse.sw360.datahandler.thrift.AddDocumentRequestStatus)4 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)4 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)4 VendorService (org.eclipse.sw360.datahandler.thrift.vendors.VendorService)4 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)3 Release (org.eclipse.sw360.datahandler.thrift.components.Release)3 Vulnerability (org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability)3 JSONObject (com.liferay.portal.kernel.json.JSONObject)2 PrintWriter (java.io.PrintWriter)2 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)2 Component (org.eclipse.sw360.datahandler.thrift.components.Component)2 UpdateType (org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType)2