int photoPkgId = -1;
ArrayList exceptionArrayList = new ArrayList();
if (contentPackage.hasArticle()) {
BasicArticle article = contentPackage.getArticle();
try {
articleId = ArticleCSHelper.storeArticle(article, con);
if ( this.dataWriter != null &&
this.dataWriter.isWatchedProcedure(ArticleCSHelper.URL_RETRIEVAL_FUNCTION) ) {
ArticleCSHelper.writeUrlsToFile(article, fileName, con, this.dataWriter);
}
}
catch (SQLException se) {
// If there's a problem inserting the article, it's impossible to store
// related content, so just throw exception.
ArticlePersistenceException ape =
new ArticlePersistenceException(se.getMessage(),
"Error trying to store article");
exceptionArrayList.add(ape);
throw new ContentPersistenceExceptions(exceptionArrayList);
}
article.setArticleId(articleId);
if (article.hasCategoryMappings()) {
Iterator catMaps = article.getCategoryMappings().iterator();
CategoryMapping currentCm = null;
while (catMaps.hasNext()) {
currentCm = (CategoryMapping) catMaps.next();
try {
CatMapCSHelper.storeCatMapping(currentCm, con, article.getArticleId());
}
catch (SQLException sql) {
CategoryMappingPersistenceException cmpe =
new CategoryMappingPersistenceException(sql.getMessage(),
"Error attempting to create category mapping with category name " +
currentCm.getCategoryName() + " and article ID " +
article.getArticleId());
exceptionArrayList.add(cmpe);
}
}
}
PubInfo pi = null;
try {
pi = PublicationHelper.getPubInfoFromPubName(article.getPubName(), con);
}
catch (SQLException se) {
// If there's a problem inserting the article, it's impossible to store
// related content, so just throw exception.
RelatedPackagePersistenceException rpe =
new RelatedPackagePersistenceException(se.getMessage(),
"Error trying to retrieve publication information for article " +
article.getArticleId());
exceptionArrayList.add(rpe);
throw new ContentPersistenceExceptions(exceptionArrayList);
}
contentPackage.setSiteId(pi.getSiteId());
contentPackage.setPubId(pi.getPubId());