Question about importing docType's using Packaging Service

57 views
Skip to first unread message

Aaron Powell

unread,
Sep 3, 2015, 6:40:00 PM9/3/15
to umbra...@googlegroups.com

I recently came across a problem with importing Document Types (well, “Content Types”) using the PackagingService API. What I’ve found is that if I import a single DocType that has structure (allowed children) those children aren’t imported.

 

Looking into the code you’ll find this – https://github.com/umbraco/Umbraco-CMS/blob/72d4457a248529c724825ea16d86e7e2dccfe400/src/Umbraco.Core/Services/PackagingService.cs#L413-L430

 

In my code I am passing in the `importStructure` flag as true, but still they don’t import. Digging a bit further into the `UpdateContentTypesStructure` method what I found is this:

https://github.com/umbraco/Umbraco-CMS/blob/72d4457a248529c724825ea16d86e7e2dccfe400/src/Umbraco.Core/Services/PackagingService.cs#L682

 

I got to wondering where the value of `_importedContentTypes` comes from and I found it back in the first method:

https://github.com/umbraco/Umbraco-CMS/blob/72d4457a248529c724825ea16d86e7e2dccfe400/src/Umbraco.Core/Services/PackagingService.cs#L338

 

What seems to be the problem is that when you import a DocType the structure it understands can only come from the other DocTypes that were imported at that same time. Basically you can’t import a DocType and have an allowed child of a DocType that is already in your CMS.

 

Now, I think I understand the rationale behind this, that a Package should be entirely self-contained so you can’t depend on something that might not exist, but at the same time I’m often using a bunch of small packages as building blocks to create a site.

 

I’m happy to work on a PR for this, but I wanted to first ask about it before I invest time on something that is by-design and I’m essentially using the import engine “wrong”.

 

Aaron Powell

unread,
Sep 3, 2015, 6:48:23 PM9/3/15
to umbra...@googlegroups.com

Just having a look into uSync and how it handles it - https://github.com/KevinJump/jumps.umbraco.usync/blob/ffed68ebd7e66f576cf34a0fb7da042d13b65440/jumps.umbraco.usync/SyncDocType.cs#L240-L277

 

Seems like they do a 2nd pass to fix the structure, which is what I was thinking to do.

--
You received this message because you are subscribed to the Google Groups "Umbraco development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to umbraco-dev...@googlegroups.com.
To post to this group, send email to umbra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/umbraco-dev/SIXPR01MB0541F428177ACF3188472A55EE680%40SIXPR01MB0541.apcprd01.prod.exchangelabs.com.
For more options, visit https://groups.google.com/d/optout.

Morten Christensen

unread,
Sep 4, 2015, 3:36:00 AM9/4/15
to Umbraco development
Yes, the idea was that a package import should be self-contained. That being said I think it would be fine to load a list of DocTypes that are already available, and use that as well (or combined) when doing the checks against what already exists.

If Shannon and Stephane doesn't have any objections or concerns I think a PR would be greatly appreciated.

- Morten

Shannon Deminick

unread,
Sep 4, 2015, 6:33:40 AM9/4/15
to Umbraco development
Sounds good to me
Reply all
Reply to author
Forward
0 new messages