Package com.dotmarketing.portlets.htmlpages.model

Examples of com.dotmarketing.portlets.htmlpages.model.HTMLPage


            }
        }

        // or Detail page with id=uuid
        else{
            HTMLPage p = APILocator.getHTMLPageAPI().loadLivePageById(structure.getDetailPage(), user, respectFrontendRoles);
          if(p != null && UtilMethods.isSet(p.getIdentifier())){
            result = p.getURI() + "?id=" + contentlet.getInode();
          }
        }

        // we send the host of the content, not the detail page (is this right?)
        if ((host != null) && !host.isSystemHost() && ! respectFrontendRoles && result !=null) {
View Full Code Here


        }
        else {
          // Map with all identifier inodes for a given uri.
          Identifier idInode = APILocator.getIdentifierAPI().find( host,url_page);
          HTMLPage livePage = (HTMLPage) APILocator.getVersionableAPI().findLiveVersion(idInode, APILocator.getUserAPI().getSystemUser(), false);
          hm.put("page_title", livePage.getTitle());
        }

        hm.put("page_url", UtilMethods.isSet(url_params)?url_page + "?" + url_params:url_page);

        if (FavoritesWebAPI.isUrlFavorite(url_page, url_params, user_id)) {
View Full Code Here

          childCampaign.setIsRecurrent(false);
          childCampaign.setLocked(true);
          HibernateUtil.saveOrUpdate(childCampaign);

          MailingList ml = (MailingList) InodeFactory.getChildOfClass(c, MailingList.class);
          HTMLPage page = (HTMLPage) InodeFactory.getChildOfClass(c, HTMLPage.class);
          Communication comm = (Communication) InodeFactory.getChildOfClass(c, Communication.class);
          UserFilter userfilter = (UserFilter) InodeFactory.getChildOfClass(c, UserFilter.class);

          if(InodeUtils.isSet(ml.getInode())){
            relationshipAPI.addRelationship(childCampaign.getInode(), ml.getInode(), "child");
          }
          if(InodeUtils.isSet(page.getInode())){
            relationshipAPI.addRelationship(childCampaign.getInode(), page.getInode(), "child");
          }
          if (InodeUtils.isSet(comm.getInode())) {
            relationshipAPI.addRelationship(childCampaign.getInode(), comm.getInode(), "child");
          }
          if (InodeUtils.isSet(userfilter.getInode())) {
            relationshipAPI.addRelationship(childCampaign.getInode(), userfilter.getInode(), "child");
          }
          HibernateUtil.saveOrUpdate(childCampaign);


          campaigns.add(childCampaign);



          c.setLocked(false);
        }
        catch (Exception ex) {
          Logger.debug(this, ex.getMessage());
        }
      }
    }
    else {
      //get a list of waiting queues
      campaigns = CampaignFactory.getWaitingCampaigns();
    }

    StringBuffer message = null;

    if (campaigns.size() == 0)
    {
      campaigns = null;
      return;
    }

    try {

      Logger.debug(DeliverCampaignThread.class, "GOING to deliver campaigns");
      Iterator<Campaign> campIter = campaigns.iterator();
     
      //### LOOP THE CAMPAIGNS ###
      while (campIter.hasNext())
      {
        //Obtain the campaign
        Campaign c = (Campaign) campIter.next();
        Communication comm = (Communication) InodeFactory.getChildOfClass(c, Communication.class);
       
        if ((comm == null) || (!InodeUtils.isSet(comm.getInode()))) {
          Logger.info(DeliverCampaignThread.class, "I didn't find a communication for campaign inode=" + c.getInode());
         
          c.setCompletedDate(new java.util.Date());
          c.setLocked(false);
          message = null;
          HibernateUtil.saveOrUpdate(c);
         
          continue;
        }

        Logger.debug(DeliverCampaignThread.class, "got campaign:" + c.getTitle());
        //Mailing list
        String campaingSendTo = c.getSendTo();

        MailingList ml = null;
        UserFilter uf = null;
        List<UserProxy> subscribers =  null;
        if ((campaingSendTo != null) && campaingSendTo.equalsIgnoreCase("mailingList")) {
          ml = (MailingList) InodeFactory.getChildOfClass(c,MailingList.class);
          if (!InodeUtils.isSet(ml.getInode()))
          {
            Logger.info(DeliverCampaignThread.class, "I didn't find a mailing list for campaign inode=" + c.getInode());
           
            c.setCompletedDate(new java.util.Date());
            c.setLocked(false);
            message = null;
            HibernateUtil.saveOrUpdate(c);
           
            continue;
          }
          else
          {
            Logger.debug(DeliverCampaignThread.class, "got mailingList:" + ml.getTitle());
            //Get the subscribers
            subscribers = MailingListFactory.getMailingListSubscribers(ml);
            Logger.debug(DeliverCampaignThread.class, "Got subscribers:" + subscribers.size());
          }
        }
        else if ((campaingSendTo != null) && campaingSendTo.equalsIgnoreCase("userFilter")) {
          uf = (UserFilter) InodeFactory.getChildOfClass(c,UserFilter.class);
          if (!InodeUtils.isSet(uf.getInode()))
          {
            Logger.info(DeliverCampaignThread.class, "I didn't find an user filter for campaign inode=" + c.getInode());
           
            c.setCompletedDate(new java.util.Date());
            c.setLocked(false);
            message = null;
            HibernateUtil.saveOrUpdate(c);
           
            continue;
          }
          else
          {
            Logger.debug(DeliverCampaignThread.class, "got user filter:" + uf.getUserFilterTitle());
            //Get the subscribers
            try {
              subscribers = UserFilterFactory.getUserProxiesFromFilter(uf);
            }
            catch (Exception e) {
              Logger.info(DeliverCampaignThread.class, "Error getting subscriber from user filter for campaign inode=" + c.getInode());
             
              c.setCompletedDate(new java.util.Date());
              c.setLocked(false);
              message = null;
              HibernateUtil.saveOrUpdate(c);
             
              continue;
            }
            Logger.debug(DeliverCampaignThread.class, "Got subscribers:" + subscribers.size());
          }
        }

        //Unsubscriber mailing list
        MailingList unSubscribers = MailingListFactory.getUnsubscribersMailingList();

        //do we have an html page?
        String alternateTextMessage = null;
        HTMLPageAPI pageAPI = APILocator.getHTMLPageAPI();
        HTMLPage htmlPage = (HTMLPage) pageAPI.loadWorkingPageById(comm.getHtmlPage(), APILocator.getUserAPI().getSystemUser(), false);
        String serverName;
        if (htmlPage != null && UtilMethods.isSet(htmlPage.getTitle())) {
          html = true;
          Logger.debug(DeliverCampaignThread.class, "Got htmlPage:"+ htmlPage.getTitle());

          // get the newsletter and the attachments
          Identifier id = APILocator.getIdentifierAPI().find(htmlPage);

          serverName = APILocator.getHostAPI().find(id.getHostId(), APILocator.getUserAPI().getSystemUser(), false).getHostname();

          //rewrite the urls
          try {
            Logger.debug(DeliverCampaignThread.class, "Retrieving page from url " + "http://"+ serverName + UtilMethods.encodeURIComponent(id.getURI()));
            message = new StringBuffer(UtilMethods.escapeUnicodeCharsForHTML(UtilMethods.getURL("http://"+ serverName + UtilMethods.encodeURIComponent(id.getURI())).toString()));
            Logger.debug(DeliverCampaignThread.class, "Page retrieved " + message);
            message = EmailFactory.alterBodyHTML(message, serverName);
            Logger.debug(DeliverCampaignThread.class, "Page altered " + message);
            alternateTextMessage = "If you are having trouble reading this message, click here: "+ "http://"+ serverName + UtilMethods.encodeURIComponent(id.getURI());
          }catch(Exception e){
            /**
             * This condition was included to avoid send 
             * campaigns without content
             * */
           
            Logger.info(DeliverCampaignThread.class, "Error generating message for campaign inode=" + c.getInode() + " and htmlPage inode=" + htmlPage.getInode());
           
            c.setCompletedDate(new java.util.Date());
            c.setLocked(false);
            message = null;
            HibernateUtil.saveOrUpdate(c);
View Full Code Here

      session.setAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION, "true");
      session.setAttribute(com.dotmarketing.util.WebKeys.PREVIEW_MODE_SESSION, null);
      session.setAttribute(com.dotmarketing.util.WebKeys.ADMIN_MODE_SESSION, "true");

      HTMLPage htmlPage = _previewHTMLPages(req, user);

      ActivityLogger.logInfo(this.getClass(), "save HTMLpage action", "User " + user.getPrimaryKey() + " save page " + htmlPage.getTitle(), HostUtil.hostNameUtil(req, _getUser(req)));

      String previewPage = (String) req.getAttribute(WebKeys.HTMLPAGE_PREVIEW_PAGE);

      if ((previewPage != null) && (previewPage.length() != 0)) {
        _sendToReferral(req, res, previewPage);
View Full Code Here

  }

  private HTMLPage _previewHTMLPages(ActionRequest req, User user) throws Exception {

    // gets html page being previewed
    HTMLPage htmlPage = (HTMLPage) req.getAttribute(WebKeys.HTMLPAGE_EDIT);

    String language = req.getParameter("language");
    if (!UtilMethods.isSet(language)) {
      language = req.getParameter(com.dotmarketing.util.WebKeys.HTMLPAGE_LANGUAGE);
    }
View Full Code Here

    java.util.List relatedAssets = new java.util.ArrayList();
    java.util.List relatedWorkflows = new java.util.ArrayList();

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

      HTMLPage htmlPage = (HTMLPage) InodeFactory.getInode(publishInode[i], HTMLPage.class);

      if (InodeUtils.isSet(htmlPage.getInode())) {
        // calls the asset factory edit

        // relatedWorkflows.addAll(WorkflowMessageFactory.getWorkflowMessageByHTMLPageWaitingForPublish(htmlPage));
        relatedAssets = PublishFactory.getUnpublishedRelatedAssets(htmlPage, relatedAssets, true, user, false);
View Full Code Here

      return;

    ActionRequestImpl reqImpl = (ActionRequestImpl) req;

    for (int i = 0; i < publishInode.length; i++) {
      HTMLPage htmlpage = (HTMLPage) InodeFactory.getInode(publishInode[i], HTMLPage.class);

      if (InodeUtils.isSet(htmlpage.getInode())) {
        // calls the asset factory edit
        try {
          PublishFactory.publishAsset(htmlpage, reqImpl.getHttpServletRequest());
          ActivityLogger.logInfo(PublishFactory.class, "Publishing HTMLpage action", "User " + user + " publishing page " + htmlpage.getTitle(), HostUtil.hostNameUtil(req, _getUser(req)));
          SessionMessages.add(reqImpl.getHttpServletRequest(), "message", "message.htmlpage_list.published");
        } catch (WebAssetException wax) {
          Logger.error(this, wax.getMessage(), wax);
          SessionMessages.add(reqImpl.getHttpServletRequest(), "error", "message.webasset.published.failed");
        }
View Full Code Here

        String page = url.substring(url.lastIndexOf("/") + 1, url.length());
        String pageName = page.replaceAll("." + Config.getStringProperty("VELOCITY_PAGE_EXTENSION"), "");

        String friendlyName = (UtilMethods.isSet(req.getParameter("friendlyName"))) ? req.getParameter("friendlyName") : pageName;

        HTMLPage htmlpage = new HTMLPage();
        htmlpage.setParent(folder.getInode());
        htmlpage.setPageUrl(url);
        htmlpage.setTitle(pageName);
        htmlpage.setFriendlyName(friendlyName);

        req.setAttribute(WebKeys.HTMLPAGE_EDIT, htmlpage);

        HTMLPageForm htmlForm = new HTMLPageForm();
        htmlForm.setParent(folder.getInode());
        htmlForm.setSelectedparent(folder.getName());
        htmlForm.setSelectedparentPath(APILocator.getIdentifierAPI().find(folder).getPath());
        htmlForm.setPageUrl(pageName);
        htmlForm.setTitle(pageName);
        htmlForm.setFriendlyName(friendlyName);

        BeanUtils.copyProperties(form, htmlpage);
        BeanUtils.copyProperties(form, htmlForm);

      } catch (Exception ae) {
        if ((referer != null) && (referer.length() != 0)) {
          if (ae.getMessage().equals(WebKeys.EDIT_ASSET_EXCEPTION)) {

            // The web asset edit threw an exception because it's
            // locked so it should redirect back with message
            java.util.Map<String, String[]> params = new java.util.HashMap<String, String[]>();
            params.put("struts_action", new String[] { "/ext/director/direct" });
            params.put("cmd", new String[] { "editHTMLPage" });
            params.put("htmlPage", new String[] { req.getParameter("inode") });
            params.put("referer", new String[] { URLEncoder.encode(referer, "UTF-8") });

            String directorURL = com.dotmarketing.util.PortletURLUtil.getActionURL(httpReq, WindowState.MAXIMIZED.toString(), params);

            _sendToReferral(req, res, directorURL);
            return;
          }
        }
        _handleException(ae, req);
        return;
      }
    }

    /*
     * If we are updating the html page, copy the information from the
     * struts bean to the hbm inode and run the update action and return to
     * the list
     */
    if ((cmd != null) && cmd.equals(Constants.ADD)) {
      try {

        if (Validator.validate(req, form, mapping)) {

          Logger.debug(this, "Calling Save Method");

          _saveWebAsset(req, res, config, form, user);
          String subcmd = req.getParameter("subcmd");

          if ((subcmd != null) && subcmd.equals(com.dotmarketing.util.Constants.PUBLISH)) {
            Logger.debug(this, "Calling Publish Method");
            _publishWebAsset(req, res, config, form, user, WebKeys.HTMLPAGE_FORM_EDIT);
          }

          // Obtain the URL for the preview page
          // pasing null referer to force
          // http://jira.dotmarketing.net/browse/DOTCMS-5971
          referer = getPreviewPageURL(req, null);

          HTMLPage htmlpage = (HTMLPage) req.getAttribute(WebKeys.HTMLPAGE_EDIT);
          if (htmlpage.isLocked())
            APILocator.getVersionableAPI().setLocked(htmlpage, false, user);

          _sendToReferral(req, res, referer);
        }

View Full Code Here

  // /// ************** ALL METHODS HERE *************************** ////////

  protected String getPreviewPageURL(ActionRequest req, String referer) {
    // Obtain the URL for the preview page
    // Retreiving the current HTMLPage
    HTMLPage existingHTMLPage = (HTMLPage) req.getAttribute(WebKeys.HTMLPAGE_EDIT);
    if (!InodeUtils.isSet(existingHTMLPage.getInode()) || !UtilMethods.isSet(referer)) {
      existingHTMLPage = (HTMLPage) req.getAttribute(WebKeys.HTMLPAGE_FORM_EDIT);
      Host host;
      try {
        host = hostAPI.findParentHost(existingHTMLPage, APILocator.getUserAPI().getSystemUser(), false);
      } catch (DotDataException e) {
        Logger.error(EditHTMLPageAction.class, e.getMessage(), e);
        throw new DotRuntimeException(e.getMessage(), e);
      } catch (DotSecurityException e) {
        Logger.error(EditHTMLPageAction.class, e.getMessage(), e);
        throw new DotRuntimeException(e.getMessage(), e);
      }
      if (host == null) {
        Folder parentFolder = (Folder) req.getAttribute(WebKeys.PARENT_FOLDER);
        if (parentFolder != null && UtilMethods.isSet(parentFolder.getHostId())) {
          try {
            host = hostAPI.find(parentFolder.getHostId(), APILocator.getUserAPI().getSystemUser(), false);
          } catch (DotDataException e) {
            Logger.error(EditHTMLPageAction.class, e.getMessage(), e);
            throw new DotRuntimeException(e.getMessage(), e);
          } catch (DotSecurityException e) {
            Logger.error(EditHTMLPageAction.class, e.getMessage(), e);
            throw new DotRuntimeException(e.getMessage(), e);
          }
        }
      }
      if (host != null) {
        String host_id = host.getIdentifier();
        // go to preview mode for this page
        java.util.Map<String, String[]> params = new java.util.HashMap<String, String[]>();
        params.put("struts_action", new String[] { "/ext/htmlpages/preview_htmlpage" });
        params.put("inode", new String[] { existingHTMLPage.getInode() + "" });
        params.put("host_id", new String[] { host_id + "" });
        return com.dotmarketing.util.PortletURLUtil.getActionURL(req, WindowState.MAXIMIZED.toString(), params);
      }
    }
    return referer;
View Full Code Here

    HttpServletRequest httpReq = reqImpl.getHttpServletRequest();

    Logger.debug(this, "I'm moving the web page");

    // gets the current container being edited from the request object
    HTMLPage webAsset = (HTMLPage) req.getAttribute(WebKeys.HTMLPAGE_EDIT);

    String parentInode = req.getParameter("parent");

    if (parentInode != null && parentInode.length() != 0 && !parentInode.equals("0")) {
      // the new parent is being passed through the request
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.htmlpages.model.HTMLPage

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.