private Long retrieveLastUpdateDate(ArtifactVersionBean artifactVersionBean) { HttpClient httpClient = new DefaultHttpClient(); String url = String.format( configurer.getArtifactVersionRepositoryPomUrl(), artifactVersionBean.getGroupId().replace(".", "/"), artifactVersionBean.getArtifactId(), artifactVersionBean.getVersion()); HttpHead httpHead = new HttpHead(url); httpHead.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE); // The possible errors here are considered as secondary and will not be seen by the user // We may want to reconsider it try { HttpResponse response = httpClient.execute(httpHead); Header lastUpdateDate = response.getFirstHeader(LAST_MODIFIED_HEADER); if (lastUpdateDate != null) { return DateUtil.parseDate(lastUpdateDate.getValue()).getTime(); } LOGGER.error( "An error occurred while retrieving the last update date for " + artifactVersionBean.getId()); } catch (Exception e) { LOGGER.error( "An error occurred while retrieving the last update date for " + artifactVersionBean.getId(), e); } return null; }
@Override public List<ArtifactVersionBean> getArtifactVersions(String groupId, String artifactId) throws ServiceException { String url = String.format( configurer.getArtifactRepositoryMetadataUrl(), groupId.replace(".", "/"), artifactId); Document doc; try { doc = Jsoup.connect(url).header(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE).get(); } catch (IOException e) { throw new ServiceException("IOException: " + e.getMessage(), e); } return parseMavenMetadata(doc); }