com.jelastic.api.environment.response.SSLCustomResponse Maven / Gradle / Ivy
The newest version!
/*Server class MD5: af40e326156b3f63c94d7400920b84a4*/
package com.jelastic.api.environment.response;
import com.jelastic.api.Response;
import com.jelastic.api.core.utils.DateUtils;
import com.jelastic.api.system.persistence.SSLCustom;
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 SSLCustomResponse extends Response {
private SSLCustom sslCustom;
public SSLCustomResponse() {
super(OK);
}
public SSLCustomResponse(SSLCustom sslCustom) {
super(OK);
this.sslCustom = sslCustom;
}
public SSLCustomResponse(int result, String error) {
super(result, error);
}
public SSLCustomResponse(int result, String error, String source, SSLCustom sslCustom) {
super(result, error, source);
this.sslCustom = sslCustom;
}
public SSLCustom getSslCustom() {
return sslCustom;
}
public void setSslCustom(SSLCustom sslCustom) {
this.sslCustom = sslCustom;
}
@Override
protected JSONObject _toJSON() throws JSONException {
JSONObject json = super._toJSON();
if (sslCustom != null) {
JSONObject sslCustomJson = new JSONObject();
sslCustomJson.put("cert_key", sslCustom.getCertKey());
sslCustomJson.put("cert", sslCustom.getCert());
sslCustomJson.put("intermediate", sslCustom.getIntermediate());
sslCustomJson.put("ssl_enable", sslCustom.isSslEnable());
sslCustomJson.put("domain", sslCustom.getDomain());
if (sslCustom.getExpireDate() != null) {
sslCustomJson.put("expiredate", DateUtils.formatSqlDateTime(sslCustom.getExpireDate()));
}
json.put("sslCustom", sslCustomJson);
}
return json;
}
@Override
public SSLCustomResponse _fromJSON(JSONObject json) {
try {
super._fromJSON(json);
if (json.has("sslCustom")) {
sslCustom.setCert(json.getString("cert"));
sslCustom.setCertKey(json.getString("cert_key"));
sslCustom.setIntermediate(json.getString("intermediate"));
sslCustom.setSslEnable(json.getBoolean("ssl_enable"));
sslCustom.setDomain(json.getString("domain"));
Date expireDate = null;
try {
expireDate = DateUtils.parseSqlDateTime(json.getString("expiredate"));
} catch (ParseException e) {
e.printStackTrace();
}
sslCustom.setExpireDate(expireDate);
}
} catch (JSONException ex) {
ex.printStackTrace();
}
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy