use of org.eclipse.sw360.datahandler.common.CommonUtils.TMP_TODO_ID_PREFIX in project sw360portal by sw360.
the class LicensesPortlet method addTodo.
@UsedAsLiferayAction
public void addTodo(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String licenseID = request.getParameter(LICENSE_ID);
String[] obligationIds = request.getParameterValues("obligations");
String todoText = request.getParameter("todoText");
String[] bools = request.getParameterValues("bools");
Todo todo = new Todo();
// add temporary id
todo.setId(TMP_TODO_ID_PREFIX + UUID.randomUUID().toString());
if (obligationIds != null) {
for (String obligationId : obligationIds) {
if (obligationId != null && !obligationId.isEmpty()) {
todo.addToObligationDatabaseIds(obligationId);
}
}
} else {
todo.setObligationDatabaseIds(Collections.emptySet());
}
todo.setText(todoText);
User user = UserCacheHolder.getUserFromRequest(request);
String moderationComment = request.getParameter(PortalConstants.MODERATION_REQUEST_COMMENT);
if (moderationComment != null) {
user.setCommentMadeDuringModerationRequest(moderationComment);
}
todo.addToWhitelist(user.getDepartment());
if (bools != null) {
List<String> theBools = Arrays.asList(bools);
todo.setDevelopment(theBools.contains("development"));
todo.setDistribution(theBools.contains("distribution"));
} else {
todo.setDevelopment(false);
todo.setDistribution(false);
}
try {
LicenseService.Iface client = thriftClients.makeLicenseClient();
RequestStatus requestStatus = client.addTodoToLicense(todo, licenseID, user);
setSessionMessage(request, requestStatus, "License", "update");
} catch (TException e) {
log.error("Error updating license details from backend", e);
}
response.setRenderParameter(LICENSE_ID, licenseID);
response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
response.setRenderParameter(SELECTED_TAB, "Todos");
}
Aggregations