Package com.dotmarketing.portlets.contentlet.business

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


  /*
   * Use only in preview mode, this methods hits the db!!
   * http://jira.dotmarketing.net/browse/DOTCMS-2110
   */
  public String getContentInode(String parsePath) {
    ContentletAPI conAPI = APILocator.getContentletAPI();
    String id = "";
    if(parsePath.indexOf(Config.getStringProperty("VELOCITY_CONTENT_EXTENSION")) == -1 || parsePath.indexOf(Config.getStringProperty("VELOCITY_CONTENT_MAP_EXTENSION")) == -1){
      id = parsePath;
    }else{
      id = getContentIdentifier(parsePath);
    }
    Identifier iden = new Identifier();
    try {
      iden = APILocator.getIdentifierAPI().find(id);
    } catch (DotDataException e1) {
      Logger.error(WebAPI.class, e1.getMessage(), e1);
    }
    String idenInode = iden.getInode();
    Language language = langAPI.getDefaultLanguage();
    long languageId = language.getId();
    Contentlet cont = null;
    try{
      cont = conAPI.findContentletByIdentifier(idenInode, true, languageId, user, true);
    }catch(Exception e){
      Logger.debug(this, e.getMessage());
      return "0";
    }

View Full Code Here


  }
 
 
  public List<Contentlet> getComments(String inode, boolean descendingOrder){
    try{
      ContentletAPI conAPI = APILocator.getContentletAPI();
      Contentlet contentlet = new Contentlet();
      try{
        contentlet = conAPI.find(inode, APILocator.getUserAPI().getSystemUser(), true);
      }catch(DotDataException e){
        Logger.debug(this, "Unable to look up contentlet with inode " + inode, e);
      }
      validateComments(contentlet);
      if(!InodeUtils.isSet(contentlet.getInode())){
        return new ArrayList<Contentlet>();
      }
      List<Contentlet> comments = null;
      if(contentlet.getStructure().getVelocityVarName().equals(commentsVelocityStructureName)){
        comments = conAPI.search("+Comments-Comments-parent:" + contentlet.getIdentifier() + " +live:true +languageid:" + contentlet.getLanguageId() + " +deleted:false", 0, -1, "Comments.datePublished " + (descendingOrder ? "desc":"asc"), APILocator.getUserAPI().getSystemUser(), true);
      }else{
        comments = conAPI.search("+" + getRelationshipName(contentlet) + ":" + contentlet.getIdentifier() + " +live:true +languageid:" + contentlet.getLanguageId() + " +deleted:false", 0, -1, "Comments.datePublished " + (descendingOrder ? "desc":"asc"), APILocator.getUserAPI().getSystemUser(), true);
      }
//      int count = 0;
//      StringBuilder bob = new StringBuilder();
//      for (Contentlet c : comments) {
//        bob.append("Comments-Comments-child:" + c.getIdentifier() + " ");
View Full Code Here

    }
  }

  public void validateComments(String contentletInode) throws DotSecurityException, DotHibernateException {
    // Load the contentlet
    ContentletAPI conAPI = APILocator.getContentletAPI();
    Contentlet contentlet = new Contentlet();
    try{
      contentlet = conAPI.find(contentletInode, APILocator.getUserAPI().getSystemUser(), true);
    }catch(DotDataException e){
      Logger.debug(this, "validateComments for no inode : " + contentletInode);
    }
    validateComments(contentlet);
  }
View Full Code Here

  }
 
  public int getCommentsCount(String inode) {
    int commentNumber = 0;
    try{
        ContentletAPI conAPI = APILocator.getContentletAPI();
        Contentlet contentlet = new Contentlet();
      contentlet = conAPI.find(inode, APILocator.getUserAPI().getSystemUser(), respectFrontendRoles);

      Structure contentletStructure = StructureCache.getStructureByInode(contentlet.getStructureInode());

        Field field =  contentletStructure.getField("CommentsCount");
        if (!InodeUtils.isSet(field.getInode())){
View Full Code Here

    float average = 0F;

    List<Contentlet> hits = new ArrayList <Contentlet>();
    String query = "+type:content +deleted:false +(+languageId:1* +identifier:" + identifier + "* +live:true)";
    try {
      ContentletAPI conAPI = APILocator.getContentletAPI();

        hits = conAPI.search(query,  -1, 0, null, APILocator.getUserAPI().getSystemUser(), false);

      if (0 < hits.size()) {
        Contentlet cont = hits.get(0);
        String structInode = (String) cont.getMap().get("stInode");
        List<Field> fields = FieldsCache.getFieldsByStructureInode(structInode);
View Full Code Here

    List<Contentlet> hits = new ArrayList <Contentlet>();

    String query = "+type:content +deleted:false +(+languageId:1* +identifier:'" + identifier + "'* +live:true)";
    try {

      ContentletAPI conAPI = APILocator.getContentletAPI();

      hits = conAPI.search(query,  -1, 0, null, APILocator.getUserAPI().getSystemUser(), false);

      if (0 < hits.size()) {
        Contentlet cont  = hits.get(0);
        String structInode = (String) cont.getMap().get("stInode");

View Full Code Here

   * @return
   * @throws DotSecurityException
   * @throws DotDataException
   */
  public List<Contentlet> pullRelatedContent (String relationshipName, String contentletInode, int limit, String orderBy) {
    ContentletAPI conAPI = APILocator.getContentletAPI();

    Contentlet contentlet = null;
    try {
      contentlet = conAPI.find(contentletInode, APILocator.getUserAPI().getSystemUser(), true);
    } catch (DotSecurityException e) {
      Logger.info(this, "Unable to look up content because of a problem getting the system user");
    } catch (DotDataException de) {
      Logger.info(this, "Unable to retrieve content with inode = " + contentletInode);
    }
View Full Code Here

   * for the front end of the web site.  This is used by the
   * #pullPersonalizedContentByCategories macro.
   */
  @SuppressWarnings("rawtypes")
  public List pullPersonalizedContentByCategories(String query, String lim, String sortBy, List categoryList) throws DotSecurityException, DotDataException {
    ContentletAPI conAPI = APILocator.getContentletAPI();
    @SuppressWarnings("unchecked")
    List<HashMap> contents = pullContent(query, lim, sortBy);
    List<HashMap> returnList = new ArrayList<HashMap>();

    for(HashMap content: contents) {
      String inode = (String) content.get("inode");

      Contentlet contentlet = new Contentlet();
      try{
        contentlet = conAPI.find(inode, user, true);
      }catch (DotDataException ex){
        Logger.error(this, "Unable to find contentlet with inode " + inode);
      }

      List<Category> categoryContentlet = categoryAPI.getChildren(contentlet, user, true);
View Full Code Here

    while(runDate.getTime().before(assetsOlderThan) || runDate.getTime().equals(assetsOlderThan)){
      try  {     
        HibernateUtil.startTransaction();
        Logger.info(CMSMaintenanceFactory.class, "Starting deleteOldAssetVersions for date: "+ UtilMethods.dateToHTMLDate(runDate.getTime(),"yyyy-MM-dd"));
 
        ContentletAPI conAPI = APILocator.getContentletAPI();
 
        Logger.info(CMSMaintenanceFactory.class, "Removing Contentlets");
        auxCount = conAPI.deleteOldContent(runDate.getTime());
        counter  += auxCount;
        Logger.info(CMSMaintenanceFactory.class, "Removed "+ auxCount+ " Contentlets");
 
        Logger.info(CMSMaintenanceFactory.class, "Removing HTML Pages");
        auxCount = APILocator.getHTMLPageAPI().deleteOldVersions(runDate.getTime());
View Full Code Here

        //Adding hooks
        addPreHook( Class.forName( SamplePreContentHook.class.getName() ).newInstance() );
        addPostHook( Class.forName( SamplePostContentHook.class.getName() ).newInstance() );

        //Testing the hooks
        ContentletAPI conAPI = APILocator.getContentletAPI();

        Long count = conAPI.contentletCount();
        System.out.println( "+++++++++++++++++++++++++++++++++++++++++++++++" );
        System.out.println( "ContentletAPI.contentletCount() = " + count );
        System.out.println( "+++++++++++++++++++++++++++++++++++++++++++++++" );
    }
View Full Code Here

TOP

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

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.