Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where are new metadata entry XMLs stored? #9

Closed
MapZombie opened this issue Jul 19, 2016 · 9 comments
Closed

Where are new metadata entry XMLs stored? #9

MapZombie opened this issue Jul 19, 2016 · 9 comments

Comments

@MapZombie
Copy link

MapZombie commented Jul 19, 2016

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
Copy link
Collaborator

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
Copy link
Author

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

@mhogeweg
Copy link
Member

to where?

@umacgillivray
Copy link
Collaborator

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
Copy link
Author

MapZombie commented Jul 20, 2016

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

@MapZombie
Copy link
Author

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
Copy link
Author

MapZombie commented Aug 9, 2016

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
Copy link
Contributor

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

Connect to a geoportal 2.0, export to folder.

@mhogeweg
Copy link
Member

mhogeweg commented Aug 29, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants