}
@Override
public Contentlet convertFatContentletToContentlet(com.dotmarketing.portlets.contentlet.business.Contentlet fatty)
throws DotDataException, DotStateException, DotSecurityException {
Contentlet con = new Contentlet();
con.setStructureInode(fatty.getStructureInode());
Map<String, Object> contentletMap = fatty.getMap();
try {
APILocator.getContentletAPI().copyProperties(con, contentletMap);
} catch (Exception e) {
Logger.error(this,"Unable to copy contentlet properties",e);
throw new DotDataException("Unable to copy contentlet properties",e);
}
con.setInode(fatty.getInode());
con.setStructureInode(fatty.getStructureInode());
con.setIdentifier(fatty.getIdentifier());
con.setSortOrder(fatty.getSortOrder());
con.setLanguageId(fatty.getLanguageId());
con.setNextReview(fatty.getNextReview());
con.setLastReview(fatty.getLastReview());
con.setOwner(fatty.getOwner());
con.setModUser(fatty.getModUser());
con.setModDate(fatty.getModDate());
con.setReviewInterval(fatty.getReviewInterval());
if(UtilMethods.isSet(fatty.getIdentifier())){
IdentifierAPI identifierAPI = APILocator.getIdentifierAPI();
Identifier identifier = identifierAPI.find(fatty.getIdentifier());
Folder folder = null;
if(identifier.getParentPath().length()>1){
folder = APILocator.getFolderAPI().findFolderByPath(identifier.getParentPath(), identifier.getHostId(), APILocator.getUserAPI().getSystemUser(),false);
}else{
folder = APILocator.getFolderAPI().findSystemFolder();
}
con.setHost(identifier.getHostId());
con.setFolder(folder.getInode());
// lets check if we have publish/expire fields to set
Structure st=con.getStructure();
if(UtilMethods.isSet(st.getPublishDateVar()))
con.setDateProperty(st.getPublishDateVar(), identifier.getSysPublishDate());
if(UtilMethods.isSet(st.getExpireDateVar()))
con.setDateProperty(st.getExpireDateVar(), identifier.getSysExpireDate());
}
else{
con.setHost(APILocator.getHostAPI().findSystemHost().getIdentifier());
con.setFolder(APILocator.getFolderAPI().findSystemFolder().getInode());
}
String wysiwyg = fatty.getDisabledWysiwyg();
if( UtilMethods.isSet(wysiwyg) ) {
List<String> wysiwygFields = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(wysiwyg,",");
while( st.hasMoreTokens() ) wysiwygFields.add(st.nextToken().trim());
con.setDisabledWysiwyg(wysiwygFields);
}
return con;
}