Package com.dotmarketing.portlets.containers.model

Examples of com.dotmarketing.portlets.containers.model.Container


        List<Container> containerList = APILocator.getTemplateAPI().getContainersInTemplate(cmsTemplate, APILocator.getUserAPI().getSystemUser(), false);

    Iterator i = containerList.iterator();
    while(i.hasNext()){
      Container ident = (Container) i.next();
     
      Container c = null;
      if (EDIT_MODE) {
        c = (Container) APILocator.getVersionableAPI().findWorkingVersion(ident.getIdentifier(),APILocator.getUserAPI().getSystemUser(),false);
      }
      else {
        c = (Container) APILocator.getVersionableAPI().findLiveVersion(ident.getIdentifier(),APILocator.getUserAPI().getSystemUser(),false);
      }
      //sets container to load the container file
      sb.append("#set ($container").append(ident.getIdentifier() ).append( " = \"" ).append( folderPath ).append( ident.getIdentifier() ).append( "." ).append( Config.getStringProperty("VELOCITY_CONTAINER_EXTENSION") ).append( "\" )");

      String sort = (c.getSortContentletsBy() == null) ? "tree_order" : c.getSortContentletsBy();

      boolean dynamicContainer = UtilMethods.isSet(c.getLuceneQuery());

      int langCounter = 0;


      List<Contentlet> contentlets = new ArrayList<Contentlet>();
      List<Contentlet> contentletsFull = new ArrayList<Contentlet>();
      if (!dynamicContainer) {
        Identifier idenHtmlPage = APILocator.getIdentifierAPI().find(htmlPage);
        Identifier idenContainer = APILocator.getIdentifierAPI().find(c);
        //The container doesn't have categories
        try{
          contentlets = conAPI.findPageContentlets(idenHtmlPage.getId(), idenContainer.getId(), sort, EDIT_MODE, -1,APILocator.getUserAPI().getSystemUser() ,false);
          if(EDIT_MODE)
              contentletsFull=contentlets;
          else
              contentletsFull = conAPI.findPageContentlets(idenHtmlPage.getId(), idenContainer.getId(), sort, true, -1,APILocator.getUserAPI().getSystemUser() ,false);
        }catch(Exception e){
          Logger.error(PageServices.class,"Unable to retrive contentlets on page", e);
        }
        Logger.debug(PageServices.class, "HTMLPage= " + htmlPage.getInode() + " Container=" + c.getInode() + " Language=-1 Contentlets=" + contentlets.size());
      }
      //this is to filter the contentlets list removing the repited identifiers
      if(contentlets.size() > 0){
        Set<String> contentletIdentList = new HashSet<String>();
        List<Contentlet> contentletsFilter = new ArrayList<Contentlet>();
        for(Contentlet cont : contentlets){
          if(!contentletIdentList.contains(cont.getIdentifier())){
            contentletIdentList.add(cont.getIdentifier());
            contentletsFilter.add(cont);
          }
        }
        contentlets = contentletsFilter;
      }
      if(contentletsFull.size() > 0){
                Set<String> contentletIdentList = new HashSet<String>();
                List<Contentlet> contentletsFilter = new ArrayList<Contentlet>();
                for(Contentlet cont : contentletsFull){
                    if(!contentletIdentList.contains(cont.getIdentifier())){
                        contentletIdentList.add(cont.getIdentifier());
                        contentletsFilter.add(cont);
                    }
                }
                contentletsFull = contentletsFilter;
            }
     
      StringBuilder widgetpree=new StringBuilder();
      StringBuilder widgetpreeFull=new StringBuilder();
     
      StringBuilder contentletList = new StringBuilder();
      int count=0;
      for(Contentlet contentlet : contentlets) {
          contentletList.append(count==0 ? "" : ",")
              .append('"').append(contentlet.getIdentifier()).append('"');
          if(contentlet.getStructure().getStructureType()== Structure.STRUCTURE_TYPE_WIDGET) {
                    Field field=contentlet.getStructure().getFieldVar("widgetPreexecute");
                    if (field!= null && UtilMethods.isSet(field.getValues()))
                        widgetpree.append(field.getValues().trim());
                }
          if(++count>=c.getMaxContentlets()) break;
      }
     
      StringBuilder contentletListFull = new StringBuilder();
            int countFull=0;
            for(Contentlet contentlet : contentletsFull) {
                contentletListFull.append(countFull==0 ? "" : ",")
                    .append('"').append(contentlet.getIdentifier()).append('"');
                if(contentlet.getStructure().getStructureType()== Structure.STRUCTURE_TYPE_WIDGET) {
                    Field field=contentlet.getStructure().getFieldVar("widgetPreexecute");
                    if (field!= null && UtilMethods.isSet(field.getValues()))
                        widgetpreeFull.append(field.getValues().trim());
                }
                if(++countFull>=c.getMaxContentlets()) break;
            }
     
      sb.append("#if($request.session.getAttribute(\"tm_date\"))");
         sb.append(widgetpreeFull);
         sb.append("#set ($contentletList" ).append( ident.getIdentifier() )
View Full Code Here


            try {
                //Integer.parseInt(x);
                Identifier identifier = APILocator.getIdentifierAPI().find(x);
                VersionableAPI versionableAPI=APILocator.getVersionableAPI();
                Container container = null;
                if (preview) {
                  container=(Container)versionableAPI.findWorkingVersion(identifier, user, true);
                } else {
                  container=(Container)versionableAPI.findLiveVersion(identifier, user, true);
                }

                Logger.debug(this,"DotResourceLoader:\tWriting out container inode = " + container.getInode());

                result = ContainerServices.buildVelocity(container, identifier, preview);
            } catch (NumberFormatException e) {
              CacheLocator.getVeloctyResourceCache().addMiss(arg0);
                Logger.warn(this,"getResourceStream: Invalid resource path provided = " + arg0 + ", request discarded.");
View Full Code Here

      //gets all identifier children
      java.util.List<Container> identifiers = APILocator.getTemplateAPI().getContainersInTemplate((Template)webAsset, APILocator.getUserAPI().getSystemUser(), false);
      java.util.Iterator<Container> identifiersIter = identifiers.iterator();
      while (identifiersIter.hasNext()) {

        Container container =(Container) identifiersIter.next();

          Logger.debug(PublishFactory.class, "*****I'm a Template -- Publishing my Container Child=" + container.getInode());
          if(!container.isLive()){
            publishAsset(container,user, respectFrontendRoles, isNewVersion);
          }
       
       
      }
View Full Code Here

      java.util.List<Container> identifiers = APILocator.getTemplateAPI().getContainersInTemplate((Template)webAsset, APILocator.getUserAPI().getSystemUser(), false);
      Iterator<Container> identifiersIter = identifiers.iterator();
      while (identifiersIter.hasNext()) {

        Container container = (Container)identifiersIter.next();
        if(!container.isLive() && (permissionAPI.doesUserHavePermission(container, PERMISSION_PUBLISH, user, respectFrontendRoles) || !checkPublishPermissions)) {
          relatedAssets.add(container);
        }
      }

    }

    if (webAsset instanceof HTMLPage) {

        Logger.debug(PublishFactory.class, "*****I'm an HTML Page -- PrePublishing");

      //gets working (not published) template parent for this html page
      Template templateParent = HTMLPageFactory.getHTMLPageTemplate((HTMLPage)webAsset,true);

      if (InodeUtils.isSet(templateParent.getInode())) {
       
        if(!templateParent.isLive() && (permissionAPI.doesUserHavePermission(templateParent, PERMISSION_PUBLISH, user, respectFrontendRoles) || !checkPublishPermissions)) {
          relatedAssets.add(templateParent);
        }


        //gets all live container children       
        java.util.List<Container> identifiers = APILocator.getTemplateAPI().getContainersInTemplate(templateParent, APILocator.getUserAPI().getSystemUser(), false);
        java.util.Iterator<Container> identifiersIter = identifiers.iterator();
        while (identifiersIter.hasNext()) {

          Container container = (Container)identifiersIter.next();

                    List categories = InodeFactory.getParentsOfClass(container, Category.class);
          List contentlets = null;

          if (categories.size() == 0) {
              Logger.debug(PublishFactory.class, "*******HTML Page PrePublishing Static Container");
              Identifier idenHtmlPage = APILocator.getIdentifierAPI().find(webAsset);
              Identifier idenContainer = APILocator.getIdentifierAPI().find(container);
              try{
                contentlets = conAPI.findPageContentlets(idenHtmlPage.getInode(),idenContainer.getInode(),null, true, -1, APILocator.getUserAPI().getSystemUser(), false);
              }catch (Exception e) {
               Logger.error(PublishFactory.class,"Unable to get contentlets on page",e);
               contentlets = new ArrayList<Contentlet>();
            }
                    }
                    else {

                    Logger.debug(PublishFactory.class, "*******HTML Page PrePublishing Dynamic Container");
                        Iterator catsIter = categories.iterator();
                        Set contentletSet = new HashSet();

                        String condition = "working=" + com.dotmarketing.db.DbConnectionFactory.getDBTrue() + " and deleted=" + com.dotmarketing.db.DbConnectionFactory.getDBFalse();
                        String sort = (container.getSortContentletsBy() == null) ? "sort_order" : container.getSortContentletsBy();

                        while (catsIter.hasNext()) {
                            Category category = (Category) catsIter.next();
                            List contentletsChildren = InodeFactory.getChildrenClassByConditionAndOrderBy(category,
                                    Contentlet.class, condition, sort);
View Full Code Here

      APILocator.getVersionableAPI().setLive(contentlet);

    /*
     * relate the page, container and contentlet
     */
    Container containerId = null;
    for(Container container : APILocator.getTemplateAPI().getContainersInTemplate(template, systemUser, false)){
      if(container.getTitle().equals("Large Column (lg-1)")) {
        containerId = container;
        break;
      }
View Full Code Here

    HibernateUtil.flush();

    /*
     * relate the page, container and contentlet
     */
    Container containerId = null;
    for(Container container : APILocator.getTemplateAPI().getContainersInTemplate(template, systemUser, false)){
      if(container.getTitle().equals("Large Column (lg-1)")){
        containerId = container;
        break;
      }
View Full Code Here

    private HTMLPage loadHtmlPage ( Contentlet contentlet ) throws DotSecurityException, DotDataException {

        Structure structure = contentlet.getStructure();

        //Create a container for the given contentlet
        Container container = new Container();
        container.setCode( "this is the code" );
        container.setFriendlyName( "test container" );
        container.setTitle( "his is the title" );
        container.setMaxContentlets( 5 );
        container.setPreLoop( "preloop code" );
        container.setPostLoop( "postloop code" );
        //Save it

        List<ContainerStructure> csList = new ArrayList<ContainerStructure>();
        ContainerStructure cs = new ContainerStructure();
        cs.setStructureId(structure.getInode());
        cs.setCode("this is the code");
        csList.add(cs);

        container = APILocator.getContainerAPI().save( container, csList, defaultHost, user, false );

        //Create a template
        String body = "<html><body> #parseContainer('" + container.getIdentifier() + "') </body></html>";
        String title = "empty test template " + UUIDGenerator.generateUuid();

        Template template = new Template();
        template.setTitle( title );
        template.setBody( body );

        template = APILocator.getTemplateAPI().saveTemplate( template, defaultHost, user, false );

        //Create the html page
        String pageUrl = "testpage_" + new Date().getTime() + "." + pageExt;
        Folder homeFolder = APILocator.getFolderAPI().createFolders( "/home/", defaultHost, user, false );
        HTMLPage htmlPage = new HTMLPage();
        htmlPage.setPageUrl( pageUrl );
        htmlPage.setFriendlyName( pageUrl );
        htmlPage.setTitle( pageUrl );
        htmlPage = APILocator.getHTMLPageAPI().saveHTMLPage( htmlPage, template, homeFolder, user, false );
        //Make it live
        APILocator.getVersionableAPI().setLive( htmlPage );

        MultiTree multiTree = new MultiTree();
        multiTree.setParent1( htmlPage.getIdentifier() );
        multiTree.setParent2( container.getIdentifier() );
        multiTree.setChild( contentlet.getIdentifier() );
        multiTree.setTreeOrder( 1 );
        MultiTreeFactory.saveMultiTree( multiTree );

        return htmlPage;
View Full Code Here

        User user=APILocator.getUserAPI().getSystemUser();
        Host host=APILocator.getHostAPI().findDefaultHost(user, false);

        // a container to use inside the template
        Container container = new Container();
        container.setFriendlyName("test container");
        container.setTitle("his is the title");
        container.setMaxContentlets(5);
        container.setPreLoop("preloop code");
        container.setPostLoop("postloop code");
        Structure st=StructureCache.getStructureByVelocityVarName("host");

        List<ContainerStructure> csList = new ArrayList<ContainerStructure>();
        ContainerStructure cs = new ContainerStructure();
        cs.setStructureId(st.getInode());
        cs.setCode("this is the code");
        csList.add(cs);
        container = APILocator.getContainerAPI().save(container, csList, host, user, false);


        String body="<html><body> #parseContainer('"+container.getIdentifier()+"') </body></html>";
        String title="empty test template "+UUIDGenerator.generateUuid();

        Template template=new Template();
        template.setTitle(title);
        template.setBody(body);

        Template saved=APILocator.getTemplateAPI().saveTemplate(template, host, user, false);

        final String tInode=template.getInode(),tIdent=template.getIdentifier();

        APILocator.getTemplateAPI().delete(saved, user, false);

        AssetUtil.assertDeleted(tInode, tIdent, "template");

        APILocator.getContainerAPI().delete(container, user, false);

        AssetUtil.assertDeleted(container.getInode(),container.getIdentifier(),"containers");
    }
View Full Code Here

        if (!InodeUtils.isSet(id.getInode()))
            return results;
        List<MultiTree> trees = MultiTreeFactory.getMultiTreeByChild(id.getInode());
        for (MultiTree tree : trees) {
            HTMLPage page = (HTMLPage) APILocator.getVersionableAPI().findWorkingVersion(tree.getParent1(), APILocator.getUserAPI().getSystemUser(), false);
            Container container = (Container) APILocator.getVersionableAPI().findWorkingVersion(tree.getParent2(), APILocator.getUserAPI().getSystemUser(), false);
            if (InodeUtils.isSet(page.getInode()) && InodeUtils.isSet(container.getInode())) {
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("page", page);
                map.put("container", container);
                results.add(map);
            }
View Full Code Here

        List<Container> sourceContainers = templateAPI.getContainersInTemplate(sourceTemplate, user, respectFrontendRoles);
        List<Container> copyContainers = templateAPI.getContainersInTemplate(template, user, respectFrontendRoles);

        List<ContainerRemapTuple> containersRemap = new LinkedList<ContainerRemapTuple>();
        for (int i = 0; i < sourceContainers.size(); i++) {
      Container sourceContainer = sourceContainers.get(i);
      Container destinationContainer = copyContainers.get(i);
          containersRemap.add(new ContainerRemapTuple(sourceContainer, destinationContainer));
        }
        TemplateContainersReMap remap = new TemplateContainersReMap(sourceTemplate, template, containersRemap);

    return copy(source, destination, forceOverwrite, copyMode, remap, user, respectFrontendRoles);
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.containers.model.Container

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.