Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.JellyTagException


    {
        Project project = AntTagLibrary.getProject( getContext() );

        if ( project == null )
        {
            throw new JellyTagException( "cannot find ant project" );
        }

        checkAttribute( getId(), "id" );
        checkAttribute( getRefid(), "refid" );

        Path path = (Path) project.getReferences().get( getId() );
        if ( path == null )
        {
            throw new JellyTagException( "cannot find the path to add to specified by 'id': " + getId() );
        }
        Path addPath = (Path) project.getReferences().get( getRefid() );
        if ( addPath == null )
        {
            throw new JellyTagException( "cannot find the path to add specified by 'refid': " + getRefid() );
        }
        path.append( addPath );
    }
View Full Code Here


        {
            BeanUtils.setProperty(this, theName, theValue);
        }
        catch (IllegalAccessException anException)
        {
            throw new JellyTagException(anException);
        }
        catch (InvocationTargetException anException)
        {
            throw new JellyTagException(anException);
        }
       
    }
View Full Code Here

     */
    public void doTag(XMLOutput output) throws JellyTagException {
        try {
            conn = getConnection();
        } catch (SQLException e) {
            throw new JellyTagException(sql + ": " + e.getMessage(), e);
        }

        /*
         * Use the SQL statement specified by the sql attribute, if any,
         * otherwise use the body as the statement.
         */
        String sqlStatement = null;
        if (sql != null) {
            sqlStatement = sql;
        } else {
            sqlStatement = getBodyText();
        }
        if (sqlStatement == null || sqlStatement.trim().length() == 0) {
            throw new JellyTagException
    (Resources.getMessage("SQL_NO_STATEMENT"));
        }

        Statement statement = null;
        int result = 0;
        try {
            if (hasParameters()) {
                PreparedStatement ps
        = new UniversalPrepStmt (conn, sqlStatement);
                statement = ps;
                setParameters(ps);
                result = ps.executeUpdate();
            } else {
                statement = conn.createStatement();
                result = statement.executeUpdate(sqlStatement);
            }
            if (var != null) {
                context.setVariable(var, new Integer(result));
            }

            // lets nullify before we close in case we get exceptions
            // while closing, we don't want to try to close again
            Statement tempStatement = statement;
            statement = null;
            tempStatement.close();
        } catch (SQLException e) {
            throw new JellyTagException
    (sqlStatement + ": " + e.getMessage(), e);
        } finally {
            if (statement != null) {
                try {
                    statement.close();
View Full Code Here

    public void doTag(XMLOutput output) throws JellyTagException {
        SQLExecutionTag parent
            = (SQLExecutionTag)findAncestorWithClass
                (this, SQLExecutionTag.class);
        if (parent == null) {
            throw new JellyTagException
                (Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT"));
        }

        Object paramValue = value;
        if (value != null) {
            paramValue = value;
        } else {
            String bodyContent = getBodyText();
            if (bodyContent != null) {
                bodyContent = bodyContent.trim();
                if (bodyContent.length() > 0) {
                    paramValue = bodyContent;
                }
            }
        }

        if (type != null) {
            int typeVal = Integer.MIN_VALUE;
            if (type.equals("ARRAY")) {
                typeVal = Types.ARRAY;
            } else if (type.equals("BLOB")) {
                typeVal = Types.BLOB;
            } else if (type.equals("CLOB")) {
                typeVal = Types.CLOB;
            } else if (type.equals("REF")) {
                typeVal = Types.REF;
            } else if (type.equals("DATALINK")) {
                typeVal = Types.DATALINK;
            } else if (type.equals("BOOLEAN")) {
                typeVal = Types.BOOLEAN;
            } else if (type.equals("BIT")) {
                typeVal = Types.BIT;
            } else if (type.equals("TINYINT")) {
                typeVal = Types.TINYINT;
            } else if (type.equals("SMALLINT")) {
                typeVal = Types.SMALLINT;
            } else if (type.equals("INTEGER")) {
                typeVal = Types.INTEGER;
            } else if (type.equals("BIGINT")) {
                typeVal = Types.BIGINT;
            } else if (type.equals("FLOAT")) {
                typeVal = Types.FLOAT;
            } else if (type.equals("REAL")) {
                typeVal = Types.REAL;
            } else if (type.equals("DOUBLE")) {
                typeVal = Types.DOUBLE;
            } else if (type.equals("NUMERIC")) {
                typeVal = Types.NUMERIC;
            } else if (type.equals("DECIMAL")) {
                typeVal = Types.DECIMAL;
            } else if (type.equals("CHAR")) {
                typeVal = Types.CHAR;
            } else if (type.equals("VARCHAR")) {
                typeVal = Types.VARCHAR;
            } else if (type.equals("LONGVARCHAR")) {
                typeVal = Types.LONGVARCHAR;
            } else if (type.equals("DATE")) {
                typeVal = Types.DATE;
            } else if (type.equals("TIME")) {
                typeVal = Types.TIME;
            } else if (type.equals("TIMESTAMP")) {
                typeVal = Types.TIMESTAMP;
            } else if (type.equals("BINARY")) {
                typeVal = Types.BINARY;
            } else if (type.equals("VARBINARY")) {
                typeVal = Types.VARBINARY;
            } else if (type.equals("LONGVARBINARY")) {
                typeVal = Types.LONGVARBINARY;
            } else if (type.equals("NULL")) {
                typeVal = Types.NULL;
            } else if (type.equals("OTHER")) {
                typeVal = Types.OTHER;
            } else if (type.equals("JAVA_OBJECT")) {
                typeVal = Types.JAVA_OBJECT;
            } else if (type.equals("DISTINCT")) {
                typeVal = Types.DISTINCT;
            } else if (type.equals("STRUCT")) {
                typeVal = Types.STRUCT;
            } else {
                throw new JellyTagException
                    ("Unrecognized value in \"type\" attribute.");
            }
       
            parent.addSQLParameter (new ParamAttributes(paramValue, typeVal));
            return;
View Full Code Here

                    maxRows = ((Integer) obj).intValue();
                } else if (obj instanceof String) {
                    try {
                        maxRows = Integer.parseInt((String) obj);
                    } catch (NumberFormatException nfe) {
                        throw new JellyTagException
          (Resources.getMessage("SQL_MAXROWS_PARSE_ERROR",
              (String) obj), nfe);
                    }
                } else {
                    throw new JellyTagException
      (Resources.getMessage("SQL_MAXROWS_INVALID"));
                }
            }
        }
 
        Result result = null;
        String sqlStatement = null;

        logger.debug( "About to lookup connection" );

        ResultSet rs = null;
        Statement statement = null;
        try {
            conn = getConnection();

            /*
             * Use the SQL statement specified by the sql attribute, if any,
             * otherwise use the body as the statement.
             */
            if (sql != null) {
                sqlStatement = sql;
            } else {
                sqlStatement = getBodyText();
            }
            if (sqlStatement == null || sqlStatement.trim().length() == 0) {
                throw new JellyTagException
        (Resources.getMessage("SQL_NO_STATEMENT"));
            }
            // We shouldn't have a negative startRow or illegal maxrows
            if ((startRow < 0) || (maxRows < -1)) {
                throw new JellyTagException
        (Resources.getMessage("PARAM_BAD_VALUE"));
            }

            /*
             * Note! We must not use the setMaxRows() method on the
             * the statement to limit the number of rows, since the
             * Result factory must be able to figure out the correct
             * value for isLimitedByMaxRows(); there's no way to check
             * if it was from the ResultSet.
             */
            if (logger.isDebugEnabled()) {
                logger.debug( "About to execute query: " + sqlStatement );
            }

            if (hasParameters()) {
                PreparedStatement ps
        = new UniversalPrepStmt (conn, sqlStatement);
                statement = ps;
                setParameters(ps);
                rs = ps.executeQuery();
            } else {
                statement = conn.createStatement();
                rs = statement.executeQuery(sqlStatement);
            }

            result = new ResultImpl(rs, startRow, maxRows);
            context.setVariable(var, result);

            // always close the result set first since it may be closed by
            // JDBC 3 when closing statements

            // lets nullify before we close in case we get exceptions
            // while closing, we don't want to try to close again
            ResultSet tempRs = rs;
            rs = null;
            tempRs.close();
            Statement tempStatement = statement;
            statement = null;
            tempStatement.close();
        } catch (SQLException e) {
            throw new JellyTagException
    (sqlStatement + ": " + e.getMessage(), e);
        } finally {
            if (rs != null) {
                try {
                    rs.close();
View Full Code Here

        }
        try {
            HandlerStack handler = new HandlerStack(new ContentHandler ());
            getXML (new XMLOutput(handler.contentHandler()));
        } catch (SAXException e) {
            throw new JellyTagException(e.getException());
        }
    }
View Full Code Here

        }
        try {
            HandlerStack handler = new HandlerStack(new ContentHandler ());
            getXML (new XMLOutput(handler.contentHandler()));
        } catch (SAXException e) {
            throw new JellyTagException(e.getException());
        }
    }
View Full Code Here

            }
        } catch (NamingException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Cannot access LDAP server: " + e.getMessage(), e);
            }
            throw new JellyTagException (e);
        }
    }
View Full Code Here

      output.endElement("queryResult");
  } catch (NamingException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Cannot access LDAP server: " + e.getMessage(), e);
            }
            throw new JellyTagException (e);
  } catch (SAXException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Cannot access LDAP server: " + e.getMessage(), e);
            }
            throw new JellyTagException (e);
  }
    }
View Full Code Here

     */
    public void doTag(XMLOutput output) throws JellyTagException {
        SetInitialContextTag parent = (SetInitialContextTag)
      findAncestorWithClass(SetInitialContextTag.class);
        if (null == parent) {
            throw new JellyTagException
    ("This tag must be enclosed inside <setInitialContext>.");
        } else {
            parent.addEnvironmentEntry (name, value);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.jelly.JellyTagException

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.