Package com.dotmarketing.beans

Examples of com.dotmarketing.beans.Host


        path += "/" + pathTokens[i];
      }
    }

    boolean userHasPublishPermission = true;
    Host host = APILocator.getHostAPI().find(hostId, user, true);
    if (!path.equals("/")) {

      Folder folder = fapi.findFolderByPath(path, host,user,false);

      //gets menu items for this folder
View Full Code Here


      itemsList = fapi.findMenuItems(folder,user,false);
    }
    else {
      //if i dont have a parent folder im ordering all the folder on the root for this folder
      String hostId = req.getParameter("hostId");
      Host host = APILocator.getHostAPI().find(hostId, user, false);
      itemsList = fapi.findSubFolders(host,true);
    }

    int increment = 0;
View Full Code Here

     
      //set the host to the domain of the URL if possible if not use the default host
      //http://jira.dotmarketing.net/browse/DOTCMS-4475
      try{
        String domainName = req.getServerName();
        Host h = null;
        h = APILocator.getHostAPI().findByName(domainName, user, false);
        if(h == null || !UtilMethods.isSet(h.getInode())){
          h = APILocator.getHostAPI().findByAlias(domainName, user, false);
        }
        if(h != null && UtilMethods.isSet(h.getInode())){
          req.getSession().setAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID, h.getIdentifier());
        }else{
          req.getSession().setAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID, APILocator.getHostAPI().findDefaultHost(APILocator.getUserAPI().getSystemUser(), true).getIdentifier());
        }
      }catch (DotSecurityException se) {
        req.getSession().setAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID, APILocator.getHostAPI().findDefaultHost(APILocator.getUserAPI().getSystemUser(), true).getIdentifier());
View Full Code Here

      Tag tag = new Tag();
      //creates new Tag
      tag.setTagName(tagName);
      tag.setUserId(userId);

      Host host = null;

      if(UtilMethods.isSet(hostId) && !hostId.equals(Host.SYSTEM_HOST)){
        try{
            if(!UtilMethods.isSet(hostId)){
              host = APILocator.getHostAPI().findDefaultHost(APILocator.getUserAPI().getSystemUser(), true);
            }
            else {
              host = APILocator.getHostAPI().find(hostId,APILocator.getUserAPI().getSystemUser(), true);
            }
          }
          catch (Exception e) {
            Logger.error(TagFactory.class, "Unable to load host.");
          }

        try {
          hostId=host.getMap().get("tagStorage").toString();
        } catch (NullPointerException e) {
          hostId = Host.SYSTEM_HOST;
        }

      }
View Full Code Here

        try {

          HibernateUtil dh = new HibernateUtil(Tag.class);
          List list = new java.util.ArrayList();

        Host host = null;
        try {
          host = APILocator.getHostAPI().find(hostFilter, APILocator.getUserAPI().getSystemUser(), true);
        }catch (Exception e){
          Logger.warn(Tag.class, "Unable to get host according to search criteria - hostId = "+ hostFilter);
        }
      if (UtilMethods.isSet(host)){

        String sortStr = "";
        if (UtilMethods.isSet(sort)) {
                String sortDirection = sort.startsWith("-")?"desc":"asc";
            sort = sort.startsWith("-")?sort.substring(1,sort.length()):sort;

            if(sort.equalsIgnoreCase("hostname")) sort = "host_id";

            sortStr = " order by " + sort + " " + sortDirection;
        } else {
          sortStr = "order by tagname";
        }

        //if tag name and host name are set as filters
        //search by name, global tags and current host.
        if(UtilMethods.isSet(tagName) && globalTagsFilter){
            dh.setQuery("from tag in class com.dotmarketing.tag.model.Tag where lower(tagname) like ? and (host_id = ? or host_id = ?) " + sortStr);
                  dh.setParam("%" + tagName.toLowerCase()  + "%");
                  try {
              dh.setParam(host.getMap().get("tagStorage").toString());
            } catch(NullPointerException e) {
              dh.setParam(Host.SYSTEM_HOST);
            }
                  dh.setParam(Host.SYSTEM_HOST);
        }
        //if global host is not set as unique filter but tag name is set, search in current host
        else if (UtilMethods.isSet(tagName) && !globalTagsFilter){
            dh.setQuery("from tag in class com.dotmarketing.tag.model.Tag where lower(tagname) like ? and (host_id = ?) " + sortStr);
            dh.setParam("%" + tagName.toLowerCase() + "%");
            try {
              dh.setParam(host.getMap().get("tagStorage").toString());
            } catch(NullPointerException e) {
              dh.setParam(Host.SYSTEM_HOST);
            }
        }else if(!UtilMethods.isSet(tagName) && globalTagsFilter){
               //check if tag name is not set and if should display global tags
               //it will check all global tags and current host tags.
          dh.setQuery("from tag in class com.dotmarketing.tag.model.Tag where "+
                  "(host_id = ? or host_id = ? ) " + sortStr);

          try {
              dh.setParam(host.getMap().get("tagStorage").toString());
            } catch(NullPointerException e) {
              dh.setParam(Host.SYSTEM_HOST);
            }
                dh.setParam(Host.SYSTEM_HOST);
        } else {
          //check all current host tags.
          String sql =  "from tag in class com.dotmarketing.tag.model.Tag ";
         
          Object tagStorage = host.getMap().get("tagStorage");
         
          if(UtilMethods.isSet(tagStorage)){
            sql = sql + "where ( host_id = ? ) " + sortStr;
            dh.setQuery(sql);
            dh.setParam(tagStorage.toString());
View Full Code Here

  public static List<Tag> getSuggestedTag(HttpServletRequest request, String name, String selectedHostId) {
    try {
      name = escapeSingleQuote(name);

      String currentHostId = "";
         Host currentHost = null;
         String hostId = "";

        //if there's a host field on form, retrieve it
        Host hostOnForm = null;
        if(UtilMethods.isSet(selectedHostId)){
          try{
            hostOnForm = APILocator.getHostAPI().find(selectedHostId,APILocator.getUserAPI().getSystemUser(), true);
            selectedHostId=hostOnForm.getMap().get("tagStorage").toString();
          }
          catch (Exception e) {
            selectedHostId=Host.SYSTEM_HOST;
            Logger.info(TagFactory.class, "Unable to load current host.");
          }
View Full Code Here

          boolean globalTagExists = false;

          //check if tag exists with same tag name but for a different host
          boolean tagExists = false;

          Host host = APILocator.getHostAPI().find(hostId, APILocator.getUserAPI().getSystemUser(), true);
          if(host.getMap().get("tagStorage") == null){
            existHostId = host.getMap().get("identifier").toString();
          }
          else {
            existHostId = host.getMap().get("tagStorage").toString();
          }
          for(Tag tag : tags){

            if(isGlobalTag(tag)){
              newTag = tag;
View Full Code Here

      Tag tag = new Tag();
      //creates new Tag
      tag.setTagName(tagName);
      tag.setUserId(userId);

      Host host = null;

      if(UtilMethods.isSet(hostId) && !hostId.equals(Host.SYSTEM_HOST)){
        try{
            if(!UtilMethods.isSet(hostId)){
              host = APILocator.getHostAPI().findDefaultHost(APILocator.getUserAPI().getSystemUser(), true);
            }
            else {
              host = APILocator.getHostAPI().find(hostId,APILocator.getUserAPI().getSystemUser(), true);
            }
          }
          catch (Exception e) {
            Logger.error(this, "Unable to load host.");
          }

          if(host.getMap().get("tagStorage") == null){
            hostId = host.getMap().get("identifier").toString();
          }
          else {
            hostId = host.getMap().get("tagStorage").toString();
          }

        /*try {
          hostId=host.getMap().get("tagStorage").toString();
        } catch(NullPointerException e) {
View Full Code Here

  public List<Tag> getSuggestedTag(HttpServletRequest request, String name, String selectedHostId) {
    try {
      name = escapeSingleQuote(name);

      String currentHostId = "";
         Host currentHost = null;
         String hostId = "";

        //if there's a host field on form, retrieve it
        Host hostOnForm = null;
        if(UtilMethods.isSet(selectedHostId)){
          try{
            hostOnForm = APILocator.getHostAPI().find(selectedHostId,APILocator.getUserAPI().getSystemUser(), true);
            selectedHostId=hostOnForm.getMap().get("tagStorage").toString();
          }
          catch (Exception e) {
            Logger.error(this, "Unable to load current host.");
          }
        }
View Full Code Here

  }

  protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,
      IOException {

    Host host;
    try {
      host = WebAPILocator.getHostWebAPI().getCurrentHost(request);
    } catch (PortalException e1) {
      Logger.error(XSPFServlet.class, e1.getMessage(), e1);
      throw new ServletException(e1.getMessage(), e1);
    } catch (SystemException e1) {
      Logger.error(XSPFServlet.class, e1.getMessage(), e1);
      throw new ServletException(e1.getMessage(), e1);
    } catch (DotDataException e1) {
      Logger.error(XSPFServlet.class, e1.getMessage(), e1);
      throw new ServletException(e1.getMessage(), e1);
    } catch (DotSecurityException e1) {
      Logger.error(XSPFServlet.class, e1.getMessage(), e1);
      throw new ServletException(e1.getMessage(), e1);
    }
    String path = request.getParameter("path");

    if (path == null) {
      return;
    }

    path = (path.endsWith("/")) ? path : path + "/";

    Folder folder = new Folder();
    try {
      folder = APILocator.getFolderAPI().findFolderByPath(path, host, APILocator.getUserAPI().getSystemUser(),false);
    } catch (Exception e1) {
      Logger.error(this,e1.getMessage(), e1);
    }
    List<File> mp3Files = InodeFactory.getChildrenClassByConditionAndOrderBy(folder, File.class,
        "lower(file_name) like '%.mp3'", "sort_order");
/*
    java.io.File cachedFile = new java.io.File(FileUtil.getRealPath("/WEB-INF/velocity/static/xspf/"
        + URLEncoder.encode(path, "UTF-8") + ".xml"));
    boolean useCache = cachedFile.exists();

    if (useCache) {
      Date d = new Date(cachedFile.lastModified());
      for (File file : mp3Files) {
        Date modDate = file.getModDate();
        if (modDate.after(d)) {
          useCache = false;
        }
      }
    }
*/
    response.setContentType("text/xml");
    PrintWriter out = response.getWriter();
    /*
    useCache = false;
    if (useCache) {
      BufferedReader fin = new BufferedReader(new FileReader(cachedFile));
      while (fin.ready()) {
        out.println(fin.readLine());
      }
      fin.close();
      out.close();
      return;
    }
*/
    StringWriter sw = new StringWriter();
    //FileWriter fout = new FileWriter(cachedFile);

    try {
      sw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");

      sw.write("<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n");
      sw.write("<trackList>");

      for (File file : mp3Files) {
        // only show live files
        if (!file.isLive()) {
          continue;
        }
        MP3File mp3 = new MP3File(file);

        sw.write("<track>\n");
        sw.write("<location>http://" + host.getHostname() + APILocator.getIdentifierAPI().find(folder).getPath() + file.getFileName()
            + "</location>\n");

        if (UtilMethods.isSet(mp3.getArtist())) {
          sw.write("<creator>" + XMLUtils.xmlEscape(mp3.getArtist()) + "</creator>\n");
        }
        if (UtilMethods.isSet(mp3.getAlbum())) {
          sw.write("<album>" + XMLUtils.xmlEscape(mp3.getAlbum()) + "</album>\n");
        }

        if (UtilMethods.isSet(mp3.getTitle())) {
          sw.write("<title>" + XMLUtils.xmlEscape(mp3.getTitle()) + "</title>\n");
        }
        if (UtilMethods.isSet(mp3.getGenre())) {
          sw.write("<genre>" + XMLUtils.xmlEscape(mp3.getGenre()) + "</genre>\n");
        }

        if (mp3.getDuration() > 0) {
          sw.write("<duration>" + mp3.getDuration() + "</duration>\n");
        }
        sw.write("<image>http://" + host.getHostname() + "/global/images/mp3logo.jpg</image>\n");

        sw.write("</track>\n");

      }

View Full Code Here

TOP

Related Classes of com.dotmarketing.beans.Host

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.