Package org.auraframework.service

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


    /**
     * Gets the UID for the application descriptor of the current context, or {@code null} if there is no application
     * (probably because of a compile error).
     */
    public static String getContextAppUid() {
        DefinitionService definitionService = Aura.getDefinitionService();
        AuraContext context = Aura.getContextService().getCurrentContext();
        DefDescriptor<? extends BaseComponentDef> app = context.getApplicationDescriptor();

        if (app != null) {
            try {
                return definitionService.getDefRegistry().getUid(null, app);
            } catch (QuickFixException e) {
                // This is perfectly possible, but the error is handled in more
                // contextually-sensible places. For here, we know there's no
                // meaningful uid, so we fall through and return null.
            }
View Full Code Here

        }
        return null;
    }

    protected DefDescriptor<?> setupQuickFix(AuraContext context) {
        DefinitionService ds = Aura.getDefinitionService();
        MasterDefRegistry mdr = context.getDefRegistry();

        try {
            DefDescriptor<ComponentDef> qfdesc = ds.getDefDescriptor("auradev:quickFixException", ComponentDef.class);
            String uid = mdr.getUid(null, qfdesc);
            context.setPreloadedDefinitions(mdr.getDependencies(uid));
            return qfdesc;
        } catch (QuickFixException death) {
            //
View Full Code Here

TOP

Related Classes of org.auraframework.service.DefinitionService

Copyright © 2018 www.massapicom. 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.