def _process_metadata(self, headers): """ Get CDMI metadata from the header and add to the body """ metadata = {} for header, value in headers.iteritems(): key = header.lower() if key.startswith(self.metadata_prefix): key, value = get_pair_from_header(value) if key != "" and value != "": metadata[key] = value return metadata
def _process_metadata(self, headers): """ Get CDMI metadata from the header and add to the body """ metadata = {} for header, value in headers.iteritems(): key = header.lower() if key.startswith(self.metadata_prefix): key, value = get_pair_from_header(value) if key != '' and value != '': metadata[key] = value return metadata
def _read_container(self, env, start_response, headers, children): # Build the response message body according to CDMI specification res = Response() res.headers["content-type"] = "application/json; charset=UTF-8" body = {} # Setup required attributes for response body body["objectType"] = Consts.CDMI_APP_CONTAINER if self.object_name: body["objectName"] = self.object_name + "/" if self.parent_name != "": body["parentURI"] = "/".join( ["", self.cdmi_root, self.account_name, self.container_name, self.parent_name, ""] ) else: body["parentURI"] = "/".join(["", self.cdmi_root, self.account_name, self.container_name, ""]) else: body["objectName"] = self.container_name + "/" body["parentURI"] = "/".join(["", self.cdmi_root, self.account_name, ""]) body["capabilitiesURI"] = "/".join( ["", self.cdmi_root, self.account_name, self.cdmi_capability_id, "container/"] ) body["completionStatus"] = "Complete" body["metadata"] = {} # Get CDMI metadata from the header and add to the body for header, value in headers.iteritems(): key = header.lower() if key.startswith(self.metadata_prefix): key, value = get_pair_from_header(value) if key != "" and value != "": body["metadata"][key] = value body["children"] = [] if children: string_to_cut = concat_parts(self.parent_name, self.object_name) size = len(string_to_cut) if size > 0: size += 1 tracking_device = {} for child in children: if child.get("name", False): child_name = child.get("name") else: child_name = child.get("subdir", False) if child_name: child_name = child_name[size:] if not child_name.endswith("/"): content_type = child.get("content_type", "") if content_type.find("directory") >= 0: child_name += "/" if tracking_device.get(child_name) is None: tracking_device[child_name] = child_name body["children"].append(child_name) if body["children"] == []: body["childrenRange"] = "" else: body["childrenRange"] = "0-" + str(len(body["children"]) - 1) res.body = json.dumps(body, indent=2) res.status_int = 200 return res
def _read_container(self, env, start_response, headers, children): # Build the response message body according to CDMI specification res = Response() res.headers['content-type'] = 'application/json; charset=UTF-8' body = {} # Setup required attributes for response body body['objectType'] = Consts.CDMI_APP_CONTAINER if self.object_name: body['objectName'] = self.object_name + '/' if self.parent_name != '': body['parentURI'] = '/'.join(['', self.cdmi_root, self.account_name, self.container_name, self.parent_name, '']) else: body['parentURI'] = '/'.join(['', self.cdmi_root, self.account_name, self.container_name, '']) else: body['objectName'] = self.container_name + '/' body['parentURI'] = '/'.join(['', self.cdmi_root, self.account_name, '']) body['capabilitiesURI'] = '/'.join(['', self.cdmi_root, self.account_name, self.cdmi_capability_id, 'container/']) body['completionStatus'] = 'Complete' body['metadata'] = {} #Get CDMI metadata from the header and add to the body for header, value in headers.iteritems(): key = header.lower() if key.startswith(self.metadata_prefix): key, value = get_pair_from_header(value) if key != '' and value != '': body['metadata'][key] = value body['children'] = [] if children: string_to_cut = concat_parts(self.parent_name, self.object_name) size = len(string_to_cut) if size > 0: size += 1 tracking_device = {} for child in children: if child.get('name', False): child_name = child.get('name') else: child_name = child.get('subdir', False) if child_name: child_name = child_name[size:] if not child_name.endswith('/'): content_type = child.get('content_type', '') if content_type.find('directory') >= 0: child_name += '/' if tracking_device.get(child_name) is None: tracking_device[child_name] = child_name body['children'].append(child_name) if body['children'] == []: body['childrenRange'] = '' else: body['childrenRange'] = '0-' + str(len(body['children']) - 1) res.body = json.dumps(body, indent=2) res.status_int = 200 return res
def _read_container(self, env, start_response, headers, children): # Build the response message body according to CDMI specification res = Response() res.headers['content-type'] = 'application/json; charset=UTF-8' body = {} # Setup required attributes for response body body['objectType'] = Consts.CDMI_APP_CONTAINER if self.object_name: body['objectName'] = self.object_name + '/' if self.parent_name != '': body['parentURI'] = '/'.join(['', self.cdmi_root, self.account_name, self.container_name, self.parent_name, '']) else: body['parentURI'] = '/'.join(['', self.cdmi_root, self.account_name, self.container_name, '']) else: body['objectName'] = self.container_name + '/' body['parentURI'] = '/'.join(['', self.cdmi_root, self.account_name, '']) body['capabilitiesURI'] = '/'.join(['', self.cdmi_root, self.account_name, self.cdmi_capability_id, 'container/']) body['completionStatus'] = 'Complete' body['metadata'] = {} #Get CDMI metadata from the header and add to the body for header, value in headers.iteritems(): key = header.lower() if key.startswith(self.metadata_prefix): key, value = get_pair_from_header(value) if key != '' and value != '': body['metadata'][key] = value body['children'] = [] if children: string_to_cut = concat_parts(self.parent_name, self.object_name) size = len(string_to_cut) if size > 0: size += 1 tracking_device = {} for child in children: if child.get('name', False): child_name = child.get('name') else: child_name = child.get('subdir', False) if child_name: child_name = child_name[size:] if not child_name.endswith('/'): content_type = child.get('content_type', '') if content_type.find('directory') >= 0: child_name += '/' if tracking_device.get(child_name) is None: tracking_device[child_name] = child_name body['children'].append(child_name) body['childrenRange'] = '0-' + str(len(body['children'])) res.body = json.dumps(body, indent=2) res.status_int = 200 return res