clone_package: Clone packages between DataONE Member Nodes

View source: R/clone_package.R

clone_packageR Documentation

Clone packages between DataONE Member Nodes

Description

This function copies a data package from one DataONE Member Node to another. Note: the dateUploaded, obsoletes, and obsoletedBy fields in the sysmeta will be reset on the cloned object. This will not update the information in the metadata object. This can also be used to restore an older version of a package to a Member Node, provided that the user subsequently obsoletes the version of the package that they used to create the clone.

Usage

clone_package(
  resource_map_pid,
  from,
  to,
  add_access_to,
  change_auth_node,
  public = FALSE,
  clone_children = FALSE,
  new_pid = TRUE
)

Arguments

resource_map_pid

(character) PID for the package resource map.

from

(D1Client) D1Client to clone package from. (Package must be public)

to

(D1Client) D1Client to clone package to. (Token must be set for this node)

add_access_to

(character) Will give read, write, and changePermission access to all strings in vector. If no additional access is desired, set to NULL. Note: setting this to NULL could lead to situations where it is not possible to read, write, or changePermissions on the cloned object.

change_auth_node

(logical) Will change the authoritativeMemberNode in the system metadata to the cloned member node if TRUE. Setting this to TRUE will allow you to edit the package after cloning. Setting this to FALSE syncs the system metadata with the package on the Authoritative Member Node, and will only allow DataONE admins with special privileges to edit package system metadata.

public

(logical) Optional. Will set public read access. Defaults to FALSE.

clone_children

(logical) Optional. Will clone all children recursively if TRUE. Defaults to FALSE.

new_pid

(logical) Optional. Will give the clone a new PID. Defaults to TRUE.

Author(s)

Dominic Mullen, dmullen17@gmail.com

See Also

copy_package()

Examples

## Not run: 
# First set up the member nodes we're cloning between
# (in this example they are the same but could be different)
to <- dataone::D1Client("STAGING", "urn:node:mnTestARCTIC")
from <- dataone::D1Client("STAGING", "urn:node:mnTestARCTIC")

# Choose a package to clone (here a new one is created)
package <- arcticdatautils::create_dummy_package(to@mn)

# Clone object
cloned_package <- clone_package(resource_map_pid = package$resource_map
                          from = from,
                           to = to,
                           add_access_to = arcticdatautils:::get_token_subject(),
                           change_auth_node = TRUE,
                           public = TRUE,
                           new_pid = TRUE)

## End(Not run)

NCEAS/datamgmt documentation built on June 5, 2023, 6:14 a.m.