cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Restrict certain users from using a Customization tool

hsha1102
11-Garnet

Restrict certain users from using a Customization tool

Hello All,

 

We have one functionality "Part Number Generator" in Customization tab which helps the users to have a certain set of part numbers in store for them if they want to create new WTParts.

 

Now I want to restrict certain users from using this functionality, either hide the functionality or disable the option.

 

Please instruct me on how to proceed. 

 

P.S: I have done customization in Java code but not so much with the jsp and js and all.

 

Thanks and Regards,

Hari R

ACCEPTED SOLUTION

Accepted Solutions

You have to create an action validation filter. I attached you an example to hide the action for all users except org and site admin.

xconf

<Service context="default" name="com.ptc.core.ui.validation.SimpleValidationFilter" targetFile="codebase/service.properties">
   <Option requestor="null"
           selector="hideForNonOrgOrSiteAdmins"
           serviceClass="xxx.validators.HideFromNonOrgOrSiteAdminActionValidation"/>
</Service>

 

Java Class

package xxx.validators;

import com.ptc.core.ui.validation.DefaultSimpleValidationFilter;
import com.ptc.core.ui.validation.UIValidationCriteria;
import com.ptc.core.ui.validation.UIValidationKey;
import com.ptc.core.ui.validation.UIValidationStatus;
import lombok.extern.slf4j.Slf4j;

/**
 * Hides an action for all user except Org and Site administrators
 */

@Slf4j
public class HideFromNonOrgOrSiteAdminActionValidation extends DefaultSimpleValidationFilter {

  @Override
  public UIValidationStatus preValidateAction(UIValidationKey uiValidationKey,
                                              UIValidationCriteria uiValidationCriteria) {
    if (log.isTraceEnabled()) {
      log.trace("  validtionKey -> " + uiValidationKey);
      log.trace("  validationCriteria -> " + uiValidationCriteria.toString());
    }
    UIValidationStatus uiValidationStatus = UIValidationStatus.HIDDEN;
    if (uiValidationCriteria.isSiteAdmin() || uiValidationCriteria.isOrgAdmin()) {
      uiValidationStatus = UIValidationStatus.ENABLED;
    }
    return uiValidationStatus;
  }
}

 

 Include filter for action (name is defined in xconf property)

<action ajax="page"
                name="xxx">
        <command class="xxx"
                 method="execute"
                 url="xxx.jsp"
                 windowType="popup"/>
        <includeFilter name="hideForNonOrgOrSiteAdmins"/>
</action>

 

 

View solution in original post

2 REPLIES 2

You have to create an action validation filter. I attached you an example to hide the action for all users except org and site admin.

xconf

<Service context="default" name="com.ptc.core.ui.validation.SimpleValidationFilter" targetFile="codebase/service.properties">
   <Option requestor="null"
           selector="hideForNonOrgOrSiteAdmins"
           serviceClass="xxx.validators.HideFromNonOrgOrSiteAdminActionValidation"/>
</Service>

 

Java Class

package xxx.validators;

import com.ptc.core.ui.validation.DefaultSimpleValidationFilter;
import com.ptc.core.ui.validation.UIValidationCriteria;
import com.ptc.core.ui.validation.UIValidationKey;
import com.ptc.core.ui.validation.UIValidationStatus;
import lombok.extern.slf4j.Slf4j;

/**
 * Hides an action for all user except Org and Site administrators
 */

@Slf4j
public class HideFromNonOrgOrSiteAdminActionValidation extends DefaultSimpleValidationFilter {

  @Override
  public UIValidationStatus preValidateAction(UIValidationKey uiValidationKey,
                                              UIValidationCriteria uiValidationCriteria) {
    if (log.isTraceEnabled()) {
      log.trace("  validtionKey -> " + uiValidationKey);
      log.trace("  validationCriteria -> " + uiValidationCriteria.toString());
    }
    UIValidationStatus uiValidationStatus = UIValidationStatus.HIDDEN;
    if (uiValidationCriteria.isSiteAdmin() || uiValidationCriteria.isOrgAdmin()) {
      uiValidationStatus = UIValidationStatus.ENABLED;
    }
    return uiValidationStatus;
  }
}

 

 Include filter for action (name is defined in xconf property)

<action ajax="page"
                name="xxx">
        <command class="xxx"
                 method="execute"
                 url="xxx.jsp"
                 windowType="popup"/>
        <includeFilter name="hideForNonOrgOrSiteAdmins"/>
</action>

 

 

Hello @BjoernRueegg ,

 

Thanks for the response. It is working.

 

Regards,

Hari R

Announcements

Top Tags