Search in sources :

Example 81 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.

the class ProjectHandlerTest method testDeleteProject2_2.

@Test(expected = Exception.class)
public void testDeleteProject2_2() throws Exception {
    RequestStatus status = handler.deleteProject("P2", user2);
    assertEquals(RequestStatus.SUCCESS, status);
    assertEquals(1, handler.getMyProjects(user1.getEmail()).size());
    assertEquals(0, handler.getMyProjects(user2.getEmail()).size());
    assertEquals(1, handler.getMyProjects(user3.getEmail()).size());
    assertEquals(2, handler.getAccessibleProjectsSummary(user1).size());
    assertEquals(0, handler.getAccessibleProjectsSummary(user2).size());
    assertEquals(2, handler.getAccessibleProjectsSummary(user3).size());
    boolean deleted = (handler.getProjectById("P2", user2) == null);
    assertEquals(true, deleted);
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) Test(org.junit.Test)

Example 82 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.

the class FossologyFileHandler method sendToFossologyExistingUpload.

private RequestStatus sendToFossologyExistingUpload(Release release, User user, String clearingTeam, ComponentService.Iface componentClient) throws TException {
    int fossologyUploadId;
    fossologyUploadId = toUnsignedInt(release.getFossologyId());
    failIf(fossologyUploadId <= 0, "release %s has an inconsistent FossologyId", release.getId());
    FossologyStatus currentStatus = fossologyUploader.getStatusInFossology(fossologyUploadId, clearingTeam);
    if (isVisible(currentStatus)) {
        updateFossologyStatus(release, user, clearingTeam, currentStatus, componentClient);
        return RequestStatus.SUCCESS;
    } else {
        return duplicateUploadFor(release, user, clearingTeam, fossologyUploadId, componentClient);
    }
}
Also used : FossologyStatus(org.eclipse.sw360.datahandler.thrift.components.FossologyStatus)

Example 83 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.

the class FossologyScriptsHandler method deployScripts.

public RequestStatus deployScripts() throws SW360Exception {
    RequestStatus status = RequestStatus.SUCCESS;
    for (String scriptFileName : SCRIPT_FILE_NAMES) {
        final InputStream inputStream = FossologyScriptsHandler.class.getResourceAsStream(SCRIPTS_FOLDER + scriptFileName);
        if (inputStream == null) {
            log.error("cannot get content of script " + scriptFileName);
            status = RequestStatus.FAILURE;
            continue;
        }
        try {
            if (!fossologyUploader.copyToFossology(scriptFileName, inputStream, true)) {
                status = RequestStatus.FAILURE;
            }
        } finally {
            closeQuietly(inputStream, log);
        }
    }
    return status;
}
Also used : InputStream(java.io.InputStream) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 84 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.

the class ModerationDatabaseHandler method deleteModerationRequest.

public RequestStatus deleteModerationRequest(String id, User user) {
    ModerationRequest moderationRequest = repository.get(id);
    if (moderationRequest != null) {
        if (hasPermissionToDeleteModerationRequest(user, moderationRequest)) {
            boolean succeeded = repository.remove(id);
            return succeeded ? RequestStatus.SUCCESS : RequestStatus.FAILURE;
        } else {
            log.error("Problems deleting moderation request: User " + user.getEmail() + " tried to delete " + "moderation request of user " + moderationRequest.getRequestingUser());
            return RequestStatus.FAILURE;
        }
    }
    log.error("Moderation request to delete was null.");
    return RequestStatus.FAILURE;
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 85 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.

the class ModerationDatabaseHandler method createRequest.

public RequestStatus createRequest(Project project, User user, Boolean isDeleteRequest) {
    Project dbproject;
    try {
        dbproject = projectDatabaseHandler.getProjectById(project.getId(), user);
    } catch (SW360Exception e) {
        log.error("Could not get original project from database. Could not generate moderation request.", e);
        return RequestStatus.FAILURE;
    }
    // Define moderators
    Set<String> moderators = getProjectModerators(dbproject);
    ModerationRequest request = createStubRequest(user, isDeleteRequest, project.getId(), moderators);
    // Set meta-data
    request.setDocumentType(DocumentType.PROJECT);
    request.setDocumentName(SW360Utils.printName(dbproject));
    // Fill the request
    ModerationRequestGenerator generator = new ProjectModerationRequestGenerator();
    request = generator.setAdditionsAndDeletions(request, project, dbproject);
    addOrUpdate(request, user);
    return RequestStatus.SENT_TO_MODERATOR;
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception)

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