Examples of JahiaException


Examples of org.jahia.exceptions.JahiaException

                StringBuffer strBuf = new StringBuffer(1024);
                strBuf.append(" extractEntry(), cannot find entry ");
                strBuf.append(entryName);
                strBuf.append(" in the jar file ");

                throw new JahiaException(CLASS_NAME, strBuf.toString(),
                                         JahiaException.SERVICE_ERROR,
                                         JahiaException.ERROR_SEVERITY);

            }

            File destDir = new File(destPath);
            if (destDir == null || !destDir.isDirectory() || !destDir.canWrite()) {

                logger.error(" cannot access to the destination dir " +
                             destPath);

                throw new JahiaException(CLASS_NAME,
                    " cannot access to the destination dir ",
                                         JahiaException.SERVICE_ERROR,
                                         JahiaException.ERROR_SEVERITY);
            }

            String path = null;

            FileInputStream fis = new FileInputStream(m_FilePath);
            BufferedInputStream bis = new BufferedInputStream(fis);
            ZipInputStream zis = new ZipInputStream(bis);
            ZipFile zf = new ZipFile(m_FilePath);
            ZipEntry ze = null;
            String zeName = null;

            while ( (ze = zis.getNextEntry()) != null &&
                          !ze.getName().equalsIgnoreCase(entryName)) {
                // loop until the requested entry
                zis.closeEntry();
            }

            try {

                if (ze.isDirectory()) {

                    while (ze != null) {
                        zeName = ze.getName();
                        path = destPath + File.separator + genPathFile(zeName);
                        File fo = new File(path);
                        if (ze.isDirectory()) {
                            fo.mkdirs();
                        } else {

                            FileOutputStream outs = new FileOutputStream(fo);
                            copyStream(zis, outs);
                            //outs.flush();
                            //outs.close();
                        }
                        zis.closeEntry();
                        ze = zis.getNextEntry();

                    }
                } else {

                    zeName = ze.getName();
                    path = destPath + File.separator + genPathFile(zeName);

                    File fo = new File(path);
                    FileOutputStream outs = new FileOutputStream(fo);
                    copyStream(zis, outs);
                    //outs.flush();
                    //outs.close();
                }

            } finally {

                // Important !!!
                zf.close();
                fis.close();
                zis.close();
                bis.close();
            }

        } catch (IOException ioe) {

            logger.error(" fail unzipping " + ioe.getMessage(), ioe);

            throw new JahiaException(CLASS_NAME, "faile processing unzip",
                                     JahiaException.SERVICE_ERROR,
                                     JahiaException.ERROR_SEVERITY, ioe);

        }
View Full Code Here

Examples of org.jahia.exceptions.JahiaException

                    "facet.locale"));
           
            resOuter.add(fieldName + PROPNAME_INDEX_SEPARATOR + fieldNameInIndex, resInner);
           
            if (!(epd.getRequiredType() == PropertyType.DATE)) {
                throw new JahiaException("Can not date facet on a field which is not a DateField: "
                        + f, "Can not date facet on a field which is not a DateField: " + f,
                        JahiaException.PARAMETER_ERROR, JahiaException.ERROR_SEVERITY);
            }
            Integer mincount = params.getFieldInt(f, FacetParams.FACET_MINCOUNT);
            if (mincount == null) {
                Boolean zeros = params.getFieldBool(f, FacetParams.FACET_ZEROS);
                // mincount = (zeros!=null && zeros) ? 0 : 1;
                mincount = (zeros != null && !zeros) ? 1 : 0;
                // current default is to include zeros.
            }
           
            final String startS = required.getFieldParam(f,
                    FacetParams.FACET_DATE_START);
            final Date start;
            try {
                start = JahiaQueryParser.DATE_TYPE.parseMath(NOW, startS);
            } catch (SolrException e) {
                throw new JahiaException(
                        "date facet 'start' is not a valid Date string: " + startS,
                        "date facet 'start' is not a valid Date string: " + startS,
                        JahiaException.PARAMETER_ERROR, JahiaException.ERROR_SEVERITY, e);
            }
            final String endS = required.getFieldParam(f, FacetParams.FACET_DATE_END);
            Date end; // not final, hardend may change this
            try {
                end = JahiaQueryParser.DATE_TYPE.parseMath(NOW, endS);
            } catch (SolrException e) {
                throw new JahiaException("date facet 'end' is not a valid Date string: " + endS,
                        "date facet 'end' is not a valid Date string: " + endS,
                        JahiaException.PARAMETER_ERROR, JahiaException.ERROR_SEVERITY, e);
            }

            if (end.before(start)) {
                throw new JahiaException("date facet 'end' comes before 'start': " + endS + " < "
                        + startS,
                        "date facet 'end' comes before 'start': " + endS + " < " + startS,
                        JahiaException.PARAMETER_ERROR, JahiaException.ERROR_SEVERITY);
            }

            final String gap = required.getFieldParam(f, FacetParams.FACET_DATE_GAP);
            final DateMathParser dmp = new DateMathParser(DateField.UTC, Locale.US);
            dmp.setNow(NOW);
            try {

                Date low = start;
                while (low.before(end)) {
                    dmp.setNow(low);
                    final String lowI = JahiaQueryParser.DATE_TYPE.toInternal(low);
                    final String label = JahiaQueryParser.DATE_TYPE.indexedToReadable(lowI, true);
                    Date high = dmp.parseMath(gap);
                    if (end.before(high)) {
                        if (params.getFieldBool(f, FacetParams.FACET_DATE_HARD_END,
                                false)) {
                            high = end;
                        } else {
                            end = high;
                        }
                    }
                    if (high.before(low)) {
                        throw new JahiaException("date facet infinite loop (is gap negative?)",
                                "date facet infinite loop (is gap negative?)",
                                JahiaException.PARAMETER_ERROR, JahiaException.ERROR_SEVERITY);
                    }
                    final String highI = JahiaQueryParser.DATE_TYPE.toInternal(high);
                    Query rangeQuery = getRangeQuery(fieldNameInIndex, lowI, highI, true, true);
                    int count = rangeCount(rangeQuery);
                    if (count >= mincount) {
                        resInner.add(label + PROPNAME_INDEX_SEPARATOR + rangeQuery.toString(),
                                count);
                    }
                    low = high;
                }
            } catch (java.text.ParseException e) {
                throw new JahiaException(
                        "date facet 'gap' is not a valid Date Math string: " + gap,
                        "date facet 'gap' is not a valid Date Math string: " + gap,
                        JahiaException.PARAMETER_ERROR, JahiaException.ERROR_SEVERITY, e);
            }
View Full Code Here

Examples of org.jahia.exceptions.JahiaException

        strOut.println("");
        strOut.println(
                "Your Server has generated an error. Please review the details below for additional information: ");
        strOut.println("");
        if (t instanceof JahiaException) {
            JahiaException nje = (JahiaException) t;
            String severityMsg = "Undefined";
            switch (nje.getSeverity()) {
                case JahiaException.WARNING_SEVERITY:
                    severityMsg = "WARNING";
                    break;
                case JahiaException.ERROR_SEVERITY:
                    severityMsg = "ERROR";
View Full Code Here

Examples of org.jahia.exceptions.JahiaException

            Document xmlDocument = dfactory.newDocumentBuilder().parse(stream);
            xmlDocument.normalize(); // clean up DOM tree a little
            xml = new Web_App_Xml(xmlDocument);
            xml.extractDocumentData();
        } catch (Exception t) {
            throw new JahiaException("JahiaXmlDocument",
                                     "Exception while parsing web.xml stream",
                                     JahiaException.ERROR_SEVERITY,
                                     JahiaException.SERVICE_ERROR, t);
        }
       
View Full Code Here

Examples of org.jahia.exceptions.JahiaException

     */
    private void extractDocumentData() throws JahiaException {

        if (m_XMLDocument == null) {

            throw new JahiaException("Web_App_Xml",
                    "Parsed web.xml document is null",
                    JahiaException.ERROR_SEVERITY, JahiaException.CONFIG_ERROR);
        }

        if (!m_XMLDocument.hasChildNodes()) {

            throw new JahiaException("Web_App_Xml",
                    "Main document node has no children",
                    JahiaException.ERROR_SEVERITY, JahiaException.CONFIG_ERROR);
        }

        // get web-app node
        Element webAppNode;
        webAppNode = (Element) m_XMLDocument.getDocumentElement();

        if (!webAppNode.getNodeName().equalsIgnoreCase("web-app")) {

            throw new JahiaException("Invalid XML format",
                    "web-app tag is not present as starting tag in file",
                    JahiaException.ERROR_SEVERITY, JahiaException.CONFIG_ERROR);
        }

        // get the webapp display name
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.