Publish/Unpublish Adobe AEM page from Java - java

We have background process that automatically creates AEM pages as well as deletes old AEM pages. For pages to appear/disappear on the published site, they need to be activated (Published) / deactivated (Unpublished).
However, after searching from Google, I am not able to find AEM Java API that can publish/unpublish pages automatically.
Where can I find information on how to do this?

what you are looking for is the Replicator api. ReplicationActionType decides if you want to activate or deactivate.
replicator.replicate(session, ReplicationActionType.ACTIVATE,path);
replicator.replicate(session,ReplicationActionType.DEACTIVATE,path);
You can obtain Replicator instance using the #Reference annotation inside your OSGI service.
#Reference
Replicator replicator;

Have you thought about running the same background process on the publisher instead of activating/deactivating the pages?
I mean in case for some reasons your process fails during activation/deactivation you need to handle it and make sure that your publishers are still in a consistent state.

https://aem.redquark.org/2018/10/day-19-replication-api-in-action.html
Please refer this reference looks to be good and moreover if you want to deactivate you can use
replicator.replicate(session, ReplicationActionType.DEACTIVATE, path);
log.info("Replicated:---- {}", path);

Related

(GAE-Standard+Java11) Sessions with multiple instances running

I have deployed my spring boot application on GAE, Java 11, Standard Environment. As per the documentation for Java11 we need to use app.yaml for configuring the instances.
I wanted to know as to how I can enable sharing of sessions between instances. As per my research, Earlier we could simply solve this problem by setting sessions-enabled and async-session-persistence in appengine-web.xml. With appengine-web.xml gone, what is the equivalent way of doing this in app.yaml.
Use case that i am trying to achieve is :
Using spring security (Unfortunately i get logged out when according to me the request of the same user goes to another instance.)
Storing the user retrieved from DB in a #SessionScoped variable so as to avoid multiple DB calls.
Any help here would be really appreciated. Thanks!
I went through a lot of documentation, but I believe that this is not inside the app.yaml configuration reference.
Alternatively, I could find that you could use session affinity in order to use a instance to reply always the requests of a same user, this can be enabled in your app you can use the next tag in your app.yaml according to this documentation.
network:
session_affinity: true
Hope this works for you.

Is it possible to create a custom form in Camunda BPM changing "on-the-fly" without re-deploy?

I'm new to Camunda and still trying to figure out what things are possible.
Camunda BPM provides at least three ways to create custom forms:
Web-based form using AngularJS https://github.com/camunda/camunda-bpm-examples/tree/master/sdk-js/browser-forms-angular
Web-based form using JSF https://github.com/camunda/camunda-bpm-examples/tree/master/bpmn-model-api/generate-jsf-form
Embedded task form using several mechanisms https://github.com/camunda/camunda-bpm-examples/tree/master/usertask
I suppose I can customize a form any of those ways, but I wonder if I can create "on-the-fly" customization based on a pre-defined template stored in a database.
For example, I have a process of handling customer requests. They usually want something from three categories: A, B, and C.
FormA, FormB, and FormC are different but having typical fields for those kinds of requests.
Is there any way to add FormD in Camunda without re-deploy and changing source code of the task/process?
I mean just add a template of FormD in the database and see changes on the next process start.
Best regards, Ivan
You can bundle process models and custom html template in a deployment and hot deploy it together. No server restart required.
You can do this via Cockpit (if EE) or REST API:
https://docs.camunda.org/manual/develop/reference/rest/deployment/
One possible way to do that is through custom form builder using external service form.io - https://forum.camunda.org/t/form-builder-drag-and-drop-form-server-validations/1092/14
Based on the answer from Camunda BPM forum: https://forum.camunda.org/t/is-it-possible-to-create-on-the-fly-changing-form/20683
So, theoretically it's achievable I assume.

Calling a REST service using business central and JBPM

We're trying to do a POC showing we can call an external REST service using JBPM in business-central.
We've created a new BPM, then added a REST service task. We notice at this point that a WID file is created that has REST definition. Inside the WID file, it defines things like URL, Method, and authentication.
We've sifted through all the 7.2 docs, but for the life of us, we cannot figure out how to actually set those parameters and do something useful. Does anyone have a simple "Hello World" using business central 7.2 calling out to an external process?
We see there's a predefinied REST handler: https://github.com/kiegroup/jbpm/blob/master/jbpm-workitems/jbpm-workitems-rest/src/main/java/org/jbpm/process/workitem/rest/RESTWorkItemHandler.java
We're lacking how to assemble all of this; we can't find documentation or examples on something that seems so simple.
Thank you!
If you're using Busines Central, you can edit the process model and check the data assignments for the specific REST node. In there you can set the values of the variables or use some process variable to map dynamic values. Hope it helps.

Workflow LockProcess AEM - Not locking the asset/page

I have a custom workflow for which the first step is default AEM "LockProcess". But somehow the asset/page not getting locked.
I have initiated the workflow as an admin and I'm using AEM 6.2
27.07.2017 13:16:09.994 *INFO* [JobHandler:
/etc/workflow/instances/server0/2017-07-25/workflow_name:/content/project/en-
us/test-general] com.day.cq.workflow.impl.process.LockProcess Locking is not
currently enabled. This is a No-Op
The same happens for "UnlockProcess".
Am I missing something here?
Thanks!!
You can enable locking of the payload in the "Day CQ Workflow Service" configuration.
Based on comments from Adobe Forum, I found there is a property
cq.workflow.service.allow.locking that should be enabled in CQWorkflowService.
Unfortunately, I could not find CQWorkflowService in http://localhost:4502/system/console/configMgr.
Digging further I found this website Missing Service that list all missing the hyperlinks for factory service and components of AEM 6.2.
Finally, I was able to initiate the default Lockprocess.

debugging in struts application

i'm new to struts... I have a struts form. i need to analyze the data posted to an action class. i just want to output the data to a page and stop further execution so as to test of it is working correctly... how is it done..?
There are many ways to debug a struts application:
Configuration Plugin: You can use configuration plugin provided by struts. To use this plugin include struts2-config-browser-plugin-x.x.x.x.jar jar in your classpath and then you can use
">Launch the configuration browser
anywhere in your application to view a lot of detail about the action class.
The second way is to use Debugging Interceptor by using property debug=true in struts.xml.
See the below link for more details:
http://struts.apache.org/release/2.2.x/docs/debugging-struts.html
The easiest way to quickly and thoroughly inspect http requests and responses and post data is to use either:
http-fox with firefox (download)
chromes' network inspector (pre-installed with chrome - ctrl-shift-i - Network - Click on the appropriate post request and the body of the post will be displayed)
If neither of these very easy tools appeal, you'll have to find the appropriate hook to attach your debugger. I've not used struts since 2002 so cann't advise.
The best method is to use System.out.print and get the result in the tomcat console... i had said i need on server side not client side.

Categories