[SOLVED] How to update products configuration cache

Any issue about Cyclos 4 scripting and Webservices

Moderators: alexandre, hugo, rmvanarkel

Post Reply
erich.manser
Posts: 24
Joined: Tue Nov 08, 2022 10:40 am

[SOLVED] How to update products configuration cache

Post by erich.manser »

When updating user or broker products by groovy scripts, the changes are shown in the system, but the users don't get the granted permissions. After I restart the cyclos app container the permissions are active.

How can I activate the new settings inside of the groovy script? Is there a call to initialize a cache refresh oder rebuild?
Last edited by erich.manser on Thu Aug 28, 2025 4:53 am, edited 1 time in total.
luis
Posts: 265
Joined: Fri Feb 17, 2006 11:01 am

Re: How to update products configuration cache

Post by luis »

The correct way of updating products (and any entity in general) is not to find the entity and modify its fields directly, because the entire service layer is bypassed (which handles validation, cache, other related updates, indexing, etc). The below example works for products, but the concept can be adjusted to configurations, groups, account types, etc:

Code: Select all

import org.cyclos.entities.users.MemberProduct
import org.cyclos.impl.users.ProductServiceLocal
import org.cyclos.impl.utils.persistence.EntityManagerHandler
import org.cyclos.model.users.products.MemberProductDTO
import org.cyclos.model.users.products.MemberProductData

ProductServiceLocal productService = binding.productServiceLocal
EntityManagerHandler entityManagerHandler = binding.entityManagerHandler

// The service methods use id. But we can find by internal name
def product = entityManagerHandler.find(MemberProduct, 'internalName')

// If you need some configuration from the data, call the getData and use its DTO
MemberProductData data = productService.getData(product.id)
MemberProductDTO dto = data.dto

// Otherwise, load the DTO directly
// MemberProductDTO dto = productService.load(product.id)

// Update the DTO
dto.adsRequireAuthorization = true

// Save the product
productService.save(dto)
As always, an IDE is recommended to setup an IDE to work with scripts: https://documentation.cyclos.org/curren ... ting-debug

Also note that the models (DTOs, VOs, Data) is distinct than the entities directly, so adjust the script as needed.
Luis Fernando Planella Gonzalez
Cyclos development team
erich.manser
Posts: 24
Joined: Tue Nov 08, 2022 10:40 am

Re: How to update products configuration cache

Post by erich.manser »

Great Information.
Thank you very much!!
Post Reply