Example usage for javax.xml.registry JAXRException JAXRException

List of usage examples for javax.xml.registry JAXRException JAXRException

Introduction

In this page you can find the example usage for javax.xml.registry JAXRException JAXRException.

Prototype

public JAXRException(Throwable cause) 

Source Link

Document

Constructs a JAXRException object initialized with the given Throwable object.

Usage

From source file:org.freebxml.omar.common.BindingUtility.java

/**
 * Get List of ObjectRefs for specified RegistryObjects
 *///from   www  .j  ava2 s  .co  m
public List getObjectRefsFromRegistryObjects(List objs) throws JAXRException {
    List refs = new ArrayList();

    try {
        if (objs.size() > 0) {
            Iterator iter = objs.iterator();

            while (iter.hasNext()) {
                IdentifiableType ro = (IdentifiableType) iter.next();
                ObjectRef ref = rimFac.createObjectRef();
                ref.setId(ro.getId());
                refs.add(ref);
            }
        }
    } catch (JAXBException e) {
        throw new JAXRException(e);
    }

    return refs;
}

From source file:org.freebxml.omar.common.BindingUtility.java

/**
* Get List of ObjectRefs for specified RegistryObjects
*//*from   ww w.ja v  a2  s. co  m*/
public List getObjectRefsFromRegistryObjectIds(List ids) throws JAXRException {
    List refs = new ArrayList();

    try {
        if (ids.size() > 0) {
            Iterator iter = ids.iterator();

            while (iter.hasNext()) {
                ObjectRef ref = rimFac.createObjectRef();
                ref.setId((String) iter.next());
                refs.add(ref);
            }
        }
    } catch (JAXBException e) {
        throw new JAXRException(e);
    }

    return refs;
}

From source file:org.freebxml.omar.common.BindingUtility.java

/**
 * Get List of Id of first-level RegistryObject or ObjectRef in a request. For
 * those kinds of request having RegistryObject and ObjectRef (e.g. SubmitObjectsRequest),
 * only the id of RegistryObject elements are returned.
 *///  w  w  w . j  a  v a2  s. com
public List getIdsFromRequest(Object registryRequest) throws JAXRException {
    List ids = new ArrayList();

    if (registryRequest instanceof AdhocQueryRequest) {
    } else if (registryRequest instanceof ApproveObjectsRequest) {
        ObjectRefListType refList = ((ApproveObjectsRequest) registryRequest).getObjectRefList();
        ids.addAll(getIdsFromObjectRefList(refList));
    } else if (registryRequest instanceof SetStatusOnObjectsRequest) {
        ObjectRefListType refList = ((SetStatusOnObjectsRequest) registryRequest).getObjectRefList();
        ids.addAll(getIdsFromObjectRefList(refList));
    } else if (registryRequest instanceof DeprecateObjectsRequest) {
        ObjectRefListType refList = ((DeprecateObjectsRequest) registryRequest).getObjectRefList();
        ids.addAll(getIdsFromObjectRefList(refList));
    } else if (registryRequest instanceof UndeprecateObjectsRequest) {
        ObjectRefListType refList = ((UndeprecateObjectsRequest) registryRequest).getObjectRefList();
        ids.addAll(getIdsFromObjectRefList(refList));
    } else if (registryRequest instanceof RemoveObjectsRequest) {
        ObjectRefListType refList = ((RemoveObjectsRequest) registryRequest).getObjectRefList();
        ids.addAll(getIdsFromObjectRefList(refList));
    } else if (registryRequest instanceof SubmitObjectsRequest) {
        RegistryObjectListType objList = ((SubmitObjectsRequest) registryRequest).getRegistryObjectList();
        List objs = getRegistryObjectList(objList);
        ids.addAll(getIdsFromRegistryObjects(objs));
    } else if (registryRequest instanceof UpdateObjectsRequest) {
        RegistryObjectListType objList = ((UpdateObjectsRequest) registryRequest).getRegistryObjectList();
        List objs = getRegistryObjectList(objList);
        ids.addAll(getIdsFromRegistryObjects(objs));
    } else if (registryRequest instanceof RelocateObjectsRequest) {
        // Do nothing.
    } else {
        throw new JAXRException(resourceBundle.getString("message.invalidRequest",
                new String[] { registryRequest.getClass().getName() }));
    }

    return ids;
}

From source file:org.freebxml.omar.common.BindingUtility.java

public Name getName(String name) throws JAXRException {
    Name internationalName = null;

    try {//from   w  w  w.  j  av  a 2 s  . com
        internationalName = rimFac.createName();

        LocalizedString ls = rimFac.createLocalizedString();
        ls.setValue(name);
        internationalName.getLocalizedString().add(ls);
    } catch (JAXBException e) {
        throw new JAXRException(e);
    }

    return internationalName;
}

From source file:org.freebxml.omar.common.BindingUtility.java

public Description getDescription(String desc) throws JAXRException {
    Description internationalDesc = null;

    try {/*from  w  w  w  .  j  a  v  a 2 s. co m*/
        internationalDesc = rimFac.createDescription();

        LocalizedString ls = rimFac.createLocalizedString();
        ls.setValue(desc);
        internationalDesc.getLocalizedString().add(ls);
    } catch (JAXBException e) {
        throw new JAXRException(e);
    }

    return internationalDesc;
}

From source file:org.freebxml.omar.common.BindingUtility.java

public SOAPElement getSOAPElementFromBindingObject(Object obj) throws JAXRException {
    SOAPElement soapElem = null;//  w w  w  .j a v a  2s .co  m

    try {
        SOAPElement parent = SOAPFactory.newInstance().createElement("dummy");

        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.marshal(obj, new DOMResult(parent));
        soapElem = (SOAPElement) parent.getChildElements().next();

    } catch (Exception e) {
        throw new JAXRException(e);
    }

    return soapElem;
}

From source file:org.freebxml.omar.common.BindingUtility.java

public void checkRegistryResponse(RegistryResponseType resp) throws JAXRException {
    if (!(resp.getStatus().equals(CANONICAL_RESPONSE_STATUS_TYPE_ID_Success))) {
        StringWriter sw = new StringWriter();
        try {/* ww  w.  j ava2s. co  m*/
            Marshaller marshaller = jaxbContext.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

            marshaller.marshal(resp, sw);
            throw new JAXRException(sw.toString());
        } catch (Exception e) {
            throw new JAXRException(e);
        }
    }
}

From source file:org.freebxml.omar.common.BindingUtility.java

/**
 * Makes an identical clone of a RegistryObjectType as a new java object.
 *//*from   w w  w.ja v a2s  . c  o m*/
public RegistryObjectType cloneRegistryObject(RegistryObjectType ro) throws JAXRException {
    RegistryObjectType roNew = null;
    try {
        StringWriter sw = new StringWriter();
        rimFac.createMarshaller().marshal(ro, sw);
        roNew = (RegistryObjectType) rimFac.createUnmarshaller()
                .unmarshal(new StreamSource(new StringReader(sw.toString())));
    } catch (javax.xml.bind.JAXBException e) {
        throw new JAXRException(e);
    }

    return roNew;
}

From source file:org.freebxml.omar.common.BindingUtility.java

public InternationalStringType createInternationalStringType(String val) throws JAXRException {
    InternationalStringType is = null;/*from   w  w w .ja  v  a2  s .c o  m*/

    try {
        is = rimFac.createInternationalStringType();
        LocalizedString ls = rimFac.createLocalizedString();
        ls.setValue(val);
        is.getLocalizedString().add(ls);
        //Use default values for lang and charset
    } catch (javax.xml.bind.JAXBException e) {
        throw new JAXRException(e);
    }

    return is;
}

From source file:org.freebxml.omar.common.BindingUtility.java

public void addRegistryObjectToSubmitRequest(SubmitObjectsRequest submitRequest, RegistryObjectType ro)
        throws JAXRException {
    try {/*www  .jav  a 2s.  c  o  m*/
        ArrayList ros = new ArrayList();
        ros.add(ro);
        org.oasis.ebxml.registry.bindings.rim.RegistryObjectList roList = rimFac.createRegistryObjectList();
        roList.getIdentifiable().addAll(ros);
        submitRequest.setRegistryObjectList(roList);
    } catch (javax.xml.bind.JAXBException e) {
        throw new JAXRException(e);
    }
}