org.exolab.castor.xml.ValidationException Java Examples

The following examples show how to use org.exolab.castor.xml.ValidationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CastorMarshaller.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Convert the given {@code XMLException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
 * unmarshalling, since Castor itself does not make this distinction in its exception hierarchy.
 * @param ex the Castor {@code XMLException} that occurred
 * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
 * or unmarshalling ({@code false})
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertCastorException(XMLException ex, boolean marshalling) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("Castor validation exception", ex);
	}
	else if (ex instanceof MarshalException) {
		if (marshalling) {
			return new MarshallingFailureException("Castor marshalling exception", ex);
		}
		else {
			return new UnmarshallingFailureException("Castor unmarshalling exception", ex);
		}
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown Castor exception", ex);
	}
}
 
Example #2
Source File: UncertaintyReader.java    From OpenDA with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static Object unMarshallString(Reader reader, Class objectClass) throws IOException {
    Unmarshaller unmarshaller = new Unmarshaller(objectClass);
    Object castor;
    try {
        InputSource is = new InputSource(reader);
        is.setSystemId("stringBuffer");
        castor = unmarshaller.unmarshal(is);
        reader.close();
    } catch (MarshalException marshalException) {
        //TODO Juzer throw proper exception so that calling function can handle it
        throw new IOException(marshalException.getMessage());
    } catch (ValidationException validationException) {
        throw new IOException(validationException.getMessage());
    }
    return castor;
}
 
Example #3
Source File: CastorMarshaller.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the given {@code XMLException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
 * unmarshalling, since Castor itself does not make this distinction in its exception hierarchy.
 * @param ex Castor {@code XMLException} that occurred
 * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
 * or unmarshalling ({@code false})
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertCastorException(XMLException ex, boolean marshalling) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("Castor validation exception", ex);
	}
	else if (ex instanceof MarshalException) {
		if (marshalling) {
			return new MarshallingFailureException("Castor marshalling exception", ex);
		}
		else {
			return new UnmarshallingFailureException("Castor unmarshalling exception", ex);
		}
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown Castor exception", ex);
	}
}
 
Example #4
Source File: QueryEntitlementHandler.java    From ralasafe with MIT License 6 votes vote down vote up
public String[] getTestContextFields() throws MarshalException, ValidationException {
	Set fields=new HashSet();
	
	for( Iterator iter=queryEntitlements.iterator(); iter.hasNext(); ) {
		QueryEntitlement entitle=(QueryEntitlement) iter.next();
		Query query=entitle.getQuery();
		
		org.ralasafe.db.sql.Query sqlQuery=query.getSqlQuery();
		Util.extractContextValueFields( sqlQuery, fields );
		
		String xmlContent=entitle.getUserCategory().getXmlContent();
		UserCategoryType unmarshal;
		unmarshal=UserCategory.unmarshal( new StringReader( xmlContent ) );
			
		DefineVariable[] variables=unmarshal.getDefineVariable();
		Util.extractContextValueFields( variables, queryManager, fields );
	}
	
	return (String[]) fields.toArray( new String[0] );
}
 
Example #5
Source File: DecisionEntitlementHandler.java    From ralasafe with MIT License 6 votes vote down vote up
public String[] getTestBusinessDataFieldTypes() throws MarshalException, ValidationException {
	String[] fields=getTestBusinessDataFields();
	String[] types=new String[fields.length];
	
	if( !StringUtil.isEmpty( businessDataClass ) ) {
		String[][] reflectJavaBean=Util.reflectJavaBean( businessDataClass );
		
		for( int i=0; i<fields.length; i++ ) {
			String field=fields[i];
			
			for( int j=0; j<reflectJavaBean.length; j++ ) {
				String[] strings=reflectJavaBean[j];
				
				if( strings[0].equals( field ) ) {
					types[i]=strings[1];
					j=reflectJavaBean.length;
				}
			}
		}
	}
	
	return types;
}
 
Example #6
Source File: UncertaintyWriter.java    From OpenDA with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void write() throws IOException, ValidationException, MarshalException {

        String rootElement = "uncertainties" ;
        Marshaller marshaller = new Marshaller(writer);
        marshaller.setRootElement(rootElement);

        //if (variables != null && variables.containsKey("UA_SCHEMALOCATION"))
        //    marshaller.setSchemaLocation("http://www.wldelft.nl " + variables.getValue("UA_SCHEMALOCATION") + rootElement + ".xsd");
        //else
            marshaller.setSchemaLocation("http://www.wldelft.nl http://datools.wldelft.nl/schemas/v1.3/" + rootElement + ".xsd");

        marshaller.marshal(this.uncertaintiesComplexType);
    }
 
Example #7
Source File: DecisionEntitlementHandler.java    From ralasafe with MIT License 5 votes vote down vote up
public String[] getTestBusinessDataFields() throws MarshalException, ValidationException {
	Set fields=new HashSet();
	
	for( Iterator iter=decisionEntitlements.iterator(); iter.hasNext(); ) {
		DecisionEntitlement entitle=(DecisionEntitlement) iter.next();
		
		String xmlContent=entitle.getBusinessData().getXmlContent();
		BusinessDataType bdt=BusinessDataType.unmarshal( new StringReader( xmlContent ) );
		DefineVariable[] defineVariables=bdt.getDefineVariable();
		Util.extractBusinessDataFields( defineVariables, fields );
	}
	
	return (String[]) fields.toArray( new String[0] );
}