com.sap.cloud.mt.subscription.json.AbstractTenantLcmPayload Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multi-tenant-subscription Show documentation
Show all versions of multi-tenant-subscription Show documentation
Spring Boot Enablement Parent
package com.sap.cloud.mt.subscription.json;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public abstract class AbstractTenantLcmPayload {
public String subscriptionGUID;//NOSONAR
public String subscriptionAppId;//NOSONAR
public String subscriptionAppName;//NOSONAR
public String subscribedTenantId;//NOSONAR
public String subscribedZoneId;//NOSONAR
public String subscribedSubdomain;//NOSONAR
public String subscribedCrmId;//NOSONAR
public String subscribedSubaccountId;//NOSONAR
public String subscriptionAppPlan;//NOSONAR
public String subscriptionAppAmount;//NOSONAR
public String[] dependentServiceInstanceAppIds;//NOSONAR
public String[] dependantServiceInstanceAppIds;//NOSONAR
public String globalAccountGUID;//NOSONAR
public String userId;//NOSONAR
public UserInfo userInfo; //NOSONAR
@JsonIgnore
private static final Logger logger = LoggerFactory.getLogger(AbstractTenantLcmPayload.class);
@JsonIgnore
protected final Map map = new HashMap<>();
@JsonIgnore
protected static final ObjectMapper mapper = new ObjectMapper();
protected AbstractTenantLcmPayload(Map map) {
this.map.putAll(map);
fillAttributesFromMap();
}
protected AbstractTenantLcmPayload() {
}
public Map getMap() {
if (map.isEmpty() && attributesSet()) {
// for compatibility if parameters are set in attributes //
map.putAll(mapper.convertValue(this, Map.class));
}
return map;
}
@Override
public String toString() {
try {
return this.getClass().getName() + mapper.writeValueAsString(getMap());
} catch (JsonProcessingException e) {
logger.error("Could not convert map into Json", e);
return this.getClass().getName();
}
}
protected void fillAttributesFromMap() {
subscriptionGUID = (String) map.get("subscriptionGUID");
subscriptionAppId = (String) map.get("subscriptionAppId");
subscriptionAppName = (String) map.get("subscriptionAppName");
subscribedTenantId = (String) map.get("subscribedTenantId");
subscribedZoneId = (String) map.get("subscribedZoneId");
subscribedSubdomain = (String) map.get("subscribedSubdomain");
subscribedCrmId = (String) map.get("subscribedCrmId");
subscribedSubaccountId = (String) map.get("subscribedSubaccountId");
subscriptionAppPlan = (String) map.get("subscriptionAppPlan");
if (map.get("subscriptionAppAmount") != null) {
subscriptionAppAmount = map.get("subscriptionAppAmount").toString();
}
if (map.get("dependentServiceInstanceAppIds") != null) {
dependentServiceInstanceAppIds = ((List