use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ProjectPortlet method update.
@UsedAsLiferayAction
public void update(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String id = request.getParameter(PROJECT_ID);
User user = UserCacheHolder.getUserFromRequest(request);
RequestStatus requestStatus;
try {
ProjectService.Iface client = thriftClients.makeProjectClient();
if (id != null) {
Project project = client.getProjectByIdForEdit(id, user);
ProjectPortletUtils.updateProjectFromRequest(request, project);
String ModerationRequestCommentMsg = request.getParameter(MODERATION_REQUEST_COMMENT);
user.setCommentMadeDuringModerationRequest(ModerationRequestCommentMsg);
requestStatus = client.updateProject(project, user);
setSessionMessage(request, requestStatus, "Project", "update", printName(project));
cleanUploadHistory(user.getEmail(), id);
response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
response.setRenderParameter(PROJECT_ID, request.getParameter(PROJECT_ID));
} else {
// Add project
Project project = new Project();
ProjectPortletUtils.updateProjectFromRequest(request, project);
AddDocumentRequestSummary summary = client.addProject(project, user);
AddDocumentRequestStatus status = summary.getRequestStatus();
switch(status) {
case SUCCESS:
String successMsg = "Project " + printName(project) + " added successfully";
SessionMessages.add(request, "request_processed", successMsg);
response.setRenderParameter(PROJECT_ID, summary.getId());
response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
break;
case DUPLICATE:
setSW360SessionError(request, ErrorMessages.PROJECT_DUPLICATE);
response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
prepareRequestForEditAfterDuplicateError(request, project, user);
break;
default:
setSW360SessionError(request, ErrorMessages.PROJECT_NOT_ADDED);
response.setRenderParameter(PAGENAME, PAGENAME_VIEW);
}
}
} catch (TException e) {
log.error("Error updating project in backend!", e);
setSW360SessionError(request, ErrorMessages.DEFAULT_ERROR_MESSAGE);
}
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class BulkReleaseEdit method updateRelease.
private void updateRelease(ResourceRequest request, ResourceResponse response) {
final User user = UserCacheHolder.getUserFromRequest(request);
RequestStatus requestStatus = RequestStatus.FAILURE;
String releaseId = request.getParameter(RELEASE_ID);
if (releaseId != null) {
try {
ComponentService.Iface client = thriftClients.makeComponentClient();
Release release = client.getReleaseById(releaseId, user);
ComponentPortletUtils.updateReleaseFromRequest(request, release);
requestStatus = client.updateRelease(release, user);
} catch (TException e) {
log.error("Release update failed", e);
requestStatus = RequestStatus.FAILURE;
}
}
renderRequestStatus(request, response, requestStatus);
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ScheduleAdminPortlet method unscheduleCveSearch.
@UsedAsLiferayAction
public void unscheduleCveSearch(ActionRequest request, ActionResponse response) throws PortletException, IOException {
try {
User user = UserCacheHolder.getUserFromRequest(request);
RequestStatus requestStatus = new ThriftClients().makeScheduleClient().unscheduleService(ThriftClients.CVESEARCH_SERVICE, user);
setSessionMessage(request, requestStatus, "Task", "unschedule");
} catch (TException e) {
log.error(e);
}
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class VendorPortlet method updateVendor.
@UsedAsLiferayAction
public void updateVendor(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String id = request.getParameter(VENDOR_ID);
final User user = UserCacheHolder.getUserFromRequest(request);
if (id != null) {
try {
VendorService.Iface vendorClient = thriftClients.makeVendorClient();
Vendor vendor = vendorClient.getByID(id);
ComponentPortletUtils.updateVendorFromRequest(request, vendor);
RequestStatus requestStatus = vendorClient.updateVendor(vendor, user);
setSessionMessage(request, requestStatus, "Vendor", "update", vendor.getShortname());
} catch (TException e) {
log.error("Error fetching release from backend!", e);
}
} else {
addVendor(request);
}
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class VendorPortlet method removeVendor.
@UsedAsLiferayAction
public void removeVendor(ActionRequest request, ActionResponse response) throws IOException, PortletException {
final RequestStatus requestStatus = ComponentPortletUtils.deleteVendor(request, log);
setSessionMessage(request, requestStatus, "Vendor", "delete");
response.setRenderParameter(PAGENAME, PAGENAME_VIEW);
}
Aggregations