if (section == null || section.getClass() != Section.class) {
return section;
}
State state = State.getInstance(section);
Section newSection;
String orientation = (String) state.getValue("orientation");
boolean isHorizontal = "HORIZONTAL".equals(orientation);
if (isHorizontal || "VERTICAL".equals(orientation)) {
ContainerSection container = isHorizontal ?
new HorizontalContainerSection() :
new VerticalContainerSection();
String beginJsp = (String) state.getValue("beginJsp");
if (!ObjectUtils.isBlank(beginJsp)) {
container.setBeginEngine("JSP");
container.setBeginScript(beginJsp);
} else {
String beginText = (String) state.getValue("beginText");
if (!ObjectUtils.isBlank(beginText)) {
container.setBeginEngine("RawText");
container.setBeginScript(beginText);
}
}
String endJsp = (String) state.getValue("endJsp");
if (!ObjectUtils.isBlank(endJsp)) {
container.setEndEngine("JSP");
container.setEndScript(endJsp);
} else {
String endText = (String) state.getValue("endText");
if (!ObjectUtils.isBlank(endText)) {
container.setEndEngine("RawText");
container.setEndScript(endText);
}
}
List<Object> childReferences
= (List<Object>) state.getValue("children");
if (!ObjectUtils.isBlank(childReferences)) {
for (Object childReference : childReferences) {
Section child = convertLegacySection(
layout, resolveReference(Section.class,
childReference));
if (child != null) {
container.getChildren().add(child);
}
}
}
newSection = container;
} else {
Object object = resolveReference(
Object.class, state.getValue("record"));
ScriptSection scriptSection;
if ("PLACEHOLDER".equals(orientation)) {
scriptSection = new MainSection();
} else if (object == null) {
scriptSection = new ScriptSection();
} else {
ContentSection contentSection = new ContentSection();
contentSection.setContent(object);
scriptSection = contentSection;
}
String recordJsp = (String) state.getValue("recordJsp");
if (!ObjectUtils.isBlank(recordJsp)) {
scriptSection.setEngine("JSP");
scriptSection.setScript(recordJsp);
} else {
String recordText = (String) state.getValue("recordText");
if (!ObjectUtils.isBlank(recordText)) {
scriptSection.setEngine("RawText");
scriptSection.setScript(recordText);
}
}
newSection = scriptSection;
}
newSection.setName((String) state.getValue("name"));
return newSection;
}