Examples of DomDriver


Examples of com.dotcms.repackage.com.thoughtworks.xstream.io.xml.DomDriver

        //http://jira.dotmarketing.net/browse/DOTCMS-5031
                if(PermissionReference.class.equals(clazz)){
                  continue;
                }

        _xstream = new XStream(new DomDriver());

        //http://jira.dotmarketing.net/browse/DOTCMS-6059
        if(clazz.equals(DashboardSummary404.class) || clazz.equals(DashboardUserPreferences.class)){
          _xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.Set.class, java.util.Set.class);
          _xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.List.class, java.util.List.class);
          _xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.Map.class, java.util.Map.class);
          Mapper mapper = _xstream.getMapper();
          _xstream.registerConverter(new HibernateCollectionConverter(mapper));
          _xstream.registerConverter(new HibernateMapConverter(mapper));
        }

        /*
         * String _shortClassName =
         * clazz.getName().substring(clazz.getName().lastIndexOf("."),clazz.getName().length());
         * xstream.alias(_shortClassName, clazz);
         */
        int i= 0;
        int step = 1000;
        int total =0;
        java.text.NumberFormat formatter = new java.text.DecimalFormat("0000000000");
        /* we will only export 10,000,000 items of any given type */
        for(i=0;i < 10000000;i=i+step){

                    _dh = new HibernateUtil(clazz);
                    _dh.setFirstResult(i);
                    _dh.setMaxResults(step);

                    //This line was previously like;
                    //_dh.setQuery("from " + clazz.getName() + " order by 1,2");
                    //This caused a problem when the database is Oracle because Oracle causes problems when the results are ordered
                    //by an NCLOB field. In the case of containers table, the second field, CODE, is an NCLOB field. Because of this,
                    //ordering is done only on the first field for the tables, which is INODE
                    if(com.dotmarketing.beans.Tree.class.equals(clazz)){
                      _dh.setQuery("from " + clazz.getName() + " order by parent, child, relation_type");
                    }
                    else if(MultiTree.class.equals(clazz)){
                      _dh.setQuery("from " + clazz.getName() + " order by parent1, parent2, child, relation_type");
                    }
                    else if(TagInode.class.equals(clazz)){
                      _dh.setQuery("from " + clazz.getName() + " order by inode, tag_id");
                    }
                    else if(Tag.class.equals(clazz)){
                      _dh.setQuery("from " + clazz.getName() + " order by tag_id, tagname");
                    }
                    else if(CalendarReminder.class.equals(clazz)){
                      _dh.setQuery("from " + clazz.getName() + " order by user_id, event_id, send_date");
                    }
                    else if(Identifier.class.equals(clazz)){
                      _dh.setQuery("from " + clazz.getName() + " order by parent_path");
                    } else {
                      _dh.setQuery("from " + clazz.getName() + " order by 1");
                    }

                    _list = _dh.list();
                    if(_list.size() ==0){
                        try {
                        _bout.close();
                        }
                        catch( java.lang.NullPointerException npe){}
                        _list = null;
                        _dh = null;
                        _bout = null;

                        break;
                    }

                    if(_list != null && _list.size() > 0 && _list.get(0) instanceof Comparable){
                      java.util.Collections.sort(_list);
                    }

            _writing = new File(backupTempFilePath + "/" + clazz.getName() + "_" + formatter.format(i) + ".xml");
            _bout = new BufferedOutputStream(new FileOutputStream(_writing));

            total = total + _list.size();

            try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                      Logger.warn(this, "An error ocurred trying to create XML files");
                        Logger.error(this,e.getMessage(),e);
                    }

            _xstream.toXML(_list, _bout);

            _bout.close();
            _list = null;
            _dh = null;
            _bout = null;

        }
        Logger.info(this, "writing : " + total + " records for " + clazz.getName());
      }

      /* Run Liferay's Tables */
      /* Companies */
      _list = PublicCompanyFactory.getCompanies();
      List<Company> companies = new ArrayList<Company>(_list);
      _xstream = new XStream(new DomDriver());
      _writing = new File(backupTempFilePath + "/" + Company.class.getName() + ".xml");
      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
      _xstream.toXML(_list, _bout);
      _bout.close();
      _list = null;
      _bout = null;

      /* Users */
      _list = APILocator.getUserAPI().findAllUsers();
      _list.add(APILocator.getUserAPI().getDefaultUser());
      _xstream = new XStream(new DomDriver());
      _writing = new File(backupTempFilePath + "/" + User.class.getName() + ".xml");
      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
      _xstream.toXML(_list, _bout);
      _bout.close();
      _list = null;
      _bout = null;

      /* Roles */
//      _list = RoleManagerUtil.findAll();
//      _xstream = new XStream(new DomDriver());
//      _writing = new File(backupTempFilePath + "/" + Role.class.getName() + ".xml");
//      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
//      _xstream.toXML(_list, _bout);
//      _bout.close();
//      _list = null;
//      _bout = null;

      /* Groups */
//      _list = new ArrayList<Group>();
//      for (Company company : companies) {
//        _list.addAll(CompanyLocalManagerUtil.getGroups(CompanyUtils.getDefaultCompany().getCompanyId()));
//      }
//      List<Group> groups = new ArrayList<Group>(_list);
//      _xstream = new XStream(new DomDriver());
//      _writing = new File(backupTempFilePath + "/" + Group.class.getName() + ".xml");
//      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
//      _xstream.toXML(_list, _bout);
//      _bout.close();
//      _list = null;
//      _bout = null;

      /* Layouts */
//      _list = LayoutManagerUtil.findAll();
//      _xstream = new XStream(new DomDriver());
//      _writing = new File(backupTempFilePath + "/" + Layout.class.getName() + ".xml");
//      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
//      _xstream.toXML(_list, _bout);
//      _bout.close();
//      _list = null;
//      _bout = null;

      /* users_roles */
      DotConnect dc = new DotConnect();
//      dc.setSQL("select * from users_roles");
//      _list = dc.getResults();
//      _xstream = new XStream(new DomDriver());
//      _writing = new File(backupTempFilePath + "/Users_Roles.xml");
//      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
//      _xstream.toXML(_list, _bout);
//      _bout.close();
//      _list = null;
//      _bout = null;
//
//      /* users_groups */
//      dc.setSQL("select * from users_groups");
//      _list = dc.getResults();
//      _xstream = new XStream(new DomDriver());
//      _writing = new File(backupTempFilePath + "/Users_Groups.xml");
//      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
//      _xstream.toXML(_list, _bout);
//      _bout.close();
//      _list = null;
//      _bout = null;
//
//      /* users_groups */
//      dc.setSQL("select * from groups_roles");
//      _list = dc.getResults();
//      _xstream = new XStream(new DomDriver());
//      _writing = new File(backupTempFilePath + "/Groups_Roles.xml");
//      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
//      _xstream.toXML(_list, _bout);
//      _bout.close();
//      _list = null;
//      _bout = null;

      /* counter */
      dc.setSQL("select * from counter");
      _list = dc.getResults();
      _xstream = new XStream(new DomDriver());
      _writing = new File(backupTempFilePath + "/Counter.xml");
      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
      _xstream.toXML(_list, _bout);
      _bout.close();
      _list = null;
      _bout = null;

      /* counter */
      dc.setSQL("select * from address");
      _list = dc.getResults();
      _xstream = new XStream(new DomDriver());
      _writing = new File(backupTempFilePath + "/Address.xml");
      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
      _xstream.toXML(_list, _bout);
      _bout.close();
      _list = null;
      _bout = null;

      /* pollschoice */
      dc.setSQL("select * from pollschoice");
      _list = dc.getResults();
      _xstream = new XStream(new DomDriver());
      _writing = new File(backupTempFilePath + "/Pollschoice.xml");
      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
      _xstream.toXML(_list, _bout);
      _bout.close();
      _list = null;
      _bout = null;

      /* pollsdisplay */
      dc.setSQL("select * from pollsdisplay");
      _list = dc.getResults();
      _xstream = new XStream(new DomDriver());
      _writing = new File(backupTempFilePath + "/Pollsdisplay.xml");
      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
      _xstream.toXML(_list, _bout);
      _bout.close();
      _list = null;
      _bout = null;

      /* pollsquestion */
      dc.setSQL("select * from pollsquestion");
      _list = dc.getResults();
      _xstream = new XStream(new DomDriver());
      _writing = new File(backupTempFilePath + "/Pollsquestion.xml");
      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
      _xstream.toXML(_list, _bout);
      _bout.close();
      _list = null;
      _bout = null;

      /* pollsvote */
      dc.setSQL("select * from pollsvote");
      _list = dc.getResults();
      _xstream = new XStream(new DomDriver());
      _writing = new File(backupTempFilePath + "/Pollsvote.xml");
      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
      _xstream.toXML(_list, _bout);
      _bout.close();
      _list = null;
      _bout = null;

      /* image */
      _list = ImageLocalManagerUtil.getImages();

      /*
       * The changes in this part were made for Oracle databases. Oracle has problems when
       * getString() method is called on a LONG field on an Oracle database. Because of this,
       * the object is loaded from liferay and DotConnect is not used
       * http://jira.dotmarketing.net/browse/DOTCMS-1911
       */

      _xstream = new XStream(new DomDriver());
      _writing = new File(backupTempFilePath + "/Image.xml");
      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
      _xstream.toXML(_list, _bout);
      _bout.close();
      _list = null;
      _bout = null;

      /* portlet */

      /*
       * The changes in this part were made for Oracle databases. Oracle has problems when
       * getString() method is called on a LONG field on an Oracle database. Because of this,
       * the object is loaded from liferay and DotConnect is not used
       * http://jira.dotmarketing.net/browse/DOTCMS-1911
       */
      dc.setSQL("select * from portlet");
      _list = dc.getResults();
      _xstream = new XStream(new DomDriver());
      _writing = new File(backupTempFilePath + "/Portlet.xml");
      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
      _xstream.toXML(_list, _bout);
      _bout.close();
      _list = null;
      _bout = null;

      /* portlet_preferences */

      try{
        _list = PortletPreferencesLocalManagerUtil.getPreferences();
      }catch(Exception e){
        Logger.error(this,"Error in retrieveing all portlet preferences");
      }
      _xstream = new XStream(new DomDriver());
      _writing = new File(backupTempFilePath + "/Portletpreferences.xml");
      _bout = new BufferedOutputStream(new FileOutputStream(_writing));
      _xstream.toXML(_list, _bout);
      _bout.close();
      _list = null;
View Full Code Here

Examples of com.thoughtworks.xstream.io.xml.DomDriver

    // retrieve metadata folder
    _metadataFolder = _tmlFile.getParent().getFolder(new Path("metadata"));
    if (_metadataFolder.exists()) {
      _metadataFile = _metadataFolder.getFile(_tmlFile.getName().substring(0, _tmlFile.getName().length() - _tmlFile.getFileExtension().length()) + "metadata.xml");
      if (_metadataFile.exists()) {
        XStream xstream = new XStream(new DomDriver());
        xstream.alias(TMLMetadataInfo.XSTREAM_ALIAS, TMLMetadataInfo.class);
        Reader reader = null;
        try {
          if(!_metadataFile.isSynchronized(IResource.DEPTH_ZERO)){
            _metadataFile.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
View Full Code Here

Examples of com.thoughtworks.xstream.io.xml.DomDriver

      TMLMetadataInfo metaData = new TMLMetadataInfo();
      metaData.setDirectAccess(directAccess);
      metaData.setDescription(description);
      metaData.setCacheable(cacheable);
      metaData.setCategory(category);
      XStream xstream = new XStream(new DomDriver());
      xstream.alias(TMLMetadataInfo.XSTREAM_ALIAS, TMLMetadataInfo.class);
      Writer writer = null;
      try {
        if (!_metadataFolder.exists()) {
          _metadataFolder.create(true, true, new NullProgressMonitor())
View Full Code Here

Examples of com.thoughtworks.xstream.io.xml.DomDriver

  public static TMLTagDefinitions fromXML(Reader in) {
    return (TMLTagDefinitions) createXStream().fromXML(in);
  }

  private static XStream createXStream() {
    XStream xstream = new XStream(new DomDriver());
    xstream.setClassLoader(TMLTagDefinitions.class.getClassLoader());
    xstream.setMode(XStream.NO_REFERENCES);
    xstream.alias("tagDefinitions", TMLTagDefinitions.class);
    xstream.alias("tag", TMLTag.class);
    xstream.alias("attribute", TMLTagAttribute.class);
View Full Code Here

Examples of com.thoughtworks.xstream.io.xml.DomDriver

    public static XStream getAnnotationProcessableXStreamInstance() {
        final XStream xstream;
        if(ClassResolver.isPresent(XPP_CLASS)) {
            xstream = new XStream();
        } else {
            xstream = new XStream(new DomDriver());
        }
        xstream.autodetectAnnotations(true);
        return xstream;
    }
View Full Code Here

Examples of com.thoughtworks.xstream.io.xml.DomDriver

  }
 
  private static class DOMXStream extends ThreadLocal {

    protected Object initialValue(){
      return  new BoboXStream(new DomDriver());
    }
View Full Code Here

Examples of com.thoughtworks.xstream.io.xml.DomDriver

  }

  public Collection query() {
    try {
      if (new File(filename).exists()) {
        XStream xstream = new XStream(new DomDriver());
        xstream.setMode(XStream.ID_REFERENCES);
        FileReader reader = new FileReader(filename);
        objects = (Set) xstream.fromXML(reader);
        reader.close();
      }
View Full Code Here

Examples of com.thoughtworks.xstream.io.xml.DomDriver

    }
  }

  public void close() {
    try {
      XStream xstream = new XStream(new DomDriver());
      xstream.setMode(XStream.ID_REFERENCES);
      FileWriter writer = new FileWriter(filename);
      xstream.toXML(objects, writer);
      writer.close();
    } catch (Exception e) {
View Full Code Here

Examples of com.thoughtworks.xstream.io.xml.DomDriver

  /**
   * Writes objects to XML-File.
   */
  public void write(Collection objects) {
    try {
      XStream xstream = new XStream(new DomDriver());
      xstream.setMode(XStream.ID_REFERENCES);
      FileWriter writer = new FileWriter(filename);
      xstream.toXML(new ArrayList(objects), writer);
      writer.close();
    } catch (IOException e) {
View Full Code Here

Examples of com.thoughtworks.xstream.io.xml.DomDriver

  /**
   * Reads collection from XML-File.
   */
  public Collection read() {
    try {
      XStream xstream = new XStream(new DomDriver());
      xstream.setMode(XStream.ID_REFERENCES);
      FileReader reader = new FileReader(filename);
      List objects = (List) xstream.fromXML(reader);
      reader.close();
      return objects;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.