use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class MyTaskSubmissionsPortlet 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);
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ComponentPortlet method generateComponentMergeWizardStep3Response.
private void generateComponentMergeWizardStep3Response(ActionRequest request, JsonGenerator jsonGenerator) throws IOException, TException {
ObjectMapper om = new ObjectMapper();
ComponentService.Iface cClient = thriftClients.makeComponentClient();
// extract request data
User sessionUser = UserCacheHolder.getUserFromRequest(request);
Component componentSelection = om.readValue(request.getParameter(COMPONENT_SELECTION), Component.class);
String componentSourceId = request.getParameter(COMPONENT_SOURCE_ID);
// perform the real merge, update merge target and delete merge source
RequestStatus status = cClient.mergeComponents(componentSelection.getId(), componentSourceId, componentSelection, sessionUser);
// generate redirect url
LiferayPortletURL componentUrl = createDetailLinkTemplate(request);
componentUrl.setParameter(PortalConstants.PAGENAME, PortalConstants.PAGENAME_DETAIL);
componentUrl.setParameter(PortalConstants.COMPONENT_ID, componentSelection.getId());
// write response JSON
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("redirectUrl", componentUrl.toString());
if (status == RequestStatus.IN_USE) {
jsonGenerator.writeStringField("error", "Cannot merge when one of the components has an active moderation request.");
} else if (status == RequestStatus.FAILURE) {
jsonGenerator.writeStringField("error", "You do not have sufficient permissions.");
}
jsonGenerator.writeEndObject();
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ComponentPortlet method updateRelease.
@UsedAsLiferayAction
public void updateRelease(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String id = request.getParameter(COMPONENT_ID);
final User user = UserCacheHolder.getUserFromRequest(request);
if (id != null) {
try {
ComponentService.Iface client = thriftClients.makeComponentClient();
Component component = client.getComponentById(id, user);
Release release;
String releaseId = request.getParameter(RELEASE_ID);
if (releaseId != null) {
release = client.getReleaseByIdForEdit(releaseId, user);
ComponentPortletUtils.updateReleaseFromRequest(request, release);
String ModerationRequestCommentMsg = request.getParameter(MODERATION_REQUEST_COMMENT);
user.setCommentMadeDuringModerationRequest(ModerationRequestCommentMsg);
RequestStatus requestStatus = client.updateRelease(release, user);
setSessionMessage(request, requestStatus, "Release", "update", printName(release));
cleanUploadHistory(user.getEmail(), releaseId);
response.setRenderParameter(PAGENAME, PAGENAME_RELEASE_DETAIL);
response.setRenderParameter(COMPONENT_ID, request.getParameter(COMPONENT_ID));
response.setRenderParameter(RELEASE_ID, request.getParameter(RELEASE_ID));
} else {
release = new Release();
release.setComponentId(component.getId());
release.setClearingState(ClearingState.NEW_CLEARING);
ComponentPortletUtils.updateReleaseFromRequest(request, release);
AddDocumentRequestSummary summary = client.addRelease(release, user);
AddDocumentRequestStatus status = summary.getRequestStatus();
switch(status) {
case SUCCESS:
response.setRenderParameter(RELEASE_ID, summary.getId());
String successMsg = "Release " + printName(release) + " added successfully";
SessionMessages.add(request, "request_processed", successMsg);
response.setRenderParameter(PAGENAME, PAGENAME_EDIT_RELEASE);
break;
case DUPLICATE:
setSW360SessionError(request, ErrorMessages.RELEASE_DUPLICATE);
response.setRenderParameter(PAGENAME, PAGENAME_EDIT_RELEASE);
prepareRequestForReleaseEditAfterDuplicateError(request, release);
break;
default:
setSW360SessionError(request, ErrorMessages.RELEASE_NOT_ADDED);
response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
}
response.setRenderParameter(COMPONENT_ID, request.getParameter(COMPONENT_ID));
}
} catch (TException e) {
log.error("Error fetching release from backend!", e);
}
}
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class LicensesPortlet method delete.
@UsedAsLiferayAction
public void delete(ActionRequest request, ActionResponse response) throws PortletException, IOException {
RequestStatus requestStatus = deleteLicense(request);
setSessionMessage(request, requestStatus, "License", "remove");
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class LicensesPortlet method update.
@UsedAsLiferayAction
public void update(ActionRequest request, ActionResponse response) throws PortletException, IOException {
LicenseService.Iface client = thriftClients.makeLicenseClient();
String licenseId = request.getParameter(LICENSE_ID);
User user = UserCacheHolder.getUserFromRequest(request);
License license = prepareLicenseForUpdate(request, client, licenseId, user);
boolean isNewLicense = isNullOrEmpty(licenseId);
boolean isAttemptToOverwriteExistingByNew = isAttemptToOverwriteExistingByNew(license, user, isNewLicense, client);
RequestStatus requestStatus = updateLicense(license, user, isAttemptToOverwriteExistingByNew, client);
if (isAttemptToOverwriteExistingByNew) {
response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
setSW360SessionError(request, ErrorMessages.LICENSE_SHORTNAME_TAKEN);
request.setAttribute(KEY_LICENSE_DETAIL, license);
} else if (isNewLicense) {
response.setRenderParameter(PAGENAME, PAGENAME_VIEW);
setSessionMessage(request, requestStatus, "License", "adde");
} else {
response.setRenderParameter(LICENSE_ID, licenseId);
response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
response.setRenderParameter(SELECTED_TAB, "Details");
setSessionMessage(request, requestStatus, "License", "update");
}
}
Aggregations