Package xdoclet

Examples of xdoclet.XDocletException


            parameters.iterator(); iter.hasNext(); ) {
            XParameter parameter = (XParameter)iter.next();
            XClass type = parameter.getType();

            if (type == null) {
                throw new XDocletException("FATAL: " + parameter);
            }

            sbuf.append(CodeUtils.capitalize(type.getName()));

            for (int cnt = parameter.getDimension(); cnt > 0; cnt--) {
                sbuf.append("Array");
            }
        }

        String result = sbuf.toString();

        if (result.indexOf("null") != -1) {
            throw new XDocletException("FATAL: " + result);
        }

        return result;
    }
View Full Code Here


    public void validateOptions() throws XDocletException
    {
        super.validateOptions();

        if (getEntityCmpClassPattern() == null || getEntityCmpClassPattern().trim().equals("")) {
            throw new XDocletException(Translator.getString(XDocletMessages.class, XDocletMessages.PARAMETER_MISSING_OR_EMPTY, new String[]{"pattern"}));
        }

        if (getEntityCmpClassPattern().indexOf("{0}") == -1) {
            throw new XDocletException(Translator.getString(XDocletModulesEjbMessages.class, XDocletModulesEjbMessages.PATTERN_HAS_NO_PLACEHOLDER));
        }
    }
View Full Code Here

    public void validateOptions() throws XDocletException
    {
        super.validateOptions();

        if (getEntityBmpClassPattern() == null || getEntityBmpClassPattern().trim().equals("")) {
            throw new XDocletException(Translator.getString(XDocletMessages.class, XDocletMessages.PARAMETER_MISSING_OR_EMPTY, new String[]{"pattern"}));
        }

        if (getEntityBmpClassPattern().indexOf("{0}") == -1) {
            throw new XDocletException(Translator.getString(XDocletModulesEjbMessages.class, XDocletModulesEjbMessages.PATTERN_HAS_NO_PLACEHOLDER));
        }
    }
View Full Code Here

    public void validateOptions() throws XDocletException
    {
        super.validateOptions();

        if (getValueObjectClassPattern() == null || getValueObjectClassPattern().trim().equals("")) {
            throw new XDocletException(
                Translator.getString(XDocletMessages.class, XDocletMessages.PARAMETER_MISSING_OR_EMPTY, new String[]{"pattern"}));
        }

        if (getValueObjectClassPattern().indexOf("{0}") == -1) {
            throw new XDocletException(Translator.getString(XDocletModulesEjbMessages.class, XDocletModulesEjbMessages.PATTERN_HAS_NO_PLACEHOLDER));
        }
    }
View Full Code Here

        super.validateOptions();

        if ((null == dataSource) &&
            ((null == driver) || (null == jdbcUrl) || (null == userName) || (null == password))) {
            // Need either a dataSource or standalone connection properties
            throw new XDocletException(Translator.getString(XDocletModulesHibernateMessages.class,
                XDocletModulesHibernateMessages.DATA_CONNECTION_REQUIRED));
        }

        if ((jndiProperties.size() > 0) && (null == jndiName)) {
            // Probably want a jndiName if you are going to specify additional properties to use with it.
            throw new XDocletException(Translator.getString(XDocletModulesHibernateMessages.class,
                XDocletModulesHibernateMessages.JNDI_NAME_FOR_PROPS_REQUIRED));
        }

        if (getDialect() == null) {
            throw new XDocletException(Translator.getString(XDocletModulesHibernateMessages.class,
                XDocletModulesHibernateMessages.SQL_DIALECT_REQUIRED));
        }
    }
View Full Code Here

        if (getVersion().startsWith("3")) {
            // 2.4 and 4.0 don't require that both params are there.
            if ((hasDatasource() && !hasDatasourceMapping()) ||
                (!hasDatasource() && hasDatasourceMapping())) {
                throw new XDocletException(Translator.getString(XDocletModulesJBossEjbMessages.class, XDocletModulesJBossEjbMessages.DATASOURCE_DATASOURCEMAPPING_PARAMETER_MISSING, new String[]{hasDatasource() ? "datasource" : "datasourcemapping"}));
            }
        }
    }
View Full Code Here

        String jbossVersion = getVersion();

        URL url = getJbossTemplateURL();

        if (url == null) {
            throw new XDocletException("can't find template for " + JBOSS_XML_FILE_NAME);
        }

        setTemplateURL(url);
        setDestinationFile(JBOSS_XML_FILE_NAME);
        if (jbossVersion.equals(JBossVersionTypes.VERSION_4_0)) {
            setPublicId(JBOSS_DD_PUBLICID_40);
            setSystemId(JBOSS_DD_SYSTEMID_40);
            setDtdURL(getClass().getResource(JBOSS_DTD_FILE_NAME_40));
        }
        else if (jbossVersion.equals(JBossVersionTypes.VERSION_3_2)) {
            setPublicId(JBOSS_DD_PUBLICID_32);
            setSystemId(JBOSS_DD_SYSTEMID_32);
            setDtdURL(getClass().getResource(JBOSS_DTD_FILE_NAME_32));
        }
        else if (jbossVersion.equals(JBossVersionTypes.VERSION_3_0) ||
            jbossVersion.equals(JBossVersionTypes.VERSION_3_0_1) ||
            jbossVersion.equals(JBossVersionTypes.VERSION_3_0_2) ||
            jbossVersion.equals(JBossVersionTypes.VERSION_3_0_3)) {
            setPublicId(JBOSS_DD_PUBLICID_30);
            setSystemId(JBOSS_DD_SYSTEMID_30);
            setDtdURL(getClass().getResource(JBOSS_DTD_FILE_NAME_30));
        }
        else {
            setPublicId(JBOSS_DD_PUBLICID_24);
            setSystemId(JBOSS_DD_SYSTEMID_24);
            setDtdURL(getClass().getResource(JBOSS_DTD_FILE_NAME_24));
        }

        startProcess();

        String ejbSpec = (String) getContext().getConfigParam("EjbSpec");

        // if there is one CMP 1.x bean or we are using JBoss 2.4, JBoss needs a jaws.xml
        //
        if (atLeastOneCmp1EntityBeanExists() || jbossVersion.equals(JBossVersionTypes.VERSION_2_4)) {

            url = getJawsTemplateURL();
            if (url == null) {
                throw new XDocletException("can't find template for " + JAWS_XML_FILE_NAME);
            }
            setTemplateURL(url);
            setDestinationFile(JAWS_XML_FILE_NAME);
            if (jbossVersion.equals(JBossVersionTypes.VERSION_3_0) ||
                jbossVersion.equals(JBossVersionTypes.VERSION_3_0_1) ||
                jbossVersion.equals(JBossVersionTypes.VERSION_3_0_2) ||
                jbossVersion.equals(JBossVersionTypes.VERSION_3_0_3) ||
                jbossVersion.equals(JBossVersionTypes.VERSION_3_2) ||
                jbossVersion.equals(JBossVersionTypes.VERSION_4_0)) {
                setPublicId(JAWS_DD_PUBLICID_30);
                setSystemId(JAWS_DD_SYSTEMID_30);
                setDtdURL(getClass().getResource(JAWS_DTD_FILE_NAME_30));
            }
            else if (ejbSpec.equals(EjbDocletTask.EjbSpecVersion.EJB_1_1)) {
                setPublicId(JAWS_DD_PUBLICID_24);
                setSystemId(JAWS_DD_SYSTEMID_24);
                setDtdURL(getClass().getResource(JAWS_DTD_FILE_NAME_24));
            }
            startProcess();
        }

        // if we are doing ejb spec 2.0, JBoss 3.0, and one CMP 2.x bean exists, JBoss needs
        // the jbosscmp-jdbc.xml file
        //
        if ((ejbSpec.equals(EjbDocletTask.EjbSpecVersion.EJB_2_0) || ejbSpec.equals(EjbDocletTask.EjbSpecVersion.EJB_2_1))
            && atLeastOneCmp2EntityBeanExists()) {

            url = getJbosscmpTemplateURL();
            if (url == null) {
                throw new XDocletException("can't find template for " + JBOSSCMP_DD_FILE_NAME);
            }

            setTemplateURL(url);

            setDestinationFile(JBOSSCMP_DD_FILE_NAME);

            if (jbossVersion.equals(JBossVersionTypes.VERSION_3_0) ||
                jbossVersion.equals(JBossVersionTypes.VERSION_3_0_1) ||
                jbossVersion.equals(JBossVersionTypes.VERSION_3_0_2) ||
                jbossVersion.equals(JBossVersionTypes.VERSION_3_0_3)) {

                setPublicId(JBOSSCMP_DD_PUBLICID_30);
                setSystemId(JBOSSCMP_DD_SYSTEMID_30);
                setDtdURL(getClass().getResource(JBOSSCMP_DTD_FILE_NAME_30));
            }
            else if (jbossVersion.equals(JBossVersionTypes.VERSION_3_2)) {

                setPublicId(JBOSSCMP_DD_PUBLICID_32);
                setSystemId(JBOSSCMP_DD_SYSTEMID_32);
                setDtdURL(getClass().getResource(JBOSSCMP_DTD_FILE_NAME_32));
            }
            else if (jbossVersion.equals(JBossVersionTypes.VERSION_4_0)) {

                setPublicId(JBOSSCMP_DD_PUBLICID_40);
                setSystemId(JBOSSCMP_DD_SYSTEMID_40);
                setDtdURL(getClass().getResource(JBOSSCMP_DTD_FILE_NAME_40));
            }
            // end of else
            else {
                throw new XDocletException("Unknown jboss version number for cmp2 " + jbossVersion);
            }
            // end of else

            startProcess();
        }
View Full Code Here

        if (file.exists()) {
            try {
                return file.toURL();
            }
            catch (MalformedURLException mue) {
                throw new XDocletException(mue, "Illegal file url: " + file.getAbsolutePath());
            }
        }
        else {
            throw new XDocletException("Couldn't find file: " + file.getAbsolutePath());
        }
    }
View Full Code Here

    {
        try {
            return (HibernateProperties) DocletContext.getInstance().getActiveSubTask();
        }
        catch (ClassCastException e) {
            throw new XDocletException(e, "May occur if attribute is used with incorrect subtask.");
        }
    }
View Full Code Here

        XMethod method = getIdMethod();

        // bomb politely if no ID method could be found
        if (method == null) {
            throw new XDocletException(
                Translator.getString(XDocletModulesHibernateMessages.class,
                XDocletModulesHibernateMessages.NO_ID_PROPERTY,
                new String[]{getCurrentClass().getQualifiedName()}));
        }

        // Determine whether or not the ID is a user-defined type.
        // If it is then it is not a composite id.
        boolean isUserType = false;

        String typeStr = method.getDoc().getTagAttributeValue("hibernate.id", "type");

        if (typeStr != null) {
            // The type attribute was supplied, so check
            // whether it implements cirrus.hibernate.UserType
            XClass typeClass = getXJavaDoc().getXClass(typeStr);

            if (typeClass != null) {
                isUserType = typeClass.isA("cirrus.hibernate.UserType") || typeClass.isA("net.sf.hibernate.UserType");
            }
        }
        else {
            typeStr = method.getReturnType().getType().getQualifiedName();
        }

        // decide whether we have composite or primitive ID
        boolean isPrimitive = TypeTagsHandler.isPrimitiveType(typeStr) ||
            "java.lang.Byte".equals(typeStr) ||
            "java.lang.Double".equals(typeStr) ||
            "java.lang.Float".equals(typeStr) ||
            "java.lang.Integer".equals(typeStr) ||
            "java.lang.Long".equals(typeStr) ||
            "java.lang.Short".equals(typeStr) ||
            "java.lang.String".equals(typeStr) ||
            "java.math.BigDecimal".equals(typeStr) ||
            "java.math.BigInteger".equals(typeStr) ||
            isUserType;

        if (isPrimitive && !composite) {
            setCurrentMethod(method);
            generate(template);
        }

        if (composite && !isPrimitive) {
            // check whether specified type satisfies us
            // it has to be serializable,
            // and implement equals itself.
            // bomb if not.
            XClass returnType = method.getReturnType().getType();

            if (returnType.isA("java.io.Serializable") && !returnType.isAbstract() &&
                !"java.lang.Object".equals(returnType.getMethod("equals(java.lang.Object)", true).getContainingClass().getQualifiedName())) {
                setCurrentMethod(method);
                generate(template);

            }
            else {
                // bomb politely that given property does not qualify as composite ID
                throw new XDocletException(
                    Translator.getString(XDocletModulesHibernateMessages.class,
                    XDocletModulesHibernateMessages.WRONG_COMPOSITE_ID,
                    new String[]{returnType.getQualifiedName()}));
            }
        }
View Full Code Here

TOP

Related Classes of xdoclet.XDocletException

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.