Search in sources :

Example 21 with Marshaller

use of org.exolab.castor.xml.Marshaller 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();
    }
}
Also used : Marshaller(org.exolab.castor.xml.Marshaller) MarshalException(org.exolab.castor.xml.MarshalException) ValidationException(org.exolab.castor.xml.ValidationException) StringWriter(java.io.StringWriter) IOException(java.io.IOException) IOException(java.io.IOException) ValidationException(org.exolab.castor.xml.ValidationException) MarshalException(org.exolab.castor.xml.MarshalException) CDBRecordDoesNotExistEx(alma.cdbErrType.CDBRecordDoesNotExistEx)

Example 22 with Marshaller

use of org.exolab.castor.xml.Marshaller in project ACS by ACS-Community.

the class XmlInOut method marshalObsProjectToFile.

public String marshalObsProjectToFile(ObsProject proj, String originalXmlFilename) throws MarshalException, ValidationException, IOException {
    String filename = getRemarshaledFilename(originalXmlFilename);
    File xmlFile = new File(module_dir, pathToXmlSamples + filename);
    Marshaller m = new Marshaller(new FileWriter(xmlFile));
    // m.setNamespaceMapping("tprj", "AlmaTest/ObsProject");
    m.marshal(proj);
    return filename;
}
Also used : Marshaller(org.exolab.castor.xml.Marshaller) FileWriter(java.io.FileWriter) File(java.io.File)

Example 23 with Marshaller

use of org.exolab.castor.xml.Marshaller in project camel by apache.

the class AbstractCastorDataFormat method createMarshaller.

public Marshaller createMarshaller(Exchange exchange) throws Exception {
    // need to create new marshaller as we may have concurrent processing
    Marshaller answer = xmlContext.createMarshaller();
    answer.setValidation(isValidation());
    return answer;
}
Also used : Marshaller(org.exolab.castor.xml.Marshaller)

Aggregations

Marshaller (org.exolab.castor.xml.Marshaller)23 StringWriter (java.io.StringWriter)13 IOException (java.io.IOException)10 MarshalException (org.exolab.castor.xml.MarshalException)7 ValidationException (org.exolab.castor.xml.ValidationException)7 Mapping (org.exolab.castor.mapping.Mapping)5 XMLContext (org.exolab.castor.xml.XMLContext)5 LaserObjectNotFoundException (cern.laser.business.LaserObjectNotFoundException)4 File (java.io.File)4 FileWriter (java.io.FileWriter)3 MalformedURLException (java.net.MalformedURLException)3 PatternSyntaxException (java.util.regex.PatternSyntaxException)3 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)2 CDBRecordDoesNotExistEx (alma.cdbErrType.CDBRecordDoesNotExistEx)2 BufferedWriter (java.io.BufferedWriter)2 FileNotFoundException (java.io.FileNotFoundException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 Vector (java.util.Vector)2