use of org.glassfish.web.deployment.runtime.LocaleCharsetInfo in project Payara by payara.
the class WebBundleRuntimeNode method addDescriptor.
/**
* Adds a new DOL descriptor instance to the descriptor instance associated with this XMLNode
*
* @param newDescriptor the new descriptor
*/
@Override
public void addDescriptor(Object newDescriptor) {
SunWebAppImpl sunWebApp = (SunWebAppImpl) descriptor.getSunDescriptor();
if (newDescriptor instanceof WebComponentDescriptor) {
WebComponentDescriptor servlet = (WebComponentDescriptor) newDescriptor;
// for backward compatibility with s1as schema2beans generated desc
Servlet s1descriptor = new Servlet();
s1descriptor.setServletName(servlet.getCanonicalName());
if (servlet.getRunAsIdentity() != null) {
s1descriptor.setPrincipalName(servlet.getRunAsIdentity().getPrincipal());
}
sunWebApp.addServlet(s1descriptor);
} else if (newDescriptor instanceof ServiceReferenceDescriptor) {
descriptor.addServiceReferenceDescriptor((ServiceReferenceDescriptor) newDescriptor);
} else if (newDescriptor instanceof SecurityRoleMapping) {
SecurityRoleMapping srm = (SecurityRoleMapping) newDescriptor;
sunWebApp.addSecurityRoleMapping(srm);
// store it in the application using pure DOL descriptors...
Application app = descriptor.getApplication();
if (app != null) {
Role role = new Role(srm.getRoleName());
SecurityRoleMapper rm = app.getRoleMapper();
if (rm != null) {
List<PrincipalNameDescriptor> principals = srm.getPrincipalNames();
for (int i = 0; i < principals.size(); i++) {
rm.assignRole(principals.get(i).getPrincipal(), role, descriptor);
}
List<String> groups = srm.getGroupNames();
for (int i = 0; i < groups.size(); i++) {
rm.assignRole(new Group(groups.get(i)), role, descriptor);
}
}
}
} else if (newDescriptor instanceof IdempotentUrlPattern) {
sunWebApp.addIdempotentUrlPattern((IdempotentUrlPattern) newDescriptor);
} else if (newDescriptor instanceof SessionConfig) {
sunWebApp.setSessionConfig((SessionConfig) newDescriptor);
} else if (newDescriptor instanceof Cache) {
sunWebApp.setCache((Cache) newDescriptor);
} else if (newDescriptor instanceof ClassLoader) {
sunWebApp.setClassLoader((ClassLoader) newDescriptor);
} else if (newDescriptor instanceof JspConfig) {
sunWebApp.setJspConfig((JspConfig) newDescriptor);
} else if (newDescriptor instanceof LocaleCharsetInfo) {
sunWebApp.setLocaleCharsetInfo((LocaleCharsetInfo) newDescriptor);
} else if (newDescriptor instanceof WebProperty) {
sunWebApp.addWebProperty((WebProperty) newDescriptor);
} else if (newDescriptor instanceof Valve) {
sunWebApp.addValve((Valve) newDescriptor);
} else
super.addDescriptor(descriptor);
}
use of org.glassfish.web.deployment.runtime.LocaleCharsetInfo in project Payara by payara.
the class DynamicWebServletRegistrationImpl method setI18nInfo.
/**
* Sets the parameter encoding (i18n) info from web.xml, sun-web.xml, glassfish-web.xml and payara-web.xml.
*/
public void setI18nInfo() {
if (webBundleDescriptor != null) {
String reqEncoding = webBundleDescriptor.getRequestCharacterEncoding();
if (reqEncoding != null) {
setRequestCharacterEncoding(reqEncoding);
}
String resEncoding = webBundleDescriptor.getResponseCharacterEncoding();
if (resEncoding != null) {
setResponseCharacterEncoding(resEncoding);
}
}
if (iasBean == null) {
return;
}
if (iasBean.isParameterEncoding()) {
formHintField = iasBean.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.FORM_HINT_FIELD);
defaultCharset = iasBean.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.DEFAULT_CHARSET);
}
LocaleCharsetInfo lcinfo = iasBean.getLocaleCharsetInfo();
if (lcinfo != null) {
if (lcinfo.getAttributeValue(LocaleCharsetInfo.DEFAULT_LOCALE) != null) {
logger.warning(LogFacade.DEFAULT_LOCALE_DEPRECATED);
}
/*
* <parameter-encoding> subelem of <sun-web-app> takes precedence
* over that of <locale-charset-info>
*/
if (lcinfo.isParameterEncoding() && !iasBean.isParameterEncoding()) {
formHintField = lcinfo.getAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, LocaleCharsetInfo.FORM_HINT_FIELD);
defaultCharset = lcinfo.getAttributeValue(LocaleCharsetInfo.PARAMETER_ENCODING, LocaleCharsetInfo.DEFAULT_CHARSET);
}
_lcMap = lcinfo.getLocaleCharsetMap();
}
if (defaultCharset != null) {
setRequestCharacterEncoding(defaultCharset);
setResponseCharacterEncoding(defaultCharset);
}
}
Aggregations