Package org.infoglue.cms.entities.management.impl.simple

Examples of org.infoglue.cms.entities.management.impl.simple.InfoGlueExportImpl


     
      List contentTypeDefinitions = ContentTypeDefinitionController.getController().getContentTypeDefinitionList(db);
      List categories = CategoryController.getController().getAllActiveCategories();
      List languages = LanguageController.getController().getLanguageList(db);
     
      InfoGlueExportImpl infoGlueExportImpl = new InfoGlueExportImpl();
     
      VisualFormatter visualFormatter = new VisualFormatter();
      String fileName = "Export_contents_" + visualFormatter.formatDate(new Date(), "yyyy-MM-dd") + ".xml";
      String filePath = CmsPropertyHandler.getDigitalAssetPath();
      String fileSystemName =  filePath + File.separator + fileName;
           
      fileUrl = CmsPropertyHandler.getWebServerAddress() + "/" + CmsPropertyHandler.getDigitalAssetBaseUrl() + "/" + fileName;
      this.fileName = fileName;
           
      String encoding = "UTF-8";
      File file = new File(fileSystemName);
            FileOutputStream fos = new FileOutputStream(file);
            OutputStreamWriter osw = new OutputStreamWriter(fos, encoding);
            Marshaller marshaller = new Marshaller(osw);
            marshaller.setMapping(map);
      marshaller.setEncoding(encoding);
      DigitalAssetBytesHandler.setMaxSize(assetMaxSize);

      infoGlueExportImpl.getRootContent().addAll(contents);
      //infoGlueExportImpl.getRootSiteNode().addAll(siteNodes);
     
      //infoGlueExportImpl.getRootContents().add((ContentImpl)content);
      //infoGlueExportImpl.getRootSiteNodes().add((SiteNodeImpl)siteNode);
     
      infoGlueExportImpl.setLanguages(languages);
      infoGlueExportImpl.setContentTypeDefinitions(contentTypeDefinitions);
      infoGlueExportImpl.setCategories(categories);
     
      marshaller.marshal(infoGlueExportImpl);
     
      osw.flush();
      osw.close();
View Full Code Here


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

    Unmarshaller unmarshaller = new Unmarshaller(map);
    unmarshaller.setWhitespacePreserve(true);
    unmarshaller.setValidation(false);
   
    InfoGlueExportImpl infoGlueExportImplRead = (InfoGlueExportImpl)unmarshaller.unmarshal(reader);
    reader.close();
    return infoGlueExportImplRead;
  }
View Full Code Here

    return infoGlueExportImplRead;
  }
 
  private Map<Integer,List<ExportContentVersionImpl>> getAllContentVersionMap(File contentVersionsFile, String encoding) throws Exception
  {
    InfoGlueExportImpl contentVersions = getInfoGlueExportImpl(contentVersionsFile, encoding);
    logger.info("contentVersions:" + contentVersions);

    float memoryLeft = ((float)Runtime.getRuntime().maxMemory() - (float)Runtime.getRuntime().totalMemory()) / 1024f / 1024f;
    logger.info("Memory after contentVersions-file:" + memoryLeft);

    Map<Integer,List<ExportContentVersionImpl>> allContentVersionMap = new HashMap<Integer,List<ExportContentVersionImpl>>();
    for(ExportContentVersionImpl contentVersion : contentVersions.getContentVersions())
    {
      List<ExportContentVersionImpl> versions = allContentVersionMap.get(contentVersion.getValueObject().getContentId());
      if(versions == null)
      {
        versions = new ArrayList<ExportContentVersionImpl>();
View Full Code Here

    Map<Integer,List<Integer>> assetVersionsMap = new HashMap<Integer,List<Integer>>();
    Map<String, AvailableServiceBinding> readAvailableServiceBindings = new HashMap<String, AvailableServiceBinding>();
    Map<Integer,Language> languages = new HashMap<Integer,Language>();
    Map<Integer,SiteNodeTypeDefinition> siteNodeTypeDefinitions = new HashMap<Integer,SiteNodeTypeDefinition>();
   
    InfoGlueExportImpl master = getInfoGlueExportImpl(mainExportFile, encoding);
    logger.info("master:" + master);
   
    for(Language lang : master.getLanguages())
    {
      languages.put(lang.getId(), lang);
    }
   
    for(SiteNodeTypeDefinition siteNodeTypeDefinition : master.getSiteNodeTypeDefinitions())
    {
      siteNodeTypeDefinitions.put(siteNodeTypeDefinition.getId(), siteNodeTypeDefinition);
    }
   
    importFoundation(master, encoding, isCopyAction, replaceMap, categoryIdMap, repositoryIdMap);

    processBean.updateProcess("Foundation imported in " + (t.getElapsedTime() / 1000) + " seconds");
   
    createContent(archiveFolder, /*contentsFile, contentVersionsFile, */encoding, repositoryIdMap, master.getRepositories(), contentIdMap, contentTypeIdMap, allContents, languages, master.getContentTypeDefinitions(), categoryIdMap, allSmallAssets, assetVersionsMap, onlyLatestVersions, isCopyAction, replaceMap);

    processBean.updateProcess("Content created in " + (t.getElapsedTime() / 1000) + " seconds");
   
    CacheController.clearCastorCaches();
    CacheController.clearCache("contentVersionCache");
    CacheController.clearCache("contentCache");
   
    processStructure(archiveFolder, /*siteNodeVersionsFile, siteNodesFile, */encoding, onlyLatestVersions, contentIdMap, siteNodeIdMap, replaceMap, repositoryIdMap, siteNodeVersionIdMap, allSiteNodes, readAvailableServiceBindings, master.getRepositories(), siteNodeTypeDefinitions);

    processBean.updateProcess("Structure imported in " + (t.getElapsedTime() / 1000) + " seconds");
   
    CacheController.clearCastorCaches();
    CacheController.clearCache("siteNodeVersionCache");
    CacheController.clearCache("siteNodeCache");
   
    Database dbStructure = CastorDatabaseService.getDatabase();
    try
    {
      dbStructure.begin();
     
      for(SmallDigitalAssetImpl asset : allSmallAssets)
      {
        List<ContentVersion> assetRelatedContentVersions = new ArrayList<ContentVersion>();
        List<Integer> versionIdsUsingAsset = assetVersionsMap.get(asset.getId());
        for(Integer cvId : versionIdsUsingAsset)
        {
          ContentVersion cv = ContentVersionController.getContentVersionController().getContentVersionWithId(cvId, dbStructure);
          assetRelatedContentVersions.add(cv);
        }
 
        File assetFile = new File(archiveFolder.getPath() + File.separator + asset.getId() + ".file");
        //logger.info("assetFile:" + assetFile.exists());
        if(assetFile.exists())
        {
          InputStream is = new FileInputStream(assetFile);
          create(asset.getValueObject(), is, assetRelatedContentVersions, dbStructure);
        }
        else
        {
          logger.info("Missing file...:" + assetFile.getPath());
        }
      }

      dbStructure.commit();
    }
    catch (Exception e)
    {
      dbStructure.rollback();
    }
    finally
    {
      dbStructure.close();
    }

    processBean.updateProcess("Assets imported in " + (t.getElapsedTime() / 1000) + " seconds");

    CacheController.clearCastorCaches();
    CacheController.clearCache("contentVersionCache");
    CacheController.clearCache("contentCache");
   
    //List allContentIds = new ArrayList();
    Iterator allContentsIterator = allContents.iterator();
    while(allContentsIterator.hasNext())
    {
      Content content = (Content)allContentsIterator.next();
      allContentIds.add(content.getContentId());
    }

    //TEST
    Map args = new HashMap();
      args.put("globalKey", "infoglue");
      PropertySet ps = PropertySetManager.getInstance("jdbc", args);

    Map<String,String> repositoryProperties = master.getRepositoryProperties();
    Iterator<String> repositoryPropertiesIterator = repositoryProperties.keySet().iterator();
    while(repositoryPropertiesIterator.hasNext())
    {
      String key = repositoryPropertiesIterator.next();
      String value = repositoryProperties.get(key);
      String[] splittedString = key.split("_");
      if(splittedString.length == 3)
      {
        String oldRepId = splittedString[1];
        key = key.replaceAll(oldRepId, "" + repositoryIdMap.get(oldRepId));
       
        if(value != null && !value.equals("null"))
        {
          try
          {
            if(key.indexOf("_WYSIWYGConfig") > -1 || key.indexOf("_StylesXML") > -1 || key.indexOf("_extraProperties") > -1)
              ps.setData(key, value.getBytes("utf-8"));
            else
              ps.setString(key, value);
          }
          catch (Exception e)
          {
            logger.error("Error saving property " + key + ":" + e.getMessage());
          }
        }
      }
    }

    Map<String,String> contentProperties = master.getContentProperties();
    Iterator<String> contentPropertiesIterator = contentProperties.keySet().iterator();
    while(contentPropertiesIterator.hasNext())
    {
      String key = contentPropertiesIterator.next();
      String value = contentProperties.get(key);
      String[] splittedString = key.split("_");
      if(splittedString.length == 3)
      {
        String oldContentId = splittedString[1];
        key = key.replaceAll(oldContentId, (String)contentIdMap.get(oldContentId));
        try
        {
          if(value != null && !value.equals("null"))
            ps.setString(key, value);
        }
        catch (Exception e)
        {
          logger.error("Error saving property " + key + ":" + e.getMessage());
        }
      }
    }

    Map<String,String> siteNodeProperties = master.getSiteNodeProperties();
    Iterator<String> siteNodePropertiesIterator = siteNodeProperties.keySet().iterator();
    while(siteNodePropertiesIterator.hasNext())
    {
      String key = siteNodePropertiesIterator.next();
      String value = siteNodeProperties.get(key);
      String[] splittedString = key.split("_");
      if(splittedString.length == 3)
      {
        String oldSiteNodeId = splittedString[1];
        key = key.replaceAll(oldSiteNodeId, (String)siteNodeIdMap.get(oldSiteNodeId));
        try
        {
          if(value != null && !value.equals("null"))
            ps.setString(key, value);
        }
        catch (Exception e)
        {
          logger.error("Error saving property " + key + ":" + e.getMessage());
        }
      }
    }

    processBean.updateProcess("Properties imported in " + (t.getElapsedTime() / 1000) + " seconds");

    Database dbAccessRight = CastorDatabaseService.getDatabase();
    try
    {
      dbAccessRight.begin();
      Collection<AccessRight> accessRights = master.getAccessRights();
      Iterator<AccessRight> accessRightsIterator = accessRights.iterator();
      while(accessRightsIterator.hasNext())
      {
        AccessRight accessRight = accessRightsIterator.next();
 
View Full Code Here

      if(siteNodeVersionsFile == null)
        throw new Exception("No siteNodeVersons file found. Looking for SiteNodeVersions_" + oldRepoId + ".xml in archive");
      if(siteNodesFile == null)
        throw new Exception("No siteNodes file found. Looking for SiteNodes_" + oldRepoId + ".xml in archive");
   
      InfoGlueExportImpl siteNodes = getInfoGlueExportImpl(siteNodesFile, encoding);
      logger.info("siteNodesFile:" + siteNodesFile.getName());
      logger.info("siteNodes:" + siteNodes);
      logger.info("siteNodes:" + siteNodes.getSiteNodes().size());
 
      for(SiteNode siteNode : siteNodes.getSiteNodes())
      {
        siteNodeMap.put(siteNode.getSiteNodeId(), siteNode);
        logger.info("putting as parent siteNode on:" + siteNode.getName() + ":" + siteNode.getValueObject().getParentSiteNodeId());
 
        if(siteNode.getValueObject().getParentSiteNodeId() == null)
        {
          logger.info("siteNode was root:" + siteNode + ":" + siteNode.getValueObject().getId() + ":" + siteNode.getValueObject().getRepositoryId());
          repositorySiteNodeMap.put("" + siteNode.getValueObject().getRepositoryId(), siteNode);
        }
        //logger.info("readContentCandidate debug...:" + readContentCandidate.getName() + ":" + readContentCandidate.getId() + ":" + readContentCandidate.getRepositoryId());
      }
     
      for(SiteNode siteNode : siteNodes.getSiteNodes())
      {
        if(siteNode.getValueObject().getParentSiteNodeId() != null)
        {
          logger.error("Looking for parent siteNode on:" + siteNode.getName() + ":" + siteNode.getValueObject().getParentSiteNodeId());
          SiteNode parentSiteNode = siteNodeMap.get(siteNode.getValueObject().getParentSiteNodeId());
          if(parentSiteNode != null)
          {
            parentSiteNode.getChildSiteNodes().add(siteNode);
            siteNode.setParentSiteNode((SiteNodeImpl)parentSiteNode);
          }
        }
       
        logger.info("Looking for repo:" + siteNode.getValueObject().getRepositoryId());
        Repository newRepository = (Repository)repositoryIdMap.get("" + siteNode.getValueObject().getRepositoryId() + "_repository");
        logger.info("newRepository:" + newRepository);
        siteNode.setRepository((RepositoryImpl)newRepository);
        siteNode.getValueObject().setRepositoryId(newRepository.getId());
        //logger.info("readContentCandidate debug...:" + readContentCandidate.getName() + ":" + readContentCandidate.getId() + ":" + readContentCandidate.getRepositoryId());
      }
 
      InfoGlueExportImpl siteNodeVersions = getInfoGlueExportImpl(siteNodeVersionsFile, encoding);
      logger.info("siteNodeVersions:" + siteNodeVersions);
 
      for(SiteNodeVersion siteNodeVersion : siteNodeVersions.getSiteNodeVersions())
      {
        List<SiteNodeVersion> versions = allSiteNodeVersionMap.get(siteNodeVersion.getValueObject().getSiteNodeId());
        if(versions == null)
        {
          versions = new ArrayList<SiteNodeVersion>();
View Full Code Here

      if(contentVersionsFile == null)
        throw new Exception("No contentVersions file found. Looking for ContentVersions_" + oldRepoId + ".xml in archive");
      if(contentsFile == null)
        throw new Exception("No contents file found. Looking for Contents_" + oldRepoId + ". in archive");

      InfoGlueExportImpl contents = getInfoGlueExportImpl(contentsFile, encoding);
      logger.info("contents:" + contents);
 
      Iterator<Content> contentsIterator = contents.getContents().iterator();
      while(contentsIterator.hasNext())
      {
        Content content = contentsIterator.next();
        logger.info("content:" + content + ":" + content.getValueObject().getId() + ":" + content.getValueObject().getRepositoryId() + ":" + content.getRepositoryId());
        contentMap.put(content.getContentId(), content);
        if(content.getValueObject().getParentContentId() == null)
        {
          logger.info("content was root:" + content + ":" + content.getValueObject().getId() + ":" + content.getValueObject().getRepositoryId() + ":" + content.getRepositoryId());
          if(!repositoryContentMap.containsKey("" + content.getRepositoryId()))
            repositoryContentMap.put("" + content.getRepositoryId(), content);
          else
            logger.info("content was root but skipping as registration allready there:" + content + ":" + content.getValueObject().getId() + ":" + content.getValueObject().getRepositoryId() + ":" + content.getRepositoryId());
               
        }
        //logger.info("readContentCandidate debug...:" + readContentCandidate.getName() + ":" + readContentCandidate.getId() + ":" + readContentCandidate.getRepositoryId());
      }
     
      contentsIterator = contents.getContents().iterator();
      while(contentsIterator.hasNext())
      {
        Content content = contentsIterator.next();
        logger.info("content:" + content.getName() + ":" + content.getValueObject().getParentContentId());
       
        if(content.getValueObject().getParentContentId() != null)
        {
          Content parentContent = contentMap.get(content.getValueObject().getParentContentId());
          if(parentContent != null)
          {
            logger.info("parentContent:" + parentContent.getName() + ":" + parentContent);
            parentContent.getChildren().add(content);
            content.setParentContent((ContentImpl)parentContent);
           
            logger.info("Children after: " + parentContent.getChildren());
          }
          else
          {
            logger.error("Something is strange with parent content id:"+content.getValueObject().getParentContentId() +" it doesn't have a parent content id:"+content.getContentId());
          }
        }
       
        logger.info("repositoryIdMap:" + repositoryIdMap);
        //logger.info("Looking for repo:" + content.getRepositoryId());
        Repository newRepository = (Repository)repositoryIdMap.get("" + content.getRepositoryId() + "_repository");
        //logger.info("newRepository:" + newRepository);
        content.setRepository((RepositoryImpl)newRepository);
        //logger.info("readContentCandidate debug...:" + readContentCandidate.getName() + ":" + readContentCandidate.getId() + ":" + readContentCandidate.getRepositoryId());
      }
     
      InfoGlueExportImpl contentVersions = getInfoGlueExportImpl(contentVersionsFile, encoding);
      logger.info("contentVersions:" + contentVersions);
      float memoryLeft = ((float)Runtime.getRuntime().maxMemory() - (float)Runtime.getRuntime().totalMemory()) / 1024f / 1024f;
      logger.info("Memory after contentVersions-file:" + memoryLeft);
     
      for(ExportContentVersionImpl contentVersion : contentVersions.getContentVersions())
      {
        List<ExportContentVersionImpl> versions = allContentVersionMap.get(contentVersion.getValueObject().getContentId());
        if(versions == null)
        {
          versions = new ArrayList<ExportContentVersionImpl>();
View Full Code Here

     
      List categories = new ArrayList();
      if(includeCategories)
        categories = CategoryController.getController().getAllActiveCategories();
     
      InfoGlueExportImpl infoGlueExportImpl = new InfoGlueExportImpl();
     
      String filePath = CmsPropertyHandler.getDigitalAssetPath();
      String tempFileName = "Export_tmp_" + Thread.currentThread().getId() + "_" + fileNamePrefix + ".xml";
      String tempFileSystemName = filePath + File.separator + tempFileName;
           
      String encoding = "UTF-8";
      File tempFile = new File(tempFileSystemName);
          FileOutputStream fos = new FileOutputStream(tempFile);
          OutputStreamWriter osw = new OutputStreamWriter(fos, encoding);
          Marshaller marshaller = new Marshaller(osw);
          marshaller.setMapping(map);
      marshaller.setEncoding(encoding);
      DigitalAssetBytesHandler.setMaxSize(-1);
 
      infoGlueExportImpl.getRootContent().addAll(contents);
     
      infoGlueExportImpl.setContentTypeDefinitions(contentTypeDefinitions);
      infoGlueExportImpl.setCategories(categories);
     
      marshaller.marshal(infoGlueExportImpl);
     
      osw.flush();
      osw.close();
View Full Code Here

      List<ContentTypeDefinition> contentTypeDefinitions = ContentTypeDefinitionController.getController().getContentTypeDefinitionList(db);
      List<CategoryVO> categories = CategoryController.getController().getAllActiveCategories();
      List<Language> languages = LanguageController.getController().getLanguageList(db);
      List<SiteNodeTypeDefinition> siteNodeTypeDefinitions = SiteNodeTypeDefinitionController.getController().getSiteNodeTypeDefinitionList(db);
     
      InfoGlueExportImpl infoGlueExportImpl = new InfoGlueExportImpl();
     
      VisualFormatter visualFormatter = new VisualFormatter();
      String fileName = "Export_contents_" + visualFormatter.formatDate(new Date(), "yyyy-MM-dd") + ".xml";
      String filePath = CmsPropertyHandler.getDigitalAssetPath();
      String fileSystemName =  filePath + File.separator + fileName;
                 
      String encoding = "UTF-8";
      file = new File(fileSystemName);
        FileOutputStream fos = new FileOutputStream(file);
        OutputStreamWriter osw = new OutputStreamWriter(fos, encoding);
        Marshaller marshaller = new Marshaller(osw);
        marshaller.setMapping(map);
      marshaller.setEncoding(encoding);
      marshaller.setValidation(false);
      DigitalAssetBytesHandler.setMaxSize(assetMaxSize);
   
      infoGlueExportImpl.getRootContent().addAll(contents);
   
      if(includeSystemTypes)
      {
        infoGlueExportImpl.setLanguages(languages);
        infoGlueExportImpl.setContentTypeDefinitions(contentTypeDefinitions);
        infoGlueExportImpl.setCategories(categories);
        infoGlueExportImpl.setSiteNodeTypeDefinitions(siteNodeTypeDefinitions);
      }
     
      marshaller.marshal(infoGlueExportImpl);
     
      osw.flush();
View Full Code Here

 
      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");
 
      Map categoryIdMap = new HashMap();
      Map contentTypeIdMap = new HashMap();
 
      importCategories(categories, null, categoryIdMap, db);
     
      updateContentTypeDefinitions(contentTypeDefinitions, categoryIdMap);
     
      List<Content> readContents = infoGlueExportImplRead.getRootContent();
 
      Map contentIdMap = new HashMap();
      Map siteNodeIdMap = new HashMap();
     
      List<Content> allContents = new ArrayList<Content>();
View Full Code Here

TOP

Related Classes of org.infoglue.cms.entities.management.impl.simple.InfoGlueExportImpl

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.