Adding documents during platform server startup

From the [documentation]<INTERNAL_LINK> I see that it is easy to add document models and users/permission documents to the platform server during startup. But we want to add our own base and demo content to the server. Unfortunatley I do not find any method.

Wo I have to fall back to curl or more fancy a [RestDocumentClient]<INTERNAL_LINK> base thingy. Correct?

Hi @tomas-thin-gale as far as I know we don’t have any ways to do this in current A12 Services or do we?

In <PROJECT_NAME> we do this by having an additional spring profile which changes the properties to another path where our test data lives.

Hm, interesting approach @dmueller_inactive you just mix in the documents as they were normal user/permission documents?

This is a very reasonable request. We can introduce a new configuration key which would point to the directory where your document XMLs are (there must be XML because JSON files do not contain model information). We can deduce the model name from the document XML and persist it during start-up.

@marcus-stellar-pool Would this approach address your problem?

Yes, if it is finished today :smiley: - just kidding.
I find the custom vs default document models a bit puzzling. If for example there would be a set of proprties to just uplaod document models and documents for your project would be easier to comprehend. While you are at it :smiley:

Writing a curl based client. IS there anything special to cinsder? Any header to send?

:slight_smile: We are preparing a concept for what you just mentioned. An option to define directories with models/documents/use-case definitions which you would be able to feed to the server and the server would import all and possibly modify its behavior based on the use-case definition.

I have created a ticket for services to implement a load of custom documents on the server start-up
<INTERNAL_LINK>

POST /api/MODEL_NAME/docs should do the trick if you are writing curl script. Make sure to include Content-type header based on the payload (json/xml) and basic auth header (if it is enabled in your server application)

Yes, my curl is acting strange:

> POST /api/docs/DomainCosmoClaims/claim1?author=1 HTTP/1.1

leads to

< HTTP/1.1 405 Method Not Allowed
< Allow: DELETE,POST,GET,PUT,OPTIONS,HEAD

could you think of any reason for this?

Herer is the completet transcript:

*   Trying <INTERNAL_IP>...
* TCP_NODELAY set
* Connected to <INTERNAL_LINK> (<INTERNAL_IP>) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [64 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [4705 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [333 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: CN=*.<INTERNAL_LINK> serialNumber=00:00:01; OU=services; O=mgm technology partners GmbH; C=DE
*  start date: May 16 14:07:08 2018 GMT
*  expire date: May 15 14:07:08 2020 GMT
*  issuer: CN=mgmSecureServiceCA; O=mgm technology partners GmbH; C=DE
*  SSL certificate verify ok.
* Server auth using Basic with user 'admin'
> POST /api/docs/DomainCosmoClaims/claim1?author=1 HTTP/1.1
> Host: <INTERNAL_LINK>
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Type: application/json;charset=utf8
> Content-Length: 477
> 
} [477 bytes data]
* upload completely sent off: 477 out of 477 bytes
< HTTP/1.1 405 Method Not Allowed
< Allow: DELETE,POST,GET,PUT,OPTIONS,HEAD
< Content-Length: 0
< Date: Thu, 27 Sep 2018 10:42:37 GMT
< Server: nginx/1.15.3
< Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Wed, 26-Sep-2018 10:42:37 GMT
< 
* Connection #0 to host <INTERNAL_LINK> left intact

I am not sure what this means:

if claim1 is document id which you wish to update please PUT instead of POST. But for creation of documents you should use POST /api/docs/DomainCosmoClaims with Content-type set to application/xml for XML and application/json for JSON files

thanks, did not spot that

btw once we finished our data uploader we might should talk to each other. I think it is usable for others as well …

Are you interested? @tomas-thin-gale, @tuan-stable-gale

I am interested. Please schedule a telco and invite me

will do - see other discussion still a bit in flux