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;
}
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);
}
}
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);
}
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);
}
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);
}
}
Aggregations