public ContentInfo formatContent(Content content) throws Exception {
EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
ContentInfo contentInfo = new ContentInfo();
ContentLanguage contentLanguageDefault = content.getContentLanguage();
contentInfo.setContentTitle(contentLanguageDefault.getContentTitle());
contentInfo.setContentShortDesc(contentLanguageDefault.getContentShortDesc());
contentInfo.setContentDesc(contentLanguageDefault.getContentDesc());
if (Format.isNullOrEmpty(contentLanguageDefault.getPageTitle())) {
contentInfo.setPageTitle(contentLanguageDefault.getContentTitle());
}
else {
contentInfo.setPageTitle(contentLanguageDefault.getPageTitle());
}
if (Format.isNullOrEmpty(contentLanguageDefault.getMetaKeywords())) {
contentInfo.setMetaKeywords(contentLanguageDefault.getContentTitle());
}
else {
contentInfo.setMetaKeywords(contentLanguageDefault.getMetaKeywords());
}
if (Format.isNullOrEmpty(contentLanguageDefault.getMetaDescription())) {
contentInfo.setMetaDescription(contentLanguageDefault.getContentTitle());
}
else {
contentInfo.setMetaDescription(contentLanguageDefault.getMetaDescription());
}
contentInfo.setContentDefaultImageUrl(null);
if (contentLanguageDefault.getImage() != null) {
String imageUrl = imageUrlPrefix +
"?type=C" +
"&imageId=" + contentLanguageDefault.getImage().getImageId();
contentInfo.setContentDefaultImageUrl(imageUrl);
}
Vector<String> contentImages = new Vector<String>();
Iterator<?> iterator = contentLanguageDefault.getImages().iterator();
while (iterator.hasNext()) {
ContentImage image = (ContentImage) iterator.next();
String imageUrl = imageUrlPrefix +
"?type=C" +
"&imageId=" + image.getImageId();
contentImages.add(imageUrl);
}
contentInfo.setContentImageUrls(contentImages);
if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
ContentLanguage contentLanguage = null;
for (ContentLanguage language : content.getContentLanguages()) {
if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfile.getSiteProfileClass().getSiteProfileClassId())) {
contentLanguage = language;
break;
}
}
if (contentLanguage != null) {
if (contentLanguage.getContentTitle() != null) {
contentInfo.setContentTitle(contentLanguage.getContentTitle());
}
if (contentLanguage.getContentShortDesc() != null) {
contentInfo.setContentShortDesc(contentLanguage.getContentShortDesc());
}
if (contentLanguage.getContentDesc() != null) {
contentInfo.setContentDesc(contentLanguage.getContentDesc());
}
if (Format.isNullOrEmpty(contentLanguageDefault.getPageTitle())) {
if (contentLanguage.getContentTitle() != null) {
contentInfo.setPageTitle(contentLanguage.getContentTitle());
}
}
else {
if (contentLanguage.getPageTitle() != null) {
contentInfo.setPageTitle(contentLanguage.getPageTitle());
}
}
if (Format.isNullOrEmpty(contentLanguageDefault.getMetaKeywords())) {
if (contentLanguage.getContentTitle() != null) {
contentInfo.setMetaKeywords(contentLanguage.getContentTitle());
}
}
else {
if (contentLanguage.getMetaKeywords() != null) {
contentInfo.setMetaKeywords(contentLanguage.getMetaKeywords());
}
}
if (Format.isNullOrEmpty(contentLanguageDefault.getMetaDescription())) {
if (contentLanguage.getContentTitle() != null) {
contentInfo.setMetaDescription(contentLanguage.getContentTitle());
}
}
else {
if (contentLanguage.getMetaKeywords() != null) {
contentInfo.setMetaDescription(contentLanguage.getMetaDescription());
}
}
if (contentLanguage.getContentImageOverride().equals(String.valueOf(Constants.VALUE_YES))) {
if (contentLanguage.getContentImageOverride().equals(String.valueOf(Constants.VALUE_YES))) {
String url = null;
contentInfo.setContentDefaultImageUrl(null);
if (contentLanguage.getImage() != null) {
url = "?type=C&" +
"&imageId=" + contentLanguage.getImage().getImageId();
contentInfo.setContentDefaultImageUrl(imageUrlPrefix + url);
}
contentImages = new Vector<String>();
Iterator<?> images = contentLanguage.getImages().iterator();
while (images.hasNext()) {
ContentImage image = (ContentImage) images.next();
url = "?type=C" +
"&imageId=" + image.getImageId();
contentImages.add(imageUrlPrefix + url);