use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class Sw360ProjectService method deleteProject.
public RequestStatus deleteProject(Project project, User sw360User) throws TException {
ProjectService.Iface sw360ProjectClient = getThriftProjectClient();
RequestStatus requestStatus = sw360ProjectClient.deleteProject(project.getId(), sw360User);
if (requestStatus != RequestStatus.SUCCESS) {
throw new RuntimeException("sw360 project with name '" + project.getName() + " cannot be deleted.");
}
return requestStatus;
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class Sw360VendorService method deleteVendor.
public void deleteVendor(Vendor vendor, User sw360User) {
try {
VendorService.Iface sw360VendorClient = getThriftVendorClient();
RequestStatus requestStatus = sw360VendorClient.deleteVendor(vendor.getId(), sw360User);
if (requestStatus == RequestStatus.SUCCESS) {
return;
}
throw new RuntimeException("sw360 vendor with name '" + vendor.getFullname() + " cannot be deleted.");
} catch (TException e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class Sw360VendorService method updateVendor.
public void updateVendor(Vendor vendor, User sw360User) {
try {
VendorService.Iface sw360VendorClient = getThriftVendorClient();
RequestStatus requestStatus = sw360VendorClient.updateVendor(vendor, sw360User);
if (requestStatus == RequestStatus.SUCCESS) {
return;
}
throw new RuntimeException("sw360 vendor with full name '" + vendor.getFullname() + " cannot be updated.");
} catch (TException e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ProjectPortlet method removeProject.
private RequestStatus removeProject(PortletRequest request) {
String projectId = request.getParameter(PortalConstants.PROJECT_ID);
String encodedDeleteComment = request.getParameter(PortalConstants.MODERATION_REQUEST_COMMENT);
final User user = UserCacheHolder.getUserFromRequest(request);
if (encodedDeleteComment != null) {
String deleteComment = new String(Base64.getDecoder().decode(encodedDeleteComment));
user.setCommentMadeDuringModerationRequest(deleteComment);
}
try {
deleteUnneededAttachments(user.getEmail(), projectId);
ProjectService.Iface client = thriftClients.makeProjectClient();
return client.deleteProject(projectId, user);
} catch (TException e) {
log.error("Error deleting project from backend", e);
}
return RequestStatus.FAILURE;
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ProjectPortlet method updateVulnerabilityRating.
private void updateVulnerabilityRating(ResourceRequest request, ResourceResponse response) throws IOException {
String projectId = request.getParameter(PortalConstants.PROJECT_ID);
User user = UserCacheHolder.getUserFromRequest(request);
VulnerabilityService.Iface vulClient = thriftClients.makeVulnerabilityClient();
RequestStatus requestStatus = RequestStatus.FAILURE;
try {
Optional<ProjectVulnerabilityRating> projectVulnerabilityRatings = wrapThriftOptionalReplacement(vulClient.getProjectVulnerabilityRatingByProjectId(projectId, user));
ProjectVulnerabilityRating link = ProjectPortletUtils.updateProjectVulnerabilityRatingFromRequest(projectVulnerabilityRatings, request);
requestStatus = vulClient.updateProjectVulnerabilityRating(link, user);
} catch (TException e) {
log.error("Error updating vulnerability ratings for project in backend.", e);
}
JSONObject responseData = JSONFactoryUtil.createJSONObject();
responseData.put(PortalConstants.REQUEST_STATUS, requestStatus.toString());
PrintWriter writer = response.getWriter();
writer.write(responseData.toString());
}
Aggregations