Search in sources :

Example 26 with RequestStatus

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

the class FossologyAwarePortlet method serveSendToFossology.

protected void serveSendToFossology(ResourceRequest request, ResourceResponse response) throws PortletException {
    final RequestStatus requestStatus = sendToFossology(request);
    renderRequestStatus(request, response, requestStatus);
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 27 with RequestStatus

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

the class FossologyAdminPortlet method serveDeployScripts.

public void serveDeployScripts(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
    RequestStatus deploy = RequestStatus.FAILURE;
    try {
        deploy = thriftClients.makeFossologyClient().deployScripts();
    } catch (TException e) {
        log.error("Error connecting to backend", e);
    }
    renderRequestStatus(request, response, deploy);
}
Also used : TException(org.apache.thrift.TException) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 28 with RequestStatus

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

the class FossologyAdminPortlet method serveCheckConnection.

public void serveCheckConnection(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
    RequestStatus checkConnection = RequestStatus.FAILURE;
    try {
        checkConnection = thriftClients.makeFossologyClient().checkConnection();
    } catch (TException e) {
        log.error("Error connecting to backend", e);
    }
    renderRequestStatus(request, response, checkConnection);
}
Also used : TException(org.apache.thrift.TException) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 29 with RequestStatus

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

the class ModerationDatabaseHandler method createRequest.

public RequestStatus createRequest(Component component, User user, Boolean isDeleteRequest) {
    Component dbcomponent;
    try {
        dbcomponent = componentDatabaseHandler.getComponent(component.getId(), user);
    } catch (SW360Exception e) {
        log.error("Could not get original component from database. Could not generate moderation request.", e);
        return RequestStatus.FAILURE;
    }
    // Define moderators
    Set<String> moderators = new HashSet<>();
    CommonUtils.add(moderators, dbcomponent.getCreatedBy());
    try {
        String department = getDepartmentByUserEmail(component.getCreatedBy());
        CommonUtils.addAll(moderators, getUsersAtLeast(UserGroup.CLEARING_ADMIN, department));
    } catch (TException e) {
        log.error("Could not get user from database. Clearing admins not added as moderators, since department is missing.");
    }
    CommonUtils.addAll(moderators, getUsersAtLeast(UserGroup.ADMIN));
    ModerationRequest request = createStubRequest(user, isDeleteRequest, component.getId(), moderators);
    // Set meta-data
    request.setDocumentType(DocumentType.COMPONENT);
    request.setDocumentName(SW360Utils.printName(dbcomponent));
    // Fill the request
    ModerationRequestGenerator generator = new ComponentModerationRequestGenerator();
    request = generator.setAdditionsAndDeletions(request, component, dbcomponent);
    if (component.isSetComponentType()) {
        request.setComponentType(component.getComponentType());
    }
    addOrUpdate(request, user);
    return RequestStatus.SENT_TO_MODERATOR;
}
Also used : TException(org.apache.thrift.TException) ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest) Component(org.eclipse.sw360.datahandler.thrift.components.Component) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception)

Example 30 with RequestStatus

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

the class ModerationDatabaseHandler method createRequest.

public RequestStatus createRequest(Release release, User user, Boolean isDeleteRequest, Function<Release, Set<String>> moderatorsProvider) {
    Release dbrelease;
    try {
        dbrelease = componentDatabaseHandler.getRelease(release.getId(), user);
    } catch (SW360Exception e) {
        log.error("Could not get original release from database. Could not generate moderation request.", e);
        return RequestStatus.FAILURE;
    }
    Set<String> moderators = moderatorsProvider.apply(dbrelease);
    ModerationRequest request = createStubRequest(user, isDeleteRequest, release.getId(), moderators);
    // Set meta-data
    request.setDocumentType(DocumentType.RELEASE);
    request.setDocumentName(SW360Utils.printName(dbrelease));
    // Fill the rest
    SW360Utils.setVendorId(release);
    SW360Utils.setVendorId(dbrelease);
    ModerationRequestGenerator generator = new ReleaseModerationRequestGenerator();
    request = generator.setAdditionsAndDeletions(request, release, dbrelease);
    try {
        Component parentComponent = componentDatabaseHandler.getComponent(release.getComponentId(), user);
        request.setComponentType(parentComponent.getComponentType());
    } catch (SW360Exception e) {
        log.error("Could not retrieve parent component type of release with ID=" + release.getId());
    }
    addOrUpdate(request, user);
    return RequestStatus.SENT_TO_MODERATOR;
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release) 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