Package com.dotmarketing.portlets.templates.struts

Examples of com.dotmarketing.portlets.templates.struts.TemplateForm


            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


    //wraps request to get session object
    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);
      }

    }

    //gets user id from request for mod user
    //gets file object for the thumbnail
    if (InodeUtils.isSet(cf.getImage())) {
      newTemplate.setImage(cf.getImage());
    }

    // *********************** BEGIN GRAZIANO issue-12-dnd-template
    if(cmd.equals(Constants.ADD_DESIGN)){
      newTemplate.setDrawed(true);

      // create the body with all the main HTML tags

//      Folder themeFolder = APILocator.getFolderAPI().find(newTemplate.getTheme(), user, false);
      String themeHostId = APILocator.getFolderAPI().find(newTemplate.getTheme(), user, false).getHostId();
      String themePath = null;

      if(themeHostId.equals(host.getInode())) {
        themePath = Template.THEMES_PATH + newTemplate.getThemeName() + "/";
      } else {
        Host themeHost = APILocator.getHostAPI().find(themeHostId, user, false);
        themePath = "//" + themeHost.getHostname() + Template.THEMES_PATH + newTemplate.getThemeName() + "/";
      }

      StringBuffer endBody = DesignTemplateUtil.getBody(newTemplate.getBody(), newTemplate.getHeadCode(), themePath, cf.isHeaderCheck(), cf.isFooterCheck());


      // set the drawedBody for future edit
      newTemplate.setDrawedBody(newTemplate.getBody());

      // set the real body
      newTemplate.setBody(endBody.toString());

      newTemplate.setHeadCode(cf.getHeadCode());
    }
    // *********************** END GRAZIANO issue-12-dnd-template

    APILocator.getTemplateAPI().saveTemplate(newTemplate,host , user, false);

View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.templates.struts.TemplateForm

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.