use of javax.xml.bind.UnmarshalException in project spring-framework by spring-projects.
the class Jaxb2RootElementHttpMessageConverter method readFromSource.
@Override
protected Object readFromSource(Class<?> clazz, HttpHeaders headers, Source source) throws IOException {
try {
source = processSource(source);
Unmarshaller unmarshaller = createUnmarshaller(clazz);
if (clazz.isAnnotationPresent(XmlRootElement.class)) {
return unmarshaller.unmarshal(source);
} else {
JAXBElement<?> jaxbElement = unmarshaller.unmarshal(source, clazz);
return jaxbElement.getValue();
}
} catch (NullPointerException ex) {
if (!isSupportDtd()) {
throw new HttpMessageNotReadableException("NPE while unmarshalling. " + "This can happen on JDK 1.6 due to the presence of DTD " + "declarations, which are disabled.", ex);
}
throw ex;
} catch (UnmarshalException ex) {
throw new HttpMessageNotReadableException("Could not unmarshal to [" + clazz + "]: " + ex.getMessage(), ex);
} catch (JAXBException ex) {
throw new HttpMessageConversionException("Could not instantiate JAXBContext: " + ex.getMessage(), ex);
}
}
use of javax.xml.bind.UnmarshalException in project intellij-community by JetBrains.
the class NexusRepositoryService method getRepositories.
@NotNull
@Override
public List<MavenRepositoryInfo> getRepositories(@NotNull String url) throws IOException {
try {
List<RepositoryType> repos = new Endpoint.Repositories(url).getRepolistAsRepositories().getData().getRepositoriesItem();
List<MavenRepositoryInfo> result = new ArrayList<>(repos.size());
for (RepositoryType repo : repos) {
if (!"maven2".equals(repo.getProvider()))
continue;
result.add(convertRepositoryInfo(repo));
}
return result;
} catch (UnmarshalException e) {
return Collections.emptyList();
} catch (JAXBException e) {
throw new IOException(e);
}
}
use of javax.xml.bind.UnmarshalException in project intellij-community by JetBrains.
the class NexusRepositoryService method findArtifacts.
@NotNull
@Override
public List<MavenArtifactInfo> findArtifacts(@NotNull String url, @NotNull MavenArtifactInfo template) throws IOException {
try {
final String packaging = StringUtil.notNullize(template.getPackaging());
final String name = StringUtil.join(Arrays.asList(template.getGroupId(), template.getArtifactId(), template.getVersion()), ":");
final SearchResults results = new Endpoint.DataIndex(url).getArtifactlistAsSearchResults(name, template.getGroupId(), template.getArtifactId(), template.getVersion(), null, template.getClassNames());
boolean tooManyResults = results.isTooManyResults();
final SearchResults.Data data = results.getData();
final ArrayList<MavenArtifactInfo> result = new ArrayList<>();
if (data != null) {
for (ArtifactType each : data.getArtifact()) {
if (!Comparing.equal(each.packaging, packaging))
continue;
result.add(convertArtifactInfo(each));
}
}
if (tooManyResults)
result.add(null);
return result;
} catch (UnmarshalException e) {
return Collections.emptyList();
} catch (JAXBException e) {
throw new IOException(e);
}
}
use of javax.xml.bind.UnmarshalException in project OpenAM by OpenRock.
the class SAXUnmarshallerHandlerImpl method handleEvent.
public void handleEvent(ValidationEvent event, boolean canRecover) throws SAXException {
ValidationEventHandler eventHandler;
try {
eventHandler = parent.getEventHandler();
} catch (JAXBException e) {
// impossible.
throw new JAXBAssertionError();
}
boolean recover = eventHandler.handleEvent(event);
// from the unmarshaller.getResult()
if (!recover)
aborted = true;
if (!canRecover || !recover)
throw new SAXException(new UnmarshalException(event.getMessage(), event.getLinkedException()));
}
use of javax.xml.bind.UnmarshalException in project OpenAM by OpenRock.
the class SAXUnmarshallerHandlerImpl method handleEvent.
public void handleEvent(ValidationEvent event, boolean canRecover) throws SAXException {
ValidationEventHandler eventHandler;
try {
eventHandler = parent.getEventHandler();
} catch (JAXBException e) {
// impossible.
throw new JAXBAssertionError();
}
boolean recover = eventHandler.handleEvent(event);
// from the unmarshaller.getResult()
if (!recover)
aborted = true;
if (!canRecover || !recover)
throw new SAXException(new UnmarshalException(event.getMessage(), event.getLinkedException()));
}
Aggregations