Esempio n. 1
0
def _gen_sys_meta(sys_meta, obj):
    '''Return system metadata for GMN

    :param sys_meta:
    Source system metadata from either CN or MN

    :param obj:
    Science object

    :return:
    GMN system metadata
    '''

    # Compute new values for size and hash
    size = len(obj)
    md5 = hashlib.md5(obj).hexdigest()

    # Merge desired system metadata from MN or CN into GMN
    _sys_meta = dataoneTypes.systemMetadata()
    _sys_meta.identifier = sys_meta.identifier
    _sys_meta.formatId = sys_meta.formatId
    _sys_meta.size = size
    _sys_meta.rightsHolder = sys_meta.rightsHolder
    _sys_meta.checksum = dataoneTypes.checksum(md5)
    _sys_meta.checksum.algorithm = "MD5"
    _sys_meta.dateUploaded = sys_meta.dateUploaded
    _sys_meta.dateSysMetadataModified = sys_meta.dateSysMetadataModified
    _sys_meta.accessPolicy = sys_meta.accessPolicy

    # Only for test environments
    _sys_meta.authoritativeMemberNode = "Nemo GMN localClient"

    return _sys_meta
def generate_sys_meta(pid, format_id, size, md5, now):
  sys_meta = dataoneTypes.systemMetadata()
  sys_meta.identifier = pid
  sys_meta.formatId = format_id
  sys_meta.size = size
  sys_meta.rightsHolder = SYSMETA_RIGHTSHOLDER
  sys_meta.checksum = dataoneTypes.checksum(md5)
  sys_meta.checksum.algorithm = 'MD5'
  sys_meta.dateUploaded = now
  sys_meta.dateSysMetadataModified = now
  sys_meta.accessPolicy = generate_public_access_policy()
  return sys_meta
Esempio n. 3
0
def generate_sys_meta(pid, format_id, size, md5, now):
    sys_meta = dataoneTypes.systemMetadata()
    sys_meta.identifier = pid
    sys_meta.formatId = format_id
    sys_meta.size = size
    sys_meta.rightsHolder = SYSMETA_RIGHTSHOLDER
    sys_meta.checksum = dataoneTypes.checksum(md5)
    sys_meta.checksum.algorithm = 'MD5'
    sys_meta.dateUploaded = now
    sys_meta.dateSysMetadataModified = now
    sys_meta.accessPolicy = generate_public_access_policy()
    return sys_meta
Esempio n. 4
0
def create_sys_meta(pid, format_id, idx, size, sha1, when):
  sysMeta                         = dataoneTypes.systemMetadata()
  sysMeta.serialVersion           = idx
  sysMeta.identifier              = pid + "_" + str(idx)
  sysMeta.formatId                = format_id
  sysMeta.size                    = size
  sysMeta.rightsHolder            = SYSMETA_RIGHTSHOLDER
  sysMeta.checksum                = sha1
  sysMeta.checksum.algorithm      = 'SHA-1'
  sysMeta.dateUploaded            = when
  sysMeta.dateSysMetadataModified = when
  sysMeta.accessPolicy            = generate_public_access_policy()
  sysMeta.replicationPolicy       = generate_replication_policy()

  return sysMeta
Esempio n. 5
0
def create_system_metadata(pid, size, checksum, algorithm=None, format_id=None,
                           access_policy=None, replication_policy=None,
                           submitter=None, owner=None, orig_mn=None,
                           auth_mn=None):
    sysmeta = dataoneTypes.systemMetadata()
    sysmeta.serialVersion = 1
    sysmeta.identifier = pid
    sysmeta.size = size
    sysmeta.checksum = dataoneTypes.checksum(checksum)
    sysmeta.dateUploaded = datetime.datetime.utcnow()
    sysmeta.dateSysMetadataModified = datetime.datetime.utcnow()

    print "utils CONFIGURATION:", id(configuration), configuration

    if algorithm is not None:
        sysmeta.checksum.algorithm = algorithm
    else:
        sysmeta.checksum.algorithm = configuration.checksum_alg
    if format_id is not None:
        sysmeta.formatId = format_id
    else:
        sysmeta.formatId = configuration.format
    if submitter is not None:
        sysmeta.submitter = submitter
    else:
        sysmeta.submitter = configuration.submitter
    if owner is not None:
        sysmeta.rightsHolder = owner
    else:
        sysmeta.rightsHolder = configuration.owner
    if orig_mn is not None:
        sysmeta.originmn = orig_mn
    else:
        sysmeta.originmn = configuration.orig_mn
    if auth_mn is not None:
        sysmeta.authoritativemn = auth_mn
    else:
        sysmeta.authoritativemn = configuration.auth_mn
    if access_policy is not None:
        sysmeta.accessPolicy = access_policy.to_pyxb()
    else:
        sysmeta.accessPolicy = access_control_module.access_control().to_pyxb()
    if replication_policy is not None:
        sysmeta.replicationPolicy = replication_policy.to_pyxb()
    else:
        sysmeta.replicationPolicy = \
            replication_policy_module.replication_policy().to_pyxb()
    return sysmeta