Package com.dotmarketing.portlets.contentlet.business

Examples of com.dotmarketing.portlets.contentlet.business.HostAPI


  }

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

    HostAPI hostAPI = APILocator.getHostAPI();

    VirtualLinkForm mlForm = (VirtualLinkForm) form;
   
    String completeUrl = null;

    String url = mlForm.getUrl();
    if( !url.startsWith("/") ) {
      url = "/" + url;
    }
   
    if (InodeUtils.isSet(mlForm.getHostId())) {
        Host host = hostAPI.find(mlForm.getHostId(), user, false);
        completeUrl = host.getHostname() + ":" + url;
    } else {
        completeUrl = url;
    }
   
View Full Code Here


    return vlinks;
  }


  public VirtualLink checkVirtualLinkForEditPermissions(VirtualLink link,User user) throws DotDataException, DotSecurityException {
    HostAPI hostAPI=APILocator.getHostAPI();
    List <Host>  hosts = hostAPI.getHostsWithPermission(PERMISSION_CREATE_VIRTUAL_LINKS, false, user, false);

    try {
      if(APILocator.getRoleAPI().doesUserHaveRole(user, APILocator.getRoleAPI().loadCMSAdminRole())){

        return link;
View Full Code Here

    try {

      User systemUser = APILocator.getUserAPI().getSystemUser();
      FolderAPI fAPI = APILocator.getFolderAPI();
      HostAPI hostAPI = APILocator.getHostAPI();
      Host systemHost = hostAPI.findSystemHost(systemUser, false);
      Structure st = getStructure();



      if(st != null && st.getVelocityVarName() != null && st.getVelocityVarName().equals("Host")) {
        Host hProxy = new Host(this);
        return hProxy.getParentPermissionable();
      }


      // if this contentlet is being saved in a folder, inherit from the folder
      if(InodeUtils.isSet(this.getFolder()) && ! "SYSTEM_FOLDER".equals(this.getFolder())) {
        return fAPI.find(this.getFolder(), APILocator.getUserAPI().getSystemUser(), false);
      }

      // if this contentlet is being saved in a host, inherit from the host
      if(InodeUtils.isSet(this.getHost()) && ! this.getHost().equals(systemHost.getIdentifier())) {
        return hostAPI.find(this.getHost(), systemUser, false);
      }

      // if this contentlet has a structure, inherit from that
      if(st != null && InodeUtils.isSet(st.getInode())){
        return st;
View Full Code Here

 

  public void checkHostCopy(Contentlet contentlet, User user, String copyOptions) {
    try {
       
          HostAPI hostAPI = APILocator.getHostAPI();
         
          Map<String, String> copyParams = new HashMap<String, String>();
          List<RegExMatch> matches = RegEX.find(copyOptions, "(?:(\\w+):([\\w-]+);?)");
          for (RegExMatch match : matches) {
            String varName = match.getGroups().get(0).getMatch();
            String varValue = match.getGroups().get(1).getMatch();
            copyParams.put(varName, varValue);
          }

          String copyFromHostId = copyParams.get("copy_from_host_id");
          boolean copyAll = copyParams.get("copy_all").equals("on");
          boolean copyTemplatesContainers = copyParams.get("copy_templates_containers").equals("on");
          boolean copyContentOnPages = copyParams.get("copy_content_on_pages").equals("on");
          boolean copyFolders = copyParams.get("copy_folders").equals("on");
          boolean copyContentOnHost = copyParams.get("copy_content_on_host").equals("on");
          boolean copyFiles = copyParams.get("copy_files").equals("on");
          boolean copyPages = copyParams.get("copy_pages").equals("on");
          boolean copyVirtualLinks = copyParams.get("copy_virtual_links").equals("on");
          boolean copyHostVariables = copyParams.get("copy_host_variables").equals("on");

          Host source = hostAPI.find(copyFromHostId, user, false);
          HostCopyOptions hostCopyOptions = null;
          if (copyAll)
            hostCopyOptions = new HostCopyOptions(copyAll);
          else
            hostCopyOptions = new HostCopyOptions(copyTemplatesContainers, copyFolders, copyFiles, copyPages, copyContentOnPages, copyContentOnHost,
View Full Code Here

    private static Host defaultHost;

    @BeforeClass
    public static void prepare () throws DotSecurityException, DotDataException {

        HostAPI hostAPI = APILocator.getHostAPI();

        //Setting the test user
        user = APILocator.getUserAPI().getSystemUser();
        defaultHost = hostAPI.findDefaultHost( user, false );
    }
View Full Code Here

    if(user == null){
      return path;
    }

    PermissionAPI pAPI = APILocator.getPermissionAPI();
    HostAPI hostAPI = APILocator.getHostAPI();

    Host host = null;
    // if someone is changing hosts as a parameter, check permissions
    if(UtilMethods.isSet(req.getParameter("host_id"))){
      try{
        host = hostAPI.find(req.getParameter("host_id"), user, false);

        if(host != null && pAPI.doesUserHavePermission(host, PermissionAPI.PERMISSION_READ, user, false)){
          req.getSession().setAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID, req.getParameter("host_id"));
          UserUtil.setLastHost(user, host);
        }
        else{
          UserUtil.setLastHost(user, null);
          req.getSession().removeAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID);
          Logger.info(this.getClass(), "user " + user.getUserId() + " does not have permission to host " +req.getParameter("host_id"));
        }
      }
      catch(Exception e){
        req.getSession().removeAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID);
        Logger.error(this.getClass(), "user " + user.getUserId() + " does not have permission to host " +req.getParameter("host_id"));
      }
    }
    // else check if the user as permissions to the host in their session (can change, login as, etc..)
    else if(UtilMethods.isSet(req.getSession().getAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID)) ){
      String x = (String) req.getSession().getAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID);
      try{
        host = hostAPI.find(x, user, false);
        if(host != null && pAPI.doesUserHavePermission(host, PermissionAPI.PERMISSION_READ, user, false)){
          req.getSession().setAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID, host.getIdentifier());
        }
        else{
          Logger.error(this.getClass(), "user " + user.getUserId() + " does not have permission to host " +req.getSession().getAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID));
          req.getSession().removeAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID);
          UserUtil.setLastHost(user,null);
        }
      }
      catch(Exception e){
        Logger.error(this.getClass(), "user " + user.getUserId() + " does not have permission to host " +req.getSession().getAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID));
        req.getSession().removeAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID);

      }
    }
    // try to get the last host from the user record
    else{

        try {
          host = UserUtil.getLastHost(user);
          req.getSession().setAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID, host.getIdentifier());
        } catch (DotDataException e) {
          Logger.debug(this.getClass(), e.toString());
        } catch (DotSecurityException e) {
          Logger.warn(this.getClass(), "User " + user.getUserId() + " does not have permissions to host " + e.toString());
        }

    }


    // finally, if user does not have a host
    // set to default host if it is not in the session
    if(!UtilMethods.isSet(req.getSession().getAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID))){
      try{
        List<Host> list = hostAPI.getHostsWithPermission(PermissionAPI.PERMISSION_READ, user, false);
        host = null;
        for(Host h : list) {
          if(!h.isSystemHost()){
            if(h.isDefault()){
              host = h;
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.contentlet.business.HostAPI

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.