use of org.exolab.castor.xml.ValidationException in project ACS by ACS-Community.
the class ACSAlarmDAOImpl method flushReductionRules.
public void flushReductionRules(alma.alarmsystem.alarmmessage.generated.ReductionDefinitions rds) {
if (conf == null || !conf.isWriteable())
throw new IllegalStateException("no writable configuration accessor");
if (rds == null)
throw new IllegalArgumentException("Null Reduction Definitions 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(rds);
} catch (MarshalException e) {
e.printStackTrace();
return;
} catch (ValidationException e) {
e.printStackTrace();
return;
}
try {
conf.deleteConfiguration(REDUCTION_DEFINITION_PATH);
conf.addConfiguration(REDUCTION_DEFINITION_PATH, FFWriter.toString().replaceFirst("xsi:type=\".*\"", ""));
//System.err.println(FFWriter.toString().replaceFirst("xsi:type=\".*\"", ""));
} catch (org.omg.CORBA.UNKNOWN e) {
try {
conf.addConfiguration(REDUCTION_DEFINITION_PATH, FFWriter.toString().replaceFirst("xsi:type=\".*\"", ""));
} catch (Exception e1) {
e1.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
throw new IllegalStateException("Reduction Rules already exists");
}
}
use of org.exolab.castor.xml.ValidationException in project ACS by ACS-Community.
the class AlarmManager method saveToCDB.
public void saveToCDB() {
Set<String> keyset = _objState.keySet();
String[] objs = new String[keyset.size()];
keyset.toArray(objs);
for (int i = 0; i < objs.length; i++) {
try {
ObjectState os = _objState.get(objs[i]);
FaultFamily ff = getFaultFamily(objs[i]);
if (ff != null)
ff.validate();
switch(os.getAction()) {
case //Error, no state assigned.
-1:
break;
case 0:
break;
case 1:
((ACSAlarmDAOImpl) _alarmDAO).addFaultFamily(ff);
break;
case 2:
((ACSAlarmDAOImpl) _alarmDAO).updateFaultFamily(ff);
break;
case 3:
ff = new FaultFamily();
ff.setName(objs[i]);
((ACSAlarmDAOImpl) _alarmDAO).removeFaultFamily(ff);
break;
default:
//Shouldn't happen.
break;
}
_objState.remove(objs[i]);
_objState.put(objs[i], new ObjectState(false));
} catch (ValidationException e) {
e.printStackTrace();
}
}
}
use of org.exolab.castor.xml.ValidationException in project ACS by ACS-Community.
the class ACSCategoryDAOImpl method flushCategories.
public void flushCategories(Categories cats) {
if (conf == null || !conf.isWriteable())
throw new IllegalStateException("no writable configuration accessor");
if (cats == null)
throw new IllegalArgumentException("Null Categories 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(cats);
} catch (MarshalException e) {
e.printStackTrace();
return;
} catch (ValidationException e) {
e.printStackTrace();
return;
}
try {
conf.deleteConfiguration(CATEGORY_DEFINITION_PATH);
conf.addConfiguration(CATEGORY_DEFINITION_PATH, FFWriter.toString().replaceFirst("xsi:type=\".*\"", ""));
} catch (org.omg.CORBA.UNKNOWN e) {
try {
conf.addConfiguration(CATEGORY_DEFINITION_PATH, FFWriter.toString().replaceFirst("xsi:type=\".*\"", ""));
} catch (Exception e1) {
e1.printStackTrace();
}
} catch (CDBXMLErrorEx e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
throw new IllegalStateException("Category already exists");
}
}
use of org.exolab.castor.xml.ValidationException in project OpenClinica by OpenClinica.
the class MetaDataReportBean method handleLoadCastor.
private String handleLoadCastor(RulesPostImportContainer rpic) {
try {
// Create Mapping
Mapping mapping = new Mapping();
mapping.loadMapping(getCoreResources().getURL("mappingMarshallerMetadata.xml"));
// Create XMLContext
XMLContext xmlContext = new XMLContext();
xmlContext.setProperty(XMLConfiguration.NAMESPACES, "true");
xmlContext.addMapping(mapping);
StringWriter writer = new StringWriter();
Marshaller marshaller = xmlContext.createMarshaller();
// marshaller.setNamespaceMapping("castor", "http://castor.org/sample/mapping/");
marshaller.setWriter(writer);
marshaller.marshal(rpic);
String result = writer.toString();
String newResult = result.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
return newResult;
} 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.ValidationException 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());
}
}
Aggregations