Package com.dotmarketing.portlets.templates.business

Examples of com.dotmarketing.portlets.templates.business.TemplateAPI


      //Looking for children templates overriding inheritance to also apply the cascade changes
      dc.setSQL(selectChildrenTemplateWithIndividualPermissionsSQL);
      dc.addParam(host.getPermissionId());
      List<Map<String, String>> idsToUpdate = dc.loadResults();
      TemplateAPI templateAPI = APILocator.getTemplateAPI();
      int permission = 0;
      if (inheritablePermission != null) {
        permission = inheritablePermission.getPermission();
      }
      for (Map<String, String> idMap : idsToUpdate) {
        String id = idMap.get("id");
        Permissionable childPermissionable;
        try {
          childPermissionable = templateAPI.findWorkingTemplate(id, systemUser, false);
        } catch (DotSecurityException e) {
          Logger.error(PermissionBitFactoryImpl.class, e.getMessage(), e);
          throw new DotRuntimeException(e.getMessage(), e);
        }
        savePermission(new Permission(id, role.getId(), permission, true), childPermissionable);
View Full Code Here


      template = templateAPI.copy(sourceTemplate, hostDestination, false, true, user, respectFrontendRoles);
    } else {
      template = sourceTemplate;
    }

    TemplateAPI templateAPI = APILocator.getTemplateAPI();

        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);
View Full Code Here

    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
View Full Code Here

    boolean respectFrontendRoles = userWebAPI.isLoggedToFrontend(req);
    String[] inodesArray = containerInode.split(",");
    String result= null;
    for(String contInode : inodesArray){
      Container cont = (Container) InodeFactory.getInode(contInode, Container.class);
      TemplateAPI templateAPI = APILocator.getTemplateAPI();
      List<Template> templates = templateAPI.findTemplates(user, true, null, null, null, null, null, 0, -1, null);
      result = checkTemplatesUsedByContainer(templates,cont,user, respectFrontendRoles);     
      if(result.length()>0){
        StringBuilder dialogMessage=new StringBuilder();
        dialogMessage.append(LanguageUtil.get(user,"container-used-templates")).append("<br> <br>");
        dialogMessage.append(LanguageUtil.get(user,"Container") + " : ").append(cont.getTitle()).append("<br>");
View Full Code Here

    return result.length()>0?result.toString():null;

  }
 
  private String checkTemplatesUsedByContainer(List<Template> templates,Container cont, User user,boolean respectFrontendRoles ) throws DotSecurityException,  DotDataException {
    TemplateAPI templateAPI = APILocator.getTemplateAPI();
    StringBuilder names=new StringBuilder();
    String result = null;
    for (Template template : templates) {
      List<Container> containers = templateAPI.getContainersInTemplate(template, user, respectFrontendRoles);
      if(containers.contains(cont)) {
        names.append(template.getTitle()).append("</br> ");
      }
    }
    result = names.toString();
View Full Code Here

        for (Folder folder : folders) {
          folderAPI.delete(folder, user, respectFrontendRoles);
        }

        // Remove Templates
        TemplateAPI templateAPI = APILocator.getTemplateAPI();
        List<Template> templates = templateAPI.findTemplates(user, true, null, host.getIdentifier(), null, null, null, 0, -1, null);
        for (Template template : templates) {
          dc.setSQL("delete from template_containers where template_id = ?");
          dc.addParam(template.getIdentifier());
          dc.loadResult();

          dc.setSQL("select inode, identifier from htmlpage where template_id = ?");
          dc.addParam(template.getIdentifier());
          List<HashMap<String, Object>> htmlpages =  dc.loadResults();
          for (HashMap<String, Object> folderMap : htmlpages) {
            String identifier = (String) folderMap.get("identifier");
            HTMLPage page = htmlPageAPI.loadWorkingPageById(identifier, user, respectFrontendRoles);
            htmlPageAPI.delete(page, user, respectFrontendRoles);
          }

          templateAPI.delete(template, user, respectFrontendRoles);
        }

        // Remove Containers
        ContainerAPI containerAPI = APILocator.getContainerAPI();
        List<Container> containers = containerAPI.findContainers(user, true, null, host.getIdentifier(), null, null, null, 0, -1, null);
View Full Code Here

        for (Folder folder : folders) {
          folderAPI.delete(folder, user, respectFrontendRoles);
        }

        // Remove Templates
        TemplateAPI templateAPI = APILocator.getTemplateAPI();
        List<Template> templates = templateAPI.findTemplates(user, true, null, host.getIdentifier(), null, null, null, 0, -1, null);
        for (Template template : templates) {
          dc.setSQL("delete from template_containers where template_id = ?");
          dc.addParam(template.getIdentifier());
          dc.loadResult();

          dc.setSQL("select inode, identifier from htmlpage where template_id = ?");
          dc.addParam(template.getIdentifier());
          List<HashMap<String, Object>> htmlpages =  dc.loadResults();
          for (HashMap<String, Object> folderMap : htmlpages) {
            String identifier = (String) folderMap.get("identifier");
            HTMLPage page = htmlPageAPI.loadWorkingPageById(identifier, user, respectFrontendRoles);
            htmlPageAPI.delete(page, user, respectFrontendRoles);
          }

          templateAPI.delete(template, user, respectFrontendRoles);
        }

        // Remove Containers
        ContainerAPI containerAPI = APILocator.getContainerAPI();
        List<Container> containers = containerAPI.findContainers(user, true, null, host.getIdentifier(), null, null, null, 0, -1, null);
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.templates.business.TemplateAPI

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.