Search in sources :

Example 1 with ModerationRequest

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

the class ModerationRequestSummary method summary.

@Override
protected ModerationRequest summary(SummaryType type, ModerationRequest document) {
    ModerationRequest copy = new ModerationRequest();
    copyField(document, copy, ModerationRequest._Fields.ID);
    copyField(document, copy, ModerationRequest._Fields.DOCUMENT_ID);
    copyField(document, copy, ModerationRequest._Fields.DOCUMENT_TYPE);
    copyField(document, copy, ModerationRequest._Fields.DOCUMENT_NAME);
    copyField(document, copy, ModerationRequest._Fields.MODERATION_STATE);
    copyField(document, copy, ModerationRequest._Fields.REQUESTING_USER);
    copyField(document, copy, ModerationRequest._Fields.MODERATORS);
    copyField(document, copy, ModerationRequest._Fields.TIMESTAMP);
    copyField(document, copy, ModerationRequest._Fields.TIMESTAMP_OF_DECISION);
    copyField(document, copy, ModerationRequest._Fields.REQUESTING_USER_DEPARTMENT);
    copyField(document, copy, ModerationRequest._Fields.COMPONENT_TYPE);
    return copy;
}
Also used : ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 2 with ModerationRequest

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

the class ModerationPortlet method renderProjectModeration.

public void renderProjectModeration(RenderRequest request, RenderResponse response, ModerationRequest moderationRequest, User user) throws IOException, PortletException, TException {
    final boolean requestDocumentDelete = moderationRequest.isRequestDocumentDelete();
    Boolean is_used = false;
    Project actual_project = null;
    try {
        ProjectService.Iface client = thriftClients.makeProjectClient();
        actual_project = client.getProjectById(moderationRequest.getDocumentId(), user);
        actual_project = client.fillClearingStateSummary(Collections.singletonList(actual_project), user).get(0);
        is_used = client.projectIsUsed(actual_project.getId());
        request.setAttribute(PortalConstants.ACTUAL_PROJECT, actual_project);
        request.setAttribute(PortalConstants.DEFAULT_LICENSE_INFO_HEADER_TEXT, getDefaultLicenseInfoHeaderText());
    } catch (TException e) {
        log.error("Could not retrieve project", e);
    }
    if (actual_project == null) {
        renderNextModeration(request, response, user, "Ignored unretrievable target", thriftClients.makeModerationClient(), moderationRequest);
        return;
    }
    if (refuseToDeleteUsedDocument(request, response, moderationRequest, user, requestDocumentDelete, is_used))
        return;
    prepareProject(request, user, actual_project);
    if (moderationRequest.isRequestDocumentDelete()) {
        include("/html/moderation/projects/delete.jsp", request, response);
    } else {
        // updateProjectFromModerationRequest and add updated project to request.
        include("/html/moderation/projects/merge.jsp", request, response);
    }
}
Also used : TException(org.apache.thrift.TException) Project(org.eclipse.sw360.datahandler.thrift.projects.Project) ProjectService(org.eclipse.sw360.datahandler.thrift.projects.ProjectService)

Example 3 with ModerationRequest

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

the class ModerationPortlet method renderUserModeration.

public void renderUserModeration(RenderRequest request, RenderResponse response, ModerationRequest moderationRequest, User user) throws IOException, PortletException, TException {
    User changedUser = null;
    try {
        UserService.Iface client = thriftClients.makeUserClient();
        changedUser = client.getByEmail(moderationRequest.getUser().getEmail());
        request.setAttribute(PortalConstants.USER, changedUser);
    } catch (TException e) {
        log.error("Could not retrieve user", e);
    }
    if (changedUser == null) {
        renderNextModeration(request, response, user, "Ignored unretrievable target", thriftClients.makeModerationClient(), moderationRequest);
        return;
    }
    List<Organization> organizations = UserUtils.getOrganizations(request);
    request.setAttribute(PortalConstants.ORGANIZATIONS, organizations);
    include("/html/moderation/users/merge.jsp", request, response);
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) Organization(com.liferay.portal.model.Organization) UserService(org.eclipse.sw360.datahandler.thrift.users.UserService)

Example 4 with ModerationRequest

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

the class ModerationPortlet method renderStandardView.

public void renderStandardView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
    User user = UserCacheHolder.getUserFromRequest(request);
    List<ModerationRequest> openModerationRequests = null;
    List<ModerationRequest> closedModerationRequests = null;
    try {
        ModerationService.Iface client = thriftClients.makeModerationClient();
        List<ModerationRequest> moderationRequests = client.getRequestsByModerator(user);
        Map<Boolean, List<ModerationRequest>> partitionedModerationRequests = moderationRequests.stream().collect(Collectors.groupingBy(ModerationPortletUtils::isOpenModerationRequest));
        openModerationRequests = partitionedModerationRequests.get(true);
        closedModerationRequests = partitionedModerationRequests.get(false);
    } catch (TException e) {
        log.error("Could not fetch moderation requests from backend!", e);
    }
    request.setAttribute(MODERATION_REQUESTS, CommonUtils.nullToEmptyList(openModerationRequests));
    request.setAttribute(CLOSED_MODERATION_REQUESTS, CommonUtils.nullToEmptyList(closedModerationRequests));
    request.setAttribute(IS_USER_AT_LEAST_CLEARING_ADMIN, PermissionUtils.isUserAtLeast(UserGroup.CLEARING_ADMIN, user) ? "Yes" : "No");
    super.doView(request, response);
}
Also used : ModerationService(org.eclipse.sw360.datahandler.thrift.moderation.ModerationService) TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) ModerationRequest(org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)

Example 5 with ModerationRequest

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

the class ModerationPortlet method renderReleaseModeration.

public void renderReleaseModeration(RenderRequest request, RenderResponse response, ModerationRequest moderationRequest, User user) throws IOException, PortletException, TException {
    Release actual_release = null;
    final boolean requestDocumentDelete = moderationRequest.isRequestDocumentDelete();
    Boolean is_used = false;
    try {
        ComponentService.Iface client = thriftClients.makeComponentClient();
        actual_release = client.getReleaseById(moderationRequest.getDocumentId(), user);
        is_used = client.releaseIsUsed(actual_release.getId());
    } catch (TException e) {
        log.error("Could not retrieve release", e);
    }
    if (actual_release == null) {
        renderNextModeration(request, response, user, "Ignored unretrievable target", thriftClients.makeModerationClient(), moderationRequest);
        return;
    }
    if (refuseToDeleteUsedDocument(request, response, moderationRequest, user, requestDocumentDelete, is_used))
        return;
    prepareRelease(request, user, actual_release);
    request.setAttribute(PortalConstants.ACTUAL_RELEASE, actual_release);
    if (requestDocumentDelete) {
        include("/html/moderation/releases/delete.jsp", request, response);
    } else {
        include("/html/moderation/releases/merge.jsp", request, response);
    }
}
Also used : TException(org.apache.thrift.TException) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Aggregations

ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)24 TException (org.apache.thrift.TException)11 User (org.eclipse.sw360.datahandler.thrift.users.User)8 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)5 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)4 Component (org.eclipse.sw360.datahandler.thrift.components.Component)4 ModerationService (org.eclipse.sw360.datahandler.thrift.moderation.ModerationService)4 Release (org.eclipse.sw360.datahandler.thrift.components.Release)3 License (org.eclipse.sw360.datahandler.thrift.licenses.License)3 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)2 Organization (com.liferay.portal.model.Organization)1 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)1 TProtocol (org.apache.thrift.protocol.TProtocol)1 THttpClient (org.apache.thrift.transport.THttpClient)1 CommonUtils.isTemporaryTodo (org.eclipse.sw360.datahandler.common.CommonUtils.isTemporaryTodo)1 DatabaseConnector (org.eclipse.sw360.datahandler.couchdb.DatabaseConnector)1 DocumentState (org.eclipse.sw360.datahandler.thrift.DocumentState)1 COTSDetails (org.eclipse.sw360.datahandler.thrift.components.COTSDetails)1 LicenseService (org.eclipse.sw360.datahandler.thrift.licenses.LicenseService)1 Obligation (org.eclipse.sw360.datahandler.thrift.licenses.Obligation)1