Skip to content

Commit

Permalink
#6 method to list groups
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Mar 21, 2019
1 parent 3e44126 commit 39e1ca8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: geonapi
Type: Package
Title: 'GeoNetwork' API R Interface
Version: 0.3-0
Date: 2019-01-29
Date: 2019-03-21
Authors@R: c(person("Emmanuel", "Blondel", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0002-5870-5762")))
Maintainer: Emmanuel Blondel <[email protected]>
Description: Provides an R interface to the 'GeoNetwork' API (<https://geonetwork-opensource.org/#api>) allowing to upload and publish metadata in a 'GeoNetwork' web-application and exposte it to OGC CSW.
Expand Down
31 changes: 31 additions & 0 deletions R/GNManager.R
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,37 @@ GNManager <- R6Class("GNManager",
return(class(self)[1])
},

#getGroups
#---------------------------------------------------------------------------
getGroups = function(){
out <- NULL
self$INFO("Getting user groups...")
req <- GNUtils$GET(
url = self$getUrl(),
path = "/xml.info",
token = private$token, cookies = private$cookies,
user = private$user, pwd = private$pwd,
query = list(type = "groups"),
verbose = self$verbose.debug
)
if(status_code(req) == 200){
self$INFO("Successfully fetched user groups!")
xml <- GNUtils$parseResponseXML(req, "UTF-8")
xml.groups <- getNodeSet(xml, "//group/group")
out <- do.call("rbind", lapply(xml.groups, function(xml.group){
out.group <- data.frame(
id = xmlGetAttr(xml.group, "id"),
name = xmlValue(xmlChildren(xml.group)$name),
stringsAsFactors = FALSE
)
return(out.group)
}))
}else{
self$ERROR("Error while fetching user groups")
}
return(out)
},

#insertMetadata
#---------------------------------------------------------------------------
insertMetadata = function(xml = NULL, file = NULL, geometa = NULL, group,
Expand Down
2 changes: 1 addition & 1 deletion R/geonapi.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' Package: \tab geonapi\cr
#' Type: \tab Package\cr
#' Version: \tab 0.3-0\cr
#' Date: \tab 2019-01-29\cr
#' Date: \tab 2019-03-21\cr
#' License: \tab MIT\cr
#' LazyLoad: \tab yes\cr
#' }
Expand Down
2 changes: 1 addition & 1 deletion man/geonapi.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 39e1ca8

Please sign in to comment.