Esri / geoportal-server-catalog

Esri Geoportal Server is a next generation open-source metadata catalog and editor, based on elasticsearch.
https://www.esri.com/en-us/arcgis/products/geoportal-server/overview
Apache License 2.0
100 stars 62 forks source link

Where are new metadata entry XMLs stored? #9

Closed MapZombie closed 7 years ago

MapZombie commented 8 years ago

As the new Geoportal does not use a database, I was wondering where the user created metadata (through metadata editor) files stored?

When a user creates metadata is it stored as an XML file on the server? If not, can this be configured to do so?

Thank you.

umacgillivray commented 8 years ago

The xml files are stored within ElasticSearch. Within the index there is an es type "item", and another type "clob". The xmls are within the "clob" type.

MapZombie commented 8 years ago

Thanks @umacgillivray . Would you know of an effective way of exporting these from ElasticSearch?

mhogeweg commented 8 years ago

to where?

umacgillivray commented 8 years ago

Java from within geoportal would look something like this `

import com.esri.geoportal.lib.elastic.util.Scroller; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; import org.elasticsearch.search.SearchHit;

public static void testExport() throws Exception { AtomicLong count = new AtomicLong(0); String dir = "C:/Projects/elastic/metadata/sampledata2/"; Scroller scroller = new Scroller(); scroller.setIndexName("metadata"); scroller.setIndexType("clob"); //scroller.setMaxDocs(10); scroller.scroll( new Consumer(){ @Override public void accept(SearchHit hit) { try { System.err.println(count.incrementAndGet()); String id = hit.getId(); String xml = (String)hit.getSource().get("sys_clob"); //System.err.println(id); Path p = Paths.get(dir+id.replace("_xml","")+".xml"); Files.write(p,xml.getBytes("UTF-8")); } catch (Exception e) { e.printStackTrace(); } } } ); } `

MapZombie commented 8 years ago

Basically I'm just looking to export these to the local geoportal server as individual XMLs.

MapZombie commented 8 years ago

I appreciate the help @umacgillivray . Would you be able to guide me as to where I would enter this code? Which file(s) would need to be edited? I am not very proficient in Java unfortunately.

Thanks.

MapZombie commented 8 years ago

Can XMLs be exported server side via editing the JavaScript? I'm getting a grasp of the save function. And looking at whether we can add a function to save to a folder as ".xml" file and elasticsearch as usual.

MetadataEditor.js

_save: function(xmlString,itemId) {

      var client = new AppClient();
      var url = client.getRestUri()+"/metadata/item";
      if (typeof itemId === "string" && itemId.length > 0) {
        url += "/"+encodeURIComponent(itemId);  /* item name id */
      }
      url = client.appendAccessToken(url);     /* Elasticsearch URL? */
      var data = {                            /* Defines Data */
        app_editor_s: "gxe",                  /* Data is from GXE */
        xml: xmlString                        /* XML String */
      };
      var headers = {"Content-Type": "application/json"}; /* Header */
      var info = {handleAs:"json",headers:headers,data:JSON.stringify(data)}; /* Handles as JSON format */
      return dojoRequest.put(url,info);    /* push to server */
    },
valentinedwv commented 8 years ago

Would this be better done as an enhancement to the geoportal-harvester?

Connect to a geoportal 2.0, export to folder.

mhogeweg commented 8 years ago

yes! especially since harvesting to a folder is already supported. you would create an input broker for Geoportal Server Catalog 2.x.

adding @pandzel in case he has already worked on such a broker for harvester