| /** |
| ****************************************************************************** |
| * Copyright © 2017-2018 PTA GmbH. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| ****************************************************************************** |
| */ |
| package org.eclipse.openk.elogbook.controller; |
| |
| |
| import org.eclipse.openk.elogbook.common.BackendConfig; |
| import org.eclipse.openk.elogbook.common.JsonGeneratorBase; |
| import org.eclipse.openk.elogbook.communication.RestServiceWrapper; |
| import org.eclipse.openk.elogbook.exceptions.BtbException; |
| import org.eclipse.openk.elogbook.viewmodel.contactbasedata.VwDetailedContact; |
| import org.eclipse.openk.elogbook.viewmodel.contactbasedata.VwDetailedContactPage; |
| |
| import java.util.ArrayList; |
| import java.util.List; |
| |
| public class ContactBaseDataManager { |
| |
| private static final ContactBaseDataManager INSTANCE = new ContactBaseDataManager(); |
| |
| private ContactBaseDataManager() { |
| } |
| |
| public static ContactBaseDataManager getInstance() { |
| return INSTANCE; |
| } |
| |
| public List<String> getUserContacts(String token) throws BtbException { |
| List<String> returnList = new ArrayList(); |
| RestServiceWrapper restServiceWrapper = new RestServiceWrapper(BackendConfig.getInstance().getContactBaseDataApiUrl(), false); |
| String response = restServiceWrapper.performGetRequest("contacts?size=2000",token); |
| VwDetailedContactPage vwDetailedContactPage = JsonGeneratorBase.getGson().fromJson(response, |
| VwDetailedContactPage.class); |
| List<VwDetailedContact> content = vwDetailedContactPage.getContent(); |
| for (VwDetailedContact vwDetailedContact : content) { |
| String userName = vwDetailedContact.getName(); |
| if (userName != null) { |
| userName = userName.replace("," ,""); |
| } |
| returnList.add(userName); |
| } |
| return returnList; |
| } |
| |
| } |