Example usage for org.xml.sax SAXException getMessage

List of usage examples for org.xml.sax SAXException getMessage

Introduction

In this page you can find the example usage for org.xml.sax SAXException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Return a detail message for this exception.

Usage

From source file:MainClass.java

static void fail(SAXException e) {
    if (e instanceof SAXParseException) {
        SAXParseException spe = (SAXParseException) e;
        System.err.printf("%s:%d:%d: %s%n", spe.getSystemId(), spe.getLineNumber(), spe.getColumnNumber(),
                spe.getMessage());/*from   ww w .  j av a  2s  .c o  m*/
    } else {
        System.err.println(e.getMessage());
    }
    System.exit(1);
}

From source file:com.aionemu.gameserver.model.TribeRelationCheck.java

@BeforeClass
public static void init() throws Exception {
    File xml = new File("./data/static_data/tribe/tribe_relations.xml");
    Schema schema = null;/*w w w.  j av a  2  s .  c o m*/
    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    TribeRelationsData tribeRelations = null;
    NpcData npcTemplates = null;

    try {
        schema = sf.newSchema(new File("./data/static_data/tribe/tribe_relations.xsd"));
        JAXBContext jc = JAXBContext.newInstance(TribeRelationsData.class);
        Unmarshaller unmarshaller = jc.createUnmarshaller();
        unmarshaller.setSchema(schema);
        tribeRelations = (TribeRelationsData) unmarshaller.unmarshal(xml);

        xml = new File("./data/static_data/npcs/npc_templates.xml");
        schema = sf.newSchema(new File("./data/static_data/npcs/npcs.xsd"));
        jc = JAXBContext.newInstance(NpcData.class);
        unmarshaller = jc.createUnmarshaller();
        unmarshaller.setSchema(schema);
        npcTemplates = (NpcData) unmarshaller.unmarshal(xml);
    } catch (SAXException e1) {
        System.out.println(e1.getMessage());
    } catch (JAXBException e2) {
        System.out.println(e2.getMessage());
    }

    // Not interesting
    DataManager.NPC_SKILL_DATA = new NpcSkillData();
    DataManager.NPC_DATA = npcTemplates;
    DataManager.TRIBE_RELATIONS_DATA = tribeRelations;
    DataManager.ZONE_DATA = new DummyZoneData();
    DataManager.WORLD_MAPS_DATA = new DummyWorldMapData();

    Config.load();
    // AIConfig.ONCREATE_DEBUG = true;
    AIConfig.EVENT_DEBUG = true;
    ThreadConfig.THREAD_POOL_SIZE = 20;
    ThreadPoolManager.getInstance();

    AI2Engine.getInstance().load(null);

    /**
     * Comment out these lines in DAOManager.registerDAO() if not using DB: <tt> 
     * if (!dao.supports(getDatabaseName(),
     *       getDatabaseMajorVersion(), getDatabaseMinorVersion())) { return; } 
     * </tt>
     */
    DAOManager.init();

    world = World.getInstance();
    asmo = DummyPlayer.createAsmodian();
    asmoPosition = World.getInstance().createPosition(DummyWorldMapData.DEFAULT_MAP, 100f, 100f, 0f, (byte) 0,
            0);

    MapRegion asmoRegion = asmoPosition.getWorldMapInstance().getRegion(100f, 100f, 0);
    asmoRegion.getObjects().put(asmo.getObjectId(), asmo);
    asmoRegion.activate();
    asmo.setPosition(asmoPosition);

    ely = DummyPlayer.createElyo();
    elyPosition = World.getInstance().createPosition(DummyWorldMapData.DEFAULT_MAP, 200f, 200f, 0f, (byte) 0,
            0);
    MapRegion elyRegion = elyPosition.getWorldMapInstance().getRegion(200f, 200f, 0);
    elyRegion.getObjects().put(ely.getObjectId(), ely);
    elyRegion.activate();
    ely.setPosition(elyPosition);

    PacketBroadcaster.getInstance();
    DuelService.getInstance();
    PlayerMoveTaskManager.getInstance();
    MoveTaskManager.getInstance();
}

From source file:eu.eidas.configuration.ConfigurationReader.java

/**
 * Read configuration.//from   w w  w.j  a  v  a  2  s.com
 *
 * @return the map< string, instance engine>
 *
 * @throws SAMLEngineException the EIDASSAML engine runtime
 *             exception
 */
public static Map<String, InstanceEngine> readConfiguration() throws SAMLEngineException {

    LOGGER.debug("Init reader: " + ENGINE_CONF_FILE);
    final Map<String, InstanceEngine> instanceConfs = new HashMap<String, InstanceEngine>();

    Document document = null;
    // Load configuration file
    final DocumentBuilderFactory factory = EIDASSAMLEngine.newDocumentBuilderFactory();
    DocumentBuilder builder;

    InputStream engineConf = null;
    try {

        factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);

        builder = factory.newDocumentBuilder();

        engineConf = ConfigurationReader.class.getResourceAsStream("/" + ENGINE_CONF_FILE);

        document = builder.parse(engineConf);

        // Read instance
        final NodeList list = document.getElementsByTagName(NODE_INSTANCE);

        for (int indexElem = 0; indexElem < list.getLength(); ++indexElem) {
            final Element element = (Element) list.item(indexElem);

            final InstanceEngine instanceConf = new InstanceEngine();

            // read every configuration.
            final String instanceName = element.getAttribute(NODE_INST_NAME);

            if (StringUtils.isBlank(instanceName)) {
                throw new EIDASSAMLEngineRuntimeException("Error reader instance name.");
            }
            instanceConf.setName(instanceName.trim());

            final NodeList confNodes = element.getElementsByTagName(NODE_CONF);

            for (int indexNode = 0; indexNode < confNodes.getLength(); ++indexNode) {

                final Element configurationNode = (Element) confNodes.item(indexNode);

                final String configurationName = configurationNode.getAttribute(NODE_CONF_NAME);

                if (StringUtils.isBlank(configurationName)) {
                    throw new EIDASSAMLEngineRuntimeException("Error reader configuration name.");
                }

                final ConfigurationEngine confSamlEngine = new ConfigurationEngine();

                // Set configuration name.
                confSamlEngine.setName(configurationName.trim());

                // Read every parameter for this configuration.
                final Map<String, String> parameters = generateParam(configurationNode);

                // Set parameters
                confSamlEngine.setParameters(parameters);

                // Add parameters to the configuration.
                instanceConf.getConfiguration().add(confSamlEngine);
            }

            // Add to the list of configurations.
            instanceConfs.put(element.getAttribute(NODE_INST_NAME), instanceConf);
        }

    } catch (SAXException e) {
        LOGGER.warn("ERROR : init library parser.", e.getMessage());
        LOGGER.debug("ERROR : init library parser.", e);
        throw new SAMLEngineException(e);
    } catch (ParserConfigurationException e) {
        LOGGER.warn("ERROR : parser configuration file xml.");
        LOGGER.debug("ERROR : parser configuration file xml.", e);
        throw new SAMLEngineException(e);
    } catch (IOException e) {
        LOGGER.warn("ERROR : read configuration file.", e.getMessage());
        LOGGER.debug("ERROR : read configuration file.", e);
        throw new SAMLEngineException(e);
    } finally {
        IOUtils.closeQuietly(engineConf);
    }

    return instanceConfs;
}

From source file:com.thruzero.common.core.utils.XmlUtils.java

/** return null if content text is valid; otherwise return error message. */
public static String validateContentText(final String contentText, final ErrorHandler xmlErrorHandler) {
    InputStream inputStream = StringUtilsExt.stringToInputStream(contentText);

    // create builder
    try {//from w w  w .j a va2  s. com
        DocumentBuilder documentParser = XmlUtils.createNonValidatingDocumentBuilder();
        XmlUtils.createDocument(documentParser, inputStream);
    } catch (SAXException e) {
        return "SAXException:" + e.getMessage(); // "SAXException:" added to guarantee that the return result will not be empty on error.
    } catch (IOException e) {
        return "IOException:" + e.getMessage(); // "IOException:" added to guarantee that the return result will not be empty on error.
    } catch (ParserConfigurationException e) {
        return "Error: Could not create document builder.";
    }

    return null;
}

From source file:de.tub.av.pe.xcapsrv.XMLValidator.java

public static Document getWellFormedDocument(Reader reader)
        throws NotWellFormedConflictException, InternalServerErrorException {
    try {//from  ww  w .ja v a  2  s .  c o m
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        DocumentBuilder parser = factory.newDocumentBuilder();
        Document docu = parser.parse(new InputSource(reader));
        //testTheCreatedDocu(docu);
        return docu;
    } catch (SAXException e) {
        throw new NotWellFormedConflictException();
    } catch (IOException e) {
        throw new InternalServerErrorException(e.getMessage());
    } catch (ParserConfigurationException e) {
        throw new InternalServerErrorException(e.getMessage());
    }
}

From source file:de.tub.av.pe.xcapsrv.XMLValidator.java

public static Element getWellFormedDocumentFragment(Reader reader)
        throws NotValidXMLFragmentConflictException, InternalServerErrorException {
    try {//w w w  .ja v a  2s  .  c om
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(false);
        DocumentBuilder parser = factory.newDocumentBuilder();
        Document dummyDocument = parser.parse(new InputSource(reader));
        return dummyDocument.getDocumentElement();
    } catch (SAXException e) {

        throw new NotValidXMLFragmentConflictException();
    } catch (IOException e) {
        throw new InternalServerErrorException(e.getMessage());
    } catch (ParserConfigurationException e) {
        throw new InternalServerErrorException(e.getMessage());
    }
}

From source file:com.sfs.jbtimporter.JBTImporter.java

/**
 * Revert the transformed issue XML files.
 *
 * @param jbt the jbt//w w  w.  ja  va  2 s  .  c om
 */
private static void revertTransformation(final JBTProcessor jbt) {

    System.out.println("Reverting transformation...");
    System.out.println("Export directory: " + jbt.getExportBase());

    List<JBTIssue> issues = new ArrayList<JBTIssue>();
    try {
        issues = jbt.parseXmlIndex();
    } catch (IOException ioe) {
        System.out.println("ERROR loading index.xml file: " + ioe.getMessage());
    } catch (SAXException se) {
        System.out.println("ERROR parsing index.xml file: " + se.getMessage());
    }
    // Process the issues in the XML file
    revertIssues(jbt, issues);
}

From source file:com.sfs.jbtimporter.JBTImporter.java

/**
 * Perform an import./*www.  j a v a2s.c  om*/
 *
 * @param jbt the jbt
 */
private static void performImport(final JBTProcessor jbt) {

    System.out.println("Beginning export...");
    System.out.println("Jira host: " + jbt.getBaseUrl());
    System.out.println("Export directory: " + jbt.getExportBase());

    List<JBTIssue> issues = new ArrayList<JBTIssue>();
    try {
        issues = jbt.parseXmlIndex();
    } catch (IOException ioe) {
        System.out.println("ERROR loading index.xml file: " + ioe.getMessage());
    } catch (SAXException se) {
        System.out.println("ERROR parsing index.xml file: " + se.getMessage());
    }
    // Process the issues in the XML file
    processIssues(jbt, issues);
}

From source file:com.sfs.jbtimporter.JBTImporter.java

/**
 * Perform a transformation.//from  w w  w. j  ava  2  s  .co m
 *
 * @param jbt the jbt
 */
private static void performTransformation(final JBTProcessor jbt) {

    System.out.println("Beginning transformation...");
    System.out.println("XSLT file: " + jbt.getXsltFileName());
    System.out.println("Export directory: " + jbt.getExportBase());

    List<JBTIssue> issues = new ArrayList<JBTIssue>();
    try {
        issues = jbt.parseXmlIndex();
    } catch (IOException ioe) {
        System.out.println("ERROR loading index.xml file: " + ioe.getMessage());
    } catch (SAXException se) {
        System.out.println("ERROR parsing index.xml file: " + se.getMessage());
    }
    // Process the issues in the XML file
    transformIssues(jbt, issues);
}

From source file:io.cloudslang.content.xml.utils.XmlUtils.java

/**
 * Transforms a string representation of an XML Node to an Node
 *
 * @param value    the node as String//from w  w  w . ja va 2  s . c  o m
 * @param features parsing features to set on the document builder
 * @return the Node object
 * @throws Exception in case the String can't be represented as a Node
 */
public static Node stringToNode(String value, String encoding, String features) throws Exception {
    Node node;
    if (StringUtils.isEmpty(encoding)) {
        encoding = "UTF-8";
    }
    try (InputStream inputStream = new ByteArrayInputStream(value.getBytes(encoding))) {
        // check if input value is a Node
        Document docNew = DocumentUtils.createDocumentBuilder(features).parse(inputStream);
        node = docNew.getDocumentElement();
    } catch (SAXException se) {
        throw new Exception("Value " + value + "is not valid XML element : " + se.getMessage());
    }
    return node;
}