class DataStorageMapper implements EntityMapper<DataStorageDoc> {

    @Override
    public XContentBuilder map(final EntityContainer<DataStorageDoc> doc) {
        try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
            AbstractDataStorage storage = doc.getEntity().getStorage();
            jsonBuilder
                    .startObject()
                    .field(DOC_TYPE_FIELD, documentType.name())
                    .field("id", storage.getId())
                    .field("parentId", storage.getParentFolderId())
                    .field("name", storage.getName())
                    .field("path", storage.getPath())
                    .field("createdDate", parseDataToString(storage.getCreatedDate()))
                    .field("description", storage.getDescription())
                    .field("storageType", storage.getType())
                    .field("regionCode", doc.getEntity().getRegionName());

            StoragePolicy storagePolicy = storage.getStoragePolicy();
            if (storagePolicy != null) {
                jsonBuilder
                        .field("storagePolicyBackupDuration", storagePolicy.getBackupDuration())
                        .field("storagePolicyLongTermStorageDuration",
                                storagePolicy.getLongTermStorageDuration())
                        .field("storagePolicyShortTermStorageDuration",
                                storagePolicy.getShortTermStorageDuration())
                        .field("storagePolicyVersioningEnabled", storagePolicy.getVersioningEnabled());
            }

            buildUserContent(doc.getOwner(), jsonBuilder);
            buildMetadata(doc.getMetadata(), jsonBuilder);
            buildPermissions(doc.getPermissions(), jsonBuilder);

            jsonBuilder.endObject();
            return jsonBuilder;
        } catch (IOException e) {
            throw new IllegalArgumentException("An error occurred while creating document: ", e);
        }
    }

}