Unmarshals the given map source into a bean.
@param source the source
@return the gateway bean
326385
public static GatewayBean unmarshallGateway(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        GatewayBean bean = new GatewayBean();
        bean.setId(asString(source.get("id")));
        bean.setName(asString(source.get("name")));
        bean.setDescription(asString(source.get("description")));
        bean.setType(asEnum(source.get("type"), GatewayType.class));
        bean.setConfiguration(asString(source.get("configuration")));
        bean.setCreatedBy(asString(source.get("createdBy")));
        bean.setCreatedOn(asDate(source.get("createdOn")));
        bean.setModifiedBy(asString(source.get("modifiedBy")));
        bean.setModifiedOn(asDate(source.get("modifiedOn")));
        postMarshall(bean);
        return bean;
    }
823028
@Override
    public BufferByteInput<T> source(final T source) {
        return (BufferByteInput<T>) super.source(source);
    }
1101610
private Unmarshaller getUnMarshaller(final MarshallerFactory marshallerFactory, final ClassResolver classResolver)
            throws IOException {
        final MarshallingConfiguration marshallingConfiguration = new MarshallingConfiguration();
        marshallingConfiguration.setVersion(2);
        marshallingConfiguration.setClassResolver(classResolver);
        return marshallerFactory.createUnmarshaller(marshallingConfiguration);
    }
889639
@SuppressWarnings("unchecked")
    public static PoliciesBean unmarshallPolicies(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        PoliciesBean bean = new PoliciesBean();
        bean.setOrganizationId(asString(source.get("organizationId")));
        bean.setEntityId(asString(source.get("entityId")));
        bean.setEntityVersion(asString(source.get("entityVersion")));
        bean.setType(asEnum(source.get("type"), PolicyType.class));
        List<Map<String, Object>> policies = (List<Map<String, Object>>) source.get("policies");
        if (policies != null) {
            for (Map<String, Object> policyMap : policies) {
                PolicyBean policy = new PolicyBean();
                policy.setOrganizationId(bean.getOrganizationId());
                policy.setEntityId(bean.getEntityId());
                policy.setEntityVersion(bean.getEntityVersion());
                policy.setType(bean.getType());
                policy.setConfiguration(asString(policyMap.get("configuration")));
                policy.setCreatedBy(asString(policyMap.get("createdBy")));
                policy.setCreatedOn(asDate(policyMap.get("createdOn")));
                PolicyDefinitionBean def = new PolicyDefinitionBean();
                def.setId(asString(policyMap.get("definitionId")));
                // Note: this is a placeholder that needs to be resolved later.
                policy.setDefinition(def);
                policy.setId(asLong(policyMap.get("id")));
                policy.setModifiedBy(asString(policyMap.get("modifiedBy")));
                policy.setModifiedOn(asDate(policyMap.get("modifiedOn")));
                policy.setName(asString(policyMap.get("name")));
                policy.setOrderIndex(asInt(policyMap.get("orderIndex")));
                bean.getPolicies().add(policy);
            }
        }
        postMarshall(bean);
        return bean;
    }
1316129
public static ClientBean unmarshallClient(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        ClientBean bean = new ClientBean();
        bean.setId(asString(source.get("id")));
        bean.setName(asString(source.get("name")));
        bean.setDescription(asString(source.get("description")));
        bean.setCreatedBy(asString(source.get("createdBy")));
        bean.setCreatedOn(asDate(source.get("createdOn")));
        postMarshall(bean);
        return bean;
    }
855627
public <S, T> FromUnmarshaller<S, T> findUnmarshaller(Class<S> source, Class<T> target) {
		return findUnmarshaller(new ConverterKey<S,T>(source, target, DefaultBinding.class));
	}
1169303
public static <E, T> List<E> convertBeans(List<T> source, Class<E> targetClass, boolean nonNullFilter) {
        return convertBeans(source, targetClass, null, false, nonNullFilter);
    }
721226
public Object sqlToJava(Object source)
    {
        if (source instanceof Integer)
        {
            if (source.equals(I_TRUE))
            {
                return Boolean.TRUE;
            }
            else
            {
                return Boolean.FALSE;
            }
        }
        else
        {
            return source;
        }
    }
1062449
@Override
    public DataByteInput<T> source(final T source) {
        return (DataByteInput<T>) super.source(source);
    }
911567
public Object javaToSql(Object source)
    {
        if (source instanceof Boolean)
        {
            if (source.equals(Boolean.TRUE))
            {
                return I_TRUE;
            }
            else
            {
                return I_FALSE;
            }
        }
        else
        {
            return source;
        }
    }
981997
public static ApiDefinitionBean unmarshallApiDefinition(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        ApiDefinitionBean bean = new ApiDefinitionBean();
        bean.setData(asString(source.get("data")));
        postMarshall(bean);
        return bean;
    }
808616
public Object sqlToJava(Object source)
    {
        try
        {
            ByteArrayInputStream stringIn =
                new ByteArrayInputStream(((String) source).getBytes());
            Base64.InputStream uuIn =
                new Base64.InputStream(stringIn, Base64.DECODE, false);
            GZIPInputStream gzipIn = new GZIPInputStream(uuIn);
            ObjectInputStream objIn = new ObjectInputStream(gzipIn);
            Object result = objIn.readObject();

            objIn.close();
            return result;
        }
        catch (Throwable t)
        {
            throw new ConversionException(t);
        }
    }
268952
@Override
    public StreamByteInput<T> source(final T source) {
        return (StreamByteInput<T>) super.source(source);
    }
1263425
public static PlanVersionSummaryBean unmarshallPlanVersionSummary(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        PlanVersionSummaryBean bean = new PlanVersionSummaryBean();
        bean.setDescription(asString(source.get("planDescription")));
        bean.setId(asString(source.get("planId")));
        bean.setName(asString(source.get("planName")));
        bean.setOrganizationId(asString(source.get("organizationId")));
        bean.setOrganizationName(asString(source.get("organizationName")));
        bean.setStatus(asEnum(source.get("status"), PlanStatus.class));
        bean.setVersion(asString(source.get("version")));
        postMarshall(bean);
        return bean;
    }
759051
public static XContentBuilder marshall(GatewayBean bean) throws StorageException {
        try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
            preMarshall(bean);
            builder
                .startObject()
                    .field("id", bean.getId())
                    .field("name", bean.getName())
                    .field("description", bean.getDescription())
                    .field("type", bean.getType())
                    .field("configuration", bean.getConfiguration())
                    .field("createdBy", bean.getCreatedBy())
                    .field("createdOn", bean.getCreatedOn().getTime())
                    .field("modifiedBy", bean.getModifiedBy())
                    .field("modifiedOn", bean.getModifiedOn().getTime())
                .endObject();
            postMarshall(bean);
            return builder;
        } catch (IOException e) {
            throw new StorageException(e);
        }
    }
1216739
public static ClientSummaryBean unmarshallClientSummary(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        ClientSummaryBean bean = new ClientSummaryBean();
        bean.setOrganizationId(asString(source.get("organizationId")));
        bean.setOrganizationName(asString(source.get("organizationName")));
        bean.setId(asString(source.get("id")));
        bean.setName(asString(source.get("name")));
        bean.setDescription(asString(source.get("description")));
        postMarshall(bean);
        return bean;
    }
716154
public static ClientVersionBean unmarshallClientVersion(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        ClientVersionBean bean = new ClientVersionBean();
        bean.setVersion(asString(source.get("version")));
        bean.setApikey(asString(source.get("apikey")));
        bean.setStatus(asEnum(source.get("status"), ClientStatus.class));
        bean.setCreatedBy(asString(source.get("createdBy")));
        bean.setCreatedOn(asDate(source.get("createdOn")));
        bean.setModifiedBy(asString(source.get("modifiedBy")));
        bean.setModifiedOn(asDate(source.get("modifiedOn")));
        bean.setPublishedOn(asDate(source.get("publishedOn")));
        bean.setRetiredOn(asDate(source.get("retiredOn")));
        postMarshall(bean);
        return bean;
    }