use of org.exolab.castor.xml.MarshalException in project ACS by ACS-Community.
the class CompHelperGenerator method getFilePar.
/**
* Method getFilePar. Gets information about COBs from xml input string.
* @param contents
* @return ComponentHelperInfo
*/
protected ComponentHelperInfo getFilePar(String contents) {
ComponentHelperInfo compHelpInfo = null;
if (m_verbose) {
System.out.println(contents);
}
Reader xmlReader = null;
try {
xmlReader = new StringReader(contents);
if (xmlReader != null) {
compHelpInfo = ComponentHelperInfo.unmarshalComponentHelperInfo(xmlReader);
}
} catch (ValidationException e) {
e.printStackTrace();
} catch (MarshalException e) {
e.printStackTrace();
} finally {
if (xmlReader != null)
try {
xmlReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return compHelpInfo;
}
use of org.exolab.castor.xml.MarshalException in project OpenClinica by OpenClinica.
the class DownloadRuleSetXmlServlet method handleLoadCastor.
private FileWriter handleLoadCastor(FileWriter writer, RulesPostImportContainer rpic) {
try {
// Create Mapping
Mapping mapping = new Mapping();
mapping.loadMapping(getCoreResources().getURL("mappingMarshaller.xml"));
// Create XMLContext
XMLContext xmlContext = new XMLContext();
xmlContext.addMapping(mapping);
Marshaller marshaller = xmlContext.createMarshaller();
marshaller.setWriter(writer);
marshaller.marshal(rpic);
return writer;
} catch (FileNotFoundException ex) {
throw new OpenClinicaSystemException(ex.getMessage(), ex.getCause());
} catch (IOException ex) {
throw new OpenClinicaSystemException(ex.getMessage(), ex.getCause());
} catch (MarshalException e) {
throw new OpenClinicaSystemException(e.getMessage(), e.getCause());
} catch (ValidationException e) {
throw new OpenClinicaSystemException(e.getMessage(), e.getCause());
} catch (MappingException e) {
throw new OpenClinicaSystemException(e.getMessage(), e.getCause());
} catch (Exception e) {
throw new OpenClinicaSystemException(e.getMessage(), e.getCause());
}
}
use of org.exolab.castor.xml.MarshalException in project ACS by ACS-Community.
the class ACSAlarmDAOImpl method updateFaultFamily.
public void updateFaultFamily(FaultFamily ff) {
if (conf == null || !conf.isWriteable())
throw new IllegalStateException("no writable configuration accessor");
if (ff == null)
throw new IllegalArgumentException("Null FaultFamily 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(ff);
} catch (MarshalException e) {
e.printStackTrace();
return;
} catch (ValidationException e) {
e.printStackTrace();
return;
}
String path = ALARM_DEFINITION_PATH + "/" + ff.getName();
try {
try {
conf.getConfiguration(path);
conf.deleteConfiguration(path);
} catch (CDBRecordDoesNotExistEx e) {
//Record does not exist, so we skip removing it.
throw new IllegalStateException("FaultFamily doesn't exist");
}
conf.addConfiguration(path, FFWriter.toString().replaceFirst("xsi:type=\".*\"", ""));
} catch (IllegalStateException e) {
throw e;
} catch (Exception e) {
e.printStackTrace();
return;
}
Vector<FaultFamily> ffs = new Vector<FaultFamily>();
ffs.add(ff);
removeAlarmsMap(ffs);
generateAlarmsMap(ffs);
}
use of org.exolab.castor.xml.MarshalException in project ACS by ACS-Community.
the class ACSAlarmDAOImpl method addFaultFamily.
public void addFaultFamily(FaultFamily ff) {
if (conf == null || !conf.isWriteable())
throw new IllegalStateException("no writable configuration accessor");
if (ff == null)
throw new IllegalArgumentException("Null FaultFamily 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(ff);
} catch (MarshalException e) {
e.printStackTrace();
return;
} catch (ValidationException e) {
e.printStackTrace();
return;
}
String path = ALARM_DEFINITION_PATH + "/" + ff.getName();
try {
conf.addConfiguration(path, FFWriter.toString().replaceFirst("xsi:type=\".*\"", ""));
} catch (Exception e) {
throw new IllegalStateException("FaultFamily already exists");
}
Vector<FaultFamily> ffs = new Vector<FaultFamily>();
ffs.add(ff);
generateAlarmsMap(ffs);
}
use of org.exolab.castor.xml.MarshalException in project ACS by ACS-Community.
the class ACSAlarmSystemDAOImpl method getConfiguration.
public AlarmSystemConfiguration getConfiguration() {
if (conf == null)
throw new IllegalStateException("null configuration accessor");
AlarmSystemConfiguration asc;
String xml;
try {
xml = conf.getConfiguration(ALARM_SYSTEM_CONFIGURATION_PATH);
} catch (CDBRecordDoesNotExistEx e) {
asc = new AlarmSystemConfiguration();
ConfigurationProperty cp = new ConfigurationProperty();
cp.setName("Implementation");
cp.setContent("ACS");
asc.addConfigurationProperty(cp);
return asc;
} catch (Exception e) {
e.printStackTrace();
return null;
}
StringReader FFReader = new StringReader(xml);
Unmarshaller FF_unmarshaller = new Unmarshaller(AlarmSystemConfiguration.class);
FF_unmarshaller.setValidation(false);
try {
asc = (AlarmSystemConfiguration) FF_unmarshaller.unmarshal(FFReader);
} catch (MarshalException e) {
e.printStackTrace();
return null;
} catch (ValidationException e) {
e.printStackTrace();
return null;
}
try {
asc.validate();
} catch (ValidationException e) {
e.printStackTrace();
}
return asc;
}
Aggregations