Search in sources :

Example 1 with SecurityRoleReference

use of com.sun.enterprise.deployment.web.SecurityRoleReference in project Payara by payara.

the class WebComponentDescriptorImpl method add.

/**
 * this method will combine the information from this "other"
 *    // WebComponentDescriptor with current WebComponentDescriptor
 *    //
 *    // when there are conflicts between the contents of the two,
 *    // the value from current WebComponentDescriptor will override
 *    // the value in "other"
 *    //
 *    // Note: in the Set API, we only add value when such value
 *    // is not existed in the Set already
 *    //
 *    // If combineUrlPatterns is false, then the first one take priority,
 *    // otherwise take the second one.
 *    //
 *    // If combineConflict is true, it will combine the init parameter
 *    // conflict information in #getConflictedInitParameterSet.
 *    //
 *    // And the conflict boolean will not be set.
 * @param other
 * @param combineUrlPatterns
 * @param combineConflict
 */
@Override
public void add(WebComponentDescriptor other, boolean combineUrlPatterns, boolean combineConflict) {
    // components are different
    if (!getCanonicalName().equals(other.getCanonicalName())) {
        return;
    }
    // components are different
    if ((isServlet() && !other.isServlet()) || (!isServlet() && other.isServlet())) {
        return;
    }
    // for simple String types, we can rely on Set API
    if (combineUrlPatterns || getUrlPatternsSet().size() == 0) {
        getUrlPatternsSet().addAll(other.getUrlPatternsSet());
    }
    // name is not in the set yet
    if (conflictedInitParameterNames == null) {
        conflictedInitParameterNames = other.getConflictedInitParameterNames();
    } else {
        conflictedInitParameterNames.addAll(other.getConflictedInitParameterNames());
    }
    if (!combineConflict) {
        for (InitializationParameter initParam : getInitializationParameterSet()) {
            conflictedInitParameterNames.remove(initParam.getName());
        }
    }
    for (Iterator<InitializationParameter> initParamIter = other.getInitializationParameterSet().iterator(); initParamIter.hasNext(); ) {
        InitializationParameter initParam = initParamIter.next();
        InitializationParameter origInitParam = getInitializationParameterByName(initParam.getName());
        if (origInitParam == null) {
            getInitializationParameterSet().add(initParam);
        } else if (combineConflict && !origInitParam.getValue().equals(initParam.getValue())) {
            getConflictedInitParameterNames().add(initParam.getName());
        }
    }
    for (SecurityRoleReference secRoleRef : other.getSecurityRoleReferenceSet()) {
        if (getSecurityRoleReferenceByName(secRoleRef.getRoleName()) == null) {
            getSecurityRoleReferenceSet().add(secRoleRef);
        }
    }
    if (getLoadOnStartUp() == null) {
        setLoadOnStartUp(other.getLoadOnStartUp());
    }
    if (isAsyncSupported() == null) {
        setAsyncSupported(other.isAsyncSupported());
    }
    if (getRunAsIdentity() == null) {
        setRunAsIdentity(other.getRunAsIdentity());
    }
    if (getMultipartConfig() == null) {
        setMultipartConfig(other.getMultipartConfig());
    }
    if (getWebComponentImplementation() == null) {
        setWebComponentImplementation(other.getWebComponentImplementation());
    }
}
Also used : InitializationParameter(com.sun.enterprise.deployment.web.InitializationParameter) SecurityRoleReference(com.sun.enterprise.deployment.web.SecurityRoleReference)

Aggregations

InitializationParameter (com.sun.enterprise.deployment.web.InitializationParameter)1 SecurityRoleReference (com.sun.enterprise.deployment.web.SecurityRoleReference)1