Package com.dotmarketing.portlets.containers.model

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


    req.setAttribute(WebKeys.CONTAINER_FORM_EDIT,
        new com.dotmarketing.portlets.containers.model.Container());
    BeanUtils.copyProperties(req.getAttribute(WebKeys.CONTAINER_FORM_EDIT),  form);

    // gets the new information for the container from the request object
    Container container = (Container) req.getAttribute(WebKeys.CONTAINER_FORM_EDIT);

    // gets the current container being edited from the request object
    Container currentContainer = (Container) req.getAttribute(WebKeys.CONTAINER_EDIT);

    //Is a new container?
    boolean isNew = !InodeUtils.isSet(currentContainer.getInode());

    //Getting the container host
        Host host = hostAPI.find(fm.getHostId(), user, false);

    //Checking permissions
    if (!isNew) {
      _checkWritePermissions(currentContainer, user, httpReq);
    } else {
      //If the asset is new checking that the user has permission to add children to the parent host
      if(!permissionAPI.doesUserHavePermission(host, PermissionAPI.PERMISSION_CAN_ADD_CHILDREN, user, false)
          || !permissionAPI.doesUserHavePermissions(PermissionableType.CONTAINERS, PermissionAPI.PERMISSION_EDIT, user)) {
        SessionMessages.add(httpReq, "message", "message.insufficient.permissions.to.save");
        throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);
      }
    }

    // Current associated templates
    List<Template> currentTemplates = InodeFactory.getChildrenClass(currentContainer, Template.class);

    // gets user id from request for mod user
    String userId = user.getUserId();

    // Associating the current structure
    Structure currentStructure = null;
    if (!InodeUtils.isSet(fm.getStructureInode())) {
      currentStructure = StructureFactory.getDefaultStructure();
    } else {
      currentStructure = StructureCache.getStructureByInode(fm.getStructureInode());
    }

    // it saves or updates the asset
    if (InodeUtils.isSet(currentContainer.getInode())) {
      Identifier identifier = APILocator.getIdentifierAPI().find(currentContainer);
      WebAssetFactory.createAsset(container, userId, identifier, false);
      container = (Container) WebAssetFactory.saveAsset(container,
          identifier);
    } else {
View Full Code Here


    HttpServletRequest httpReq = reqImpl.getHttpServletRequest();

    Logger.debug(this, "I'm copying the Container");

    // gets the current template being edited from the request object
    Container currentContainer = (Container) req
        .getAttribute(WebKeys.CONTAINER_EDIT);

    // Checking permissions
    _checkCopyAndMovePermissions(currentContainer, user, httpReq,
        "copy");
View Full Code Here

    SessionMessages.add(httpReq, "message", "message.containers.copy");
  }

  public void _getVersionBackWebAsset(ActionRequest req, ActionResponse res,
      PortletConfig config, ActionForm form, User user) throws Exception {
    Container workingContainer = (Container) super._getVersionBackWebAsset(
        req, res, config, form, user, Container.class,
        WebKeys.CONTAINER_EDIT);
    ContainerServices.invalidate(workingContainer, true);
  }
View Full Code Here

        return list.size()>0;
    }

    public static Container getContainerByFriendlyName(String friendlyName) {
        HibernateUtil dh = new HibernateUtil(Container.class);
        Container container = null ;
        try {
      dh.setQuery("from inode in class com.dotmarketing.portlets.containers.model.Container where type='containers' and friendly_name = ? and live=" + com.dotmarketing.db.DbConnectionFactory.getDBTrue());
      dh.setParam(friendlyName);
      container = (Container) dh.load();
    } catch (DotHibernateException e) {
View Full Code Here

    public static Container copyContainer (Container currentContainer) throws DotDataException, DotStateException, DotSecurityException {

      HostAPI hostAPI = APILocator.getHostAPI();

    //gets the new information for the template from the request object
    Container newContainer = new Container();

    newContainer.copy(currentContainer);
         newContainer.setFriendlyName(currentContainer.getFriendlyName()
        + " (COPY) ");
         newContainer.setTitle(currentContainer.getTitle() + " (COPY) ");

        //Copy the structure
//        Structure st = StructureCache.getStructureByInode(currentContainer.getStructureInode());
//        newContainer.setStructureInode(st.getInode());



    //persists the webasset
    HibernateUtil.saveOrUpdate(newContainer);


    //Copy the host
    Host h;
    try {
      h = hostAPI.findParentHost(currentContainer, APILocator.getUserAPI().getSystemUser(), false);
    } catch (DotSecurityException e) {
      Logger.error(ContainerFactory.class, e.getMessage(), e);
      throw new DotRuntimeException(e.getMessage(), e);
    }
        //TreeFactory.saveTree(new Tree(h.getIdentifier(), newContainer.getInode()));

        //creates new identifier for this webasset and persists it
    Identifier newIdentifier = APILocator.getIdentifierAPI().createNew(newContainer, h);

    // save identifier id
    HibernateUtil.saveOrUpdate(newContainer);

    APILocator.getVersionableAPI().setWorking(newContainer);
    if(currentContainer.isLive())
        APILocator.getVersionableAPI().setLive(newContainer);

    PermissionAPI perAPI = APILocator.getPermissionAPI();
    //Copy permissions
    perAPI.copyPermissions(currentContainer, newContainer);

    //saves to working folder under velocity
    ContainerServices.invalidate(newContainer, newIdentifier,
        true);

    // issue-2093 Copying multiple structures per container
    if(currentContainer.getMaxContentlets()>0) {

      List<ContainerStructure> sourceCS = APILocator.getContainerAPI().getContainerStructures(currentContainer);
      List<ContainerStructure> newContainerCS = new LinkedList<ContainerStructure>();

      for (ContainerStructure oldCS : sourceCS) {
        ContainerStructure newCS = new ContainerStructure();
        newCS.setContainerId(newContainer.getIdentifier());
        newCS.setStructureId(oldCS.getStructureId());
        newCS.setCode(oldCS.getCode());
        newContainerCS.add(newCS);
      }
View Full Code Here

   
    if (req.getParameter("popup") != null)
    {
      if (req.getParameter("container_inode") != null)
      {
        Container cont = (Container) InodeFactory.getInode(req.getParameter("container_inode"), Container.class);

        List<Structure> structures = APILocator.getContainerAPI().getStructuresInContainer(cont);
        req.setAttribute(WebKeys.Structure.STRUCTURES, structures);
      }
      else if (req.getParameter("structure_id") != null)
View Full Code Here

    if (publishInode == null) return;
   
    ActionRequestImpl reqImpl = (ActionRequestImpl)req;
   
    for (int i=0;i<publishInode.length;i++) {
      Container container = (Container) InodeFactory.getInode(publishInode[i],Container.class);
 
      if (InodeUtils.isSet(container.getInode())) {
        //calls the asset factory edit
       
        try{
          PublishFactory.publishAsset(container,reqImpl.getHttpServletRequest());
          SessionMessages.add(req, "message", "message.container_list.published");
        } catch(DotSecurityException wax){
          Logger.error(this, wax.getMessage(),wax);
          SessionMessages.add(req, "error", "message.webasset.published.failed");
        } catch(WebAssetException wax){
          Logger.error(this, wax.getMessage(),wax);
          SessionMessages.add(req, "error", "message.webasset.published.failed");
        }
      }
     
      ActivityLogger.logInfo(this.getClass(), "Publishing Container action", "User " + user.getPrimaryKey() + " publishing container" + container.getTitle(), HostUtil.hostNameUtil(req, user));
    }

   
   
  }
View Full Code Here

    if (currentContentlet.getInode().equalsIgnoreCase(contentlet.getInode())) {
      String htmlpage_inode = req.getParameter("htmlpage_inode");
      String contentcontainer_inode = req.getParameter("contentcontainer_inode");
      HTMLPage htmlParent = (HTMLPage) InodeFactory.getInode(htmlpage_inode, HTMLPage.class);
      Logger.debug(this, "Added Contentlet to parent=" + htmlParent.getInode());
      Container containerParent = (Container) InodeFactory.getInode(contentcontainer_inode, Container.class);
      Logger.debug(this, "Added Contentlet to parent=" + containerParent.getInode());

      Identifier iden = APILocator.getIdentifierAPI().find(contentlet);

      if (InodeUtils.isSet(htmlParent.getInode()) && InodeUtils.isSet(containerParent.getInode()) && InodeUtils.isSet(contentlet.getInode())) {
        Identifier htmlPageIdentifier = APILocator.getIdentifierAPI().find(htmlParent);
        Identifier containerIdentifier = APILocator.getIdentifierAPI().find(containerParent);
        Identifier contenletIdentifier = APILocator.getIdentifierAPI().find(contentlet);
        MultiTree multiTree = MultiTreeFactory.getMultiTree(htmlPageIdentifier, containerIdentifier,
            contenletIdentifier);
        Logger.debug(this, "Getting multitree for=" + htmlParent.getInode() + " ," + containerParent.getInode()
            + " ," + contentlet.getIdentifier());
        Logger.debug(this, "Coming from multitree parent1=" + multiTree.getParent1() + " parent2="
            + multiTree.getParent2());

        if (!InodeUtils.isSet(multiTree.getParent1()) && !InodeUtils.isSet(multiTree.getParent2()) && !InodeUtils.isSet(multiTree.getChild())) {

          Logger.debug(this, "MTree is null!!! Creating new one!");

          MultiTree mTree = new MultiTree(htmlPageIdentifier.getInode(), containerIdentifier.getInode(),
              contenletIdentifier.getInode(),null,containerParent.getMaxContentlets());
          MultiTreeFactory.saveMultiTree(mTree);
        }

        //Updating the last mod user and last mod date of the page
        htmlParent.setModDate(new Date());
View Full Code Here

        respectFrontendRoles)) {
      throw new DotSecurityException("You don't have permission to wirte in the destination folder.");
    }

    //gets the new information for the template from the request object
    Container newContainer = new Container();

    newContainer.copy(source);

    String appendToName = getAppendToContainerTitle(source.getTitle(), destination);
         newContainer.setFriendlyName(source.getFriendlyName() + appendToName);
         newContainer.setTitle(source.getTitle() + appendToName);

        //Copy the structure relationship
//        Structure st = StructureCache.getStructureByInode(source.getStructureInode());
//        newContainer.setStructureInode(st.getInode());

        //creates new identifier for this webasset and persists it
    Identifier newIdentifier = APILocator.getIdentifierAPI().createNew(newContainer, destination);

        newContainer.setIdentifier(newIdentifier.getId());
    //persists the webasset
    save(newContainer);

    if(source.isWorking()){
      APILocator.getVersionableAPI().setWorking(newContainer);
    }
    if(source.isLive()){
      APILocator.getVersionableAPI().setLive(newContainer);
    }

    // issue-2093 Copying multiple structures per container
    if(source.getMaxContentlets()>0) {

      List<ContainerStructure> sourceCS = getContainerStructures(source);
      List<ContainerStructure> newContainerCS = new LinkedList<ContainerStructure>();

      for (ContainerStructure oldCS : sourceCS) {
        ContainerStructure newCS = new ContainerStructure();
        newCS.setContainerId(newContainer.getIdentifier());
        newCS.setStructureId(oldCS.getStructureId());
        newCS.setCode(oldCS.getCode());
        newContainerCS.add(newCS);
      }
View Full Code Here

  @SuppressWarnings("unchecked")
  public Container getWorkingContainerById(String id, User user, boolean respectFrontendRoles) throws DotDataException, DotSecurityException {

    //Trying to get the container from Working cache.
    Container container = CacheLocator.getContainerCache().getWorking(id);
   
    //If it is not in cache.
    if(container == null){
     
      //Get container from DB.
      HibernateUtil dh = new HibernateUtil(Container.class);
     
      dh.setSQLQuery("select {containers.*} from containers, inode containers_1_, container_version_info vv " +
          "where containers.inode = containers_1_.inode and vv.working_inode=containers.inode and " +
          "vv.identifier = ?");
     
      dh.setParam(id);
     
      List<Container> list = dh.list();

      //If DB return something.
      if(!list.isEmpty()){
        Container containerAux = list.get(0);

        if (!permissionAPI.doesUserHavePermission(containerAux, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles)) {
          throw new DotSecurityException("You don't have permission to read the source file.");
        }

        if(InodeUtils.isSet(containerAux.getInode())){
          //container is the one we are going to return.
          container = containerAux;
          //Add to cache.
          CacheLocator.getContainerCache().add(container.getIdentifier(), container);
        }
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.