Search in sources :

Example 1 with TableTagTypeParserException

use of org.mifos.framework.exceptions.TableTagTypeParserException in project head by mifos.

the class TableTag method doStartTag.

/**
     * Function to render the tag
     */
@Override
public int doStartTag() throws JspException {
    // call the helper method to display the result.
    try {
        // Value of the list which we are getting from the Cache
        List list = getList();
        if (list == null) {
            return super.doStartTag();
        }
        if (list.size() == 0) {
            JspWriter out = pageContext.getOut();
            XmlBuilder result;
            result = noResults((String) SessionUtils.getAttribute(Constants.OFFICE_NAME, (HttpServletRequest) pageContext.getRequest()), (String) SessionUtils.getAttribute(Constants.BRANCH_ID, (HttpServletRequest) pageContext.getRequest()), (String) SessionUtils.getAttribute(Constants.SEARCH_STRING, (HttpServletRequest) pageContext.getRequest()));
            out.write(result.getOutput());
            return super.doStartTag();
        }
        getTableData(list);
    } catch (TableTagException tte) {
        throw new JspException(tte);
    } catch (TableTagParseException ttpe) {
        throw new JspException(ttpe);
    } catch (TableTagTypeParserException tttpe) {
        throw new JspException(tttpe);
    } catch (IOException ioe) {
        throw new JspException(ioe);
    } catch (HibernateSearchException hse) {
        throw new JspException(hse);
    } catch (PageExpiredException e) {
        throw new JspException(e);
    }
    return super.doStartTag();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TableTagException(org.mifos.framework.exceptions.TableTagException) JspException(javax.servlet.jsp.JspException) TableTagParseException(org.mifos.framework.exceptions.TableTagParseException) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) XmlBuilder(org.mifos.framework.struts.tags.XmlBuilder) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) TableTagTypeParserException(org.mifos.framework.exceptions.TableTagTypeParserException)

Example 2 with TableTagTypeParserException

use of org.mifos.framework.exceptions.TableTagTypeParserException in project head by mifos.

the class TypeParser method parser.

public Files parser(String filename) throws TableTagTypeParserException {
    Files file = null;
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setValidating(true);
        factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
        // Specify our own schema - this overrides the schemaLocation in the
        // xml file
        factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", "type.xsd");
        DocumentBuilder builder = factory.newDocumentBuilder();
        builder.setErrorHandler(null);
        Document document = builder.parse(MifosResourceUtil.getClassPathResourceAsStream(filename));
        Node fileNode = document.getFirstChild();
        file = new Files();
        file.setFileName(createFileName(fileNode));
    } catch (ParserConfigurationException pce) {
        throw new TableTagTypeParserException(pce);
    } catch (IOException ioe) {
        throw new TableTagTypeParserException(ioe);
    } catch (SAXParseException saxpe) {
        throw new TableTagTypeParserException(saxpe);
    } catch (SAXException saxe) {
        throw new TableTagTypeParserException(saxe);
    } catch (MifosRuntimeException saxe) {
        throw new TableTagTypeParserException(saxe);
    }
    return file;
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) SAXParseException(org.xml.sax.SAXParseException) Node(org.w3c.dom.Node) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Document(org.w3c.dom.Document) TableTagTypeParserException(org.mifos.framework.exceptions.TableTagTypeParserException) SAXException(org.xml.sax.SAXException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with TableTagTypeParserException

use of org.mifos.framework.exceptions.TableTagTypeParserException in project head by mifos.

the class TypeParser method createFileName.

private FileName[] createFileName(Node file) throws TableTagTypeParserException {
    NodeList fileNameNodeList = ((Element) file).getElementsByTagName(TableTagConstants.FILENAME);
    if (fileNameNodeList.getLength() == 0) {
        throw new TableTagTypeParserException(fileNameNodeList.toString());
    }
    FileName[] fileName = new FileName[fileNameNodeList.getLength()];
    for (int i = 0; i < fileNameNodeList.getLength(); i++) {
        fileName[i] = new FileName();
        fileName[i].setName((fileNameNodeList.item(i).getAttributes().getNamedItem(TableTagConstants.NAME).getNodeValue()));
        fileName[i].setPath((fileNameNodeList.item(i).getAttributes().getNamedItem(TableTagConstants.PATH).getNodeValue()));
    }
    return fileName;
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) TableTagTypeParserException(org.mifos.framework.exceptions.TableTagTypeParserException)

Aggregations

TableTagTypeParserException (org.mifos.framework.exceptions.TableTagTypeParserException)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 JspException (javax.servlet.jsp.JspException)1 JspWriter (javax.servlet.jsp.JspWriter)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)1 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)1 TableTagException (org.mifos.framework.exceptions.TableTagException)1 TableTagParseException (org.mifos.framework.exceptions.TableTagParseException)1 XmlBuilder (org.mifos.framework.struts.tags.XmlBuilder)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1