Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Carl Bussema 38 posts 140 karma points
    Feb 09, 2016 @ 19:25
    Carl Bussema
    0

    Courier: Custom Handler, Dependency, Resource

    I'm writing a custom handler for a datatype that stores references both to other nodes (by integer Node ID) and media object (also by integer Node ID), wrapped in some JSON with some other properties.

    I have no trouble getting my handler to run and found it easy to just convert the int IDs into a GUID when packing and reverse that conversion when extracting. The question is, are media files supposed to be dependencies or resources?

    The documentation really doesn't explain clearly what the difference is; so I've just been using item.Dependencies.Add(mediaGuid, ItemProviderIds.mediaItemProviderGuid); Is there any particular reason to use item.Resources at all? It seems to work correctly without any calls to item.Resources.Add(), but I don't know if that's just getting lucky or what.

    Also, in debugging the code, I notice that

    public override void PackagingProperty(Item item, ContentProperty propertyData) gets invoked 3 times with the exact same arguments (there's only one use of the particular data type on this page anyway, and I haven't chosen "include all nodes below this.").

    I have two custom Providers, and when I put breakpoints on their PackagingProperty calls, I see

    Foo.PackagingProperty()
    Bar.PackagingProperty()
    Foo.PackagingProperty()
    Bar.PackagingProperty()
    Foo.PackagingProperty()
    Bar.PackagingProperty()
    

    In all 6 cases, Item is the same, and across the three Foo's the propertyData is the same, likewise the 3 Bar's all match on their propertyData.

    During extraction, each ExtractingProperty() is called only once. Foo, then Bar. Again, this all seems to work, but I'm trying to diagnose a problem where Courier sometimes creates a duplicate copy of the node I'm trying to transfer, which then breaks all subsequent transfers. Seemed like my custom handlers were a good place to start, but I don't see anything overtly wrong with them. Is there any explanation for why Courier invokes PackagingProperty() three times per property?

  • Alex Lindgren 158 posts 355 karma points
    Feb 15, 2016 @ 21:06
    Alex Lindgren
    0

    If I understand correctly (which might not be the case), Resources are for adding files (such as Javascript files) while Dependencies are adding Umbraco nodes.

  • Carl Bussema 38 posts 140 karma points
    Feb 15, 2016 @ 21:15
    Carl Bussema
    0

    That was my first impression, but media seems to be a little odd in that it's both the Umbraco Node and the filesystem object. Adding it as a dependency seems to work; it adds the media metadata and transfers the file. So I guess it's "dependency for nodes, resources for files that are not nodes."

    Now if only anyone could explain why PackagingProperty() gets invoked multiple times...

Please Sign in or register to post replies

Write your reply to:

Draft