code: 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);
          }
      }
docs: Marshals the given bean into the given map.
  @param bean the bean
  @return the content builder
  @throws StorageException when a storage problem occurs while storing a bean