Search in sources :

Example 6 with RemoteCredentials

use of org.eclipse.sw360.datahandler.thrift.projectimport.RemoteCredentials in project sw360portal by sw360.

the class ProjectImportPortlet method doView.

@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
    List<Project> importables = new ArrayList<>();
    Boolean loggedIn = false;
    String loggedInServer = "";
    RemoteCredentials reCred = getRemoteCredentialsFromSession(request.getPortletSession());
    String projectName = request.getParameter(ProjectImportConstants.PROJECT_NAME);
    if (!nullToEmpty(reCred.getServerUrl()).isEmpty()) {
        importables = loadImportables(reCred, projectName);
        loggedIn = true;
        loggedInServer = reCred.getServerUrl();
    }
    String idName = getIdName();
    request.setAttribute("idName", idName);
    request.setAttribute("importables", importables);
    request.setAttribute("loggedIn", loggedIn);
    request.setAttribute("loggedInServer", loggedInServer);
    super.doView(request, response);
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) RemoteCredentials(org.eclipse.sw360.datahandler.thrift.projectimport.RemoteCredentials) ArrayList(java.util.ArrayList)

Example 7 with RemoteCredentials

use of org.eclipse.sw360.datahandler.thrift.projectimport.RemoteCredentials in project sw360portal by sw360.

the class ProjectImportPortletTest method testUpdateInputSourceWithoutUrl.

@Test
public void testUpdateInputSourceWithoutUrl() throws Exception {
    ProjectImportPortlet.LoginState loginState = new ProjectImportPortlet.LoginState();
    RemoteCredentials remoteCredentials = new RemoteCredentials();
    new ProjectImportPortlet().setNewImportSource(remoteCredentials, session, responseData, loginState);
    verify(responseData).put(ProjectImportConstants.RESPONSE__STATUS, ProjectImportConstants.RESPONSE__DB_URL_NOT_SET);
}
Also used : RemoteCredentials(org.eclipse.sw360.datahandler.thrift.projectimport.RemoteCredentials) Test(org.junit.Test)

Example 8 with RemoteCredentials

use of org.eclipse.sw360.datahandler.thrift.projectimport.RemoteCredentials in project sw360portal by sw360.

the class ProjectImportPortletTest method testUpdateInputSourceWithUrlUpdatesSession.

@Test
public void testUpdateInputSourceWithUrlUpdatesSession() throws Exception {
    ProjectImportPortlet.LoginState loginState = new ProjectImportPortlet.LoginState();
    RemoteCredentials remoteCredentials = new RemoteCredentials();
    remoteCredentials.setUsername(name);
    remoteCredentials.setPassword(password);
    remoteCredentials.setServerUrl(newURL);
    new ProjectImportPortlet().setNewImportSource(remoteCredentials, session, responseData, loginState);
    verify(session).setAttribute(ProjectImportConstants.USERNAME, name);
    verify(session).setAttribute(ProjectImportConstants.PASSWORD, password);
    verify(session).setAttribute(ProjectImportConstants.SERVER_URL, newURL);
}
Also used : RemoteCredentials(org.eclipse.sw360.datahandler.thrift.projectimport.RemoteCredentials) Test(org.junit.Test)

Aggregations

RemoteCredentials (org.eclipse.sw360.datahandler.thrift.projectimport.RemoteCredentials)6 JSONObject (com.liferay.portal.kernel.json.JSONObject)3 Test (org.junit.Test)3 JSONArray (com.liferay.portal.kernel.json.JSONArray)2 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)2 ArrayList (java.util.ArrayList)1 ImportStatus (org.eclipse.sw360.datahandler.thrift.importstatus.ImportStatus)1 User (org.eclipse.sw360.datahandler.thrift.users.User)1