Skip to main content
1-Visitor
July 4, 2017
Solved

Custom actions hidden

  • July 4, 2017
  • 1 reply
  • 4340 views

Hi everyone,

 

I have a problem with my custom action validators. I created some custom actions and attached custom validators to them. I extend the DefaultUIComponentValidator class and override the preValidateAction function. The possible results based on the verifications are DENIED or ENABLED. However when I log in with a user that is not added to any organization (Site level user) and added as Member to a product, I don't see the action. Using jcaDebug it tells me that the action is HIDDEN by my validator. How is this possible? I don't set it to HIDDEN in any case.

This is only happening if the user is not added to any organization.

 

Thx in advance for suggestions!

BR,

Tamás

Best answer by TamasBiro

Hi olivierfresse,

 

thx for the suggestion, I tried it but it didn't fix the problem. The organization container is the same... getPrincipal will fail without notice. What we found out that if we use SessionServerHelper.manager.setAccessEnforced(false) before getting the principal (WTGroup) and setting it back afterwards, it will work.

 

BR,

Tamás

1 reply

1-Visitor
July 5, 2017

Could you attach the validator class? Are you referring to anything that requires a domain or container reference in your validator?

TamasBiro1-VisitorAuthor
1-Visitor
July 5, 2017

My validators require container references... after some debugging I figured out that the problem is with this part: 

 

WTContainer container= part.getContainer();

WTOrganization org = container.getOrganization();

WTGroup orgAdminGroup = (WTGroup) org.getAdministrator().getPrincipal();

 

In the last line it fails. Sometimes this code is ran on method server 1 and sometimes on method server 2. On method server 2 it works, on method server 1 at the last line fails without going to the catch clause of the try like if nothing should happen afterwards. Not even logging after this line will appear.

15-Moonstone
July 5, 2017

Use services to get the containers. 

 

import wt.inf.container.OrgContainer
import wt.inf.container.WTContainer
import wt.inf.container.WTContainerServerHelper

// initialized somewhere...
WTPart p;

WTContainer wtContainer = WTContainerServerHelper.getContainer(p,false);

// The org is the container of the product/library/project...

OrgContainer orgContainer = WTContainerServerHelper.getContainer(wtContainer,false);