Package org.auraframework.throwable

Examples of org.auraframework.throwable.AuraRuntimeException


            if (!isProduction() && resourcesGroup != null && resourcesGroup.isStale()) {
                resourcesGroup.reset();
            }
            return resourcesGroup.getGroupHash().toString();
        } catch (IOException e) {
            throw new AuraRuntimeException("Can't read Aura resources files", e);
        }
    }
View Full Code Here


                            descriptor = d;
                        }

                        try {
                            if (descriptor.getDefType() != DefType.COMPONENT) {
                                throw new AuraRuntimeException(String.format("%s is not a component", descriptor));
                            }

                            ComponentDef c = descriptor.getDef();
                            if (c.isAbstract()) {
                                throw new AuraRuntimeException(String.format("%s cannot be instantiated directly.",
                                        descriptor));
                            }
                           
                            // new component may have its own controllerdef so add that one
                            ControllerDef cd = c.getControllerDef();
                            if (cd != null) {
                                this.valueProviders.put(ValueProviderType.CONTROLLER.getPrefix(), cd);
                            }
                        } catch (DefinitionNotFoundException dnfe) {
                            throw new AuraRuntimeException(String.format("%s did not provide a valid component",
                                    providerDef.getDescriptor()), dnfe);
                        }

                        attributeSet.setRootDefDescriptor(descriptor);
View Full Code Here

                Component template = instanceService.getInstance(templateDef.getDescriptor(), attributes);
                renderingService.render(template, out);
            }
        } catch (QuickFixException e) {
            throw new AuraRuntimeException(e);
        }
    }
View Full Code Here

    }

    @Override
    public Set<DefDescriptor<RootDefinition>> find(DefDescriptor<RootDefinition> matcher) {
        if (AuraTextUtil.isNullEmptyOrWhitespace(matcher.getNamespace())) {
            throw new AuraRuntimeException(String.format("Empty or malformed namespace in: %s",
                    matcher.getQualifiedName()));
        }
        return sourceFactory.find(matcher);
    }
View Full Code Here

    @Override
    public void save(RootDefinition def) {
        Source<?> source = sourceFactory.getSource(def.getDescriptor());
        if (source == null) {
            throw new AuraRuntimeException("Cannot find location to save definition.");
        }
        // Before saving a new definition, clear the old definition in the
        // source.
        source.clearContents();
        SourceWriter writer = ParserFactory.getWriter(source.getFormat());
View Full Code Here

            if (!preloaded) {
                json.writeMapEntry("eventDef", getEventDef());
            }
            json.writeMapEnd();
        } catch (QuickFixException x) {
            throw new AuraRuntimeException(x);
        }
    }
View Full Code Here

        ApplicationDef def = (ApplicationDef) value;

        String outputPath = (String) args.get("outputPath");
        if (outputPath == null) {
            throw new AuraRuntimeException(
                    "'outputPath' directory path is required as an attribute to use this FormatAdapter");
        }

        String appName = def.getDescriptor().getName();
        File outputDir = new File(outputPath, appName);
        if (outputDir.exists()) {
            throw new AuraRuntimeException(String.format("%s exists.  Please select another location.",
                    outputDir.getAbsolutePath()));
        } else {
            outputDir.mkdirs();
        }

        File html = new File(outputDir, "index.html");

        InstanceService instanceService = Aura.getInstanceService();
        RenderingService renderingService = Aura.getRenderingService();

        ContextService contextService = Aura.getContextService();
        AuraContext context = contextService.getCurrentContext();

        Writer htmlWriter = new FileWriter(html);
        try {
            String uid = context.getDefRegistry().getUid(null, def.getDescriptor());
            Set<DefDescriptor<?>> dependencies = context.getDefRegistry().getDependencies(uid);

            ComponentDef templateDef = def.getTemplateDef();
            Map<String, Object> attributes = Maps.newHashMap();

            StringBuilder sb = new StringBuilder();
            // Get the preload css
            List<String> styles = Lists.newArrayList(String.format("%s.css", appName));
            this.writeHtmlStyles(styles, sb);
            File css = new File(outputDir, String.format("%s.css", appName));
            FileWriter cssWriter = new FileWriter(css);
            try {
                Aura.getServerService().writeAppCss(dependencies, cssWriter);
            } finally {
                cssWriter.close();
            }
            attributes.put("auraStyleTags", sb.toString());

            // Clear sb out
            sb.setLength(0);

            List<String> scripts = Lists.newArrayList("aura.js", String.format("%s.js", appName));
            writeHtmlScripts(scripts, sb);

            // Get the framework js
            File auraJs = new File(outputDir, "aura.js");
            FileWriter auraJsWriter = new FileWriter(auraJs);
            InputStream in = Aura.getConfigAdapter().getResourceLoader()
                    .getResourceAsStream("aura/javascript/aura_dev.js");
            InputStreamReader reader = new InputStreamReader(in);
            try {
                Aura.getConfigAdapter().regenerateAuraJS();
                IOUtil.copyStream(reader, auraJsWriter);
            } finally {
                try {
                    auraJsWriter.close();
                } finally {
                    reader.close();
                }
            }

            Application instance = instanceService.getInstance(def, null);

            // Get the preload js
            File js = new File(outputDir, String.format("%s.js", appName));
            FileWriter jsWriter = new FileWriter(js);
            try {
                Aura.getServerService().writeDefinitions(dependencies, jsWriter);

                // Write the app at the bottom of the same file

                Map<String, Object> auraInit = Maps.newHashMap();

                auraInit.put("instance", instance);
                auraInit.put("token", AuraServlet.getToken());
                auraInit.put("host", context.getContextPath());

                contextService.startContext(Mode.PROD, Format.HTML, Authentication.AUTHENTICATED, def.getDescriptor());
                auraInit.put("context", contextService.getCurrentContext());
                jsWriter.append("\n$A.initConfig($A.util.json.resolveRefs(");
                Json.serialize(auraInit, jsWriter, context.getJsonSerializationContext());
                jsWriter.append("));\n");
            } finally {
                jsWriter.close();
            }

            attributes.put("auraScriptTags", sb.toString());

            DefDescriptor<StyleDef> styleDefDesc = templateDef.getStyleDescriptor();
            if (styleDefDesc != null) {
                attributes.put("auraInlineStyle", styleDefDesc.getDef().getCode());
            }

            attributes.put("autoInitialize", false);
            Component template = instanceService.getInstance(templateDef.getDescriptor(), attributes);
            renderingService.render(template, htmlWriter);
        } catch (QuickFixException e) {
            throw new AuraRuntimeException(e);
        } finally {
            htmlWriter.close();
        }
    }
View Full Code Here

        try {
            // FIXME: W-1242779 actually write something.
            writer = source.getWriter();
        } catch (Exception e) {
            throw new AuraRuntimeException(e);
        } finally {
            try {
                if (writer != null) {
                    writer.flush();
                    writer.close();
                }
            } catch (Exception e) {
                throw new AuraRuntimeException(e);
            }
        }
    }
View Full Code Here

            attributes.put("auraInit", Json.serialize(auraInit, context.getJsonSerializationContext()));
            Component template = instanceService.getInstance(templateDef.getDescriptor(), attributes);
            renderingService.render(template, out);
        } catch (QuickFixException e) {
            throw new AuraRuntimeException(e);
        }
    }
View Full Code Here

            writeClassBegin(writer, componentDef);
            writeLineBreaks(writer, 2);
            writeMethods(writer, componentDef);
            writeBlockEnd(writer);
        } catch (Exception e) {
            throw new AuraRuntimeException(e);
        } finally {
            try {
                if (writer != null) {
                    writer.flush();
                    writer.close();
                }
            } catch (Exception e) {
                throw new AuraRuntimeException(e);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.auraframework.throwable.AuraRuntimeException

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.