def _generate_public_access_policy_pyxb(self):
   access_policy_pyxb = v2.AccessPolicy()
   access_rule_pyxb = v2.AccessRule()
   access_rule_pyxb.permission = [v2.Permission.read, ]
   access_rule_pyxb.subject = ["public", ]
   access_policy_pyxb.allow = [access_rule_pyxb, ]
   return access_policy_pyxb
 def _generate_sysmeta(self, scimeta_str, pid, sid, record_datetime):
   sysmeta_pyxb = v2.systemMetadata()
   sysmeta_pyxb.seriesId = sid
   sysmeta_pyxb.formatId = self.node_dict['sci_md_formatId']
   sysmeta_pyxb.size = len(scimeta_str)
   sysmeta_pyxb.checksum = d1_common.checksum.create_checksum_object_from_string(
     scimeta_str
   )
   sysmeta_pyxb.identifier = pid
   # sysmeta_pyxb.dateUploaded = datetime.datetime.strptime(record_datetime, "%Y-%m-%dT%H:%M:%SZ")
   sysmeta_pyxb.dateUploaded = record_datetime
   sysmeta_pyxb.dateSysMetadataModified = datetime.datetime.now()
   sysmeta_pyxb.rightsHolder = self.node_dict['rightsholder']
   sysmeta_pyxb.submitter = self.node_dict['submitter']
   sysmeta_pyxb.authoritativeMemberNode = self.node_dict['authoritativeMN']
   sysmeta_pyxb.originMemberNode = self.node_dict['originMN']
   # Access policies for SlenderNode design pattern default to public read only
   accessPolicy = v2.AccessPolicy()
   accessRule = v2.AccessRule()
   accessRule.subject.append(d1_common.const.SUBJECT_PUBLIC)
   permission = v2.Permission('read')
   accessRule.permission.append(permission)
   accessPolicy.append(accessRule)
   sysmeta_pyxb.accessPolicy = accessPolicy
   return sysmeta_pyxb
Example #3
0
 def generate_public_access_policy(self):
     accessPolicy = dataoneTypes.accessPolicy()
     accessRule = dataoneTypes.AccessRule()
     accessRule.subject.append(d1_common.const.SUBJECT_PUBLIC)
     permission = dataoneTypes.Permission('read')
     accessRule.permission.append(permission)
     accessPolicy.append(accessRule)
     return accessPolicy
def _generate_public_access_policy():
    """This function generates an access policy which is needed as part of system metadata for describing a science
    metadata object. In an adapter-based implementation, the ability to modify records is managed by the native
    repository, not GMN, and any changes in the native repository simple cascade down to GMN. This means it is
     unnecessary to set specific access policies for individual records. Therefore, a generic public read-only access
      policy is generated and assigned as part of system metadata to every record as it is loaded."""
    accessPolicy = v2.AccessPolicy()
    accessRule = v2.AccessRule()
    accessRule.subject.append(d1_common.const.SUBJECT_PUBLIC)
    permission = v2.Permission('read')
    accessRule.permission.append(permission)
    accessPolicy.append(accessRule)
    return accessPolicy
Example #5
0
def build_sysmeta(pid=None, obj=None, fmt=None, sid=None):

    if pid is None:
        return 1
    if obj is None:
        return 1
    if fmt is None:
        fmt = 'application/octet-stream'

    obj_size = os.path.getsize(obj)
    obj_md5 = md5(obj)

    accessPolicy = dataoneTypes_v2_0.accessPolicy()
    accessRule = dataoneTypes_v2_0.AccessRule()
    accessRule.subject.append('gmn-local')
    accessRule.permission.append('changePermission')
    accessPolicy.append(accessRule)
    accessRule = dataoneTypes_v2_0.AccessRule()
    accessRule.subject.append('public')
    accessRule.permission.append('read')
    accessPolicy.append(accessRule)

    d1_sys_meta = dataoneTypes_v2_0.systemMetadata()
    d1_sys_meta.serialVersion = 1
    d1_sys_meta.identifier = pid
    d1_sys_meta.size = obj_size
    d1_sys_meta.formatId = fmt
    d1_sys_meta.rightsHolder = 'gmn-local'
    d1_sys_meta.checksum = obj_md5
    d1_sys_meta.checksum.algorithm = 'MD5'
    d1_sys_meta.accessPolicy = accessPolicy

    if sid is not None:
        d1_sys_meta.seriesId = sid

    return d1_sys_meta