AnsweredAssumed Answered

content rule fails to trigger after nodeService.createNode

Question asked by chatch on Oct 3, 2007
Latest reply on Nov 28, 2008 by erik.kirs
I have a rule on a folder that transforms any new content that is RTF into HTML. If I add content via the web client using 'Add Content' it triggers fine. However from the following code snippet it fails to trigger:


        NodeRef typeNodeRef = nodeService.createNode(
                typeParentRef,
                ContentModel.ASSOC_CONTAINS,
                QName.createQName("{http://www.alfresco.org/model/content/1.0}"
                        + filename), typeQName, properties).getChildRef();
        logger.debug("created type with ref=" + typeNodeRef);

        ContentReader contentReader = contentService.getRawReader(contentUrl);
        contentReader.setMimetype(reqParams.get("mimetype"));

        ContentWriter contentWriter = contentService.getWriter(typeNodeRef,
                ContentModel.PROP_CONTENT, true);
        contentWriter.setMimetype(reqParams.get("mimetype"));

        contentWriter.putContent(contentReader);

The code is run in a WebScript (inherits from DeclarativeWebScript).  Also the folder that the rule is on is created from a space template in the same web script but I don't believe this should be a problem?

I can actually pull back the rule and action programmatically and invoke it to get it to work but obviously this is not ideal… 

Has anyone seen something like this or have any idea what I can try?

Outcomes