}
pomFile = File.createTempFile("uploaded-pom-", ".xml", configurer.getTmpDirectory());
fileUpload.writeTo(pomFile);
PomBean pomBean = mavenCentralSearchApiService.searchFromPom(pomFile);
ArtifactPomSearchPanel.this.pomBeanModel.setObject(pomBean);
ArtifactPomSearchPanel.this.pomContentModel.setObject(null);
} catch (Exception e) {
LOGGER.error("Unable to parse " + fileSelect.getFileUpload().getClientFileName() + " file", e);
Session.get().error(getString("artifact.follow.pom.error"));
} finally {
FileUtils.deleteQuietly(pomFile);
}
// Lors de la soumission d'un formulaire de recherche, on retourne sur la première page
for (IPageable pageable : pageableList) {
pageable.setCurrentPage(0);
}
}
};
fileSelectForm.add(fileSelect);
fileSelectForm.add(new SubmitLink("fileSelectSubmit"));
add(new Label("fileSelectLabel", new ResourceModel("artifact.follow.pom.search.file")));
add(fileSelectForm);
// File content form
Form<Void> fileContentForm = new StatelessForm<Void>("fileContentForm") {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit() {
if (ArtifactPomSearchPanel.this.pomContentModel.getObject() == null) {
getSession().error(getString("artifact.follow.pom.error.noContent"));
return;
}
try {
PomBean pomBean = mavenCentralSearchApiService.searchFromPom(ArtifactPomSearchPanel.this.pomContentModel.getObject());
ArtifactPomSearchPanel.this.pomBeanModel.setObject(pomBean);
} catch (Exception e) {
LOGGER.error("Unable to parse the pom content from the provided string", e);
Session.get().error(getString("artifact.follow.pom.error"));