use of org.eclipse.sw360.datahandler.thrift.AddDocumentRequestStatus 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.AddDocumentRequestStatus 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.AddDocumentRequestStatus 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);
}
}
Aggregations