Package com.dotmarketing.portlets.languagesmanager.business

Examples of com.dotmarketing.portlets.languagesmanager.business.LanguageAPI


   * @param parametersOptions The macro form options parameters
   * @return Map<Relationship,List<Contentlet>>
   * @throws DotSecurityException
   **/
  private static Map<Relationship,List<Contentlet>> getRelationships(Structure structure, Contentlet contentlet, String parametersOptions,List<String> parametersName,List<String[]> values, User user) throws DotDataException, DotSecurityException{
    LanguageAPI lAPI = APILocator.getLanguageAPI();
    Map<Relationship, List<Contentlet>> contentRelationships = new HashMap<Relationship, List<Contentlet>>();
    if(contentlet == null)
      return contentRelationships;
    List<Relationship> rels = RelationshipFactory.getAllRelationshipsByStructure(contentlet.getStructure());
    for (Relationship rel : rels) {

      String[] opt = parametersOptions.split(";");
      for(String text: opt){
        if(text.indexOf(rel.getRelationTypeValue()) != -1){

          String[] identArray = text.substring(text.indexOf("=")+1).replaceAll("\\[", "").replaceAll("\\]", "").split(",");

          List<Contentlet> cons = conAPI.findContentletsByIdentifiers(identArray, true, lAPI.getDefaultLanguage().getId(), user, true);
          if(cons.size()>0){
            contentRelationships.put(rel, cons);
          }
        }
      }
      for(int i=0; i < parametersName.size(); i++){
        String fieldname = parametersName.get(i);
        String[] fieldValue = values.get(i);
        if(fieldname.indexOf(rel.getRelationTypeValue()) != -1){
          List<Contentlet> cons = conAPI.findContentletsByIdentifiers(fieldValue, true, lAPI.getDefaultLanguage().getId(), user, true);
          if(cons.size()>0){
            if(contentRelationships.containsKey(rel)){
              cons.addAll(contentRelationships.get(rel));
            }
            contentRelationships.put(rel, cons);
View Full Code Here


   * @param values The fields values
   * @return Contentlet
   * @throws DotDataException
   */
  private static Contentlet setAllFields(String structureName, List<String> parametersName, List<String[]> values) throws DotDataException{
    LanguageAPI lAPI = APILocator.getLanguageAPI();
    Structure st = StructureCache.getStructureByName(structureName);
    String contentletInode = null;
    long contentLanguageId = 1;
    Field fileField = new Field(),imageField=new Field(),binaryField=new Field();
    List<Field> fields = FieldsCache.getFieldsByStructureInode(st.getInode());
View Full Code Here

                //Identifier identifier = (Identifier) InodeFactory.getInode(x, Identifier.class);
              Identifier identifier = APILocator.getIdentifierAPI().find(x);
                Contentlet contentlet = null;
                if(CacheLocator.getVeloctyResourceCache().isMiss(arg0)){
                  if(LanguageWebAPI.canDefaultContentToDefaultLanguage()) {
                     LanguageAPI langAPI = APILocator.getLanguageAPI();
                     language = Long.toString(langAPI.getDefaultLanguage().getId());
                  } else {
                    throw new ResourceNotFoundException("Contentlet is a miss in the cache");
                  }
              }
               
                try {
                  contentlet = conAPI.findContentletByIdentifier(identifier.getInode(), !preview,new Long(language) , APILocator.getUserAPI().getSystemUser(), true);
                } catch (DotContentletStateException e) {
                    contentlet = null;
                }
               
                if(contentlet == null || !InodeUtils.isSet(contentlet.getInode()) || contentlet.isArchived()){
                   
                    LanguageAPI langAPI = APILocator.getLanguageAPI();
                    long lid = langAPI.getDefaultLanguage().getId();
                    if(lid!=Long.parseLong(language)) {
                        Contentlet cc = conAPI.findContentletByIdentifier(identifier.getInode(), !preview,lid , APILocator.getUserAPI().getSystemUser(), true);
                        if(cc!=null && UtilMethods.isSet(cc.getInode())
                                 && !cc.isArchived() && LanguageWebAPI.canApplyToAllLanguages(cc)) {
                            contentlet = cc;
View Full Code Here

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

        HostAPI hostAPI = APILocator.getHostAPI();
        LanguageAPI languageAPI = APILocator.getLanguageAPI();

        //Setting the test user
        user = APILocator.getUserAPI().getSystemUser();
        defaultHost = hostAPI.findDefaultHost( user, false );
        pageExt = Config.getStringProperty( "VELOCITY_PAGE_EXTENSION" );
        //Getting the default language
        defaultLanguage = languageAPI.getDefaultLanguage();

        /*
        ORIGINAL TEXT
        A stemmer for English, for example, should identify the string 'cats' (and possibly 'catlike', 'catty' etc.) as based on the root 'cat',
        and 'stemmer', 'stemming', 'stemmed' as based on 'stem'.
View Full Code Here

      Contentlet firstContentlet = conAPI.find(inode, currentUser, true);

      List<Map<String,String>> contentletList = new ArrayList<Map<String,String>>();

      LanguageAPI langAPI = APILocator.getLanguageAPI();
      ContentletAPI contentletAPI = APILocator.getContentletAPI();
      List<Language> langs = langAPI.getLanguages();
      Contentlet languageContentlet = null;

      String identifier = String.valueOf(firstContentlet.getIdentifier());

      Structure targetStructure = firstContentlet.getStructure();
      List<Field> targetFields = FieldsCache.getFieldsByStructureInode(targetStructure.getInode());

      boolean parent = false;
      try{
            parent = firstContentlet.getBoolProperty("dotCMSParentOnTree") ;
        }
        catch(Exception e){

        }

      for(Language lang : langs){

        Map<String, String> contentDetails = new HashMap<String, String>();
        try{
          languageContentlet = null;
          languageContentlet = contentletAPI.findContentletByIdentifier(firstContentlet.getIdentifier(), true, lang.getId(), currentUser, false);
        }catch (Exception e) {
          try{
          languageContentlet = contentletAPI.findContentletByIdentifier(firstContentlet.getIdentifier(), false, lang.getId(), currentUser, false);
          }catch (Exception e1) {  }
        }

        boolean hasListedFields = false;

        if((languageContentlet == null) || (!UtilMethods.isSet(languageContentlet.getInode()))){

          contentDetails.put( "langCode" , langAPI.getLanguageCodeAndCountry(lang.getId(),null));
          contentDetails.put("langName", lang.getLanguage());
          contentDetails.put("langId", lang.getId()+"");
            contentDetails.put("inode", "");
          contentDetails.put("parent", parent+"");
          contentDetails.put("working", "false");
          contentDetails.put("live", "false");
          contentDetails.put("deleted", "true");
          contentDetails.put("locked", "false");
          contentDetails.put("siblingInode", firstContentlet.getInode());

          for (Field f : targetFields) {
            if (f.isIndexed() || f.isListed()) {
              hasListedFields = true;
              String fieldName = f.getFieldName();
              String fieldValue = "";
              contentDetails.put(fieldName, fieldValue);
            }
          }
          if( !hasListedFields ) {
            contentDetails.put("identifier", identifier);
          }


        }else{

          contentDetails.put( "langCode" , langAPI.getLanguageCodeAndCountry(lang.getId(),null));
          contentDetails.put("langName", lang.getLanguage());
          contentDetails.put("langId", lang.getId()+"");
            contentDetails.put("inode", languageContentlet.getInode());
          contentDetails.put("parent", parent+"");
          contentDetails.put("working", languageContentlet.isWorking()+"");
View Full Code Here

  private void _loadProps(
    String name, String localeKey) {

    if(name.contains("cms_language")) {
      LanguageAPI langAPI = APILocator.getLanguageAPI();
      List<LanguageKey> keys;
      if(localeKey.split("_").length > 1) {
        keys = langAPI.getLanguageKeys(localeKey.split("_")[0], localeKey.split("_")[1]);
      } else {
        keys = langAPI.getLanguageKeys(localeKey.split("_")[0]);

      }

      if (keys.size() < 1) {
        return;
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.languagesmanager.business.LanguageAPI

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.