Package org.infoglue.cms.entities.content

Examples of org.infoglue.cms.entities.content.Content


      map.loadMapping(CastorDatabaseService.class.getResource("/xml_mapping_content_2.5.xml").toString())

      // All ODMG database access requires a transaction
      db.begin();

      Content parentContent = ContentController.getContentController().getContentWithId(parentContentId, db);
      logger.info("parentContent:" + parentContent.getName());
      this.repositoryId = parentContent.getRepositoryId();
     
      //String encoding = "ISO-8859-1";
      logger.debug("file:" + file.exists() + ":" + file.getPath());
          FileInputStream fis = new FileInputStream(file);
            InputStreamReader reader = new InputStreamReader(fis, encoding);
      //Reader reader = new FileReader(file);

      Unmarshaller unmarshaller = new Unmarshaller(map);
      unmarshaller.setWhitespacePreserve(true);
      unmarshaller.setValidation(false);

      InfoGlueExportImpl infoGlueExportImplRead = (InfoGlueExportImpl)unmarshaller.unmarshal(reader);
      Collection contentTypeDefinitions = infoGlueExportImplRead.getContentTypeDefinitions();
      logger.info("Found " + contentTypeDefinitions.size() + " content type definitions");
      Collection categories = infoGlueExportImplRead.getCategories();
      logger.info("Found " + categories.size() + " categories");
      Collection<Language> languages = infoGlueExportImplRead.getLanguages();
      logger.info("Found " + languages.size() + " languages");

      Map categoryIdMap = new HashMap();
      Map contentTypeIdMap = new HashMap();

      importCategories(categories, null, categoryIdMap, db);
      updateContentTypeDefinitions(contentTypeDefinitions, categoryIdMap);
     
      Map<Integer,Language> languageIdMap = new HashMap<Integer,Language>();
      logger.info("languages:" + languages);
      for(Language lang : languages)
      {
        languageIdMap.put(lang.getId(), lang);
      }
     
      List readContents = infoGlueExportImplRead.getRootContent();

      Map contentIdMap = new HashMap();
      Map siteNodeIdMap = new HashMap();
     
      List allContents = new ArrayList();
     
      Iterator readContentsIterator = readContents.iterator();
      while(readContentsIterator.hasNext())
      {
        Content readContent = (Content)readContentsIterator.next();
       
        readContent.setRepository((RepositoryImpl)parentContent.getRepository());
        readContent.setParentContent((ContentImpl)parentContent);
       
        createContents(readContent, contentIdMap, contentTypeIdMap, languageIdMap, allContents, Collections.unmodifiableCollection(contentTypeDefinitions), categoryIdMap, version, db);
        parentContent.getChildren().add(readContent);
      }
         
      List allContentIds = new ArrayList();
      Iterator allContentsIterator = allContents.iterator();
      while(allContentsIterator.hasNext())
      {
        Content content = (Content)allContentsIterator.next();
        allContentIds.add(content.getContentId());
      }

      db.commit();
      db.close();
           
      Iterator allContentIdsIterator = allContentIds.iterator();
      while(allContentIdsIterator.hasNext())
      {
        Integer contentId = (Integer)allContentIdsIterator.next();
        try
        {
          db = CastorDatabaseService.getDatabase();
          db.begin();
 
          Content content = ContentController.getContentController().getContentWithId(contentId, db);
          updateContentVersions(content, contentIdMap, siteNodeIdMap);
 
          db.commit();
        }
        catch(Exception e)
View Full Code Here


    if(childContents != null)
    {
      Iterator childContentsIterator = childContents.iterator();
      while(childContentsIterator.hasNext())
      {
        Content childContent = (Content)childContentsIterator.next();
        childContent.setRepository(content.getRepository());
        childContent.setParentContent((ContentImpl)content);
        createContents(childContent, idMap, contentTypeDefinitionIdMap, languageIdMap, allContents, contentTypeDefinitions, categoryIdMap, version, db);
      }
    }
   
    return allContents;
View Full Code Here

      for(int i=0; i<contentIds.length; i++)
      {
        Integer contentId = new Integer(contentIds[i]);
        //Repository repository   = RepositoryController.getController().getRepositoryWithId(repositoryId, db);
        //SiteNode siteNode     = SiteNodeController.getController().getRootSiteNode(repositoryId, db);
        Content content     = ContentController.getContentController().getContentWithId(contentId, db);
        //siteNodes.add(siteNode);
        contents.add(content);
      }
     
      List contentTypeDefinitions = ContentTypeDefinitionController.getController().getContentTypeDefinitionList(db);
View Full Code Here

    oql.bind(limit);
     
      QueryResults results = oql.execute(Database.READONLY);
    while (results.hasMore())
        {
      Content content = (Content)results.next();
      contentList.add(content);
        }
   
    results.close();
    oql.close();
View Full Code Here

  public ContentVO create(CreateContentWizardInfoBean createContentWizardInfoBean) throws ConstraintException, SystemException
  {
    Database db = CastorDatabaseService.getDatabase();
    ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

    Content content = null;

    beginTransaction(db);

    try
    {
      content = create(db, createContentWizardInfoBean.getParentContentId(), createContentWizardInfoBean.getContentTypeDefinitionId(), createContentWizardInfoBean.getRepositoryId(), createContentWizardInfoBean.getContent().getValueObject());
     
      Iterator it = createContentWizardInfoBean.getContentVersions().keySet().iterator();
      while (it.hasNext())
      {
        Integer languageId = (Integer)it.next();
        logger.info("languageId:" + languageId);
        ContentVersionVO contentVersionVO = (ContentVersionVO)createContentWizardInfoBean.getContentVersions().get(languageId);
        contentVersionVO = ContentVersionController.getContentVersionController().createMedium(content.getContentId(), languageId, contentVersionVO, db).getValueObject();
      }
     
      //Bind if needed?
     
      ceb.throwIfNotEmpty();
           
      commitTransaction(db)
    }
    catch(ConstraintException ce)
    {
      logger.warn("An error occurred so we should not complete the transaction:" + ce, ce);
      rollbackTransaction(db);
      throw ce;
    }
    catch(Exception e)
    {
      logger.error("An error occurred so we should not complete the transaction:" + e.getMessage());
      logger.warn("An error occurred so we should not complete the transaction:" + e.getMessage(), e);
      rollbackTransaction(db);
      throw new SystemException(e.getMessage());
    }

    return content.getValueObject();
  }
View Full Code Here

    public ContentVO create(Integer parentContentId, Integer contentTypeDefinitionId, Integer repositoryId, ContentVO contentVO) throws ConstraintException, SystemException
    {
        Database db = CastorDatabaseService.getDatabase();
        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

        Content content = null;

        beginTransaction(db);

        try
        {
            content = create(db, parentContentId, contentTypeDefinitionId, repositoryId, contentVO);
            ceb.throwIfNotEmpty();
           
            commitTransaction(db)
        }
        catch(ConstraintException ce)
        {
            logger.warn("An error occurred so we should not complete the transaction:" + ce, ce);
            rollbackTransaction(db);
            throw ce;
        }
        catch(Exception e)
        {
      logger.error("An error occurred so we should not complete the transaction:" + e.getMessage());
      logger.warn("An error occurred so we should not complete the transaction:" + e.getMessage(), e);
            rollbackTransaction(db);
            throw new SystemException(e.getMessage());
        }

        return content.getValueObject();
    }
View Full Code Here

              if(repositoryId == null)
          repositoryId = parentContentVO.getRepositoryId()
             
              if(parentContentVO.getIsBranch() == false)
              {
                Content parentContent = getMediumContentWithId(parentContentVO.getId(), db);
                parentContent.setIsBranch(new Boolean(true));
              }
            }
           
            //RepositoryVO repository = RepositoryController.getController().getRepositoryVOWithId(repositoryId, db);
View Full Code Here

   * This method deletes a content and also erases all the children and all versions.
   */
     
  public void delete(ContentVO contentVO, Database db, boolean skipRelationCheck, boolean skipServiceBindings, boolean forceDelete, InfoGluePrincipal infogluePrincipal) throws ConstraintException, SystemException, Exception
  {
    Content content = null;
    try
    {
      content = getContentWithId(contentVO.getContentId(), db);
    }
    catch(SystemException e)
    {
      return;
    }
   
    Content parent = content.getParentContent();
    if(parent != null)
    {
      /*
      synchronized (controller)
      {
        //db.lock(controller);
      */ 
        Iterator childContentIterator = parent.getChildren().iterator();
        while(childContentIterator.hasNext())
        {
            Content candidate = (Content)childContentIterator.next();
            if(candidate.getId().equals(contentVO.getContentId()))
            {
                deleteRecursive(content, childContentIterator, db, skipRelationCheck, skipServiceBindings, forceDelete, infogluePrincipal);
            }
        }
      /*
 
View Full Code Here

       
        Collection children = content.getChildren();
    Iterator childrenIterator = children.iterator();
    while(childrenIterator.hasNext())
    {
      Content childContent = (Content)childrenIterator.next();
      deleteRecursive(childContent, childrenIterator, db, skipRelationCheck, skipServiceBindings, forceDelete, infogluePrincipal);        
       }
    content.setChildren(new ArrayList());
   
    boolean isDeletable = getIsDeletable(content, infogluePrincipal, db);
View Full Code Here

    public ContentVO update(ContentVO contentVO, Integer contentTypeDefinitionId) throws ConstraintException, SystemException
    {
        Database db = CastorDatabaseService.getDatabase();

        Content content = null;

        beginTransaction(db);

        try
        {
            content = (Content)getObjectWithId(ContentImpl.class, contentVO.getId(), db);
        content.setVO(contentVO);
       
            if(contentTypeDefinitionId != null)
            {
                ContentTypeDefinition contentTypeDefinition = ContentTypeDefinitionController.getController().getContentTypeDefinitionWithId(contentTypeDefinitionId, db);
                content.setContentTypeDefinition((ContentTypeDefinitionImpl)contentTypeDefinition);
            }
           
            commitTransaction(db);
        }
        catch(Exception e)
        {
      logger.error("An error occurred so we should not complete the transaction:" + e.getMessage());
      logger.warn("An error occurred so we should not complete the transaction:" + e.getMessage(), e);
            rollbackTransaction(db);
            throw new SystemException(e.getMessage());
        }

        return content.getValueObject();
    }       
View Full Code Here

TOP

Related Classes of org.infoglue.cms.entities.content.Content

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.