use of org.xml.sax.SAXParseException in project che by eclipse.
the class MavenServerService method reconcilePom.
@GET
@Path("pom/reconcile")
@ApiOperation(value = "Reconcile pom.xml file")
@ApiResponses({ @ApiResponse(code = 200, message = "OK") })
@Produces("application/json")
public List<Problem> reconcilePom(@ApiParam(value = "The paths to pom.xml file which need to be reconciled") @QueryParam("pompath") String pomPath) {
VirtualFileEntry entry = null;
List<Problem> result = new ArrayList<>();
try {
entry = cheProjectManager.getProjectsRoot().getChild(pomPath);
if (entry == null) {
return result;
}
Model.readFrom(entry.getVirtualFile());
org.eclipse.che.api.vfs.Path path = entry.getPath();
String pomContent = entry.getVirtualFile().getContentAsString();
MavenProject mavenProject = mavenProjectManager.findMavenProject(ResourcesPlugin.getWorkspace().getRoot().getProject(path.getParent().toString()));
if (mavenProject == null) {
return result;
}
List<MavenProjectProblem> problems = mavenProject.getProblems();
int start = pomContent.indexOf("<project ") + 1;
int end = start + "<project ".length();
List<Problem> problemList = problems.stream().map(mavenProjectProblem -> DtoFactory.newDto(Problem.class).withError(true).withSourceStart(start).withSourceEnd(end).withMessage(mavenProjectProblem.getDescription())).collect(Collectors.toList());
result.addAll(problemList);
} catch (ServerException | ForbiddenException | IOException e) {
LOG.error(e.getMessage(), e);
} catch (XMLTreeException exception) {
Throwable cause = exception.getCause();
if (cause != null && cause instanceof SAXParseException) {
result.add(createProblem(entry, (SAXParseException) cause));
}
}
return result;
}
use of org.xml.sax.SAXParseException in project tomcat by apache.
the class SetParentClassLoaderRule method load.
/**
* Start a new server instance.
*/
public void load() {
long t1 = System.nanoTime();
initDirs();
// Before digester - it may be needed
initNaming();
// Create and execute our Digester
Digester digester = createStartDigester();
InputSource inputSource = null;
InputStream inputStream = null;
File file = null;
try {
try {
file = configFile();
inputStream = new FileInputStream(file);
inputSource = new InputSource(file.toURI().toURL().toString());
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug(sm.getString("catalina.configFail", file), e);
}
}
if (inputStream == null) {
try {
inputStream = getClass().getClassLoader().getResourceAsStream(getConfigFile());
inputSource = new InputSource(getClass().getClassLoader().getResource(getConfigFile()).toString());
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug(sm.getString("catalina.configFail", getConfigFile()), e);
}
}
}
// Alternative: don't bother with xml, just create it manually.
if (inputStream == null) {
try {
inputStream = getClass().getClassLoader().getResourceAsStream("server-embed.xml");
inputSource = new InputSource(getClass().getClassLoader().getResource("server-embed.xml").toString());
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug(sm.getString("catalina.configFail", "server-embed.xml"), e);
}
}
}
if (inputStream == null || inputSource == null) {
if (file == null) {
log.warn(sm.getString("catalina.configFail", getConfigFile() + "] or [server-embed.xml]"));
} else {
log.warn(sm.getString("catalina.configFail", file.getAbsolutePath()));
if (file.exists() && !file.canRead()) {
log.warn("Permissions incorrect, read permission is not allowed on the file.");
}
}
return;
}
try {
inputSource.setByteStream(inputStream);
digester.push(this);
digester.parse(inputSource);
} catch (SAXParseException spe) {
log.warn("Catalina.start using " + getConfigFile() + ": " + spe.getMessage());
return;
} catch (Exception e) {
log.warn("Catalina.start using " + getConfigFile() + ": ", e);
return;
}
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// Ignore
}
}
}
getServer().setCatalina(this);
getServer().setCatalinaHome(Bootstrap.getCatalinaHomeFile());
getServer().setCatalinaBase(Bootstrap.getCatalinaBaseFile());
// Stream redirection
initStreams();
// Start the new server
try {
getServer().init();
} catch (LifecycleException e) {
if (Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE")) {
throw new java.lang.Error(e);
} else {
log.error("Catalina.start", e);
}
}
long t2 = System.nanoTime();
if (log.isInfoEnabled()) {
log.info("Initialization processed in " + ((t2 - t1) / 1000000) + " ms");
}
}
use of org.xml.sax.SAXParseException 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;
}
use of org.xml.sax.SAXParseException in project head by mifos.
the class StateXMLParser method loadMapFromXml.
public Map<StateEntity, List<StateEntity>> loadMapFromXml(String filename, String configurationName) {
Map<StateEntity, List<StateEntity>> transitionMap = new HashMap<StateEntity, List<StateEntity>>();
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", "StateMachine.xsd");
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setErrorHandler(null);
Document document = builder.parse(MifosResourceUtil.getClassPathResourceAsStream(filename));
Node mapToprocess = null;
/*
* String configurationName = ""; if
* (stateConfiguration=="configuration1") configurationName = "1";
* else configurationName = "2";
*/
NodeList configMaps = document.getElementsByTagName("stateConfiguration");
for (int m = 0; m < configMaps.getLength(); m++) {
Node stateConfiguration = configMaps.item(m);
if (configurationName.equals(stateConfiguration.getAttributes().getNamedItem("configurationName").getNodeValue())) {
mapToprocess = stateConfiguration;
}
}
// NodeList stateList = firstChild.getChildNodes();
NodeList stateList = mapToprocess.getChildNodes();
for (int i = 0; i < stateList.getLength(); i++) {
// each state has state id and possiblestates as childern
Node state = stateList.item(i);
// iterate for each child of state
NodeList stateInfoList = state.getChildNodes();
StateEntity currentState = null;
List<StateEntity> currntPossibleStates = new ArrayList<StateEntity>();
for (int j = 0; j < stateInfoList.getLength(); j++) {
Node info = stateInfoList.item(j);
if ("stateid".equals(info.getLocalName())) {
Element ele = (Element) info;
currentState = new StateEntity(Short.valueOf(((Text) ele.getFirstChild()).getData()));
}
if ("possiblestates".equals(info.getLocalName())) {
// get all the childern
NodeList allStates = info.getChildNodes();
currntPossibleStates = new ArrayList<StateEntity>();
for (int k = 0; k < allStates.getLength(); k++) {
Node infoState = allStates.item(k);
NodeList eachPossiblechild = infoState.getChildNodes();
for (int l = 0; l < eachPossiblechild.getLength(); l++) {
Node eachPossiblechildelement = eachPossiblechild.item(l);
if ("stateid".equals(eachPossiblechildelement.getLocalName())) {
Element element = (Element) eachPossiblechildelement;
Short possibleTrantionId = Short.valueOf(((Text) element.getFirstChild()).getData());
currntPossibleStates.add(new StateEntity(possibleTrantionId));
}
}
}
}
}
if (currentState != null) {
transitionMap.put(currentState, currntPossibleStates);
}
}
} catch (ParserConfigurationException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (SAXParseException e) {
throw new RuntimeException(e);
} catch (SAXException e) {
throw new RuntimeException(e);
}
return transitionMap;
}
use of org.xml.sax.SAXParseException in project head by mifos.
the class XMLParser method parser.
public ColumnPropertyMapping parser() throws SystemException {
Document document = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(MifosResourceUtil.getClassPathResourceAsStream("org/mifos/framework/util/resources/audit/ColumnMapping.xml"));
getColumnPropertyMapping(document);
} catch (ParserConfigurationException e) {
throw new SystemException(e);
} catch (IOException e) {
throw new SystemException(e);
} catch (SAXParseException e) {
throw new SystemException(e);
} catch (SAXException e) {
throw new SystemException(e);
}
return columnPropertyMapping;
}
Aggregations