Copied to clipboard

Flag this post as spam?

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


  • M 40 posts 273 karma points
    Jul 25, 2017 @ 13:48
    M
    0

    Examine PDF with Media Protect problem

    Hi Richard,

    I'm having a problem, possibly related to the IsProtected issue, and I'm hoping you can help.

    I've just installed the package via nuget and I'm trying to use it with ExaminePDF to add allowed groups into the index. The problem is, whenever my code hits IsProtected it just sort of kills the examine index without a real error.

    My Code:

    void ExamineEvents_GatheringNodeData(object sender, IndexingNodeDataEventArgs e)
    {
        if (e.IndexType == "media")
        {
            AddMediaProperties(e);
        }
        else
        {
            AddToContentsField(e);
        }
    
    }
    private void AddMediaProperties(IndexingNodeDataEventArgs e)
    {          
        int nodeId = int.Parse(e.Node.Attribute("id").Value);
        string path = e.Node.Attribute("path").Value;
        bool protectedTest = Library.IsProtected(nodeId, path);
        e.Fields.Add("_Test", "true");
    }
    

    As soon as it's assigned protectedTest once it dies, and my index contains no results. If I comment out that line it works and _Test is added to the index.

    I get the same result if I use IsProtected in an if statement. Using breakpoints I can see it gets to the If then stops - if won't go into the if or the else clause.

    All help welcome. Thanks in advance

    *EDIT: I did some more testing and I'm getting A first chance exception of type 'System.ArgumentNullException' occurred in System.Web.dll

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jul 26, 2017 @ 05:15
    Richard Soeteman
    0

    Hi,

    MediaProtect is using UmbracoContext which is using HttpContext to get to the services. It seems that this is not available in the Examine indexing process.

    Best to request isprotected etc at runtime.

    Best,

    Richard

  • M 40 posts 273 karma points
    Jul 26, 2017 @ 10:33
    M
    100

    Hi Richard,

    Thanks for your reply. I've got around the problem as you suggested - I've injected the ID and Path so I can filter at runtime*. However, ExaminePDF doesn't seem to be indexing the protected files. Is that something your aware of, or am I doing something wrong? I've set the indexer to supportProtected="true" not sure what else I can do?

    Thanks

    *For anyone looking for an answer:

    void ExamineEvents_GatheringNodeData(object sender, IndexingNodeDataEventArgs e)
    {
        if (e.IndexType == "media")
        {
            AddMediaProperties(e);
        }
        else
        {
            AddToContentsField(e);
        }
    }
    private void AddMediaProperties(IndexingNodeDataEventArgs e)
    {
        string nodeId = e.Node.Attribute("id").Value;
        string path = e.Node.Attribute("path").Value;
    
        e.Fields.Add("id", nodeId);
        e.Fields.Add("path", path);
    }
    
  • M 40 posts 273 karma points
    Jul 26, 2017 @ 13:52
    M
    0

    Hi Richard,

    More testing and I've found ExaminePDF and Media Protect ARE playing nicely together, but the ExaminePDF index doesn't store/search the file name (which is what I was testing).

    Thanks for helping me resolve the original issue.

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jul 27, 2017 @ 06:30
    Richard Soeteman
    0

    Great to hear it's solved!

Please Sign in or register to post replies

Write your reply to:

Draft