Search in sources :

Example 61 with RequestStatus

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

the class LicensesPortlet method editExternalLink.

@UsedAsLiferayAction
public void editExternalLink(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    String licenseId = request.getParameter(LICENSE_ID);
    String remoteLink = request.getParameter(License._Fields.EXTERNAL_LICENSE_LINK.name());
    if (!Strings.isNullOrEmpty(licenseId)) {
        try {
            User user = UserCacheHolder.getUserFromRequest(request);
            LicenseService.Iface client = thriftClients.makeLicenseClient();
            final License license = client.getByID(licenseId, user.getDepartment());
            license.setExternalLicenseLink(CommonUtils.nullToEmptyString(remoteLink));
            final RequestStatus requestStatus = client.updateLicense(license, user, user);
            renderRequestStatus(request, response, requestStatus);
        } catch (TException e) {
            log.error("Error updating license", e);
        }
    }
    response.setRenderParameter(LICENSE_ID, licenseId);
    response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
    response.setRenderParameter(SELECTED_TAB, "Details");
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 62 with RequestStatus

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

the class LicensesPortlet method addTodo.

@UsedAsLiferayAction
public void addTodo(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    String licenseID = request.getParameter(LICENSE_ID);
    String[] obligationIds = request.getParameterValues("obligations");
    String todoText = request.getParameter("todoText");
    String[] bools = request.getParameterValues("bools");
    Todo todo = new Todo();
    // add temporary id
    todo.setId(TMP_TODO_ID_PREFIX + UUID.randomUUID().toString());
    if (obligationIds != null) {
        for (String obligationId : obligationIds) {
            if (obligationId != null && !obligationId.isEmpty()) {
                todo.addToObligationDatabaseIds(obligationId);
            }
        }
    } else {
        todo.setObligationDatabaseIds(Collections.emptySet());
    }
    todo.setText(todoText);
    User user = UserCacheHolder.getUserFromRequest(request);
    String moderationComment = request.getParameter(PortalConstants.MODERATION_REQUEST_COMMENT);
    if (moderationComment != null) {
        user.setCommentMadeDuringModerationRequest(moderationComment);
    }
    todo.addToWhitelist(user.getDepartment());
    if (bools != null) {
        List<String> theBools = Arrays.asList(bools);
        todo.setDevelopment(theBools.contains("development"));
        todo.setDistribution(theBools.contains("distribution"));
    } else {
        todo.setDevelopment(false);
        todo.setDistribution(false);
    }
    try {
        LicenseService.Iface client = thriftClients.makeLicenseClient();
        RequestStatus requestStatus = client.addTodoToLicense(todo, licenseID, user);
        setSessionMessage(request, requestStatus, "License", "update");
    } catch (TException e) {
        log.error("Error updating license details from backend", e);
    }
    response.setRenderParameter(LICENSE_ID, licenseID);
    response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
    response.setRenderParameter(SELECTED_TAB, "Todos");
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 63 with RequestStatus

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

the class LicensesPortlet method changeText.

@UsedAsLiferayAction
public void changeText(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    String licenseId = request.getParameter(LICENSE_ID);
    String text = request.getParameter(License._Fields.TEXT.name());
    if (!isNullOrEmpty(licenseId)) {
        try {
            User user = UserCacheHolder.getUserFromRequest(request);
            LicenseService.Iface client = thriftClients.makeLicenseClient();
            final License license = client.getByID(licenseId, user.getDepartment());
            license.setText(CommonUtils.nullToEmptyString(text));
            final RequestStatus requestStatus = client.updateLicense(license, user, user);
            renderRequestStatus(request, response, requestStatus);
        } catch (TException e) {
            log.error("Error updating license", e);
        }
    }
    response.setRenderParameter(LICENSE_ID, licenseId);
    response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
    response.setRenderParameter(SELECTED_TAB, "LicenseText");
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 64 with RequestStatus

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

the class LicensesPortlet method deleteLicense.

private RequestStatus deleteLicense(PortletRequest request) {
    String licenseId = request.getParameter(PortalConstants.LICENSE_ID);
    final User user = UserCacheHolder.getUserFromRequest(request);
    try {
        LicenseService.Iface client = thriftClients.makeLicenseClient();
        return client.deleteLicense(licenseId, user);
    } catch (TException e) {
        log.error("Error deleting license from backend", e);
    }
    return RequestStatus.FAILURE;
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 65 with RequestStatus

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

the class ModerationPortlet method serveDeleteModerationRequest.

private void serveDeleteModerationRequest(ResourceRequest request, ResourceResponse response) throws IOException {
    RequestStatus requestStatus = ModerationPortletUtils.deleteModerationRequest(request, log);
    serveRequestStatus(request, response, requestStatus, "Problem removing moderation request", log);
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) RemoveModeratorRequestStatus(org.eclipse.sw360.datahandler.thrift.RemoveModeratorRequestStatus)

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