Examples of DefinitionService


Examples of org.auraframework.service.DefinitionService

     * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
     *      javax.servlet.http.HttpServletResponse)
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        DefinitionService definitionService;
        AuraContext context;
        String tagName;
        DefType defType;

        //
        // Initial setup. This should never fail.
        //
        try {
            response.setCharacterEncoding(UTF_ENCODING);
            context = Aura.getContextService().getCurrentContext();
            response.setContentType(getContentType(context.getFormat()));
            definitionService = Aura.getDefinitionService();
        } catch (RuntimeException re) {
            //
            // If we can't get this far, log the exception and bolt.
            // We can't do our normal exception handling because
            // at this point we simply broke.
            //
            Aura.getExceptionAdapter().handleException(re);
            send404(request, response);
            return;
        }

        DefDescriptor<? extends BaseComponentDef> defDescriptor;
        BaseComponentDef def;

        //
        // Now check and fetch parameters.
        // These are not formally part of the Aura API, as this is the initial
        // request. All we need are a tag/type or descriptor. Except, of course,
        // the special case of nocache, which is required by the appcache handling.
        // I would love for a simpler way to be figured out.
        //
        try {
            String nocache = nocacheParam.get(request);
            if (nocache != null && !nocache.isEmpty()) {
                handleNoCacheRedirect(nocache, response);
                return;
            }
            tagName = tag.get(request);
            defType = defTypeParam.get(request, DefType.COMPONENT);
            if (tagName == null || tagName.isEmpty()) {
                throw new AuraRuntimeException("Invalid request, tag must not be empty");
            }

            Mode mode = context.getMode();
            if (!isValidDefType(defType, mode)) {
                send404(request, response);
                return;
            }

            if (context.getFormat() != Format.HTML) {
                throw new AuraRuntimeException("Invalid request, GET must use HTML");
            }

            defDescriptor = definitionService.getDefDescriptor(tagName,
                    defType == DefType.APPLICATION ? ApplicationDef.class : ComponentDef.class);
        } catch (RequestParam.InvalidParamException ipe) {
            handleServletException(new SystemErrorException(ipe), false, context, request, response, false);
            return;
        } catch (RequestParam.MissingParamException mpe) {
            handleServletException(new SystemErrorException(mpe), false, context, request, response, false);
            return;
        } catch (Throwable t) {
            handleServletException(new SystemErrorException(t), false, context, request, response, false);
            return;
        }

        // Knowing the app, we can do the HTTP headers, so of which depend on
        // the app in play, so we couldn't do this earlier.
        setBasicHeaders(defDescriptor, request, response);

        try {
            context.setFrameworkUID(Aura.getConfigAdapter().getAuraFrameworkNonce());

            context.setApplicationDescriptor(defDescriptor);
            definitionService.updateLoaded(defDescriptor);
            def = definitionService.getDefinition(defDescriptor);
           
            if (!context.isTestMode() && !context.isDevMode()) {
              assertAccess(def);
            }
        } catch (QuickFixException qfe) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.