Search in sources :

Example 1 with QueryMetadata

use of com.emc.object.s3.bean.QueryMetadata in project ecs-dashboard by carone1.

the class ElasticS3ObjectDAO method toJsonFormat.

/**
 * Converts Query Object data into JSON
 *
 * @param queryObject - Query Object
 * @param namespace - Namespace
 * @param bucket - Bucket
 * @param collectionTime - Collection Time
 * @param builder - Builder
 * @return XContentBuilder
 */
private static XContentBuilder toJsonFormat(QueryObject queryObject, String namespace, String bucket, Date collectionTime, XContentBuilder builder) {
    try {
        if (builder == null) {
            builder = XContentFactory.jsonBuilder();
        }
        // add known basic fields
        builder = builder.startObject().field(KEY_TAG, queryObject.getObjectName()).field(KEY_TAG + ANALYZED_TAG, queryObject.getObjectName()).field(ETAG_TAG, queryObject.getObjectId()).field(NAMESPACE_TAG, namespace).field(BUCKET_TAG, bucket).field(COLLECTION_TIME, collectionTime);
        // Add custom MS Key values as dynamic fields
        for (QueryMetadata metadata : queryObject.getQueryMds()) {
            for (Entry<String, String> entry : metadata.getMdMap().entrySet()) {
                builder.field(entry.getKey(), entry.getValue());
            }
        }
        builder.endObject();
    } catch (IOException e) {
        throw new RuntimeException(e.getLocalizedMessage());
    }
    return builder;
}
Also used : QueryMetadata(com.emc.object.s3.bean.QueryMetadata) IOException(java.io.IOException)

Aggregations

QueryMetadata (com.emc.object.s3.bean.QueryMetadata)1 IOException (java.io.IOException)1