I have a hook where to add an organization and few custom field variables (Expando Variables) automatically to a liferay portal. How do I run that hook or a method in the hook during liferay setup or the first time I start a liferay portal? Does anyone have any links or codes for this?
Thanks
To reiterate your requirement you need to do some custom actions when Liferay server is started, so from what I understand you need a startup custom action hook.
This is nothing but a simple hook where you would override some porperties from portal.properties and provide a custom action class like MyCustomStartupAction or MyCustomGlobalAction in that property and implement it.
In the user-guide here is a list of some properties you can configure: Startup Events
This SO Answer gives more information about creating a hook with such properties.
When you deploy that Hook (war file) into your server and restart it, in the (bin) logs, you could see one log statement which says that your particular Hook is available for use. This means your Hook has been successfully deployed into your Liferay portal.
To run the Hook or invoke a particular method inside your Hook, you need to invoke the flow for which your Hook was written.
For eg., if you have written a hook for logout.events.post= and if you want to invoke this, then you need to logout from your portal.
In your case you have written a Hook for registration. So, you need to do registration. Remember your Hook method should have extended Action class.
Related
From what I understand, from SAP Commerce Cloud 2005 onward the way to customize the REST-endpoints within SAP Commerce Cloud for Spartacus is to use commercewebservices (non-template) and then add own occ-extensions with your REST-endpoints.
That works fine for new endpoints, but what if I want to customize an existing controller from within commercewebservices? Since I am not using the template anymore commercewebservices cannot be modified anymore. I don't see a way how I could for example customize de.hybris.platform.commercewebservices.core.v2.controller.CartsController.
Swapping out commercewebservices with your own extension generated from the template does not work since multiple OOTB (e.g. cmsocc) extensions depend on commercewebservices hence it will always be loaded and clash with our own extension derived from commercewebservices.
Customizing commercewebservices with an addOn also does not solve the problem since, as I understand, it is not possible to add your own controller and bind it to the a url-pattern already used from a controller within commercewebservices
If you want to override an existing API endpoint (CartsController in our case), you can do so with the #RequestMappingOverride annotation.
Using this annotation, you can "shadow" the existing request mapping of the out-of-the-box controller with your custom controller in your own OCC extension.
You can find more details and an example here:
Overriding the REST API [help.sap.com]
EDIT
And let's not forget:
All of the action happens in the facades anyway, and you can also extend the API responses without overriding the Controller using the WsDTO concept plus additional converters. (see Extending Data Objects[help.sap.com] for more details)
Thanks for the response.
The annotation RequestMappingOverride works fine. There is one problem with this approach, lets assume I do following:
Introduce an new called MyController extending the CartsController
Override a single method and annotated this method with RequestMappingOverride
Starting up the system I do get now ambiguous mappings on all mappings of CartsController which I did not override
The reason is, I have now two Controllers registered with the same mappings. The CartsController and MyController which inherits all the methods which are not overriden from CartsController. The only solution I found is to override every single method of the CartsController, annotate all methods with RequestMappingOverride and then just do a super call. That is a bit clumsy and leads to a lot of boilerplate code. I wish the annoation RequestMappingOverride would work on class-level rather than only on method level
We are using Maximo 7.6.0.8. We need to route a workflow with RESTAPI json services. It can be with ROUTEWF action, or custom java class/automation script.
I was searching web for weeks but find nothing :(
Does anyone know how Maximo route a workflow? What is behind ROUTEWF action? And how can I manually start ROUTEWF action? Or how can I copy what ROUTEWF action do?
I have implemented a functional Liferay service using service builder and I want to call a method on the -LocalServiceUtil class just as soon as I possibly can. This is a task I wish to perform when the service starts and also when the service is redeployed.
Even though all the methods on the -LocalServiceUtil class are static, they will throw a BeanLocatorException if they are called too soon.
com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set for servlet context portal-navigation-impl
Is there any way to call a method on the -LocalServiceImpl instance or otherwise so that I can do this?
Thank you
As you speak about the initialization order: I'm not 100% sure about this, but I'd write a startup action. This gets run everytime a hook (or plugin) starts up - including a redeploy. Sounds like what you want - and if the initialization order works, this is your solution.
Otherwise: Create a separate hook that's dependent on the one that you're currently using. That will be restarted as well, but only run once the hook providing the *-LocalService did already start up. (dependency is declared in liferay-plugin-package.properties, with the key required-deployment-context - this is from memory - somebody correct me if I'm wrong.)
Following is my requirement :
Whenever site is created, with help of GroupListener we are adding some custom attributes to created site.
So assume that you are crating "Liferay Test" site then it will have some fix custom attribute "XYZ" with value set in GroupListeners onAfterCreate method.
I can see this value in custom fields under site settings.
Now based on this values, we are creating groups in another system(out of liferay, using webservices).
So far so good.
Whenever we are deleting the site we need to remove the equivalent groups from other system via web service.
But while deleting site, in GroupListener we are not able to retrieve the custom attributes.
On further debug by adding expando listener, I observed that Expando listeners are getting called first and then delete method of GroupLocalService/GroupListener.
And hence we are not able to delete the groups present in another system.
So I was wondering if we can have ordering defined for listeneres.
Note: Since we were not getting custom attributes in listeners we implemented GroupLocalServiceImpl and with this we are getting custom attributes in delete method on local environment but not on our stage environment which has clustering.
You shouldn't use the ModelListeners for this kind of change, rather create ServiceWrappers, e.g. wrap the interesting methods in GroupLocalService (for creation as well as deletion).
This will also enable you to react to failures to create records in your external system etc.
I have a project built on top OSGi and Karaf server. For dependency injection we are using Aries Blueprint.
The main part of the project is a Apache Camel routes and integration things, but now I need to create some maintenance web interface.
So I give a try to JSF - PrimeFaces implementation. I was able to create some demo, which works in OSGi under Karaf, that's ok.
Now I'd like to know if it's possible to use Blueprint here, to reference some already existing OSGi services we have and inject the service into JSF Bean, so we can benefit from already written code.
Can you help me, please?
We solved this in the following way:
We created a listener that:
Creates a ServiceTracker that tracks the BlueprintContainer service attached to the same bundle
Puts the servicetracker into the ServletContext attributes
We created an ELResolver that uses this ServiceTracker and if there is a BlueprintContainer available it uses the getComponentInstance of that to get the value
The listener opens the servicetracer during application initialization and closes it during application destroy
Our listener class: https://source.everit.biz/svn/everit-util/trunk/core/src/main/java/org/everit/util/core/servlet/ServiceLoaderListener.java
Our EL resolver class: https://source.everit.biz/svn/everit-util/trunk/core/src/main/java/org/everit/util/core/el/OsgiELResolver.java
User/pass: guest/guest
After you registered your custom el-resolver all el-expressions will be evaluated in the way that id-s of component instances will be searched inside the blueprint container. In case you say that you have a bean-property in your faces-config.xml with the value #{myComponent} it will be searched inside the BlueprintContainer.