Search in sources :

Example 91 with JAXBElement

use of javax.xml.bind.JAXBElement in project midpoint by Evolveum.

the class Upload method unmarshalFile.

private static Object unmarshalFile(File file) throws JAXBException, FileNotFoundException {
    JAXBContext jc = ModelClientUtil.instantiateJaxbContext();
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    Object o = unmarshaller.unmarshal(new FileInputStream(file));
    if (o instanceof JAXBElement) {
        return ((JAXBElement) o).getValue();
    } else {
        return o;
    }
}
Also used : JAXBContext(javax.xml.bind.JAXBContext) JAXBElement(javax.xml.bind.JAXBElement) Unmarshaller(javax.xml.bind.Unmarshaller) FileInputStream(java.io.FileInputStream)

Example 92 with JAXBElement

use of javax.xml.bind.JAXBElement in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method dumpAttributes.

protected void dumpAttributes(ShadowType shadowType) {
    ShadowAttributesType attributes = shadowType.getAttributes();
    System.out.println("Attributes for " + shadowType.getObjectClass().getLocalPart() + " " + getOrig(shadowType.getName()) + " {" + attributes.getAny().size() + " entries):");
    for (Object item : attributes.getAny()) {
        if (item instanceof Element) {
            Element e = (Element) item;
            System.out.println(" - " + e.getLocalName() + ": " + e.getTextContent());
        } else if (item instanceof JAXBElement) {
            JAXBElement je = (JAXBElement) item;
            String typeInfo = je.getValue() instanceof String ? "" : (" (" + je.getValue().getClass().getSimpleName() + ")");
            System.out.println(" - " + je.getName().getLocalPart() + ": " + je.getValue() + typeInfo);
        } else {
            System.out.println(" - " + item);
        }
    }
}
Also used : JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) ShadowAttributesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType) JAXBElement(javax.xml.bind.JAXBElement)

Example 93 with JAXBElement

use of javax.xml.bind.JAXBElement in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method getAttributesAsMap.

protected Map<String, Object> getAttributesAsMap(ShadowType shadowType) {
    Map<String, Object> rv = new HashMap<>();
    ShadowAttributesType attributes = shadowType.getAttributes();
    for (Object item : attributes.getAny()) {
        if (item instanceof Element) {
            Element e = (Element) item;
            put(rv, e.getLocalName(), e.getTextContent());
        } else if (item instanceof JAXBElement) {
            JAXBElement je = (JAXBElement) item;
            put(rv, je.getName().getLocalPart(), je.getValue());
        } else {
        // nothing to do here
        }
    }
    return rv;
}
Also used : HashMap(java.util.HashMap) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) ShadowAttributesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType) JAXBElement(javax.xml.bind.JAXBElement)

Example 94 with JAXBElement

use of javax.xml.bind.JAXBElement in project ddf by codice.

the class TestCswFilterDelegate method testFeatureIdOr.

@Test
public void testFeatureIdOr() throws JAXBException, SAXException, IOException, XpathException {
    ObjectFactory filterObjectFactory = new ObjectFactory();
    FeatureIdType fidType = new FeatureIdType();
    fidType.setFid("cswRecord.1234");
    List<JAXBElement<? extends AbstractIdType>> fidFilters = new ArrayList<>();
    fidFilters.add(filterObjectFactory.createFeatureId(fidType));
    FilterType idFilter = new FilterType();
    idFilter.setId(fidFilters);
    FeatureIdType fidType2 = new FeatureIdType();
    fidType2.setFid("cswRecord.5678");
    List<JAXBElement<? extends AbstractIdType>> fidFilters2 = new ArrayList<>();
    fidFilters2.add(filterObjectFactory.createFeatureId(fidType2));
    FilterType idFilter2 = new FilterType();
    idFilter2.setId(fidFilters2);
    List<FilterType> filters = new ArrayList<>();
    filters.add(idFilter);
    filters.add(idFilter2);
    FilterType filterType = cswFilterDelegateLatLon.or(filters);
    String xml = getXmlFromMarshaller(filterType);
    assertXpathExists("/ogc:Filter/ogc:FeatureId[@fid='cswRecord.1234']", xml);
    assertXpathExists("/ogc:Filter/ogc:FeatureId[@fid='cswRecord.5678']", xml);
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) ObjectFactory(net.opengis.filter.v_1_1_0.ObjectFactory) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) AbstractIdType(net.opengis.filter.v_1_1_0.AbstractIdType) FeatureIdType(net.opengis.filter.v_1_1_0.FeatureIdType) Test(org.junit.Test)

Example 95 with JAXBElement

use of javax.xml.bind.JAXBElement in project ddf by codice.

the class TestCswFilterDelegate method testFeatureIdAndComparisonOpsOr.

@Test(expected = UnsupportedOperationException.class)
public void testFeatureIdAndComparisonOpsOr() throws JAXBException, SAXException, IOException {
    ObjectFactory filterObjectFactory = new ObjectFactory();
    FeatureIdType fidType = new FeatureIdType();
    fidType.setFid("cswRecord.1234");
    List<JAXBElement<? extends AbstractIdType>> fidFilters = new ArrayList<>();
    fidFilters.add(filterObjectFactory.createFeatureId(fidType));
    FilterType idFilter = new FilterType();
    idFilter.setId(fidFilters);
    FilterType propertyIsLikeFilter = cswFilterDelegateLatLon.propertyIsLike(propertyName, likeLiteral, isCaseSensitive);
    List<FilterType> filterList = new ArrayList<>();
    filterList.add(idFilter);
    filterList.add(propertyIsLikeFilter);
    cswFilterDelegateLatLon.or(filterList);
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) ObjectFactory(net.opengis.filter.v_1_1_0.ObjectFactory) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) AbstractIdType(net.opengis.filter.v_1_1_0.AbstractIdType) FeatureIdType(net.opengis.filter.v_1_1_0.FeatureIdType) Test(org.junit.Test)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)650 QName (javax.xml.namespace.QName)194 Element (org.w3c.dom.Element)124 RequestSecurityTokenType (org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType)102 RequestSecurityTokenResponseType (org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseType)95 ArrayList (java.util.ArrayList)93 MessageImpl (org.apache.cxf.message.MessageImpl)92 WrappedMessageContext (org.apache.cxf.jaxws.context.WrappedMessageContext)90 Test (org.junit.Test)87 STSPropertiesMBean (org.apache.cxf.sts.STSPropertiesMBean)86 StaticSTSProperties (org.apache.cxf.sts.StaticSTSProperties)83 Crypto (org.apache.wss4j.common.crypto.Crypto)82 JAXBException (javax.xml.bind.JAXBException)81 PasswordCallbackHandler (org.apache.cxf.sts.common.PasswordCallbackHandler)77 JAXBContext (javax.xml.bind.JAXBContext)75 CustomTokenPrincipal (org.apache.wss4j.common.principal.CustomTokenPrincipal)72 Unmarshaller (javax.xml.bind.Unmarshaller)65 ServiceMBean (org.apache.cxf.sts.service.ServiceMBean)61 StaticService (org.apache.cxf.sts.service.StaticService)61 RequestSecurityTokenResponseCollectionType (org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseCollectionType)58