use of org.eclipse.sw360.datahandler.thrift.users.RequestedAction in project sw360portal by sw360.
the class ProjectImportPortlet method handleRequestedAjaxAction.
public JSONObject handleRequestedAjaxAction(String requestedAction, ResourceRequest request, ResourceResponse response, LoginState loginState) throws IOException, PortletException {
PortletSession session = request.getPortletSession();
RemoteCredentials remoteCredentials = getRemoteCredentialsFromSession(session);
JSONObject responseData = JSONFactoryUtil.createJSONObject();
switch(requestedAction) {
case ProjectImportConstants.USER_ACTION__IMPORT_DATA:
User user = UserCacheHolder.getUserFromRequest(request);
List<String> selectedIds = getProjectIdsForImport(request);
importBdpProjects(user, selectedIds, responseData, remoteCredentials);
break;
case ProjectImportConstants.USER_ACTION__NEW_IMPORT_SOURCE:
RemoteCredentials newCredentials = new RemoteCredentials().setUsername(request.getParameter(ProjectImportConstants.USERNAME)).setPassword(request.getParameter(ProjectImportConstants.PASSWORD)).setServerUrl(request.getParameter(ProjectImportConstants.SERVER_URL));
if (!validateCredentials(newCredentials)) {
responseData.put(ProjectImportConstants.RESPONSE__STATUS, ProjectImportConstants.RESPONSE__UNAUTHORIZED);
} else {
setNewImportSource(newCredentials, session, responseData, loginState);
}
break;
case ProjectImportConstants.USER_ACTION__UPDATE_IMPORTABLES:
String projectName = request.getParameter(ProjectImportConstants.PROJECT_NAME);
updateImportables(responseData, loginState, remoteCredentials, projectName);
break;
case ProjectImportConstants.USER_ACTION__DISCONNECT:
putRemoteCredentialsIntoSession(session, new RemoteCredentials());
loginState.logout();
break;
default:
loginState.logout();
break;
}
return responseData;
}
Aggregations