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()+"");