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

com.abiquo.commons.model.ConnectionData Maven / Gradle / Ivy

/**
 * The Abiquo Platform
 * Cloud management application for hybrid clouds
 * Copyright (C) 2008 - Abiquo Holdings S.L.
 *
 * This application is free software; you can redistribute it and/or
 * modify it under the terms of the GNU LESSER GENERAL PUBLIC
 * LICENSE as published by the Free Software Foundation under
 * version 3 of the License
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * LESSER GENERAL PUBLIC LICENSE v.3 for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */
package com.abiquo.commons.model;

import static com.google.common.base.Objects.equal;

import java.util.HashMap;
import java.util.Map;

import javax.xml.bind.annotation.XmlType;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.google.common.base.Objects;

/**
 * Hypervisor connection data attributes. It holds the host, manager and agent connection fields.
 */
@XmlType(name = "connectionData")
@JsonPropertyOrder(alphabetic = true)
public class ConnectionData extends HypervisorLocator
{
    /** The hypervisor username */
    protected String user;

    /** The hypervisor password */
    protected String password;

    /** The hypervisor manager username */
    protected String managerUser;

    /** The hypervisor manager password */
    protected String managerPassword;

    /** The hypervisor agent username */
    protected String agentUser;

    /** The hypervisor agent password */
    protected String agentPassword;

    /** The endpoint connection to the cloud provider */
    protected String endpoint;

    /** Addition parameters to add in the {@link WithContextProperties} connection */
    protected Map contextProperties;

    /**
     *
     */
    public ConnectionData()
    {
    }

    public ConnectionData(final HypervisorLocator other)
    {
        super(other.ip, other.hostname, other.port, other.managerIp, other.managerPort,
            other.agentIp, other.agentPort, other.type);
    }

    public ConnectionData(final ConnectionData other)
    {
        super(other.ip, other.hostname, other.port, other.managerIp, other.managerPort,
            other.agentIp, other.agentPort, other.type);
        user = other.user;
        password = other.password;
        managerUser = other.managerUser;
        managerPassword = other.managerPassword;
        agentUser = other.agentUser;
        agentPassword = other.agentPassword;
        endpoint = other.endpoint;
        contextProperties = new HashMap<>(other.getContextProperties());
    }

    public String getUser()
    {
        return user;
    }

    public void setUser(final String user)
    {
        this.user = user;
    }

    public String getPassword()
    {
        return password;
    }

    public void setPassword(final String password)
    {
        this.password = password;
    }

    public String getManagerUser()
    {
        return managerUser;
    }

    public void setManagerUser(final String managerUser)
    {
        this.managerUser = managerUser;
    }

    public String getManagerPassword()
    {
        return managerPassword;
    }

    public void setManagerPassword(final String managerPassword)
    {
        this.managerPassword = managerPassword;
    }

    public String getAgentUser()
    {
        return agentUser;
    }

    public void setAgentUser(final String agentUser)
    {
        this.agentUser = agentUser;
    }

    public String getAgentPassword()
    {
        return agentPassword;
    }

    public void setAgentPassword(final String agentPassword)
    {
        this.agentPassword = agentPassword;
    }

    public String getEndpoint()
    {
        return endpoint;
    }

    public void setEndpoint(final String endpoint)
    {
        this.endpoint = endpoint;
    }

    public Map getContextProperties()
    {
        if (contextProperties == null)
        {
            contextProperties = new HashMap<>();
        }

        return contextProperties;
    }

    public void setContextProperties(final Map contextProperties)
    {
        this.contextProperties = contextProperties;
    }

    @JsonIgnore
    public boolean hasContextProperties()
    {
        return contextProperties != null && !contextProperties.isEmpty();
    }

    @Override
    public boolean equals(final Object obj)
    {
        if (obj == null)
        {
            return false;
        }

        if (getClass() != obj.getClass())
        {
            return false;
        }

        final ConnectionData other = (ConnectionData) obj;

        return super.equals(obj) && equal(user, other.user) && equal(password, other.password)
            && equal(managerUser, other.managerUser)
            && equal(managerPassword, other.managerPassword) && equal(agentUser, other.agentUser)
            && equal(agentPassword, other.agentPassword) && equal(endpoint, other.endpoint)
            && equal(type, other.type);
    }

    @Override
    public int hashCode()
    {
        return Objects.hashCode(ip, port, managerIp, managerPort, agentIp, agentPort, user,
            password, managerUser, managerPassword, agentUser, agentPassword, endpoint, type);
    }

    @Override
    public String toString()
    {
        return super.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy