CmsClient client = new CmsClient(logonGuid);
Project project = client.getProject(sessionKey, projectGuid);
// collect all lv values for all lvs and restore lv afterwards
// remember current lv for later restore
LanguageVariant currentLv = project.getCurrentLanguageVariant();
LanguageVariantDependentValuesMatrix matrix = new LanguageVariantDependentValuesMatrix();
try {
for (int i = 0; i < languages.length; i++) {
// switch language variant
String language = languages[i];
LanguageVariant lv = project.setCurrentLanguageVariantByRfcLanguageId(language);
System.out.println(project.getCurrentLanguageVariant().getName());
// get page content elements in current lv
Page currentPg = project.getPageById("3466");
System.out.println("dbg " + lv.getName() + "=" + currentPg.getHeadline());
matrix.addProperty("headline", currentPg.getHeadline(), lv);
matrix.addProperty("changed by", currentPg.getLastChangedByUserName(), lv);
matrix.addProperty("changed on", currentPg.getLastChangedOnAsddMMyyyy(), lv);
matrix.addProperty("state", currentPg.getStateInfo(), lv);
List<ContentElement> contentElements = currentPg.getContentElements(false);
// // out values
// for (ContentElement contentElement : contentElements) {
// System.out.println("dbg " + contentElement.getTemplateElementName() + " " + contentElement.getValueAsString());
// }
matrix.add(contentElements, lv);
}
// out properties
String[] properties = { "headline", "changed by", "changed on", "state" };
for (int j = 0; j < properties.length; j++) {
String property = properties[j];
System.out.print(property + " ");
for (int i = 0; i < languages.length; i++) {
// switch language variant
String language = languages[i];
LanguageVariant languageVariant = project.getLanguageVariantByRfcLanguageId(language);
System.out.print(languageVariant.getRfcLanguageId() + "="
+ matrix.getPropertyValue(property, languageVariant) + " ");
}
System.out.println();
}
// out content element values per lv
List<TemplateElement> templateElements = matrix.getTemplateElements();
System.out.println(templateElements.size() + " content elements for page found");
// Set<LanguageVariant> languageVariants = matrix.getLanguageVariants();
LanguageVariant mainLv = project.getMainLanguageVariant();
for (TemplateElement templateElement : templateElements) {
System.out.print(templateElement.isLanguageVariantDependent() + " " + templateElement.getName() + " ");
for (int i = 0; i < languages.length; i++) {
// switch language variant
String language = languages[i];
LanguageVariant languageVariant = project.getLanguageVariantByRfcLanguageId(language);
ContentElement contentElement = matrix.getContentElement(templateElement, languageVariant);
String value = "n/a";
if (contentElement != null) {
value = contentElement.getValueAsString();
}
System.out.print("result " + languageVariant.getRfcLanguageId() + "=" + value + " ");
if (matrix.isTextValueDifferentFromMainLanguage(templateElement, mainLv, languageVariant)) {
System.out.println(" ==> value different");
}
}
System.out.println();