use of org.exolab.castor.xml.MarshalException in project ACS by ACS-Community.
the class ACSAlarmSystemDAOImpl method flushConfiguration.
public void flushConfiguration(AlarmSystemConfiguration asc) {
if (conf == null || !conf.isWriteable())
throw new IllegalStateException("no writable configuration accessor");
if (asc == null)
throw new IllegalArgumentException("Null Alarm System Configuration argument");
StringWriter FFWriter = new StringWriter();
Marshaller FF_marshaller;
try {
FF_marshaller = new Marshaller(FFWriter);
} catch (IOException e) {
e.printStackTrace();
return;
}
FF_marshaller.setValidation(false);
try {
FF_marshaller.marshal(asc);
} catch (MarshalException e) {
e.printStackTrace();
return;
} catch (ValidationException e) {
e.printStackTrace();
return;
}
try {
conf.deleteConfiguration(ALARM_SYSTEM_CONFIGURATION_PATH);
conf.addConfiguration(ALARM_SYSTEM_CONFIGURATION_PATH, FFWriter.toString().replaceFirst("xsi:type=\".*\"", ""));
} catch (CDBRecordDoesNotExistEx e) {
try {
conf.addConfiguration(ALARM_SYSTEM_CONFIGURATION_PATH, FFWriter.toString().replaceFirst("xsi:type=\".*\"", ""));
} catch (Exception e1) {
e1.printStackTrace();
}
} catch (org.omg.CORBA.UNKNOWN e) {
try {
conf.addConfiguration(ALARM_SYSTEM_CONFIGURATION_PATH, FFWriter.toString().replaceFirst("xsi:type=\".*\"", ""));
} catch (Exception e1) {
e1.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.exolab.castor.xml.MarshalException in project tdi-studio-se by Talend.
the class ELTMapSaveToEmfMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
ProcessType processType = getProcessType(item);
boolean modified = false;
if (processType != null) {
for (Object obj : processType.getNode()) {
NodeType nodeType = (NodeType) obj;
StringReader stringReader = null;
if (nodeType.getStringData() != null && !"".equals(nodeType.getStringData())) {
stringReader = new StringReader(nodeType.getStringData());
}
final String componentName = nodeType.getComponentName();
if (stringReader != null) {
if (componentName != null && componentName.startsWith("tELT") && componentName.endsWith("Map")) {
modified = true;
StringBuilder input = null;
Unmarshaller unmarshaller = new Unmarshaller(ExternalDbMapData.class);
unmarshaller.setWhitespacePreserve(true);
try {
BufferedReader r = new BufferedReader(stringReader);
input = new StringBuilder();
String line;
while ((line = r.readLine()) != null) {
input.append(line);
//$NON-NLS-0$
input.append("\r\n");
}
//$NON-NLS-0$ //$NON-NLS-1$
String buf = input.toString().replaceAll("<table-entries .*?>.*?</table-entries>", "");
stringReader.close();
stringReader = new StringReader(buf);
ExternalDbMapData externalData = (ExternalDbMapData) unmarshaller.unmarshal(stringReader);
DBMapData emfMapperData = DbmapFactory.eINSTANCE.createDBMapData();
DBMapHelper.saveDataToEmf(emfMapperData, externalData);
nodeType.setNodeData(emfMapperData);
nodeType.setStringData("");
} catch (MarshalException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
} catch (ValidationException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
} catch (IOException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
} finally {
if (stringReader != null) {
stringReader.close();
}
}
}
}
}
}
try {
if (modified) {
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} else {
return ExecutionResult.SUCCESS_NO_ALERT;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
Aggregations