Get parent page node for component in magnolia - magnolia

I configured a listener in the magnolia observation module that uses info.magnolia.module.observation.commands.RestrictToNodeTypeEventListener for mgnl:component node type. When a NODE_ADDED, NODE_MOVED, NODE_REMOVED, PROPERTY_ADDED, PROPERTY_CHANGED and PROPERTY_REMOVED event happens on the mgnl:component it triggers a custom command class.
In the custom command class the node is of type mgnl:component and the path is for example: node at path /aalongpubname/de/test-page-for-observer/content/01 but I need to get the parent mgnl:page node for it (ie. /aalongpubname/de/test-page-for-observer). The component could also be nested ie. not at the first level. What is the easiest way to do this?

I believe one of the way to do this is: NodeUtil.getNearestAncestorOfType(node,"mgnl:page").getName()

Related

Listenerconfigurations in the observation module of magnolia - best practices question

I would like to trigger a custom command that extends BaseRepositoryCommand when someone adds, removes or changes a node or property for mgnl:page, mgnl:area and mgnl:component node types.
I was thinking of using the magnolia observation module for this. Do I have to create separate listenerConfigurations for each node type and event type? In my case it would be 6 event-types for 3 node-types or 18 different
listenerConfigurations. Does that have implications on performance?
Please have a look at: info.magnolia.cms.util.WorkspaceObservingManager
There you can use the method #registerChangeListener which you can specify the workspace you want to observe as well as the list of node types you wish.
Performance-wise, it should be smooth since it uses directly JCR observation mechanism under its hood.

How to make RSS Feed Generator for ASRP Blog Posts in AEM 6.2

Am looking for generate RSS feed from ASRP blog Posts from AEM to Integrate in Third Party Plugin,
does AEM have any OOTB solution for this ?
or we need to create a custom RSS feed generator ?
any help would be appreciated.
Thanks
As per the Adobe Forum Thread, RSS OOTB feature is currently unavailable for AEM 6.1/ 6.2 Communities. So, you can create custom polling importer and do your stuff.
To create custom importer:
You need to define two properties in your importer class:
You can write your custom code in the overridden method.
When this service is deployed in AEM instance, your custom importer can be seen in the dropdown of the polling configuration.
Polling configuration has a dialog, which you need to fill while creating your polling nodes. The below diagram shows how values given in config dialog mapped to node properties and then to importData() method:
The importData() method of custom importer gets the value of its parameter from this configuration. Thus you need to specify these properties in the dialog:
Type: It defines feedType property of poll config node.
URL: It defines feedUrl property. This mandatory field defines the source( or xml) to read.
Import to path: It is the path where nodes needs to be created. It defines target property. This path is resolved to a resource and is passed in importData(). If target value is not provided, path of the configuration node is resolved.
Update Interval in Seconds: It tells after how many seconds it needs to poll. Its default value is 1800 and minimum value is 300. It defines interval property of pollConfig node.
There is one more property in pollConfig node i.e. source which is concatenation of
<feedType>:<feedUrl>
After poling nodes are created, it will fetch your feeds from the given URL and store it in the targetted path.

Why does the error occurs then I try to utilize pzRDExportWrapper in Pega 7.1.8?

I have a task to export a repeat grid's content to Excel. I have read an
article, but I still can't realize how to properly use it. I tried to repeat article's steps to provide pzRDExportWrapper, but after I click "Save" button I get the error:
Method: Rule-Obj-Activity instance not found:
Sb-FW-CTrackFW-Work.pzRDExportWrapper. Details: Invalid value for
Activity name passed to ActivityAssembler.
Could anybody give me any suggestions? Thank you.
You invoke activity from another activity which applies to class Sb-FW-CTrackFW-Work. Rule Resolution use primary context Sb-FW-CTrackFW-Work class and try invoke activity pzRDExportWrapper from it and you get error (because rule resolution can't found invoked activity in this class).
Activity pzRDExportWrapper applies to Rule-Obj-Report-Definition class. Try invoke from it.
Try activity step as below:
Call Rule-Obj-Report-Definition.pzRDExportWrapper
Or use step page for this step which defined as applies to Rule-Obj-Report-Definition class(you can declare it on Pages&Classes tab)
Okay. I have resolved the issue (thank you njc). I have two sections on a lone web page.
A context of the first section is my custom data page Co-Name-FW-Data-Search. The Search page has some single value properties which are initialized by an user via an UI.
The second section is a repeat grid section, a report definition as a source. My Search page pointed out in a Pages and Classes tab. Also there is a Page, which is created by report definition and contains results. The report definition takes Search’s values as parameters.
So, I have created an activity and passed the Search page and a Cods-Pega-List MyResultList as parameters. There are some steps in the activity:
Check if Search is null. If true- skip step; else - transfer Search properties into Params props with Data Transform.
Set Param.exportmode = "excel"
Call pzRDExportWrapper with Step Page MyResultList.pyReportDefinition. Pass current parameter page.
P.S.: If it doesn’t work try to play with report definition’s settings.
P.P.S.: An only minus of pzExportWrapper is that it invokes report definition again.

how to implement source filter property page?

I have followed the instructions at http://msdn.microsoft.com/en-us/library/windows/desktop/dd375010%28v=vs.85%29.aspx to create a property page for my CSourceStream based stream.
When testing with amcap I can see that amcap now shows the menu item to show the capture pin properties (ISpecifyPropertyPages::GetPages is queried). The problem is that when amcap calls OleCreatePropertyFrame it returns with E_FAIL and I am not sure why, it does not seem to even get to the stage of quering my dll for the factory method to instantiate the CBasePropertyPage based property class.
The problem was my DllRegisterServer only registered my filter.
I can use AMovieDllRegisterServer2 to register all components in g_Templates but that function does not register source filters properly so for the moment I am just calling AMovieDllRegisterServer2 and then re-registering my filter with source filter specific code.

Prevent deletion of folder (type) in Plone unless parent is being deleted

I want to prevent deletion of instance of a folderish type in Plone, excepting when a parent folder is being deleted. I have a hunch that an event handler can prevent deletion (raise an exception in an IObjectRemovedEvent handler bound to a marker interface), but implementing the exception to this rule seems harder to pin down: I want to allow deletion of the item when its parent folder is being deleted.
My initial hunch was that I could traverse __parent__ pointers and check if an attribute was set on the parent (or some distant indirect container) that it was being deleted, but I am not sure how I would set this attribute on deletion of the parent prior to an attempt to delete the contained child (otherwise not allowing deletion). So now, I'm questioning whether I am approaching this the right way? Am I misunderstanding the problem constraints for deleting objects in Plone? Should I look to plone.app.linkintegrity source to borrow tricks?
My use case: a "settings folder" inside a "project" folder -- intrinsically, the settings folder should never be allowed to be deleted unless the project folder itself is being deleted. I guess I'm asking for referential integrity for a very-specific containment relationship.
How would you prevent deletion of an object except in the case it was being deleted as a direct result of its parent being deleted?
After a fair bit of time, I have finally found a solution to this general problem (but in a different context):
Create a subscriber on the parent for the parent's interface and OFS.interfaces.IObjectWillBeMovedEvent.
That handler should use zope.globalrequest.getRequest() to get the request object, and adapt that to IAnnotations to get an annotations object on the request (a global for the duration of the request, in practical terms).
The IObjectWillBeMovedEvent handler will save a tuple form of the physical path tuple(context.getPhysicalPath()) on the annotation object.
The event handler for IObjectRemovedEvent attempting to block deletion of the child item will pass if its path shares a base path of the parent (see example).
By consequence, an exception is only raised if an attempt is made to delete the object itself, but not when its parent is deleted.
See example: http://bazaar.launchpad.net/~upiq-dev/upiq/dev-uu.formlibrary/revision/113

Resources