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

com.jelastic.api.system.persistence.SSLCustom Maven / Gradle / Ivy

The newest version!
/*Server class MD5: caddc6745ce129f085b89b81cddc0f60*/
package com.jelastic.api.system.persistence;

import com.jelastic.api.core.utils.DateUtils;
import com.jelastic.api.core.orm.dao.AbstractEntity;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.ParseException;
import java.util.Date;

/**
 * @name Jelastic API Client
 * @version 8.11.2
 * @copyright Jelastic, Inc.
 */
public class SSLCustom extends AbstractEntity {

    private static final String ID = "id";

    private static final String SSL_ENABLE = "ssl_enable";

    private static final String CERT_KEY = "certKey";

    private static final String CERT = "cert";

    private static final String INTERMEDIATE = "intermediate";

    private static final String DOMAIN = "domain";

    private static final String EXPIREDATE = "expireDate";

    private String certKey;

    private String cert;

    private String intermediate;

    private String domain;

    private boolean sslEnable;

    private Date expireDate;

    public SSLCustom() {
    }

    public SSLCustom(String certKey, String cert, String intermediate, boolean sslEnable, Date expireDate) {
        this.certKey = certKey;
        this.cert = cert;
        this.intermediate = intermediate;
        this.sslEnable = sslEnable;
        this.expireDate = expireDate;
    }

    public String getCertKey() {
        return certKey;
    }

    public void setCertKey(String certKey) {
        this.certKey = certKey;
    }

    public String getCert() {
        return cert;
    }

    public void setCert(String cert) {
        this.cert = cert;
    }

    public String getIntermediate() {
        return intermediate;
    }

    public void setIntermediate(String intermediate) {
        this.intermediate = intermediate;
    }

    public String getDomain() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain = domain;
    }

    public boolean isSslEnable() {
        return sslEnable;
    }

    public void setSslEnable(boolean sslEnable) {
        this.sslEnable = sslEnable;
    }

    public Date getExpireDate() {
        return expireDate;
    }

    public void setExpireDate(Date expireDate) {
        this.expireDate = expireDate;
    }

    @Override
    public SSLCustom clone() {
        SSLCustom sslCustom = new SSLCustom(certKey, cert, intermediate, sslEnable, expireDate);
        sslCustom.setDomain(domain);
        return sslCustom;
    }

    public JSONObject toJSON(boolean isExport) throws JSONException {
        JSONObject json = new JSONObject();
        json.put(ID, getId());
        json.put(SSL_ENABLE, isSslEnable());
        if (isExport) {
            json.put(CERT_KEY, getCertKey());
            json.put(CERT, getCert());
            json.put(INTERMEDIATE, getIntermediate());
            json.put(DOMAIN, getDomain());
            if (getExpireDate() != null) {
                json.put(EXPIREDATE, DateUtils.formatSqlDateTime(getExpireDate()));
            }
        }
        return json;
    }

    public JSONObject _toJSON() throws JSONException {
        return toJSON(false);
    }

    public SSLCustom _fromJSON(JSONObject json) throws JSONException {
        if (json.has(ID)) {
            this.setId(json.getInt(ID));
        }
        if (json.has(SSL_ENABLE)) {
            this.setSslEnable(json.getBoolean(SSL_ENABLE));
        }
        if (json.has(CERT)) {
            this.setCert(json.getString(CERT));
        }
        if (json.has(CERT_KEY)) {
            this.setCertKey(json.getString(CERT_KEY));
        }
        if (json.has(INTERMEDIATE)) {
            this.setIntermediate(json.getString(INTERMEDIATE));
        }
        if (json.has(DOMAIN)) {
            this.setDomain(json.getString(DOMAIN));
        }
        if (json.has(EXPIREDATE)) {
            Date expireDate = null;
            try {
                expireDate = DateUtils.parseSqlDateTime(json.getString(EXPIREDATE));
            } catch (ParseException e) {
            }
            this.setExpireDate(expireDate);
        }
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy