use of com.twinsoft.convertigo.engine.InvalidSourceException in project convertigo by convertigo.
the class UIComponent method preconfigure.
@Override
public void preconfigure(Element element) throws Exception {
super.preconfigure(element);
String version = element.getAttribute("version");
long priority = Long.valueOf(element.getAttribute("priority")).longValue();
// TODO: REMOVE BEFORE RELEASE !!!
boolean doMigration = false;
if (!doMigration) {
return;
}
if (VersionUtils.compare(version, "7.9.0") < 0) {
try {
NodeList properties = element.getElementsByTagName("property");
int len = properties.getLength();
Element propElement;
for (int i = 0; i < len; i++) {
propElement = (Element) properties.item(i);
if (propElement != null && propElement.getParentNode().equals(element)) {
String propertyName = propElement.getAttribute("name");
Element valueElement = (Element) XMLUtils.findChildNode(propElement, Node.ELEMENT_NODE);
if (valueElement != null) {
Document document = valueElement.getOwnerDocument();
Object content = XMLUtils.readObjectFromXml(valueElement);
// This is data of the peusdo-bean
if ("beanData".equals(propertyName) && content instanceof String) {
try {
boolean needChange = false;
List<String> logList = new ArrayList<String>();
IonBean ionBean = new IonBean((String) content);
List<IonProperty> propertyList = new ArrayList<IonProperty>();
propertyList.addAll(ionBean.getProperties().values());
// Walk through properties
for (IonProperty ionProperty : propertyList) {
String ionPropertyName = ionProperty.getName();
String modeUpperCase = ionProperty.getMode().toUpperCase();
if (Mode.SOURCE.equals(Mode.valueOf(modeUpperCase))) {
MobileSmartSourceType msst = ionProperty.getSmartType();
String smartValue = msst.getSmartValue();
if (smartValue != null && !smartValue.isEmpty()) {
try {
MobileSmartSource mss = MobileSmartSource.migrate(smartValue);
if (mss != null) {
boolean migrated = !smartValue.equals(mss.toJsonString());
if (migrated) {
msst.setSmartValue(mss.toJsonString());
ionBean.setPropertyValue(ionPropertyName, msst);
needChange = true;
logList.add("Done migration of \"" + ionPropertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + ")");
}
}
} catch (Exception e) {
if (e instanceof InvalidSourceException) {
Engine.logBeans.warn("Failed to migrate \"" + ionPropertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + "): " + e.getMessage());
} else {
Engine.logBeans.error("Failed to migrate \"" + ionPropertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + ")", e);
}
}
}
}
}
// Store new beandata property value
if (needChange) {
String beanData = ionBean.toBeanData();
Element newValueElement = (Element) XMLUtils.writeObjectToXml(document, beanData);
propElement.replaceChild(newValueElement, valueElement);
hasChanged = true;
logList.forEach(s -> Engine.logBeans.warn(s));
}
} catch (Exception e) {
Engine.logBeans.error("Failed to migrate \"" + propertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + ")", e);
}
} else // This is a MobileSmartSourceType property
if (content instanceof MobileSmartSourceType) {
MobileSmartSourceType msst = (MobileSmartSourceType) content;
// Property is in 'SRC' mode
if (Mode.SOURCE.equals(msst.getMode())) {
try {
String smartValue = msst.getSmartValue();
if (smartValue != null && !smartValue.isEmpty()) {
MobileSmartSource mss = MobileSmartSource.migrate(smartValue);
if (mss != null) {
boolean migrated = !smartValue.equals(mss.toJsonString());
if (migrated) {
msst.setSmartValue(mss.toJsonString());
// Store new property value
Element newValueElement = (Element) XMLUtils.writeObjectToXml(document, msst);
propElement.replaceChild(newValueElement, valueElement);
hasChanged = true;
Engine.logBeans.warn("Done migration of \"" + propertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + ")");
}
}
}
} catch (Exception e) {
if (e instanceof InvalidSourceException) {
Engine.logBeans.warn("Failed to migrate \"" + propertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + "): " + e.getMessage());
} else {
Engine.logBeans.error("Failed to migrate \"" + propertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + ")", e);
}
}
}
}
}
}
}
} catch (Exception e) {
throw new EngineException("Unable to preconfigure the mobile uicomponent \"" + getName() + "\".", e);
}
}
}
use of com.twinsoft.convertigo.engine.InvalidSourceException in project convertigo by convertigo.
the class UIComponent method preconfigure.
@Override
public void preconfigure(Element element) throws Exception {
super.preconfigure(element);
String version = element.getAttribute("version");
long priority = Long.valueOf(element.getAttribute("priority")).longValue();
// TODO: REMOVE BEFORE RELEASE !!!
boolean doMigration = false;
if (!doMigration) {
return;
}
if (VersionUtils.compare(version, "7.9.0") < 0) {
try {
NodeList properties = element.getElementsByTagName("property");
int len = properties.getLength();
Element propElement;
for (int i = 0; i < len; i++) {
propElement = (Element) properties.item(i);
if (propElement != null && propElement.getParentNode().equals(element)) {
String propertyName = propElement.getAttribute("name");
Element valueElement = (Element) XMLUtils.findChildNode(propElement, Node.ELEMENT_NODE);
if (valueElement != null) {
Document document = valueElement.getOwnerDocument();
Object content = XMLUtils.readObjectFromXml(valueElement);
// This is data of the peusdo-bean
if ("beanData".equals(propertyName) && content instanceof String) {
try {
boolean needChange = false;
List<String> logList = new ArrayList<String>();
IonBean ionBean = new IonBean((String) content);
List<IonProperty> propertyList = new ArrayList<IonProperty>();
propertyList.addAll(ionBean.getProperties().values());
// Walk through properties
for (IonProperty ionProperty : propertyList) {
String ionPropertyName = ionProperty.getName();
String modeUpperCase = ionProperty.getMode().toUpperCase();
if (Mode.SOURCE.equals(Mode.valueOf(modeUpperCase))) {
MobileSmartSourceType msst = ionProperty.getSmartType();
String smartValue = msst.getSmartValue();
if (smartValue != null && !smartValue.isEmpty()) {
try {
MobileSmartSource mss = MobileSmartSource.migrate(smartValue);
if (mss != null) {
boolean migrated = !smartValue.equals(mss.toJsonString());
if (migrated) {
msst.setSmartValue(mss.toJsonString());
ionBean.setPropertyValue(ionPropertyName, msst);
needChange = true;
logList.add("Done migration of \"" + ionPropertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + ")");
}
}
} catch (Exception e) {
if (e instanceof InvalidSourceException) {
Engine.logBeans.warn("Failed to migrate \"" + ionPropertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + "): " + e.getMessage());
} else {
Engine.logBeans.error("Failed to migrate \"" + ionPropertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + ")", e);
}
}
}
}
}
// Store new beandata property value
if (needChange) {
String beanData = ionBean.toBeanData();
Element newValueElement = (Element) XMLUtils.writeObjectToXml(document, beanData);
propElement.replaceChild(newValueElement, valueElement);
hasChanged = true;
logList.forEach(s -> Engine.logBeans.warn(s));
}
} catch (Exception e) {
Engine.logBeans.error("Failed to migrate \"" + propertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + ")", e);
}
} else // This is a MobileSmartSourceType property
if (content instanceof MobileSmartSourceType) {
MobileSmartSourceType msst = (MobileSmartSourceType) content;
// Property is in 'SRC' mode
if (Mode.SOURCE.equals(msst.getMode())) {
try {
String smartValue = msst.getSmartValue();
if (smartValue != null && !smartValue.isEmpty()) {
MobileSmartSource mss = MobileSmartSource.migrate(smartValue);
if (mss != null) {
boolean migrated = !smartValue.equals(mss.toJsonString());
if (migrated) {
msst.setSmartValue(mss.toJsonString());
// Store new property value
Element newValueElement = (Element) XMLUtils.writeObjectToXml(document, msst);
propElement.replaceChild(newValueElement, valueElement);
hasChanged = true;
Engine.logBeans.warn("Done migration of \"" + propertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + ")");
}
}
}
} catch (Exception e) {
if (e instanceof InvalidSourceException) {
Engine.logBeans.warn("Failed to migrate \"" + propertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + "): " + e.getMessage());
} else {
Engine.logBeans.error("Failed to migrate \"" + propertyName + "\" property for the object \"" + getName() + "\" (priority: " + priority + ")", e);
}
}
}
}
}
}
}
} catch (Exception e) {
throw new EngineException("Unable to preconfigure the mobile uicomponent \"" + getName() + "\".", e);
}
}
}
Aggregations