Geostore - backend

392 views
Skip to first unread message

HawXedge

unread,
Feb 16, 2021, 4:25:35 AM2/16/21
to mapstore-users
Hello,

My name is Mislav Srečec, I'm a 3rd year student at the Polytechnic of Zagreb and I'm currently trying to use your open source projects: Mapstore and Geostore.

I'm currently in a bit of a pickle because I'm trying to wrap my head around the backend of the application. The frontend is amazing and I can understand everything regarding the Redux store and React SPA, but the backend of the application is written in Java - and this semester I also use Java Spring Boot and Hybernate frameworks on my final project application. 

My issue is that I'm trying to understand how I could add RESTful services to the backend of the application, because when I built the app, i got all jar files that include .class files of geostore-rest-api located in target folder, but I can't find the source code of those files on mapstore project that I forked from github repo (https://github.com/geosolutions-it/MapStore2). I see that those files are on geostore project in a different repository (https://github.com/geosolutions-it/geostore/tree/master/src/core/services-api/src/main/java/it/geosolutions/geostore/services), but I don't know how to get access to the source code of the geostore project that is being built into the final mapstore.war file. 

My main goal is to add another database (deceased.db) to the existing project that would include models of deceased located in the graves whose locations are stored on geostore.db (postgres db).

I'm trying to build a simple GiS solution that would allow us to have simple REST api that I would use to communicate with the frontend of the application and interact with the database deceased.db that I would add to the project. 

Another option is to add Models of Deceased to the geostore.db project and link then to the locations of the graves, which would require me to fork and modify the existing project (geostore),
which in my opinion would be optimal solution, but the one whose possibilities I would still like to explore.

The app would target the graves of the deceased via mapstore client and also perform basic CRUD operations with the models of the deceased that I would add to the Backend of the application.

Thank you for your amazing project and hopefully one day I get to the level where I could contribute myself to the open source project.

Respectfully,

Mislav Srečec

Petar Sapunar

unread,
Feb 16, 2021, 5:42:07 AM2/16/21
to mapstor...@googlegroups.com
Hi 
i got the same problem. Looking forward to resolving this issues.

Virus-free. www.avast.com

--
You received this message because you are subscribed to the Google Groups "mapstore-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapstore-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapstore-users/43081f33-2ad1-4f4c-ada8-531e71c3a6e1n%40googlegroups.com.

Toni Petrinović

unread,
Feb 16, 2021, 5:42:43 AM2/16/21
to mapstore-users
WOW, the same problem

Mauro Bartolomeoli

unread,
Feb 17, 2021, 9:34:45 AM2/17/21
to mapstor...@googlegroups.com
Hello to all the MapStore backend interested people,


My issue is that I'm trying to understand how I could add RESTful services to the backend of the application, because when I built the app, i got all jar files that include .class files of geostore-rest-api located in target folder, but I can't find the source code of those files on mapstore project that I forked from github repo (https://github.com/geosolutions-it/MapStore2). I see that those files are on geostore project in a different repository (https://github.com/geosolutions-it/geostore/tree/master/src/core/services-api/src/main/java/it/geosolutions/geostore/services), but I don't know how to get access to the source code of the geostore project that is being built into the final mapstore.war file. 

The current Java backend is composed by 3 different parts:
 - a set of internal MapStore specific REST services (https://github.com/geosolutions-it/MapStore2/tree/master/backend)

Shortly:
 - GeoStore is a storage API service, that MapStore uses to store its resources (maps, dashboards, geostories, etc.) and includes the security infrastructure based on Spring Security
 - HttpProxy is a simple proxy used to manage cross-origin requests to external services
 - the internal backend is where the things get more interesting (because is an example of how you can add your own services), currently here we have some services to manage the MapStore configuration and extensions

To add your own services, you need to work with the Spring framework that is used to host the APIs.
In particular, we use SpringMVC, so you can add your own controllers just creating a @Controller annotated class (e.g. https://github.com/geosolutions-it/MapStore2/blob/master/backend/src/main/java/it/geosolutions/mapstore/ConfigController.java)
All SpringMVC controllers are reachable from the /rest/config/<controllerName> endpoint

You can create your own project for these services, and include the built jar in your MapStore deploy, the new REST APIs will be automatically available due to Spring.

You can also restrict access to specific users (only by role at the moment) with a specific Annotation (an example here: https://github.com/geosolutions-it/MapStore2/blob/master/backend/src/main/java/it/geosolutions/mapstore/UploadPluginController.java#L76)

Take into account that  unfortunately we depend on a quite old version of Spring (3.0.5), so you would not be able to use the more advanced Spring functionalities available in more recent releases.


My main goal is to add another database (deceased.db) to the existing project that would include models of deceased located in the graves whose locations are stored on geostore.db (postgres db).
I'm trying to build a simple GiS solution that would allow us to have simple REST api that I would use to communicate with the frontend of the application and interact with the database deceased.db that I would add to the project. 

Another option is to add Models of Deceased to the geostore.db project and link then to the locations of the graves, which would require me to fork and modify the existing project (geostore),
which in my opinion would be optimal solution, but the one whose possibilities I would still like to explore.

I would use two distinct databases, so that you don't depend on the MapStore internal one and can work independently from it.
 

The app would target the graves of the deceased via mapstore client and also perform basic CRUD operations with the models of the deceased that I would add to the Backend of the application.
Thank you for your amazing project and hopefully one day I get to the level where I could contribute myself to the open source project.

It would be awesome. Consider that you can contribute in several ways. Asking questions that can be useful for others too is one of them.

--

Regards,

Mauro Bartolomeoli

==
GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information.
==

Dott. Mauro Bartolomeoli
@mauro_bart
Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy

mobile: +39 393 904 1756
phone: +39 0584 962313
fax:      +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia.

This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

HawXedge

unread,
Feb 18, 2021, 4:25:21 PM2/18/21
to mapstore-users
Dott. Mauro Bartolomeoli, thank you so much for your response !

I have another question.

Maybe a better solution would be to write my own service in something like NodeJS which I am more familiar with. If I were to make requests to the Node server from the MapStore client, and benefit from the use of the Mapstore Backend authentication layer, would I have to add Node server address to http-proxy white list ?

If that were true, would I have to add the address to proxy.properties file in web/src/main/resources folder ?

Maybe something like:
------------------------------------------------------------------------------------------------------------------------------------------------

hostnameWhitelist = localhost,demo1.geo-solutions.it,demo.geo-solutions.it, mynodeservice

hostsWhitelist = 127.0.0.1:3000 #for Node running on 3000
------------------------------------------------------------------------------------------------------------------------------------------------  

TLDR: How could I add my external Node server domain/address to http-proxy in mapstore so that I could invoke my node server api that is fetching data from the second database from mapstore client after authenticating the user.

WARNING: I am a junior developer so please forgive my naivety, and If I'm wrong I would be more than happy to be corrected rather than continue in a wrong direction :D :D :D 

Erwin Sterrenburg

unread,
Feb 19, 2021, 8:50:59 AM2/19/21
to mapstore-users

@Mislav

I have used a similar approach (would have no idea where to even start with Java...):
  • Do a request to a simple golang webservice with the same authkey (that MapStore also uses to identify it's user with our GeoServer) and the id of a resource as url-parameter.
  • Webservice checks whether user has viewing rights or editing rights on the MapStore resource (dependent on the request on of these can be enough).
  • Webservice performs its task if allowed, or can return an appropriate error if not allowed.
Integration within the MapStore backend may be more elegant for your use case, there may be a large flaw in my approach, yet it does seem to do the job.
Also, I don't know how the proxy properties should look like though (that's still to-do, currently the proxy is accepting more than it should).

Erwin

HawXedge

unread,
Feb 19, 2021, 9:07:12 AM2/19/21
to mapstor...@googlegroups.com
Thank you so much ! 😀

--
You received this message because you are subscribed to a topic in the Google Groups "mapstore-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mapstore-users/4JCgzPyiWDE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mapstore-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapstore-users/85b32887-8980-42b3-9876-8fe9de0e7dc3n%40googlegroups.com.

Mauro Bartolomeoli

unread,
Feb 19, 2021, 12:39:56 PM2/19/21
to mapstor...@googlegroups.com
Hi,


Maybe a better solution would be to write my own service in something like NodeJS which I am more familiar with. If I were to make requests to the Node server from the MapStore client, and benefit from the use of the Mapstore Backend authentication layer, would I have to add Node server address to http-proxy white list ?

Yes, that's doable too.
Using the proxy  is enabled for all hosts if you don't explicitly set a white list.

Another way would be to enable cross-origin access on your NodeJS backend and configure the frontend to use it directly via CORS, without leveraging the proxy. 
I am not a NodeJS expert, so I don't know how to enable cross-origin, but I think you should find info on the web for that.

On the MapStore side, you can enable CORS for your server in localConfig.json, adding its url into the useCORS list:



Reply all
Reply to author
Forward
Message has been deleted
0 new messages