Package org.auraframework.throwable.quickfix

Examples of org.auraframework.throwable.quickfix.InvalidDefinitionException


                    context.getInstanceStack().setAttributeIndex(idx);
                    components.add(((ComponentDefRef) defRef).newInstance(valueProvider));
                    context.getInstanceStack().clearAttributeIndex(idx);
                    idx += 1;
                } else {
                    throw new InvalidDefinitionException(String.format("Expected Component, recieved %s", defRef
                            .getClass().getName()), getLocation());
                }
            }
        }
        return components;
View Full Code Here


    @Override
    public void validateDefinition() throws QuickFixException {
        super.validateDefinition();
        if (this.provide == null) {
            throw new InvalidDefinitionException("No provide function was found", getLocation());
        }
    }
View Full Code Here

     * @throws QuickFixException quick fix
     */
    @Override
    public void validateDefinition() throws QuickFixException {
        if (StringUtils.isBlank(this.name) && StringUtils.isBlank(this.url)) {
            throw new InvalidDefinitionException("Must have either a name or url", getLocation());
        }
        if (this.type == null) {
            throw new InvalidDefinitionException("Missing required type", getLocation());
        }
        if (this.parentDescriptor == null) {
            throw new InvalidDefinitionException("No parent for ClientLibraryDef", getLocation());
        }

        if (StringUtils.isNotBlank(this.url)) {
            if (StringUtils.startsWithIgnoreCase(this.url, DefDescriptor.CSS_PREFIX + "://") ||
                StringUtils.startsWithIgnoreCase(this.url, DefDescriptor.JAVASCRIPT_PREFIX + "://")) {

                if (!StringUtils.startsWithIgnoreCase(this.url, this.type.toString())) {
                    throw new InvalidDefinitionException("ResourceDef type must match library type", getLocation());
                }

                DefDescriptor<ResourceDef> resourceDesc = DefDescriptorImpl.getInstance(this.url, ResourceDef.class);
                if (!resourceDesc.exists()) {
                    throw new InvalidDefinitionException("No resource named " + this.url + " found", getLocation());
                }

            } else {
                // must have the same file extension as type
                if (!StringUtils.endsWithIgnoreCase(this.url, "." + this.type.toString())) {
                    throw new InvalidDefinitionException("Url file extension must match type", getLocation());
                }
            }
        }
    }
View Full Code Here

        builder.setParentDescriptor(defDescriptor);
        builder.setLocation(getLocation());

        String library = getAttributeValue(ATTRIBUTE_LIBRARY);
        if (AuraTextUtil.isNullEmptyOrWhitespace(library)) {
            throw new InvalidDefinitionException(String.format("%s missing library attribute", TAG), getLocation());
        }
        DefDescriptor<LibraryDef> descriptor = DefDescriptorImpl.getInstance(library.trim(), LibraryDef.class);
        builder.setDescriptor(descriptor);

        String property = getAttributeValue(ATTRIBUTE_PROPERTY);
        if (AuraTextUtil.isNullEmptyOrWhitespace(property)) {
            throw new InvalidDefinitionException(String.format("%s missing property attribute", TAG), getLocation());
        }
        builder.setProperty(property.trim());

        builder.setDescription(getAttributeValue(RootTagHandler.ATTRIBUTE_DESCRIPTION));
View Full Code Here

        builder.setType(ClientLibraryDef.Type.JS);
        if (StringUtils.isNotBlank(type)) {
            try {
                builder.setType(ClientLibraryDef.Type.valueOf(type.trim().toUpperCase()));
            } catch (IllegalArgumentException iae) {
                throw new InvalidDefinitionException("Missing valid type", getLocation());
            }
        }

        String modeStr = getAttributeValue(ATTRIBUTE_MODES);
        Set<AuraContext.Mode> modes = Collections.emptySet();
        if (StringUtils.isNotBlank(modeStr)) {
            modes = Sets.newHashSet();
            List<String> modesList = AuraTextUtil.splitSimpleAndTrim(modeStr, ",", 0);
            for (String m : modesList) {
                try {
                    modes.add(AuraContext.Mode.valueOf(m.toUpperCase()));
                } catch (IllegalArgumentException iae) {
                    throw new InvalidDefinitionException("Invalid mode specified", getLocation());
                }
            }
        }
        builder.setModes(modes);
    }
View Full Code Here

        super.validateDefinition();

        // must have valid name
        String name = this.descriptor.getName();
        if (!AuraTextUtil.validateAttributeName(name)) {
            throw new InvalidDefinitionException(String.format(INVALID_NAME, name), getLocation());
        }

        // must have a value
        if (value == null) {
            throw new InvalidDefinitionException(MISSING_VALUE, getLocation());
        }
    }
View Full Code Here

        // themes with providers are basically only expected to be used in isolation from other features
        if (descriptorProvider != null || mapProvider != null) {
            if (!vars.isEmpty()) {
                String msg = String.format("Theme %s must not specify vars if using a provider", descriptor);
                throw new InvalidDefinitionException(msg, getLocation());
            }

            if (!imports.isEmpty()) {
                String msg = String.format("Theme %s must not specify imports if using a provider", descriptor);
                throw new InvalidDefinitionException(msg, getLocation());
            }

            if (extendsDescriptor != null) {
                String msg = String.format("Theme %s must not use 'extends' and 'provider' attributes together",
                        descriptor);
                throw new InvalidDefinitionException(msg, getLocation());
            }

            // component-bundle themes can't use a provider
            if (isCmpTheme) {
                String msg = String.format("Component theme %s must not specify a provider", descriptor);
                throw new InvalidDefinitionException(msg, getLocation());
            }

            // namespace default theme should not utilize a provider
            DefDescriptor<ThemeDef> nsDefaultTheme = Themes.getNamespaceDefaultTheme(descriptor);
            if (nsDefaultTheme.equals(descriptor)) {
                String msg = String.format("Namespace-default theme %s must not specify a provider", descriptor);
                throw new InvalidDefinitionException(msg, getLocation());
            }
        }
    }
View Full Code Here

            }

            // can't extend itself
            if (extendsDescriptor.equals(descriptor)) {
                String msg = String.format("Theme %s cannot extend itself", descriptor);
                throw new InvalidDefinitionException(msg, getLocation());
            }

            // ensure no circular hierarchy
            DefDescriptor<ThemeDef> current = extendsDescriptor;
            while (current != null) {
                if (current.equals(descriptor)) {
                    String msg = String.format("%s must not through its parent eventually extend itself", descriptor);
                    throw new InvalidDefinitionException(msg, getLocation());
                }
                current = current.getDef().getExtendsDescriptor();
            }

            // it would be a mistake to extend an imported theme
            if (imports.contains(extendsDescriptor)) {
                String msg = String.format("Cannot extend and import from the same theme %s", extendsDescriptor);
                throw new InvalidDefinitionException(msg, getLocation());
            }

            // cmp themes can't extend other themes. This is an arbitrary restriction to prevent improper usage.
            // if changing, be sure to look over any impact on appendDependencies as well.
            if (isCmpTheme) {
                String msg = String.format("Component theme %s must not extend any other theme", descriptor);
                throw new InvalidDefinitionException(msg, getLocation());
            }

            // the parent theme must not be a cmp theme. This would usually be a mistake/improper usage.
            if (extendsDescriptor.getDef().isCmpTheme()) {
                String msg = String.format("Theme %s must not extend from a component theme", descriptor);
                throw new InvalidDefinitionException(msg, getLocation());
            }
        }

        // cmp themes cannot import. most of the time this would be improper usage.
        // if changing, be sure to look over any impact on appendDependencies as well.
        if (isCmpTheme && !imports.isEmpty()) {
            throw new InvalidDefinitionException("Component themes cannot import another theme", getLocation());
        }

        for (DefDescriptor<ThemeDef> theme : imports) {
            ThemeDef def = theme.getDef();

            // can't import a cmp theme
            if (def.isCmpTheme()) {
                String msg = String.format("Theme %s cannot be imported because it is a component theme", theme);
                throw new InvalidDefinitionException(msg, getLocation());
            }

            // can't import a theme with a parent. This is an arbitrary restriction to enforce a level of var lookup
            // simplicity and prevent misuse of imports.
            if (def.getExtendsDescriptor() != null) {
                String msg = String.format("Theme %s cannot be imported since it uses the 'extends' attribute", theme);
                throw new InvalidDefinitionException(msg, getLocation());
            }

            // can't import a theme that uses a provider.
            if (def.getDescriptorProvider() != null || def.getMapProvider() != null) {
                String msg = String.format("Theme %s cannot be imported since it uses a provider", theme);
                throw new InvalidDefinitionException(msg, getLocation());
            }
        }

        // vars
        for (VarDef def : vars.values()) {
View Full Code Here

    }

    @Override
    public void validateDefinition() throws QuickFixException {
        if (themeDescriptor == null) {
            throw new InvalidDefinitionException("Missing name", getLocation());
        }
    }
View Full Code Here

    @Override
    public void validateDefinition() throws QuickFixException {
        super.validateDefinition();
        // default is required attribute
        if (AuraTextUtil.isNullEmptyOrWhitespace(defaultLayout)) {
            throw new InvalidDefinitionException("The \"default\" attribute is required for layouts", getLocation());
        }
        // the default layout must exist
        if (getLayoutDef(defaultLayout) == null) {
            throw new InvalidDefinitionException(
                    String.format("The default layout \"%s\" doesn't exist", defaultLayout), getLocation());
        }
        // if catchall is specified, it must exist
        if (catchall != null && (AuraTextUtil.isEmptyOrWhitespace(catchall) || getLayoutDef(catchall) == null)) {
            throw new InvalidDefinitionException(String.format("The catchall layout \"%s\" doesn't exist", catchall),
                    getLocation());
        }
        for (LayoutDef layout : getLayoutDefs()) {
            layout.validateDefinition();
        }
View Full Code Here

TOP

Related Classes of org.auraframework.throwable.quickfix.InvalidDefinitionException

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.