Package com.xmultra.processor.db.cms.content

Examples of com.xmultra.processor.db.cms.content.BasicArticle


  private BasicArticle getArticleFromPkgContent(Element pkgContentElem)
      throws ParseException {
    Element articleElem = this.xmlParseUtils.getSingletonElement(pkgContentElem, "Article");

    BasicArticle ba = null;

    if (articleElem != null) {
      ba = new BasicArticle();
      ba.setStartTime(this.getStartTimeFromArticle(articleElem));
      ba.setEndTime(this.getEndTimeFromArticle(articleElem));
      ba.setHeadline(this.getHeadlineFromArticle(articleElem));
      ba.setLead(this.getLeadFromArticle(articleElem));
      ba.setDateline(this.getDatelineFromArticle(articleElem));
      ba.setVersionNum(this.getVersionNumFromArticle(articleElem));
      ba.setByline(this.getBylineFromArticle(articleElem));
      ba.setBody(this.getBodyFromArticle(articleElem));
      ba.setRank(this.getRankFromArticle(articleElem));
      ba.setHeadline2(this.getHeadline2FromArticle(articleElem));
      ba.setBycredit(this.getCreditlineFromArticle(articleElem));
      ba.setFileName(this.getFilenameFromArticle(articleElem));
      ba.setDisableIndex(this.getDisableIndexFromArticle(articleElem));
      ba.setCatName(this.getCategoryNameFromArticle(articleElem));
      ba.setPubName(this.getPubNameFromArticle(articleElem));
      ba.setColumnistName(this.getColumnistNameFromArticle(articleElem));
      ba.setDocSourceType(this.getDocSourceTypeFromArticle(articleElem));
      ba.setDocSource(this.getDocSourceFromArticle(articleElem));
      ba.setSig(this.getSigFromArticle(articleElem));
      ba.setKicker(this.getKickerFromArticle(articleElem));
      ba.setHasTable(this.getHasTableFromArticle(articleElem));
      ba.setNpSection(this.getNpSectionFromArticle(articleElem));
      ba.setNpPage(this.getNpPageFromArticle(articleElem));
      ba.setNpEdition(this.getNPEditionFromArticle(articleElem));
      ba.setMapToTaxonomy(this.getMapToTaxonomyFromArticle(articleElem));
      ba.setPubDate(this.getPubDateFromArticle(articleElem));
      ba.setOverride(this.getOverrideFromArticle(articleElem));
      // Set article status equal 1 by default.
      ba.setStatus(1);

      // Get all CategoryMapping nodes from article element.
      NodeList catMapNodes = pkgContentElem.getElementsByTagName("CategoryMapping");
Console.displayDev("XmlContentFactory", "CategoryMapping nodes: " + catMapNodes, true, "scb");
      CategoryMapping currentCatMap = null;
      int numCatMapNodes = catMapNodes.getLength();
      // Add all category mappings to the article object.
      for (int i = 0; i < numCatMapNodes; i++) {
        currentCatMap =
            this.getCatMappingFromCatMapElem((Element)catMapNodes.item(i));
        ba.addCategoryMapping(currentCatMap);
      }
    }
    // If no article in Document, ba will be null.
    return ba;
  }
View Full Code Here


    ContentPackage cp = null;
    // Select root element (PackageContent).
    Element pkgContentElem = doc.getDocumentElement();
    // Retrieve article object from the package content
    BasicArticle ba = this.getArticleFromPkgContent(pkgContentElem);
    if (ba != null) {
      // Create content package.
      cp = new ContentPackage();
      cp.setArticle(ba);

      if (this.contentContainsPhotoPkg(pkgContentElem)) {
        String fileName = ba.getFileName();
        PhotoPackage pp = new PhotoPackage();
        pp.setCategoryId(ba.getCategoryId());
        pp.setCreateBy("Insert process");
        // CMS limits photo package "name" to 50 characters.
        pp.setDescription(fileName.substring(0, Math.min(fileName.length(), 41)) +
                          "_" + ba.getStartTimeAsMMDDYYYYString());
        pp.setStartTime(ba.getStartTime());
        Date startTime = ba.getStartTime();
        Calendar cal = Calendar.getInstance();
        cal.setTime(startTime);
        // Make end time one month later than start time.
        cal.add(Calendar.MONTH, 1);
        Date endTime = cal.getTime();
        pp.setEndTime(endTime);
        pp.setKeywords(fileName.substring(0, Math.min(fileName.length(), 100)));
        pp.setNational(false);
        pp.setPubId(ba.getPubId());

        Element photoPkgElem =
            this.xmlParseUtils.getSingletonElement(pkgContentElem, "PhotoPackage");
        NodeList photoNodes = photoPkgElem.getElementsByTagName("Photo");
        int numPhotos = 0;
View Full Code Here

    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());
View Full Code Here

TOP

Related Classes of com.xmultra.processor.db.cms.content.BasicArticle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.