use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ProjectDatabaseHandler method deleteProject.
// /////////////////////////////
// DELETE INDIVIDUAL OBJECTS //
// /////////////////////////////
public RequestStatus deleteProject(String id, User user) throws SW360Exception {
Project project = repository.get(id);
assertNotNull(project);
if (checkIfInUse(id)) {
return RequestStatus.IN_USE;
}
// Remove the project if the user is allowed to do it by himself
if (makePermission(project, user).isActionAllowed(RequestedAction.DELETE)) {
removeProjectAndCleanUp(project);
return RequestStatus.SUCCESS;
} else {
return moderator.deleteProject(project, user);
}
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ProjectDatabaseHandler method updateProjectFromAdditionsAndDeletions.
public RequestStatus updateProjectFromAdditionsAndDeletions(Project projectAdditions, Project projectDeletions, User user) {
try {
Project project = getProjectById(projectAdditions.getId(), user);
project = moderator.updateProjectFromModerationRequest(project, projectAdditions, projectDeletions);
return updateProject(project, user);
} catch (SW360Exception e) {
log.error("Could not get original project when updating from moderation request.");
return RequestStatus.FAILURE;
}
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ComponentPortlet method updateVulnerabilityVerification.
private void updateVulnerabilityVerification(ResourceRequest request, ResourceResponse response) throws IOException {
String[] releaseIds = request.getParameterValues(PortalConstants.RELEASE_IDS + "[]");
String[] vulnerabilityIds = request.getParameterValues(PortalConstants.VULNERABILITY_IDS + "[]");
User user = UserCacheHolder.getUserFromRequest(request);
VulnerabilityService.Iface vulClient = thriftClients.makeVulnerabilityClient();
RequestStatus requestStatus = RequestStatus.SUCCESS;
try {
if (vulnerabilityIds.length != releaseIds.length) {
throw new SW360Exception("Length of vulnerabilities (" + vulnerabilityIds.length + ") does not match the length of releases (" + releaseIds.length + ")!");
}
for (int i = 0; i < vulnerabilityIds.length; i++) {
String vulnerabilityId = vulnerabilityIds[i];
String releaseId = releaseIds[i];
Vulnerability dbVulnerability = vulClient.getVulnerabilityByExternalId(vulnerabilityId, user);
ReleaseVulnerabilityRelation dbRelation = vulClient.getRelationByIds(releaseId, dbVulnerability.getId(), user);
ReleaseVulnerabilityRelation resultRelation = ComponentPortletUtils.updateReleaseVulnerabilityRelationFromRequest(dbRelation, request);
requestStatus = vulClient.updateReleaseVulnerabilityRelation(resultRelation, user);
if (requestStatus != RequestStatus.SUCCESS) {
break;
}
}
} catch (TException e) {
log.error("Error updating vulnerability verification in backend.", e);
requestStatus = RequestStatus.FAILURE;
}
JSONObject responseData = JSONFactoryUtil.createJSONObject();
responseData.put(PortalConstants.REQUEST_STATUS, requestStatus.toString());
PrintWriter writer = response.getWriter();
writer.write(responseData.toString());
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class ComponentPortlet method updateComponent.
// ! Actions
@UsedAsLiferayAction
public void updateComponent(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String id = request.getParameter(COMPONENT_ID);
final User user = UserCacheHolder.getUserFromRequest(request);
try {
ComponentService.Iface client = thriftClients.makeComponentClient();
if (id != null) {
Component component = client.getComponentByIdForEdit(id, user);
ComponentPortletUtils.updateComponentFromRequest(request, component);
String ModerationRequestCommentMsg = request.getParameter(MODERATION_REQUEST_COMMENT);
user.setCommentMadeDuringModerationRequest(ModerationRequestCommentMsg);
RequestStatus requestStatus = client.updateComponent(component, user);
setSessionMessage(request, requestStatus, "Component", "update", component.getName());
cleanUploadHistory(user.getEmail(), id);
response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
response.setRenderParameter(COMPONENT_ID, request.getParameter(COMPONENT_ID));
} else {
Component component = new Component();
ComponentPortletUtils.updateComponentFromRequest(request, component);
AddDocumentRequestSummary summary = client.addComponent(component, user);
AddDocumentRequestStatus status = summary.getRequestStatus();
switch(status) {
case SUCCESS:
String successMsg = "Component " + component.getName() + " added successfully";
SessionMessages.add(request, "request_processed", successMsg);
response.setRenderParameter(COMPONENT_ID, summary.getId());
response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
break;
case DUPLICATE:
setSW360SessionError(request, ErrorMessages.COMPONENT_DUPLICATE);
response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
prepareRequestForEditAfterDuplicateError(request, component);
break;
default:
setSW360SessionError(request, ErrorMessages.COMPONENT_NOT_ADDED);
response.setRenderParameter(PAGENAME, PAGENAME_VIEW);
}
}
} catch (TException e) {
log.error("Error fetching component from backend!", e);
}
}
use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.
the class LicensesPortlet method updateWhiteList.
@UsedAsLiferayAction
public void updateWhiteList(ActionRequest request, ActionResponse response) throws PortletException, IOException {
// we get a list of todoDatabaseIds and Booleans and we have to update the whiteList of each todo if it changed
String licenseId = request.getParameter(LICENSE_ID);
String[] whiteList = request.getParameterValues("whiteList");
// As empty arrays are not passed as parameters
if (whiteList == null)
whiteList = new String[0];
final User user = UserCacheHolder.getUserFromRequest(request);
String moderationComment = request.getParameter(PortalConstants.MODERATION_REQUEST_COMMENT);
if (moderationComment != null) {
user.setCommentMadeDuringModerationRequest(moderationComment);
}
try {
LicenseService.Iface client = thriftClients.makeLicenseClient();
RequestStatus requestStatus = client.updateWhitelist(licenseId, ImmutableSet.copyOf(whiteList), user);
setSessionMessage(request, requestStatus, "License", "update");
} catch (TException e) {
log.error("Error updating whitelist!", e);
}
response.setRenderParameter(LICENSE_ID, licenseId);
response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
response.setRenderParameter(SELECTED_TAB, "Todos");
}
Aggregations