Possible to create Content Types for Relationship via API

52 views
Skip to first unread message

Fredrik Westermarck

unread,
Jun 12, 2017, 9:51:42 AM6/12/17
to dotCMS User Group
Hi!

Is it possible to create a Content Type for a relationship between two Content Types using the REST API? Not the actual relationship between two related contents but the Content Type for the relationship?

I have a compound content type that has a couple of related content types that I would like to be able to setup using the API so that it's not necessary to edit the relationship in the Web UI on a new installation before starting to migrate content (also via the API).

Best regards,
Fredrik Westermarck

Jason Tesser

unread,
Jun 12, 2017, 10:23:55 AM6/12/17
to dotCMS User Group

In 4.1 you can create content types via Rest


--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/585ec0ac-0947-4f47-9719-e41008e8109a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dean Gonzalez

unread,
Jun 12, 2017, 12:54:32 PM6/12/17
to dot...@googlegroups.com

On Mon, Jun 12, 2017 at 8:23 AM, Jason Tesser <jason...@gmail.com> wrote:

In 4.1 you can create content types via Rest

On Mon, Jun 12, 2017, 9:51 AM Fredrik Westermarck <fredrik.w...@gmail.com> wrote:
Hi!

Is it possible to create a Content Type for a relationship between two Content Types using the REST API? Not the actual relationship between two related contents but the Content Type for the relationship?

I have a compound content type that has a couple of related content types that I would like to be able to setup using the API so that it's not necessary to edit the relationship in the Web UI on a new installation before starting to migrate content (also via the API).

Best regards,
Fredrik Westermarck

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/585ec0ac-0947-4f47-9719-e41008e8109a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Thank you,

Dean Gonzalez
General Manager, dotCMS Costa Rica
Training Manager



Eurocenter I
Primer Nivel, Oficina dotCMS
Barreal de Heredia, frente a CENADA
Heredia, Costa Rica
Main: 
305-900-2001 | Direct: +506.6185.7137

   

Fredrik Westermarck

unread,
Jun 13, 2017, 4:29:49 AM6/13/17
to dotCMS User Group, de...@dotcms.com
Hi!

We're using 4.1.0 as the target version in our development.

Yes, I have read the documentation that Dean posted but there are no example, or mention on, how to create a new Content Type for a relation using the REST API as far as I can tell.

I looked at the request that is produced in the Web UI and made a JSON-file from that and tried to create a Content Type with a call like https://auth.dotcms.com/docs/latest/content-type-api#createContentType but the response was that the request was missing the clazz-attribute - which is true.

However I'm unable to find, in the documentation, what clazz to use for a Relation Content Type. Where can I find the different clazz-attributes that can be used? Or does someone have an full example on how to create a valid JSON for adding a Relation Content Type?

Best regards,
Fredrik Westermarck


Den måndag 12 juni 2017 kl. 18:54:32 UTC+2 skrev Dean Gonzalez:
On Mon, Jun 12, 2017 at 8:23 AM, Jason Tesser <jason...@gmail.com> wrote:

In 4.1 you can create content types via Rest

On Mon, Jun 12, 2017, 9:51 AM Fredrik Westermarck <fredrik.w...@gmail.com> wrote:
Hi!

Is it possible to create a Content Type for a relationship between two Content Types using the REST API? Not the actual relationship between two related contents but the Content Type for the relationship?

I have a compound content type that has a couple of related content types that I would like to be able to setup using the API so that it's not necessary to edit the relationship in the Web UI on a new installation before starting to migrate content (also via the API).

Best regards,
Fredrik Westermarck

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/585ec0ac-0947-4f47-9719-e41008e8109a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.

Jason Tesser

unread,
Jun 13, 2017, 6:56:46 AM6/13/17
to dotCMS User Group, de...@dotcms.com

I need to look it up later but o don't think you can create the relationship yet thick the rest. I thought you waned to create the content type on the other side of the relationship


Fredrik Westermarck

unread,
Jun 15, 2017, 5:47:52 AM6/15/17
to dotCMS User Group
Hi!

Yes, please hav a look if it's possible to create a Relationship Content Type using the REST API. If it's not possible are there an alternate way to create the Relationship Content Types e.g. using the Java API?

We were expecting to be able to automate the migration from our current CMS by creating Content Types and Content.

Jason Tesser

unread,
Jun 15, 2017, 7:15:34 AM6/15/17
to dotCMS User Group
It would take a little Java but wrapping our RelationshipAPI with a Jersey REST Resource is pretty simple.  You can do that

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.

Fredrik Westermarck

unread,
Jun 15, 2017, 7:51:58 AM6/15/17
to dotCMS User Group
Hi!

Could you point me in the right directions for the docs and if there are any examples? All I found was the Javadoc for the API and it was not too detailed. :)

Fredrik Westermarck

unread,
Aug 29, 2017, 8:04:04 AM8/29/17
to dotCMS User Group
Hi!

Does anyone have a working example on how to create a Content Type for a relationship between two Content Types using the Java API or some other method? Or point me to some documentation on how to get started? Any help in the matter would be greatly appreciated.

We're evaluating if we are going to use dotCMS as a successor for our current CMS. In order for us to develop a new implementation in dotCMS it's essential, and somewhat of a dealbreaker for us, to be able to automate the creation of content types (incl content types for relationships) and the content it-self since we have quite a bit of existing content that needs to be migrated.

Would the Java API be faster to handle content imports? The REST API seems to be rather slow with about 1 insert/sec. That's of course dependent on the HW but would the Java API bypass some of the SW-stack? We're currently using the binary distro for 4.1.1 with a local MySQL.

Jason Tesser

unread,
Aug 29, 2017, 8:55:51 AM8/29/17
to dotCMS User Group
Hi Fredrik.  I think the answer I gave in this thread is the right one. It actually ties into what you are asking. Yes I would use our Java API and you can deploy a warpper around the Java API as a REST End point. This is pretty easy to do and our plugin-seeds have examples for it 

Nathan Keiter

unread,
Aug 29, 2017, 11:04:43 AM8/29/17
to dot...@googlegroups.com
Once you get a RESTful service setup to accept JSON, your internal API calls might look something like this:


JSON to contentlet + related contentlets.

[cid:2ec2d0a4-ae47-45c8-9e8c-ac2766b0d726]


API wrappers:

[cid:bbfbaa98-f280-4511-ba86-12730511f8a0]


Nathan I. Keiter | Lead Network Applications Programmer | Administrative Advisory Council Member | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of Jason Tesser <jason....@dotcms.com>
Sent: Tuesday, August 29, 2017 8:55 AM
To: dotCMS User Group
Subject: Re: [dotcms] Re: Possible to create Content Types for Relationship via API

Hi Fredrik. I think the answer I gave in this thread is the right one. It actually ties into what you are asking. Yes I would use our Java API and you can deploy a warpper around the Java API as a REST End point. This is pretty easy to do and our plugin-seeds have examples for it
https://github.com/dotCMS/plugin-seeds/tree/master/OSGi/com.dotcms.rest
https://github.com/dotCMS/plugin-seeds<https://github.com/dotCMS/plugin-seeds/tree/master/OSGi/com.dotcms.rest>
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/3f8f2a5b-cff0-4041-a497-758e69db336e%40googlegroups.com<https://groups.google.com/d/msgid/dotcms/3f8f2a5b-cff0-4041-a497-758e69db336e%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/c838c698-51c1-4351-bc61-a59872ea1030%40googlegroups.com<https://groups.google.com/d/msgid/dotcms/c838c698-51c1-4351-bc61-a59872ea1030%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAKKUxWfYY7UpCgUGimHE_0kvgi%3DkDRyyosUMKh%2B%2B_b16e-UN8g%40mail.gmail.com<https://groups.google.com/d/msgid/dotcms/CAKKUxWfYY7UpCgUGimHE_0kvgi%3DkDRyyosUMKh%2B%2B_b16e-UN8g%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Fredrik Westermarck

unread,
Sep 4, 2017, 8:57:08 AM9/4/17
to dotCMS User Group
Hi Jason!

Yes, that's probably the best way to create and add the Content-Types if one needs to dynamically create Content-Types for relationships. In my case that's really not an issue since I don't require to create relationships other than in an initial migration from another CMS.

Out of curiosity I examined the starter application since it does what I need to do. The starter application that gets setup during the first start of a fresh dotCMS installation seems to have the desired functionality in place already since it creates Relation-Content types - but from an XML-file. The file that in the starter package contains relationships that are being created is com.dotmarketing.portlets.structure.model.Relationship_0000000000.xml.

A relationship definition in the file looks like this:
<com.dotmarketing.portlets.structure.model.Relationship>
    <iDate class="sql-timestamp">2017-03-09 22:58:24.331</iDate>
    <type>relationship</type>
    <owner></owner>
    <inode>30a7b43a-1935-4d5f-9f8b-22d72b26eb16</inode>
    <parentStructureInode>5a19371b-6b31-46d1-94db-8e100197cbb4</parentStructureInode>
    <childStructureInode>9cec8e2c-3bd7-4217-8149-0bd569abd00b</childStructureInode>
    <parentRelationName>LandingPage</parentRelationName>
    <childRelationName>Testimonial</childRelationName>
    <relationTypeValue>LandingPage-Testimonial</relationTypeValue>
    <cardinality>1</cardinality>
    <parentRequired>false</parentRequired>
    <childRequired>false</childRequired>
    <fixed>false</fixed>
  </com.dotmarketing.portlets.structure.model.Relationship>

Would it be possible to use the same mechanism, as in the initial startup of dotCMS, as a part of my migration process to create content-types for relationships?
Anyone that can point me in the right direction to what code is responsible for making the import in the starter package?

Jason Tesser

unread,
Sep 4, 2017, 9:05:26 AM9/4/17
to dotCMS User Group
I would directly use our Java API if you want to marshal the object and unmarshal it in a plugin that then takes the object and passes it to our Java API then that would be fine 

Fredrik Westermarck

unread,
Sep 4, 2017, 9:30:30 AM9/4/17
to dotCMS User Group
Hi!

But it seems to be a bit of unnecessary work to create an REST-endpoint if there already are functionality that does what I need. I have no requirement to create relationship content-types other than in an initial migration.
Reply all
Reply to author
Forward
0 new messages