Search in sources :

Example 11 with MarshalException

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;
}
Also used : MarshalException(org.exolab.castor.xml.MarshalException) ValidationException(org.exolab.castor.xml.ValidationException) StringReader(java.io.StringReader) StringReader(java.io.StringReader) Reader(java.io.Reader) IOException(java.io.IOException) ComponentHelperInfo(alma.acs.tools.comphelpergen.generated.ComponentHelperInfo)

Example 12 with MarshalException

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());
    }
}
Also used : Marshaller(org.exolab.castor.xml.Marshaller) MarshalException(org.exolab.castor.xml.MarshalException) ValidationException(org.exolab.castor.xml.ValidationException) XMLContext(org.exolab.castor.xml.XMLContext) FileNotFoundException(java.io.FileNotFoundException) Mapping(org.exolab.castor.mapping.Mapping) IOException(java.io.IOException) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) MappingException(org.exolab.castor.mapping.MappingException) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException) ValidationException(org.exolab.castor.xml.ValidationException) MarshalException(org.exolab.castor.xml.MarshalException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) MappingException(org.exolab.castor.mapping.MappingException)

Example 13 with MarshalException

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);
}
Also used : Marshaller(org.exolab.castor.xml.Marshaller) MarshalException(org.exolab.castor.xml.MarshalException) ValidationException(org.exolab.castor.xml.ValidationException) IOException(java.io.IOException) LaserObjectNotFoundException(cern.laser.business.LaserObjectNotFoundException) PatternSyntaxException(java.util.regex.PatternSyntaxException) ValidationException(org.exolab.castor.xml.ValidationException) MarshalException(org.exolab.castor.xml.MarshalException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) CDBRecordDoesNotExistEx(alma.cdbErrType.CDBRecordDoesNotExistEx) StringWriter(java.io.StringWriter) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Vector(java.util.Vector)

Example 14 with MarshalException

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);
}
Also used : Marshaller(org.exolab.castor.xml.Marshaller) MarshalException(org.exolab.castor.xml.MarshalException) ValidationException(org.exolab.castor.xml.ValidationException) StringWriter(java.io.StringWriter) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) IOException(java.io.IOException) Vector(java.util.Vector) LaserObjectNotFoundException(cern.laser.business.LaserObjectNotFoundException) PatternSyntaxException(java.util.regex.PatternSyntaxException) ValidationException(org.exolab.castor.xml.ValidationException) MarshalException(org.exolab.castor.xml.MarshalException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 15 with MarshalException

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;
}
Also used : ConfigurationProperty(alma.alarmsystem.alarmmessage.generated.ConfigurationProperty) MarshalException(org.exolab.castor.xml.MarshalException) ValidationException(org.exolab.castor.xml.ValidationException) AlarmSystemConfiguration(alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration) StringReader(java.io.StringReader) Unmarshaller(org.exolab.castor.xml.Unmarshaller) IOException(java.io.IOException) ValidationException(org.exolab.castor.xml.ValidationException) MarshalException(org.exolab.castor.xml.MarshalException) CDBRecordDoesNotExistEx(alma.cdbErrType.CDBRecordDoesNotExistEx)

Aggregations

MarshalException (org.exolab.castor.xml.MarshalException)17 ValidationException (org.exolab.castor.xml.ValidationException)16 IOException (java.io.IOException)15 StringWriter (java.io.StringWriter)7 Marshaller (org.exolab.castor.xml.Marshaller)7 LaserObjectNotFoundException (cern.laser.business.LaserObjectNotFoundException)6 StringReader (java.io.StringReader)6 Unmarshaller (org.exolab.castor.xml.Unmarshaller)6 CDBRecordDoesNotExistEx (alma.cdbErrType.CDBRecordDoesNotExistEx)5 FileNotFoundException (java.io.FileNotFoundException)4 MalformedURLException (java.net.MalformedURLException)4 PatternSyntaxException (java.util.regex.PatternSyntaxException)4 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)3 Mapping (org.exolab.castor.mapping.Mapping)3 MappingException (org.exolab.castor.mapping.MappingException)3 XMLContext (org.exolab.castor.xml.XMLContext)3 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)2 Vector (java.util.Vector)2 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)2