Spring boot starter cache working concept - spring

I have implemented spring boot starter cache using #EnableCaching annotation in main method and #Cacheable(value="allproductCache") in the service layer.
I have one doubt, is this cache is user level or application level? let suppose i add some new product and that all product list with new product should be visible to UI in productlist whoever is logged in to that application.
So for do that what i am thinking is to clear the server cached when anyone is adding a product so a fresh getallproduct request will hit and get the updated product list but i wanted to make sure that it is application level if i clear the cache using cacheManager.getCache(name).clear(); should able to clear the server cache and can be reflect to all user who are logged into the application.

Related

Saving and retrieving menus in database and filter their display in thymeleaf and spring boot

I would like to create a spring boot application where navigation menus would be saved in MySql database and retrieve them from DB and displayed on a web page after user is logged in and based on his/her application roles. These menus should be on any page the user is allowed to access. I'm new to spring boot framework and would like to ask any good man/women to point me to a very good tutorial to accomplish these tasks. If spring boot has a different approach to create the requested dynamic navigation menus l'm eager to learn that approach.
I'm greatful in advance.
Many thanks

Too Much Overhead with Firestore and Spring Boot JPA repository

I'm working on my own personal project of a JIRA-like ticket tracker that I can use for my own projects. I've decided to use the GCP stack and have a Vue.js frontend hosted on firebase and a Spring Boot App Engine backend.
I was originally thinking of having a firestore with the project, and this is where I will keep track of the tickets. I was then going through the firestore on the App Engine start and setting up a JPA repository with all tickets currently in there. Any creation or modification of tickets will go from the frontend UI -> spring boot repo -> update the firestore. I have created an Entity/Class called Ticket which is what I am using to store all the data for each document from firestore and is what is being kept in the repo, and plan to make REST API calls to the backend in order to create new tickets/modify current ones.
My question is as I was building out this last section it seems actually like having this spring boot repo may be too much overhead and data being passed around, slowing down the application (or even just pure duplicate code). Is it better to just use pure Firestore and modify the data directly there, or am I on the right track and actually this Spring Boot repo should be kept in?

Activiti 6.0 to custom user/group data in Spring Boot

In activiti 6.0, I have two app: activiti-app and activiti-rest
I want activiti-app and activiti-rest use my custom authentication (own user and group database).
I have follow this question to make a custom authentication session
Configure Activiti to reuse the existing user/group data in Spring Boot
But, after create project, I don't know what should I do next?
I have try to copy .jar code to activiti-app/WEB-INF/lib and activiti-rest/WEB-INF/lib but nothing happend.
So, what should I do after I done my custom authentication project to customize activiti 6.0 user and group.
Many thanks
You need to make sure you configure your custom user and group session factories are registered with the Process Engine Configuration.
There are a couple of ways to do this.
The easiest is to simply update the application engine configuration classes and set the session factories.
If you prefer not to touch the core code (this is more of an issue if using th enterprise edition) or you re using Spring Boot, you can implement an "processEngineConfigurationConfigurer" class which allows you to get access to the Process Engine Configuration before it is initialized.
Which ever way you choose, the registration code is the same:
Map<Class<?>, SessionFactory> sessionFactories = processEngineConfiguration.getSessionFactories();
sessionFactories.put(userManagerFactory.getSessionType(), userManagerFactory);
sessionFactories.put(groupManagerFactory.getSessionType(), groupManagerFactory);
processEngineConfiguration.setSessionFactories(sessionFactories);
This should register your custom session factories.
Hope this helps,
Greg

How to update Spring Security Management Console?

I have a User entity and apart from default fields/methods (I took the whole content from grails docs) I added fields like address, number etc. (Strings).
Now I rebuilded the whole project, deployed and I still don't see those in Spring Security Management Console.
How to force Spring Security Management Console to show my custom User fields?
I'm going to assume a couple of things when authoring this answer:
What you meant by the first part of the question is that you have added fields to the User domain class that was generated by the Spring Security Plugin
You are speaking of the Spring Security UI Plugin when you say "Management Console"
With those two assumptions in mind, you need to take a look at this documentation. Simply adding the fields to the Domain class will not affect the UI plugin, as the plugin has pre-defined views and controllers for dealing with the default fields in the domain object.
You need to "override" these views and controllers to support your new fields. From the sounds of it, running this script should "extract" the views and controller you need:
grails s2ui-override user <controller_package>
Where the controller_package is the package you would like the new UserController class to be a part of.

Session handling in Struts 2.1.6

I have a project with the following setup:
Tomcat 6.x
Struts 2.1.6
DisplayTag 1.2
Spring 2.x (1 or 5, don't remember now)
I want to know to to do session controlling in every action of my app, like if the users weren't logged in, they're redirect to certain page to login (in the case of my project, either the user come to a special crafted url like login/SPECIALHASHTOLOGIN or won't enter at all.
Need more details?
Thx in advance.
I'm still new to S2 as well, but I believe what you will need to do is modify the default interceptor stack (or create a custom stack) and add a custom interceptor. This custom interceptor will need to implement SessionAware to access the user session, and must implement your custom logic (which action to redirect to, which URLs do not need protection, etc.).
Here is a good tutorial of a LoginInterceptor that behaves similar to what you are requesting.
Acegi security is a great way to add security to your web app if you're already using Spring. Here's a decent 1-hour Acegi tutorial.

Resources