All Downloads are FREE. Search and download functionalities are using the official Maven repository.

website.automate.teamcity.server.global.ServerConfigModel Maven / Gradle / Ivy

package website.automate.teamcity.server.global;

import java.util.Collection;
import java.util.List;

import website.automate.teamcity.server.io.model.AccountSerializable;
import website.automate.teamcity.server.web.mapper.AccountResponseMapper;
import website.automate.teamcity.server.web.model.AccountResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class ServerConfigModel {

    private final ServerConfigPersistenceManager configPersistenceManager = ServerConfigPersistenceManager.getInstance();
    
    private final AccountResponseMapper accountMapper = AccountResponseMapper.getInstance();
    
    private ObjectMapper mapper = new ObjectMapper();
    
    private List getAccounts(){
        Collection accounts = configPersistenceManager.getAccounts();
        return accountMapper.safeMapCollection(accounts);
    }
    
    public String getAccountsAsJson() throws JsonProcessingException{
        Collection accounts = getAccounts();
        return mapper.writeValueAsString(accounts.toArray(new AccountResponse[accounts.size()]));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy