CQ5: disable an ObservationListener during package upload - aem

I have an ObservationListener that does a few things when an author adds/deletes components from a parsys in /content. The problem I'm running into is that the same events I'm listening to, fire whenever a package is installed (and that can get costly). I would like a way to either edit the package manager workflow to disable my service, install the package, then renable the service when the package is finished, or differentiate a package install from a node being edited and ignore them in my listener.
Alternatively, I'm curious if there is an import/install queue of some sort that I could watch so --- if my event is fired and the queue is full/still has items to install, wait until the queue is empty, then continue on with my event handling.
thank you

I don't think Sling or CQ provide events to let you know when things are about to be installed.
If it's JCR events that you are listening to, you might use Event.getUserID() to find out who's changing content and differentiate between admin (or whichever user is used to install content packages) and regular users. But note that if you later switch to an Oak-based content repository there are some limitations with this, see http://jackrabbit.apache.org/oak/docs/differences.html

Related

Forced to make intents global when used as custom intents in scenes

I'm currently migrating from Dialogflow to Actions Builder, things have gone well so far however after adding custom intents to my scenes the test simulator prompts me with the warning "Intent 'intent_name' is used as an action, but not added as a global event." blocking my ability to test the action until I configure the intent as global.
Since configuring intents as global enables implicit invocation it seems inappropriate to apply it to all intents, especially those which have no business being accessed implicitly.
Has anyone experienced this warning? Any tips to get past this error without configuring the intent as global?
Cheers
Additional info on scenes and deep link actions:
On enter -> Welcome intent:
Enter condition: Call 'Welcome' webhook.
User intent handling: When 'intent_name' is matched -> call webhook 'intent_name'. No transition, no web based send prompts.
Launch test simulator, try to enable test, get prompted to make 'intent_name' a global event.
Within the intent, 'is this a global event' no is selected as it's mid conversation not suitable for implicit/deep-linked entry. No errors/warnings reported in the sdk for the intent.
Additional project info:
Initially created the project last year by using the built in migration tool; migration efforts stalled as the test simulator ran into other issues which eventually resolved themselves https://github.com/actions-on-google/assistant-conversation-nodejs/issues/9
After the above blockage I had continued Dialogflow development, so a new migration was necessary due to significant changes. Rather than use the built in migration tool I chose to delete the previously imported intents & types then manually imported the data using the Gactions CLI tool.
Perhaps it'd be easier to just use a new Google project? I don't see any misconfiguration in the intent nor scene, so perhaps the project is corrupted somehow?

Start an application at system start without login

We have a new server running and we got some new programs doing import routines. So far so good... But there is one program that is put into autostart folder. So it doesn't run until admin logs in and it stops if we logout.
I'd like to put this one into a seperate session so it may work without any interaction by simply starting it with the task scheduler at startup. Is this the right way to do this? Is it safe if I log in later and log out?
Many thanks!
Edit: The applications shows as a symbol in the task bar if running, it can be configured by this. Anything I must know about this if I change?
Edit: It is not my application, I cannot rewrite it as a service.
I successfully added the application by using task schelduler on startup. Login and logout will not quit the application but no symbol is shown. Please add details to my side questions and I'll mark your answer as the accepted one.
Edit: Ended up using this one. If I have to configure, I stop the application in task manager and start it again by link. After that I quit the application and restart it by task scheduler manual start.
You need to run your program as a Windows Service. One way of doing it is using the sc.exe program:
> sc create <new_service_name> binPath= "c:\myapp\myapp.exe"
You can read about it here.
You need to separate your application in two.
To allow it to run without a user session, you need a windows service. That should handle all the background stuff. You can then register the service and set it to start when the system starts.
To allow it to have a UI, and show up in the notification area, you need a windows application. This will be in autostart as usual, and will communicate with the service - for example, over named pipes.
While it is still (barely) possible to run an UI application without a user session, it's only maintained for backwards compatibility, and already shows a lot of problems. It will likely be removed altogether in the future, because it breaks quite a few contracts. Do not rely on hacks like this.
I also used the task scheduler to create the application at system startup. It should be noted that if you want to use for mining, you have to disable an option in "settings" where it says that if the application lasts more than three days in a row it will end.
It really works wonderfully!
it is a old question but I recently solved in another way...
(before I was using a scheduled-task for startup but this gave me diverse problems with lots software...)
Some programs also for diverse reasons must be run at a user level... or even inside a specific user session...
So the best way I found was to use a tool like Sysinternal/Autoruns to program the auto-logon to a specific user (it is a registry setting)... and in the startup-folder of that user (or any other "autorun/autolaunch" task)... run a script that first locks the screen... and next runs the other intended programs... that will run under that user profile...
so you can choose a standard user or a administrator... or even launch programs from a standard user in adminsitrator mode...
I hope will help...
This "hack" solved me many problems with startup apps...
I could not get the "sc create" command to work. Instead I manually edited the registry using regedit. I added a new key in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services.
I used the following page to figure out required parameters and their values. Note that the names do not map.
https://learn.microsoft.com/en-us/windows-hardware/drivers/install/inf-addservice-directive
Old question, but for anyone that stumbles here. Use srvany to set the program as a custom service.
Note that when you do this with for example dropbox, googledrive, etc., you will need stop the service, then open the program normally to make changes like password, updates, etc.
below is a well enough intro.
https://www.iceflatline.com/2015/12/run-a-windows-application-as-a-service-with-srvany/
Download the tool kit here
https://www.microsoft.com/en-us/download/details.aspx?id=17657
Convert user application to Service and Register it using Regsvr32 or installutil.exe. It will start the service using SYSTEM user account. Which is a high privilege account.
Note : You can`t run any Window based application. Even a Message only window.

Queue of workflows' launchers

I am working on AEM6, but this problem is also applicable to previous version of the platform.
I have noticed that default workflows "DAM Update Asset" and "DAM Parse Word Documents" are started by launchers /etc/workflow/launcher/config/update_asset_create and /etc/workflow/launcher/config/parse_word_docx_create. These workflows are always started in the same order (parse word docx is started after update asset create). I wanted to implement similar functionality, so I created my own workflow with one process and then created launcher very similar to docx parser launcher.
The problem is that my launcher starts before default DAM Update Asset workflow. Is there any way to set an order of the launchers?
I would suggest trying to avoid depending on this behavior. Instead, why not invoke your processes as part of the DAM Update Asset workflow?
You Can use the Process Step inside one workflow, and on the basis of completion of one task you can invoke other workflow from inside it. Please Refer this Answer : CQ5 Programmatically Run a Workflow .
Thanks

Is there auto-syncing in netbeans for external changes

I know netbeans syncs the original files once I save, but if there is a file changed externally is there a way for netbeans to recognize this and either tell me to re-sync it or automatically resync it with the new changes?
Here's what makes this behavior possible:
NetBeans 6.9 contains a feature that automatically looks for external changes to keep informations about files up-to-date. We have some reports that it can slow down NetBeans mainly, when an open project has many folders. When NetBeans find out that files were externally changed, it re-scans the files to keep data up-to-date that are used with features like code completion, navigation etc. Unfortunately the notification and following re-scanning can take some time and during this time many mentioned features are waiting for the finishing of scanning. There is option Enable auto-scanning of sources that can switch off this behavior. The option you can find it in Options dialog, Miscellaneous category and Files tab.
The default behavior is that NetBeans also looks for external changes when the main window gets focus. This is can be during developing a web application very often when user switches between browser and IDE. The mentioned option also switch this off.
When you switch off option Enable auto-scanning of sources you can still keep the information up-to-date, just invoke Scan for External Changes action from Sources menu manually.
(Here's the original article by Petr Pisl)
I find it counterproductive to leave this setting on, as sometimes auto-loading external changes to a file opened in the UI without asking for permission first can ruin your day when you're forced to make small local changes that you don't want replicated in your repository. I'm sure other people can think of more reasons to advocate for "warn before loading external changes" behavior to be implemented in NB. That is one of the reasons why I like Eclipse better sometimes.

What's the best way to get Eclipse users to regularly update a plugin?

I'm going to be distributing a plugin that will be routinely updated with features, bug fixes, and updates to downloadable corpuses.
The usual update site mechanism can do the update ok - when the user asks it to.
The problem is that (unlike MS Office), the automatic updater preference is off by default and I don't want to change that default for my users or count on them changing it.
Can I write something that occasionally checks for updates? Or prompt the user regularly? What's bad form and what's acceptable ?
Eclipse 3.4 check automatically for plugin updates by default.
You will see a popup window in the bottom right when an update is available.
To configure automatic updates, go to Window > Preferences > Install Updates > Automatic Updates
The absolute sure fire way is to make sure that your updates are compelling. The user will do the rest