35 #include "rjson_utils.h"
45 #define prolog std::string("Granule::").append(__func__).append("() - ")
49 string granule_LINKS_REL_DATA_ACCES =
"http://esipfed.org/ns/fedsearch/1.1/data#";
50 string granule_LINKS_REL_METADATA_ACCESS =
"http://esipfed.org/ns/fedsearch/1.1/data#";
51 string granule_LINKS =
"links";
52 string granule_LINKS_REL=
"rel";
53 string granule_LINKS_HREFLANG =
"hreflang";
54 string granule_LINKS_HREF =
"href";
55 string granule_SIZE =
"granule_size";
56 string granule_LMT =
"updated";
58 string granule_ID =
"id";
60 string granule_NAME =
"title";
66 setDataAccessUrl(granule_obj);
67 setMetadataAccessUrl(granule_obj);
68 setLastModifiedStr(granule_obj);
73 this->d_name = rju.getStringValue(go, granule_NAME);
78 this->d_id = rju.getStringValue(go, granule_ID);
83 this->d_size_str = rju.getStringValue(go, granule_SIZE);
91 this->d_last_modified_time = rju.getStringValue(go, granule_LMT);
100 bool result = itr != go.MemberEnd();
101 string msg = prolog + (result?
"Located":
"FAILED to locate") +
" the value '"+granule_LINKS+
"' in object.";
102 BESDEBUG(MODULE, msg << endl);
104 throw CmrError(
"ERROR: Failed to located '"+granule_LINKS+
"' section for CMRGranule!",__FILE__,__LINE__);
108 throw CmrError(
"ERROR: The '"+granule_LINKS+
"' object is NOT an array!",__FILE__,__LINE__);
122 string rel = rju.getStringValue(link,granule_LINKS_REL);
123 if(rel == granule_LINKS_REL_DATA_ACCES){
124 this->d_data_access_url = rju.getStringValue(link,granule_LINKS_HREF);
128 throw CmrError(
"ERROR: Failed to locate granule data access link ("+granule_LINKS_REL_DATA_ACCES+
"). :(",__FILE__,__LINE__);
140 string rel = rju.getStringValue(link,granule_LINKS_REL);
141 if(rel == granule_LINKS_REL_METADATA_ACCESS){
142 this->d_metadata_access_url = rju.getStringValue(link,granule_LINKS_HREF);
146 throw CmrError(
"ERROR: Failed to locate granule metadata access link ("+granule_LINKS_REL_METADATA_ACCESS+
"). :(",__FILE__,__LINE__);
152 item->
set_type(bes::CatalogItem::leaf);
154 item->
set_lmt(getLastModifiedStr());
bool is_data(const std::string &item) const
is there a handler that can process this
(Constant) member iterator for a JSON object value
void set_name(std::string n)
Set the name of the item.
std::string get_name() const
The name of this item in the node.
void set_size(size_t s)
Set the size of the item.
void set_is_data(bool id)
Is this item data that the BES should interpret?
void set_lmt(std::string lmt)
Set the LMT for this item.
void set_type(item_type t)
Set the type for this item.
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)