From 574c6c208a7a6b389397ca8d192a6434969472a7 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Mon, 11 Sep 2017 16:26:35 -0800 Subject: [PATCH] Remove usages of log_message in interactive functions --- R/access.R | 42 +++++++++---------- R/editing.R | 38 ++++++++--------- R/helpers.R | 8 ++-- R/inserting.R | 2 +- R/packaging.R | 114 +++++++++++++++++++++++++------------------------- R/sysmeta.R | 4 +- 6 files changed, 104 insertions(+), 104 deletions(-) diff --git a/R/access.R b/R/access.R index b427ae1..c1829a7 100644 --- a/R/access.R +++ b/R/access.R @@ -33,11 +33,11 @@ set_rights_holder <- function(mn, pids, subject) { # Change rightsHolder (if needed) if (sysmeta@rightsHolder == subject) { - log_message(paste0("rightsHolder field is already set to ", subject, ". System Metadata not updated.")) + message(paste0("rightsHolder field is already set to ", subject, ". System Metadata not updated.")) result[i] <- TRUE } else { # Update System Metadata - log_message(paste0("Updating rightsHolder for PID ", pid, " from ", sysmeta@rightsHolder, " to ", subject, ".")) + message(paste0("Updating rightsHolder for PID ", pid, " from ", sysmeta@rightsHolder, " to ", subject, ".")) sysmeta@rightsHolder <- subject @@ -47,7 +47,7 @@ set_rights_holder <- function(mn, pids, subject) { sysmeta = sysmeta) }, error = function(e) { - log_message(e) + message(e) e }) @@ -103,10 +103,10 @@ set_access <- function(mn, pids, subjects, permissions=c("read", "write", "chang if (changed) { result[pid] <- TRUE - log_message(paste0("Updating System Metadata for ", pid, ".")) + message(paste0("Updating System Metadata for ", pid, ".")) dataone::updateSystemMetadata(mn, pid, sysmeta) } else { - log_message(paste0("No changes needed for ", pid, ". Not updating.")) + message(paste0("No changes needed for ", pid, ". Not updating.")) result[pid] <- FALSE } } @@ -154,8 +154,8 @@ remove_public_read <- function(mn, pids) { dataone::getSystemMetadata(mn, pid) }, error = function(e) { - log_message(paste0("Failed to get system metadata for PID '", pid, "' on MN '", mn@endpoint, "'.\n")) - log_message(e) + message(paste0("Failed to get system metadata for PID '", pid, "' on MN '", mn@endpoint, "'.\n")) + message(e) e }) @@ -167,13 +167,13 @@ remove_public_read <- function(mn, pids) { changed <- FALSE if (!datapack::hasAccessRule(sysmeta, "public", "read")) { - log_message(paste0("Skipping setting public read because ", pid, " is not public.")) + message(paste0("Skipping setting public read because ", pid, " is not public.")) next } changed <- TRUE - log_message(paste0("Removing public read access on ", pid, ".")) + message(paste0("Removing public read access on ", pid, ".")) sysmeta@accessPolicy <- sysmeta@accessPolicy[!(grepl("public", sysmeta@accessPolicy$subject) & grepl("read", sysmeta@accessPolicy$permission)),] # Update the sysmeta @@ -181,8 +181,8 @@ remove_public_read <- function(mn, pids) { dataone::updateSystemMetadata(mn, pid, sysmeta) }, error = function(e) { - log_message(paste0("Failed to update System Metadata for PID '", pid, "'.\n")) - log_message(e) + message(paste0("Failed to update System Metadata for PID '", pid, "'.\n")) + message(e) e }) @@ -230,8 +230,8 @@ set_rights_and_access <- function(mn, pids, subject, permissions=c("read", "writ dataone::getSystemMetadata(mn, pid) }, error = function(e) { - log_message(paste0("Failed to get system metadata for PID '", pid, "' on MN '", mn@endpoint, "'.\n")) - log_message(e) + message(paste0("Failed to get system metadata for PID '", pid, "' on MN '", mn@endpoint, "'.\n")) + message(e) e }) @@ -246,33 +246,33 @@ set_rights_and_access <- function(mn, pids, subject, permissions=c("read", "writ if (subject != sysmeta@rightsHolder) { changed <- TRUE - log_message(paste0("Setting rights holder to ", subject, ".")) + message(paste0("Setting rights holder to ", subject, ".")) sysmeta@rightsHolder <- subject } else { - log_message(paste0("Skipping setting rightsHolder as rightsHolder is already ", sysmeta@rightsHolder, ".\n")) + message(paste0("Skipping setting rightsHolder as rightsHolder is already ", sysmeta@rightsHolder, ".\n")) } for (permission in permissions) { if (datapack::hasAccessRule(sysmeta, subject, permission)) { - log_message(paste0("Skipping the addition of permission '", permission, "' for subject '", subject, "'\n")) + message(paste0("Skipping the addition of permission '", permission, "' for subject '", subject, "'\n")) next } changed <- TRUE - log_message(paste0("Adding permission '", permission, "' for subject '", subject, "'\n")) + message(paste0("Adding permission '", permission, "' for subject '", subject, "'\n")) sysmeta <- datapack::addAccessRule(sysmeta, subject, permission) } if (changed == TRUE) { - log_message(paste0("Updating System Metadata for ", pid, ".")) + message(paste0("Updating System Metadata for ", pid, ".")) update_response <- tryCatch({ dataone::updateSystemMetadata(mn, pid, sysmeta) }, error = function(e) { - log_message(paste0("Failed to update System Metadata for PID '", pid, "'.\n")) - log_message(e) + message(paste0("Failed to update System Metadata for PID '", pid, "'.\n")) + message(e) e }) @@ -280,7 +280,7 @@ set_rights_and_access <- function(mn, pids, subject, permissions=c("read", "writ stop("Failed update.") } } else { - log_message(paste0("No changes needed for ", pid, ".")) + message(paste0("No changes needed for ", pid, ".")) } # Save the result for this PID diff --git a/R/editing.R b/R/editing.R index 89efded..d9fdbb4 100644 --- a/R/editing.R +++ b/R/editing.R @@ -56,7 +56,7 @@ publish_object <- function(mn, # Get the clone_pid sysmeta to use for the rightsHolder and accessPolicy, and replicationPolicy if (!is.null(clone_pid)) { - log_message(paste0("Cloning System Metadata for new object from ", clone_pid, ".")) + message(paste0("Cloning System Metadata for new object from ", clone_pid, ".")) clone_sysmeta <- dataone::getSystemMetadata(mn, clone_pid) } @@ -80,7 +80,7 @@ publish_object <- function(mn, sysmeta <- clear_replication_policy(sysmeta) if (!is.null(sid)) { - log_message(paste0("Setting SID to '", sid, "'.")) + message(paste0("Setting SID to '", sid, "'.")) sysmeta@seriesId <- sid } @@ -143,7 +143,7 @@ update_object <- function(mn, pid, path, format_id=NULL, new_pid=NULL, sid=NULL) paste0("The format_id of '", format_id, "' is not a valid format ID. See https://cn.dataone.org/cn/v2/formats for the current list. This package stores a copy and may be out of date with that list so please email the author if needed.")) } - log_message(paste0("Updating object ", pid, " with the file at ", path, ".")) + message(paste0("Updating object ", pid, " with the file at ", path, ".")) # Generate a PID if needed if (is.null(new_pid)) { @@ -321,7 +321,7 @@ publish_update <- function(mn, # Get some things from the node if (is.null(metadata_path)) { # Get the metadata doc - log_message("Getting metadata from the MN.") + message("Getting metadata from the MN.") eml <- EML::read_eml(rawToChar(dataone::getObject(mn, metadata_pid)), asText = TRUE) } else { # Alternatively, read an edited metadata file from disk if provided @@ -329,27 +329,27 @@ publish_update <- function(mn, stop(paste0("Metadata doesn't exist: ", metadata_path)) } - log_message(paste0("Getting metadata from the path: ", metadata_path, ".")) + message(paste0("Getting metadata from the path: ", metadata_path, ".")) eml <- EML::read_eml(metadata_path) } # get the metadata sysmeta from the node metadata_sysmeta <- dataone::getSystemMetadata(mn, metadata_pid) - log_message("Downloaded EML and sysmeta...") + message("Downloaded EML and sysmeta...") # Generate PIDs for our updated objects if (is.null(identifier)) { if (use_doi) { - log_message("Minting a new DOI") + message("Minting a new DOI") metadata_updated_pid <- dataone::generateIdentifier(mn, scheme = "DOI") - log_message(paste0("Minted a new DOI of ", metadata_updated_pid, ".")) + message(paste0("Minted a new DOI of ", metadata_updated_pid, ".")) } else { metadata_updated_pid <- new_uuid() - log_message(paste0("Using generated UUID PID of ", metadata_updated_pid, ".")) + message(paste0("Using generated UUID PID of ", metadata_updated_pid, ".")) } } else { - log_message(paste0("Using manually-specified identifier of ", identifier, ".")) + message(paste0("Using manually-specified identifier of ", identifier, ".")) metadata_updated_pid <- identifier } @@ -428,7 +428,7 @@ publish_update <- function(mn, metadata_pid, metadata_sysmeta@rightsHolder) - log_message(paste0("Updated metadata document ", metadata_pid, " with ", metadata_updated_pid, ".")) + message(paste0("Updated metadata document ", metadata_pid, " with ", metadata_updated_pid, ".")) # Update the resource map ######################### @@ -443,7 +443,7 @@ publish_update <- function(mn, set_rights_holder(mn, response[["resource_map"]], metadata_sysmeta@rightsHolder) - log_message("Updated resource map") + message("Updated resource map") # Update the parent resource map to add the new package ####################################################### @@ -452,12 +452,12 @@ publish_update <- function(mn, stop("Missing required parameters to update parent package.") } - log_message("Updating parent resource map...") + message("Updating parent resource map...") # Check to see if the just-updated package is in the list of # parent_child_pids, notify the user, and add it to the list if (!(resmap_updated_pid %in% parent_child_pids)) { - log_message("Adding the new resource map to the list of child PIDs in the parent package.") + message("Adding the new resource map to the list of child PIDs in the parent package.") parent_child_pids <- c(parent_child_pids, resmap_updated_pid) } @@ -514,7 +514,7 @@ create_resource_map <- function(mn, nchar(metadata_pid) > 0) if (check_first) { - log_message("Checking all the object passed in as arguments exist before going on...") + message("Checking all the object passed in as arguments exist before going on...") stopifnot(object_exists(mn, metadata_pid)) if (!is.null(data_pids)) @@ -598,7 +598,7 @@ update_resource_map <- function(mn, nchar(metadata_pid) > 0) if (check_first) { - log_message("Checking all the object passed in as arguments exist before going on...") + message("Checking all the object passed in as arguments exist before going on...") stopifnot(object_exists(mn, resource_map_pid)) stopifnot(object_exists(mn, metadata_pid)) @@ -646,7 +646,7 @@ update_resource_map <- function(mn, rm(sysmeta) - log_message(paste0("Getting updated copy of System Metadata for ", resource_map_pid)) + message(paste0("Getting updated copy of System Metadata for ", resource_map_pid)) sysmeta <- dataone::getSystemMetadata(mn, resource_map_pid) stopifnot(class(sysmeta) == "SystemMetadata") @@ -671,7 +671,7 @@ update_resource_map <- function(mn, } # Update it - log_message(paste0("Updating resource map...")) + message(paste0("Updating resource map...")) resmap_update_response <- dataone::updateObject(mn, pid = resource_map_pid, newpid = identifier, @@ -686,7 +686,7 @@ update_resource_map <- function(mn, file.remove(new_rm_path) } - log_message(paste0("Successfully updated ", resource_map_pid, " with ", identifier, ".")) + message(paste0("Successfully updated ", resource_map_pid, " with ", identifier, ".")) return(resmap_update_response) } diff --git a/R/helpers.R b/R/helpers.R index 32148c0..c853398 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -36,7 +36,7 @@ create_dummy_metadata <- function(mn, data_pids=NULL) { sysmeta <- add_admin_group_access(sysmeta) sysmeta <- datapack::addAccessRule(sysmeta, "public", "read") - log_message(paste0("Creating metadata ", pid)) + message(paste0("Creating metadata ", pid)) pid <- dataone::createObject(mn, pid, metadata_file, sysmeta) # Remove the temporary EML File @@ -77,7 +77,7 @@ create_dummy_object <- function(mn) { sysmeta <- add_admin_group_access(sysmeta) sysmeta <- datapack::addAccessRule(sysmeta, "public", "read") - log_message(paste0("Creating object ", pid)) + message(paste0("Creating object ", pid)) create_response <- dataone::createObject(mn, pid, tmp, sysmeta) file.remove(tmp) @@ -134,7 +134,7 @@ create_dummy_package <- function(mn, size = 2) { sysmeta <- add_admin_group_access(sysmeta) sysmeta <- datapack::addAccessRule(sysmeta, "public", "read") - log_message(paste0("Creating resource map ", pid)) + message(paste0("Creating resource map ", pid)) resource_map_pid <- dataone::createObject(mn, pid, resmap_path, sysmeta) list(metadata = meta_pid, @@ -178,7 +178,7 @@ create_dummy_parent_package <- function(mn, children) { sysmeta <- add_admin_group_access(sysmeta) sysmeta <- datapack::addAccessRule(sysmeta, "public", "read") - log_message(paste0("Creating parent package map ", pid)) + message(paste0("Creating parent package map ", pid)) create_response <- createObject(mn, pid, resmap_path, sysmeta) list(parent = create_response, diff --git a/R/inserting.R b/R/inserting.R index 702355e..34202a8 100644 --- a/R/inserting.R +++ b/R/inserting.R @@ -47,7 +47,7 @@ create_from_folder <- function(mn, path, data_pids=NULL) { publish_object(mn, data_path, data_format_ids[data_path]) }, error = function(e) { - log_message(e) + message(e) e }) diff --git a/R/packaging.R b/R/packaging.R index 090c2dc..0b4cd18 100644 --- a/R/packaging.R +++ b/R/packaging.R @@ -27,7 +27,7 @@ insert_file <- function(inventory, file, env=NULL) { validate_environment(env) if (is_token_expired(env$mn)) { - log_message("Token is expired. Returning un-modified inventory.") + message("Token is expired. Returning un-modified inventory.") return(inventory) } @@ -42,7 +42,7 @@ insert_file <- function(inventory, file, env=NULL) { identifier_scheme <- env$data_identifier_scheme } - log_message(paste0("Using identifier scheme ", identifier_scheme, ".")) + message(paste0("Using identifier scheme ", identifier_scheme, ".")) # Determine the PID to use inventory_file[1,"pid"] <- get_or_create_pid(inventory_file[1,], @@ -50,7 +50,7 @@ insert_file <- function(inventory, file, env=NULL) { scheme = identifier_scheme) if (is.na(inventory_file[1,"pid"])) { - log_message(paste0("PID was NA for file ", file, ".\n")) + message(paste0("PID was NA for file ", file, ".\n")) return(inventory_file) } @@ -61,7 +61,7 @@ insert_file <- function(inventory, file, env=NULL) { env$rights_holder) if (is.null(sysmeta)) { - log_message(paste0("System Metadata creation failed for file ", file, ".\n")) + message(paste0("System Metadata creation failed for file ", file, ".\n")) return(inventory_file) } @@ -73,7 +73,7 @@ insert_file <- function(inventory, file, env=NULL) { } if (inventory_file[1,"created"] == FALSE) { - log_message(paste0("Object creation failed for file ", file, ".\n")) + message(paste0("Object creation failed for file ", file, ".\n")) return(inventory_file) } @@ -106,7 +106,7 @@ insert_package <- function(inventory, package, env=NULL) { validate_environment(env) if (is_token_expired(env$mn)) { - log_message("Token is expired. Returning un-modified inventory.") + message("Token is expired. Returning un-modified inventory.") return(inventory) } @@ -148,7 +148,7 @@ insert_package <- function(inventory, package, env=NULL) { scheme = env$metadata_identifier_scheme) if (is.na(files[files_idx_metadata,"pid"])) { - log_message(paste0("Metadata PID was NA for package ", package, ".\n")) + message(paste0("Metadata PID was NA for package ", package, ".\n")) return(files) } @@ -159,7 +159,7 @@ insert_package <- function(inventory, package, env=NULL) { env$rights_holder) if (is.null(metadata_sysmeta)) { - log_message(paste0("System Metadata creation failed for metadata object in package ", package, ".\n")) + message(paste0("System Metadata creation failed for metadata object in package ", package, ".\n")) return(files) } @@ -177,11 +177,11 @@ insert_package <- function(inventory, package, env=NULL) { } if (files[files_idx_metadata,"created"] == FALSE) { - log_message(paste0("Object creation failed for metadata object in package ", package, ".\n")) + message(paste0("Object creation failed for metadata object in package ", package, ".\n")) return(files) } } else { - log_message("Skipped creating metadata because it was already created.") + message("Skipped creating metadata because it was already created.") } # Insert data files if needed @@ -190,11 +190,11 @@ insert_package <- function(inventory, package, env=NULL) { for (data_idx in files_idx_data) { # Skip if already created if (files[data_idx,"created"] == TRUE) { - log_message(paste0("File ", files[data_idx,"filename"], " in package ", package, " already created. Moving on to the next data object.\n")) + message(paste0("File ", files[data_idx,"filename"], " in package ", package, " already created. Moving on to the next data object.\n")) next } - log_message(paste0("Processing data index ", data_idx, " in package ", package, "\n")) + message(paste0("Processing data index ", data_idx, " in package ", package, "\n")) # Determine the PID to use for the data files[data_idx,"pid"] <- get_or_create_pid(files[data_idx,], @@ -202,7 +202,7 @@ insert_package <- function(inventory, package, env=NULL) { scheme = env$data_identifier_scheme) if (is.na(files[data_idx,"pid"])) { - log_message(paste0("Data PID was NA for file ", files[data_idx,'filename'], " in package ", package, ". Stopping early.\n")) + message(paste0("Data PID was NA for file ", files[data_idx,'filename'], " in package ", package, ". Stopping early.\n")) return(files) } @@ -213,7 +213,7 @@ insert_package <- function(inventory, package, env=NULL) { env$rights_holder) if (is.null(metadata_sysmeta)) { - log_message(paste0("System Metadata creation failed for metadata object in package ", package, ".\n")) + message(paste0("System Metadata creation failed for metadata object in package ", package, ".\n")) return(files) } @@ -226,35 +226,35 @@ insert_package <- function(inventory, package, env=NULL) { } if (files[data_idx,"created"] == FALSE) { - log_message(paste0("Object creation failed for metadata object in package ", package, ".\n")) + message(paste0("Object creation failed for metadata object in package ", package, ".\n")) return(files) } } } else { - log_message("Skipped creating data files because they were all created.") + message("Skipped creating data files because they were all created.") } # At this point, all of the metadata and data should be created, let's check if (!all(is.character(files[,"pid"])) && !all(files[,"created"] == TRUE)) { - log_message(paste0("Not all files in package ", package, " have PIDs and are created. Skipping Resource Map creation.\n")) + message(paste0("Not all files in package ", package, " have PIDs and are created. Skipping Resource Map creation.\n")) return(files) } # Generate and create() the Resource Map - log_message(paste0("Generating resource map for package ", package, ".\n")) + message(paste0("Generating resource map for package ", package, ".\n")) resource_map_pid <- generate_resource_map_pid(files[files_idx_metadata,"pid"]) resource_map_filepath <- generate_resource_map(files[files_idx_metadata,"pid"], files[files_idx_data,"pid"], child_pids) - log_message(paste0("Resource map PID is ", resource_map_pid, " for package with metadata file ", files[files_idx_metadata,"file"], ".\n")) + message(paste0("Resource map PID is ", resource_map_pid, " for package with metadata file ", files[files_idx_metadata,"file"], ".\n")) resource_map_format_id <- "http://www.openarchives.org/ore/terms" resource_map_checksum <- digest::digest(resource_map_filepath, algo = "sha256") resource_map_size_bytes <- file.info(resource_map_filepath)$size resource_map_file_name <- paste0(stringr::str_replace_all(resource_map_pid, ":", "_"), ".xml") - log_message(paste0("Generating system metadata for resource map for package ", package, ".\n")) + message(paste0("Generating system metadata for resource map for package ", package, ".\n")) resource_map_sysmeta <- new("SystemMetadata", identifier = resource_map_pid, formatId = resource_map_format_id, @@ -271,7 +271,7 @@ insert_package <- function(inventory, package, env=NULL) { resource_map_sysmeta <- add_access_rules(resource_map_sysmeta) - log_message(paste0("Creating resource map for package ", package, ".\n")) + message(paste0("Creating resource map for package ", package, ".\n")) create_resource_map_response <- NULL create_resource_map_response <- tryCatch({ dataone::createObject(env$mn, @@ -280,8 +280,8 @@ insert_package <- function(inventory, package, env=NULL) { sysmeta = resource_map_sysmeta) }, error = function(e) { - log_message(paste0("Error encountered while calling create() on the Resource Map for package ", package, ".\n")) - log_message(e$message) + message(paste0("Error encountered while calling create() on the Resource Map for package ", package, ".\n")) + message(e$message) e } ) @@ -295,7 +295,7 @@ insert_package <- function(inventory, package, env=NULL) { files$resmap_created <- TRUE } - log_message(print(files)) + message(print(files)) return(files) } @@ -522,11 +522,11 @@ get_or_create_pid <- function(file, mn, scheme="UUID") { # Check if the existing PID is a valid one if (!is.na(pid) && is.character(pid) && nchar(pid) > 0) { - log_message(paste0("Using existing PID of ", pid, "\n")) + message(paste0("Using existing PID of ", pid, "\n")) return(pid) } - log_message(paste0("Minting new PID with scheme ", scheme, "\n")) + message(paste0("Minting new PID with scheme ", scheme, "\n")) if (scheme == "UUID") { pid <- paste0("urn:uuid:", uuid::UUIDgenerate()) @@ -538,8 +538,8 @@ get_or_create_pid <- function(file, mn, scheme="UUID") { dataone::generateIdentifier(mn, scheme) }, error = function(e) { - log_message(paste0("Error generating identifier for file ", file[1,"file"], ".\n")) - log_message(e$message) + message(paste0("Error generating identifier for file ", file[1,"file"], ".\n")) + message(e$message) e } ) @@ -613,8 +613,8 @@ create_sysmeta <- function(file, base_path, submitter, rights_holder) { }, error = function(e) { - log_message(paste0("Error generated during the call to create_sysmeta() for the metadata file ", file[1,"file"], "\n")) - log_message(e$message) + message(paste0("Error generated during the call to create_sysmeta() for the metadata file ", file[1,"file"], "\n")) + message(e$message) e } ) @@ -673,8 +673,8 @@ create_object <- function(file, sysmeta, base_path, mn) { sysmeta = sysmeta) }, error = function(e) { - log_message(paste0("Error generated during the call to MNStorage.create() for the metadata file ", file[1,"file"], "\n")) - log_message(e$message) + message(paste0("Error generated during the call to MNStorage.create() for the metadata file ", file[1,"file"], "\n")) + message(e$message) e }) @@ -689,14 +689,14 @@ create_object <- function(file, sysmeta, base_path, mn) { # Print out the insert rate time_diff_sec <- round(as.numeric(Sys.time() - before_time, "secs"), 2) mb_per_s <- round(file_size_mb / time_diff_sec, 2) - log_message(paste0("Inserted ", file_size_mb, " MB in ", time_diff_sec, " s (", mb_per_s, " MB/s)\n")) + message(paste0("Inserted ", file_size_mb, " MB in ", time_diff_sec, " s (", mb_per_s, " MB/s)\n")) if (is.character(response) && nchar(response) > 0) { result <- TRUE - log_message(paste0("Successfully created object with PID ", response, " for file ", file[1,"file"], ".\n")) + message(paste0("Successfully created object with PID ", response, " for file ", file[1,"file"], ".\n")) } else { result <- FALSE - log_message(paste0("Failed to created object with PID ", response, " for file ", file[1,"file"], ".\n")) + message(paste0("Failed to created object with PID ", response, " for file ", file[1,"file"], ".\n")) } result @@ -830,7 +830,7 @@ update_package <- function(inventory, # Check the token if (is_token_expired(env$mn)) { - log_message("Token is expired. Returning un-modified inventory.") + message("Token is expired. Returning un-modified inventory.") return(package_files) } @@ -839,28 +839,28 @@ update_package <- function(inventory, data_file_idx <- which(package_files$is_metadata == FALSE) stopifnot(length(metadata_file_idx) == 1) - log_message(paste0("Updating package ", package, "\n")) + message(paste0("Updating package ", package, "\n")) # Find the converted EML documente if (!file.exists(env$alternate_path)) { - log_message(paste0("Alternate path location of ", env$alternate_path, " does not exist. Returning.\n")) + message(paste0("Alternate path location of ", env$alternate_path, " does not exist. Returning.\n")) return(package_files) } eml_file_path <- path_join(c(env$alternate_path, package_files[metadata_file_idx,"file"])) if (!file.exists(eml_file_path)) { - log_message(paste0("EML file not found at path ", eml_file_path, ".\n")) + message(paste0("EML file not found at path ", eml_file_path, ".\n")) return(package_files) } - log_message(paste0("Converted document is at ", eml_file_path, "\n")) + message(paste0("Converted document is at ", eml_file_path, "\n")) # Get a new PID and replace the packageId new_pid <- package_files[metadata_file_idx,"pid"] old_pid <- package_files[metadata_file_idx,"pid_old"] - log_message(paste0("Updating object with old PID ", old_pid, " with new PID ", new_pid, ".\n")) + message(paste0("Updating object with old PID ", old_pid, " with new PID ", new_pid, ".\n")) stopifnot(!is.na(new_pid), is.character(new_pid), @@ -878,12 +878,12 @@ update_package <- function(inventory, # Call MNStorage.update on the metadata object # Does this PID even exist? Stop now if it doesn't. if (!object_exists(env$mn_base_url, old_pid)) { - log_message(paste0("Object with PID ", old_pid, " not found. Returning package.\n")) + message(paste0("Object with PID ", old_pid, " not found. Returning package.\n")) return(package_files) } # Update the object if it doesn't exist on the MN - log_message(paste0("Checking if metadata object with pid ", new_pid, " already exists.\n")) + message(paste0("Checking if metadata object with pid ", new_pid, " already exists.\n")) if (!object_exists(env$mn_base_url, new_pid)) { sysmeta <- new("SystemMetadata", @@ -910,8 +910,8 @@ update_package <- function(inventory, sysmeta = sysmeta) }, error = function(e) { - log_message(paste0("Error produced during call to updateObject for metadata ", package_files[metadata_file_idx,"file"], " in package ", package, "\n")) - log_message(e) + message(paste0("Error produced during call to updateObject for metadata ", package_files[metadata_file_idx,"file"], " in package ", package, "\n")) + message(e) e }) @@ -923,10 +923,10 @@ update_package <- function(inventory, # Set the updated flag to TRUE package_files$updated <- TRUE - log_message(paste0("Inserted updated metadata object for package ", package, "\n")) + message(paste0("Inserted updated metadata object for package ", package, "\n")) } else { - log_message(paste0("Metadata object already exists. Moving on to the resource map.\n")) + message(paste0("Metadata object already exists. Moving on to the resource map.\n")) } @@ -973,12 +973,12 @@ update_package <- function(inventory, # Check if the new resource map already exists if (object_exists(env$mn_base_url, resource_map_pid)) { - log_message(paste0("The new resource map with PID ", resource_map_pid, " already exists. Finishing up.\n")) + message(paste0("The new resource map with PID ", resource_map_pid, " already exists. Finishing up.\n")) } else { # Now check if the OLD resource map exists if (!object_exists(env$mn_base_url, old_resmap_pid)) { - log_message(paste0("Old resource map with PID ", resource_map_pid, " doesn't exist. Using createObject instead of updateObject.\n")) + message(paste0("Old resource map with PID ", resource_map_pid, " doesn't exist. Using createObject instead of updateObject.\n")) create_response <- tryCatch({ dataone::createObject(x = env$mn, @@ -987,17 +987,17 @@ update_package <- function(inventory, sysmeta = resource_map_sysmeta) }, error = function(e) { - log_message(paste0("Error produced during call to createObject for resource map ", resource_map_pid, " in package ", package, "\n")) - log_message(e) + message(paste0("Error produced during call to createObject for resource map ", resource_map_pid, " in package ", package, "\n")) + message(e) e }) if (inherits(create_response, "error")) { - log_message("There was an error calling createObject. Returning package files as is.\n") + message("There was an error calling createObject. Returning package files as is.\n") return(package_files) } - log_message(create_response) + message(create_response) } else { # Update the old resource map update_response <- tryCatch({ @@ -1008,17 +1008,17 @@ update_package <- function(inventory, sysmeta = resource_map_sysmeta) }, error = function(e) { - log_message(paste0("Error produced during call to updateObject for resource map ", package_files[metadata_file_idx,"file"], " in package ", package, "\n")) - log_message(e) + message(paste0("Error produced during call to updateObject for resource map ", package_files[metadata_file_idx,"file"], " in package ", package, "\n")) + message(e) e }) if (inherits(update_response, "error")) { - log_message("There was an error calling updateObject Returning package files as is.\n") + message("There was an error calling updateObject Returning package files as is.\n") return(package_files) } - log_message(update_response) + message(update_response) } } diff --git a/R/sysmeta.R b/R/sysmeta.R index 09d64b6..235c1b5 100644 --- a/R/sysmeta.R +++ b/R/sysmeta.R @@ -67,7 +67,7 @@ remove_public_access <- function(sysmeta) { #' @examples add_admin_group_access <- function(sysmeta) { if (!inherits(sysmeta, "SystemMetadata")) { - log_message(paste0("An object of class ", class(sysmeta), " was passed in. Returning unmodified object.\n")) + message(paste0("An object of class ", class(sysmeta), " was passed in. Returning unmodified object.\n")) return(sysmeta) } @@ -97,7 +97,7 @@ replace_subject <- function(sysmeta, from="cn=arctic-data-admins,dc=dataone,dc=org", to="CN=arctic-data-admins,DC=dataone,DC=org") { if (!inherits(sysmeta, "SystemMetadata")) { - log_message(paste0("An object of class ", class(sysmeta), " was passed in. Returning unmodified object.\n")) + message(paste0("An object of class ", class(sysmeta), " was passed in. Returning unmodified object.\n")) return(sysmeta) }