Search in sources :

Example 1 with MultipartConfigDescriptor

use of org.glassfish.web.deployment.descriptor.MultipartConfigDescriptor in project Payara by payara.

the class MultipartConfigHandler method processAnnotation.

private HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, WebComponentDescriptor webCompDesc) throws AnnotationProcessorException {
    MultipartConfig multipartConfigAn = (MultipartConfig) ainfo.getAnnotation();
    com.sun.enterprise.deployment.web.MultipartConfig multipartConfig = webCompDesc.getMultipartConfig();
    if (multipartConfig == null) {
        multipartConfig = new MultipartConfigDescriptor();
        webCompDesc.setMultipartConfig(multipartConfig);
    }
    if (multipartConfig.getLocation() == null) {
        multipartConfig.setLocation(multipartConfigAn.location());
    }
    if (multipartConfig.getMaxFileSize() == null) {
        multipartConfig.setMaxFileSize(multipartConfigAn.maxFileSize());
    }
    if (multipartConfig.getMaxRequestSize() == null) {
        multipartConfig.setMaxRequestSize(multipartConfigAn.maxRequestSize());
    }
    if (multipartConfig.getFileSizeThreshold() == null) {
        multipartConfig.setFileSizeThreshold(multipartConfigAn.fileSizeThreshold());
    }
    return getDefaultProcessedResult();
}
Also used : MultipartConfig(javax.servlet.annotation.MultipartConfig) MultipartConfigDescriptor(org.glassfish.web.deployment.descriptor.MultipartConfigDescriptor)

Example 2 with MultipartConfigDescriptor

use of org.glassfish.web.deployment.descriptor.MultipartConfigDescriptor in project Payara by payara.

the class ServletNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent node in the DOM tree
 * @param descriptor the descriptor to write
 * @return the DOM tree top node
 */
@Override
public Node writeDescriptor(Node parent, WebComponentDescriptor descriptor) {
    Node myNode = super.writeDescriptor(parent, descriptor);
    appendTextChild(myNode, WebTagNames.SERVLET_NAME, descriptor.getCanonicalName());
    if (descriptor.isServlet()) {
        appendTextChild(myNode, WebTagNames.SERVLET_CLASS, descriptor.getWebComponentImplementation());
    } else {
        appendTextChild(myNode, WebTagNames.JSP_FILENAME, descriptor.getWebComponentImplementation());
    }
    // init-param*
    WebCommonNode.addInitParam(myNode, WebTagNames.INIT_PARAM, descriptor.getInitializationParameters());
    if (descriptor.getLoadOnStartUp() != null) {
        appendTextChild(myNode, WebTagNames.LOAD_ON_STARTUP, String.valueOf(descriptor.getLoadOnStartUp()));
    }
    appendTextChild(myNode, WebTagNames.ENABLED, String.valueOf(descriptor.isEnabled()));
    if (descriptor.isAsyncSupported() != null) {
        appendTextChild(myNode, WebTagNames.ASYNC_SUPPORTED, String.valueOf(descriptor.isAsyncSupported()));
    }
    // run-as
    RunAsIdentityDescriptor runAs = descriptor.getRunAsIdentity();
    if (runAs != null) {
        RunAsNode runAsNode = new RunAsNode();
        runAsNode.writeDescriptor(myNode, WebTagNames.RUNAS_SPECIFIED_IDENTITY, runAs);
    }
    // sercurity-role-ref*
    Enumeration roleRefs = descriptor.getSecurityRoleReferences();
    SecurityRoleRefNode roleRefNode = new SecurityRoleRefNode();
    while (roleRefs.hasMoreElements()) {
        roleRefNode.writeDescriptor(myNode, WebTagNames.ROLE_REFERENCE, (RoleReference) roleRefs.nextElement());
    }
    // multipart-config
    MultipartConfigDescriptor multipartConfigDesc = (MultipartConfigDescriptor) descriptor.getMultipartConfig();
    if (multipartConfigDesc != null) {
        MultipartConfigNode multipartConfigNode = new MultipartConfigNode();
        multipartConfigNode.writeDescriptor(myNode, WebTagNames.MULTIPART_CONFIG, multipartConfigDesc);
    }
    return myNode;
}
Also used : Enumeration(java.util.Enumeration) RunAsIdentityDescriptor(com.sun.enterprise.deployment.RunAsIdentityDescriptor) Node(org.w3c.dom.Node) MultipartConfigDescriptor(org.glassfish.web.deployment.descriptor.MultipartConfigDescriptor)

Aggregations

MultipartConfigDescriptor (org.glassfish.web.deployment.descriptor.MultipartConfigDescriptor)2 RunAsIdentityDescriptor (com.sun.enterprise.deployment.RunAsIdentityDescriptor)1 Enumeration (java.util.Enumeration)1 MultipartConfig (javax.servlet.annotation.MultipartConfig)1 Node (org.w3c.dom.Node)1