Search in sources :

Example 6 with EntryType

use of org.talend.schemas.esb.locator._2011._11.EntryType in project airavata by apache.

the class StorageCreator method findServerName.

protected String findServerName(String besUrl, EndpointReferenceType smsEpr) throws Exception {
    int besIndex = besUrl.indexOf("StorageFactory?res");
    String ss = besUrl.substring(0, besIndex);
    ss = ss + "Registry";
    EndpointReferenceType eprt = WSUtilities.makeServiceEPR(ss, "default_registry", Registry.REGISTRY_PORT);
    RegistryClient registry = new RegistryClient(eprt, secProps);
    // first, check if server name is already in the EPR...
    String dn = WSUtilities.extractServerIDFromEPR(smsEpr);
    if (dn != null) {
        return dn;
    }
    // otherwise find a matching service in the registry
    String url = smsEpr.getAddress().getStringValue();
    if (url.contains("/services/"))
        url = url.substring(0, url.indexOf("/services"));
    if (log.isDebugEnabled())
        log.debug("Checking for services at " + url);
    for (EntryType entry : registry.listEntries()) {
        if (entry.getMemberServiceEPR().getAddress().getStringValue().startsWith(url)) {
            dn = WSUtilities.extractServerIDFromEPR(entry.getMemberServiceEPR());
            if (dn != null) {
                return dn;
            }
        }
    }
    return null;
}
Also used : EndpointReferenceType(org.w3.x2005.x08.addressing.EndpointReferenceType) EntryType(org.oasisOpen.docs.wsrf.sg2.EntryType) RegistryClient(de.fzj.unicore.wsrflite.xmlbeans.client.RegistryClient)

Example 7 with EntryType

use of org.talend.schemas.esb.locator._2011._11.EntryType in project midpoint by Evolveum.

the class ParamsTypeUtil method fromParamsType.

public static Map<String, Serializable> fromParamsType(ParamsType paramsType, PrismContext prismContext) throws SchemaException {
    if (paramsType != null) {
        Map<String, Serializable> params = new HashMap<String, Serializable>();
        Serializable realValue = null;
        for (EntryType entry : paramsType.getEntry()) {
            if (entry.getEntryValue() != null) {
                Serializable value = (Serializable) entry.getEntryValue().getValue();
                if (value instanceof RawType) {
                    XNode xnode = ((RawType) value).getXnode();
                    if (xnode instanceof PrimitiveXNode) {
                        realValue = ((PrimitiveXNode) xnode).getGuessedFormattedValue();
                    }
                } else {
                    realValue = value;
                }
            }
            params.put(entry.getKey(), (Serializable) (realValue));
        }
        return params;
    }
    return null;
}
Also used : Serializable(java.io.Serializable) EntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.EntryType) PrimitiveXNode(com.evolveum.midpoint.prism.xnode.PrimitiveXNode) HashMap(java.util.HashMap) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) XNode(com.evolveum.midpoint.prism.xnode.XNode) PrimitiveXNode(com.evolveum.midpoint.prism.xnode.PrimitiveXNode) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType)

Example 8 with EntryType

use of org.talend.schemas.esb.locator._2011._11.EntryType in project midpoint by Evolveum.

the class ParamsTypeUtil method fromParamsType.

public static Map<String, Serializable> fromParamsType(ParamsType paramsType) {
    if (paramsType != null) {
        Map<String, Serializable> params = new HashMap<String, Serializable>();
        Serializable realValue = null;
        for (EntryType entry : paramsType.getEntry()) {
            if (entry.getEntryValue() != null) {
                //					Serializable value = (Serializable) entry.getEntryValue().getValue();
                //					if (value instanceof RawType){
                //						XNode xnode = ((RawType) value).getXnode();
                //						if (xnode instanceof PrimitiveXNode){
                //							realValue = ((PrimitiveXNode) xnode).getGuessedFormattedValue();
                //						}
                //					} else {
                //						realValue = value;
                //					}
                //				}
                params.put(entry.getKey(), (Serializable) entry.getEntryValue());
            }
        }
        return params;
    }
    return null;
}
Also used : Serializable(java.io.Serializable) EntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.EntryType) HashMap(java.util.HashMap)

Example 9 with EntryType

use of org.talend.schemas.esb.locator._2011._11.EntryType in project midpoint by Evolveum.

the class ParamsTypeUtil method createEntryElement.

/**
	 * Temporary workaround, brutally hacked -- so that the conversion 
	 * of OperationResult into OperationResultType 'somehow' works, at least to the point
	 * where when we:
	 * - have OR1
	 * - serialize it into ORT1
	 * - then deserialize into OR2
	 * - serialize again into ORT2
	 * so we get ORT1.equals(ORT2) - at least in our simple test case :)
	 * 
	 * FIXME: this should be definitely reworked
	 * 
	 * @param entry
	 * @return
	 */
private static EntryType createEntryElement(String key, Serializable value) {
    EntryType entryType = new EntryType();
    entryType.setKey(key);
    if (value != null) {
        Document doc = DOMUtil.getDocument();
        if (value instanceof ObjectType && ((ObjectType) value).getOid() != null) {
            // Store only reference on the OID. This is faster and getObject can be used to retrieve
            // the object if needed. Although is does not provide 100% accuracy, it is a good tradeoff.
            setObjectReferenceEntry(entryType, ((ObjectType) value));
        // these values should be put 'as they are', in order to be deserialized into themselves
        } else if (value instanceof String || value instanceof Integer || value instanceof Long) {
            entryType.setEntryValue(new JAXBElement<Serializable>(SchemaConstants.C_PARAM_VALUE, Serializable.class, value));
        } else if (XmlTypeConverter.canConvert(value.getClass())) {
        //				try {
        //					entryType.setEntryValue(new JXmlTypeConverter.toXsdElement(value, SchemaConstants.C_PARAM_VALUE, doc, true));
        //				} catch (SchemaException e) {
        //					LOGGER.error("Cannot convert value {} to XML: {}",value,e.getMessage());
        //					setUnknownJavaObjectEntry(entryType, value);
        //				}
        } else if (value instanceof Element || value instanceof JAXBElement<?>) {
            entryType.setEntryValue((JAXBElement<?>) value);
        // FIXME: this is really bad code ... it means that 'our' JAXB object should be put as is
        } else if ("com.evolveum.midpoint.xml.ns._public.common.common_3".equals(value.getClass().getPackage().getName())) {
            JAXBElement<Object> o = new JAXBElement<Object>(SchemaConstants.C_PARAM_VALUE, Object.class, value);
            entryType.setEntryValue(o);
        } else {
            setUnknownJavaObjectEntry(entryType, value);
        }
    }
    return entryType;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) UnknownJavaObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.UnknownJavaObjectType) EntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.EntryType) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) JAXBElement(javax.xml.bind.JAXBElement) Document(org.w3c.dom.Document)

Example 10 with EntryType

use of org.talend.schemas.esb.locator._2011._11.EntryType in project tesb-rt-se by Talend.

the class LocatorRestServiceTest method registerEndpointExpectedLocatorException.

@Test(expected = WebApplicationException.class)
public void registerEndpointExpectedLocatorException() throws ServiceLocatorException, InterruptedException {
    sl.register(endpoint(), EasyMock.eq(true));
    EasyMock.expectLastCall().andStubThrow(new ServiceLocatorException("test"));
    replayAll();
    RegisterEndpointRequest req = new RegisterEndpointRequest();
    EntryType entryType = new EntryType();
    entryType.setKey("test");
    entryType.getValue().add("test");
    req.getEntryType().add(entryType);
    req.setEndpointURL(ENDPOINTURL);
    req.setServiceName(SERVICE_NAME.toString());
    lps.registerEndpoint(req);
}
Also used : RegisterEndpointRequest(org.talend.schemas.esb.locator.rest._2011._11.RegisterEndpointRequest) EntryType(org.talend.schemas.esb.locator.rest._2011._11.EntryType) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) Test(org.junit.Test)

Aggregations

EntryType (org.talend.schemas.esb.locator.rest._2011._11.EntryType)5 EntryType (com.evolveum.midpoint.xml.ns._public.common.common_3.EntryType)4 Test (org.junit.Test)4 RegisterEndpointRequest (org.talend.schemas.esb.locator.rest._2011._11.RegisterEndpointRequest)4 ServiceLocatorException (org.talend.esb.servicelocator.client.ServiceLocatorException)3 RootXNode (com.evolveum.midpoint.prism.xnode.RootXNode)2 RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)2 RegistryClient (de.fzj.unicore.wsrflite.xmlbeans.client.RegistryClient)2 Serializable (java.io.Serializable)2 HashMap (java.util.HashMap)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 EntryType (org.oasisOpen.docs.wsrf.sg2.EntryType)2 BindingType (org.talend.esb.servicelocator.client.BindingType)2 SLPropertiesImpl (org.talend.esb.servicelocator.client.SLPropertiesImpl)2 SimpleEndpoint (org.talend.esb.servicelocator.client.SimpleEndpoint)2 TransportType (org.talend.esb.servicelocator.client.TransportType)2 EntryType (org.talend.schemas.esb.locator._2011._11.EntryType)2 EndpointReferenceType (org.w3.x2005.x08.addressing.EndpointReferenceType)2 PrimitiveXNode (com.evolveum.midpoint.prism.xnode.PrimitiveXNode)1 XNode (com.evolveum.midpoint.prism.xnode.XNode)1