Package com.dotmarketing.portlets.templates.model

Examples of com.dotmarketing.portlets.templates.model.Template


    //calls edit method from super class that returns parent folder
    super._editWebAsset(req, res, config, form, user,
        WebKeys.TEMPLATE_EDIT);

    //This can't be done on the WebAsset so it needs to be done here.
    Template template = (Template) req.getAttribute(WebKeys.TEMPLATE_EDIT);

    // *********************** BEGIN GRAZIANO issue-12-dnd-template
    if(cmd.equals(Constants.DESIGN))
      template.setDrawed(true);
    // *********************** END GRAZIANO issue-12-dnd-template

    if(UtilMethods.isSet(template.getTheme())) {
      Folder themeFolder = APILocator.getFolderAPI().find(template.getTheme(), user, false);
      template.setThemeName(themeFolder.getName());
    }

    if(InodeUtils.isSet(template.getInode())) {
      _checkReadPermissions(template, user, httpReq);
    }

    //gets image file --- on the image field on the template we store the image's identifier
    //Identifier imageIdentifier = (Identifier) InodeFactory.getInode(template.getImage(), Identifier.class);
    File imageFile = new File();
    Boolean fileAsContent = false;
    Contentlet imageContentlet = new Contentlet();

    if(InodeUtils.isSet(template.getImage())){
      Identifier imageIdentifier = APILocator.getIdentifierAPI().find(template.getImage());
      if(imageIdentifier!=null && UtilMethods.isSet(imageIdentifier.getAssetType())) {
          if(fileAsContent = imageIdentifier.getAssetType().equals("contentlet")) {
            imageContentlet = APILocator.getContentletAPI().findContentletByIdentifier(imageIdentifier.getId(), false, APILocator.getLanguageAPI().getDefaultLanguage().getId(), APILocator.getUserAPI().getSystemUser(), false);
          } else {
            imageFile = (File) APILocator.getVersionableAPI().findWorkingVersion(imageIdentifier,APILocator.getUserAPI().getSystemUser(),false);
          }
      }
    }

    TemplateForm cf = (TemplateForm) form;

    //gets the template host
    HttpSession session = httpReq.getSession();

    TemplateAPI templateAPI = APILocator.getTemplateAPI();
    Host templateHost = templateAPI.getTemplateHost(template);

    if(templateHost == null) {
          String hostId= (String)session.getAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID);
          if(!hostId.equals("allHosts")) {
          //Setting the default host = the selected crumbtrail host if it is a new container
              Host crumbHost = hostAPI.find(hostId, user, false);
              if(crumbHost != null && permissionAPI.doesUserHavePermission(crumbHost, PermissionAPI.PERMISSION_CAN_ADD_CHILDREN, user, false))
                cf.setHostId(hostId);
          }
    } else {
      cf.setHostId(templateHost.getIdentifier());
    }
    ActivityLogger.logInfo(this.getClass(), "Edit Template action", "User " + user.getPrimaryKey() + " edit template " + cf.getTitle(), HostUtil.hostNameUtil(req, _getUser(req)));
    cf.setImage(fileAsContent?imageContentlet.getIdentifier():imageFile.getIdentifier());

    // *********************** BEGIN GRAZIANO issue-12-dnd-template
    req.setAttribute(WebKeys.TEMPLATE_IS_DRAWED, template.isDrawed());
    // *********************** END GRAZIANO issue-12-dnd-template
  }
View Full Code Here


    ActionRequestImpl reqImpl = (ActionRequestImpl) req;
    HttpServletRequest httpReq = reqImpl.getHttpServletRequest();

    //gets TemplateForm struts bean
    TemplateForm cf = (TemplateForm) form;
    Template newTemplate = new Template();
    //gets the new information for the container from the request object

    BeanUtils.copyProperties(newTemplate,form);
    req.setAttribute(WebKeys.TEMPLATE_FORM_EDIT, newTemplate);

    //gets the current template being edited from the request object
    Template currentTemplate = (Template) req.getAttribute(WebKeys.TEMPLATE_EDIT);

    //Retrieves the host were the template will be assigned to
    Host host = hostAPI.find(cf.getHostId(), user, false);

    boolean isNew = !InodeUtils.isSet(currentTemplate.getInode());

    //Checking permissions
    if (!isNew) {
      _checkWritePermissions(currentTemplate, user, httpReq);
      newTemplate.setIdentifier(currentTemplate.getIdentifier());
    } 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)) {
        SessionMessages.add(httpReq, "message", "message.insufficient.permissions.to.save");
        throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);
View Full Code Here

    HttpServletRequest httpReq = reqImpl.getHttpServletRequest();

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

    //gets the current template being edited from the request object
    Template currentTemplate = (Template) req
    .getAttribute(WebKeys.TEMPLATE_EDIT);

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

  }

  public void _getVersionBackWebAsset(ActionRequest req, ActionResponse res,
      PortletConfig config, ActionForm form, User user) throws Exception {

    Template versionTemplate = (Template) InodeFactory.getInode(req
        .getParameter("inode_version"), Template.class);

//    Identifier id = (Identifier)APILocator.getIdentifierAPI().find(versionTemplate);

    //Template workingTemplate = (Template)APILocator.getVersionableAPI().findWorkingVersion(id, APILocator.getUserAPI().getSystemUser(),false);
View Full Code Here

    //creates a set of related pages for this template
    Set relatedPages = new HashSet();

    for (int i=0;i<publishInode.length;i++) {

      Template template = (Template) InodeFactory.getInode(publishInode[i],Template.class);
     
      if (InodeUtils.isSet(template.getInode())) {
           
        //calls the asset factory edit
        try{
          PublishFactory.publishAsset(template,reqImpl.getHttpServletRequest());
          ActivityLogger.logInfo(this.getClass(), "Publish Template action", "User " + user.getPrimaryKey() + " publishing template" + template.getTitle(), HostUtil.hostNameUtil(req, _getUser(req)));
          SessionMessages.add(req, "message", "message.template_list.published");
        }catch(WebAssetException wax){
          Logger.error(this, wax.getMessage(),wax);
          SessionMessages.add(req, "error", "message.webasset.published.failed");
        }
View Full Code Here

    // information to this new version.
    Iterator<Template> it = currentTemplates.iterator();

    // update templates to new version
    while (it.hasNext()) {
      Template parentInode = (Template) it.next();
      parentInode.addChild(container);
    }
    Identifier identifier = APILocator.getIdentifierAPI().find(container);

    //Saving the host of the container
    identifier.setHostId(host.getIdentifier());
View Full Code Here

    if (currentTemplates != null) {
      Iterator<Template> it = currentTemplates.iterator();

      // update templates to new version
      while (it.hasNext()) {
        Template parentInode = (Template) it.next();
        TreeFactory.saveTree(new Tree(parentInode.getInode(), container.getInode()));
      }
    }

    // save the container-structure relationships , issue-2093
    for (ContainerStructure cs : containerStructureList) {
View Full Code Here

     * @throws DotDataException
     */
    private static void addTemplate ( Contentlet contentlet, Container container ) throws DotSecurityException, DotDataException {

        //Create the new template
        Template template = new Template();

        String body = "<html>\n<head>\n</head>\n<body>\n</body>\n#parseContainer('" + container.getIdentifier() + "')\n<br>\n<br>\n#parseContainer('" + container.getIdentifier() + "')\n</html>";
        template.setBody( body );
        template.setFooter( "" );
        template.setFriendlyName( "JUnit Test Template Friendly Name" );
        template.setHeader( "" );
        template.setIDate( new Date() );
        template.setImage( "" );
        template.setModDate( new Date() );
        template.setModUser( user.getUserId() );
        template.setOwner( user.getUserId() );
        template.setSelectedimage( "" );
        template.setShowOnMenu( true );
        template.setSortOrder( 2 );
        template.setTitle( "JUnit Test Template" );
        template.setType( "template" );

        //Saving the template
        template = templateAPI.saveTemplate( template, defaultHost, user, false );

        //Create an htmlPage for this template
View Full Code Here

    public void saveHTMLPage() throws Exception {
        User sysuser=APILocator.getUserAPI().getSystemUser();
        Host host=APILocator.getHostAPI().findDefaultHost(sysuser, false);
        String ext="."+Config.getStringProperty("VELOCITY_PAGE_EXTENSION");

        Template template=new Template();
        template.setTitle("a template "+UUIDGenerator.generateUuid());
        template.setBody("<html><body> I'm mostly empty </body></html>");
        template=APILocator.getTemplateAPI().saveTemplate(template, host, sysuser, false);

        Folder folder=APILocator.getFolderAPI().createFolders(
                "/test_junit/test_"+UUIDGenerator.generateUuid().replaceAll("-", "_"), host, sysuser, false);
View Full Code Here

            cs.setStructureId(structure.getInode());
            cs.setCode("this is the code");
            csList.add(cs);
            container=APILocator.getContainerAPI().save(container, csList, host, sysuser, false);

            template=new Template();
            template.setTitle("empty template "+uuid);
            template.setBody("<html><body>\n #parseContainer('"+container.getIdentifier()+"')\n </body></html>");
            template=APILocator.getTemplateAPI().saveTemplate(template, host, sysuser, false);

            // detail page for url mapped structure
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.templates.model.Template

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.