Java Code Examples for javax.xml.datatype.DatatypeConfigurationException#getMessage()

The following examples show how to use javax.xml.datatype.DatatypeConfigurationException#getMessage() . 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: Converter.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Converts a list of calendar objects
 * 
 * @param calendar the list of gregorian calendars
 * 
 * @return list of XML gregorian calendars
 */
public static List<XMLGregorianCalendar> convertCalendar(List<GregorianCalendar> calendar) {
	if (calendar == null) {
		return null;
	}

	DatatypeFactory df;
	try {
		df = DatatypeFactory.newInstance();
	} catch (DatatypeConfigurationException e) {
		throw new CmisRuntimeException("Convert exception: " + e.getMessage(), e);
	}

	List<XMLGregorianCalendar> result = new ArrayList<XMLGregorianCalendar>();
	for (GregorianCalendar cal : calendar) {
		result.add(df.newXMLGregorianCalendar(cal));
	}

	return result;
}
 
Example 2
Source File: CalendarDuration1243Test.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * main method.
 *
 * @param args Standard args.
 */
public static void main(String[] args) {
    try {
        String dateTimeString = "2006-11-22T00:00:00.0+01:02";
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        XMLGregorianCalendar cal = dtf.newXMLGregorianCalendar( dateTimeString );
        System.out.println( "XMLGregCal:" + cal.toString() );
        System.out.println( "GregCal:" + cal.toGregorianCalendar() );
        String toGCal = cal.toGregorianCalendar().toString();
        if (toGCal.indexOf("GMT+12:00") > -1) {
            throw new RuntimeException("Expected GMT+01:02");
        }
    } catch (DatatypeConfigurationException ex) {
        throw new RuntimeException(ex.getMessage());
    }
}
 
Example 3
Source File: CalendarDuration1097Test.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * main method.
 *
 * @param args Standard args.
 */
public static void main(String[] args) {
    try {
        String dateTimeString = "0001-01-01T00:00:00.0000000-05:00";
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        XMLGregorianCalendar cal = dtf.newXMLGregorianCalendar( dateTimeString );
        System.out.println( "Expected: 0001-01-01T00:00:00.0000000-05:00");
        System.out.println( "Actual:" + cal.toString() );
        System.out.println( "toXMLFormat:" + cal.toXMLFormat() );
        String test = cal.toString();
        if (test.indexOf("E-7") > -1) {
            throw new RuntimeException("Expected: 0001-01-01T00:00:00.0000000-05:00");
        }
    } catch (DatatypeConfigurationException ex) {
        throw new RuntimeException(ex.getMessage());
    }
}
 
Example 4
Source File: Converter.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Converts a calendar object
 * 
 * @param calendar gregorian calendar
 * 
 * @return an XML gregorian calendar
 */
public static XMLGregorianCalendar convertCalendar(GregorianCalendar calendar) {
	if (calendar == null) {
		return null;
	}

	DatatypeFactory df;
	try {
		df = DatatypeFactory.newInstance();
	} catch (DatatypeConfigurationException e) {
		throw new CmisRuntimeException("Convert exception: " + e.getMessage(), e);
	}

	return df.newXMLGregorianCalendar(calendar);
}
 
Example 5
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private String convertAspectPropertyValue(Object value)
{
    if (value instanceof Date)
    {
        GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
        cal.setTime((Date) value);
        value = cal;
    }

    if (value instanceof GregorianCalendar)
    {
        DatatypeFactory df;
        try
        {
            df = DatatypeFactory.newInstance();
        }
        catch (DatatypeConfigurationException e)
        {
            throw new IllegalArgumentException("Aspect conversation exception: " + e.getMessage(), e);
        }
        return df.newXMLGregorianCalendar((GregorianCalendar) value).toXMLFormat();
    }

    // MNT-12496 MNT-15044
    // Filter for AtomPub and Web services bindings only. Browser/json binding already encodes.
    if (AlfrescoCmisServiceCall.get() != null &&
            (CallContext.BINDING_ATOMPUB.equals(AlfrescoCmisServiceCall.get().getBinding()) ||
             CallContext.BINDING_WEBSERVICES.equals(AlfrescoCmisServiceCall.get().getBinding())))
    {
    	return filterXmlRestrictedCharacters(value.toString());
    }
    else
    {
    	return value.toString();
    }
}
 
Example 6
Source File: ToXmlCompleteRevocRefsConverter.java    From xades4j with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void convertIntoObjectTree(
        PropertyDataObject propData,
        XmlUnsignedPropertiesType xmlProps,
        Document doc)
{
    CompleteRevocationRefsData complRevocRefsData = (CompleteRevocationRefsData)propData;

    // Only CRL refs are supported.
    XmlCRLRefsType xmlCRLRefs = new XmlCRLRefsType();
    List<XmlCRLRefType> xmlCRLRefsList = xmlCRLRefs.getCRLRef();
    try
    {
        for (CRLRef crlRef : complRevocRefsData.getCrlRefs())
        {
            XmlCRLIdentifierType xmlCrlId = new XmlCRLIdentifierType();
            xmlCrlId.setIssueTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(crlRef.issueTime));
            xmlCrlId.setIssuer(crlRef.issuerDN);
            xmlCrlId.setNumber(crlRef.serialNumber); // May be null.

            XmlDigestAlgAndValueType xmlDigest = new XmlDigestAlgAndValueType();
            XmlDigestMethodType xmlDigestMethod = new XmlDigestMethodType();
            xmlDigestMethod.setAlgorithm(crlRef.digestAlgUri);
            xmlDigest.setDigestValue(crlRef.digestValue);
            xmlDigest.setDigestMethod(xmlDigestMethod);

            XmlCRLRefType xmlCrlRef = new XmlCRLRefType();
            xmlCrlRef.setCRLIdentifier(xmlCrlId);
            xmlCrlRef.setDigestAlgAndValue(xmlDigest);

            xmlCRLRefsList.add(xmlCrlRef);
        }
    } catch (DatatypeConfigurationException ex)
    {
        throw new UnsupportedOperationException(ex.getMessage(), ex);
    }

    XmlCompleteRevocationRefsType xmlComplRevocRefs = new XmlCompleteRevocationRefsType();
    // Only CRL refs are supported.
    xmlComplRevocRefs.setCRLRefs(xmlCRLRefs);
    xmlProps.getUnsignedSignatureProperties().setCompleteRevocationRefs(xmlComplRevocRefs);
}