Search in sources :

Example 1 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class RegistryPackageTypeHelper method populateLists.

private void populateLists() {
    serviceBindings.clear();
    services.clear();
    extrinsicObjects.clear();
    organizations.clear();
    persons.clear();
    associations.clear();
    if (registryPackageType == null) {
        return;
    }
    if (registryPackageType.isSetRegistryObjectList()) {
        RegistryObjectListType registryObjectList = registryPackageType.getRegistryObjectList();
        for (JAXBElement<? extends IdentifiableType> identifiableType : registryObjectList.getIdentifiable()) {
            RegistryObjectType registryObject = (RegistryObjectType) identifiableType.getValue();
            if (registryObject instanceof ExtrinsicObjectType) {
                extrinsicObjects.add((ExtrinsicObjectType) registryObject);
            } else if (registryObject instanceof ServiceType) {
                ServiceType service = (ServiceType) registryObject;
                services.add(service);
                serviceBindings.addAll(service.getServiceBinding());
            } else if (registryObject instanceof OrganizationType) {
                organizations.add((OrganizationType) registryObject);
            } else if (registryObject instanceof PersonType) {
                persons.add((PersonType) registryObject);
            } else if (registryObject instanceof AssociationType1) {
                associations.add((AssociationType1) registryObject);
            }
        }
    }
}
Also used : RegistryObjectListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType) ServiceType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType) AssociationType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) PersonType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)

Example 2 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class MetacardMarshaller method getRegistryPackageFromMetacard.

/**
     * Converts the metacards metadata into a RegistryPackageType object
     *
     * @param mcard A metacard with ebrim metadata
     * @return A RegistryPackageType object created from the ebrim metadata
     * @throws ParserException
     */
public RegistryPackageType getRegistryPackageFromMetacard(Metacard mcard) throws ParserException {
    JAXBElement<RegistryObjectType> registryObjectTypeJAXBElement;
    String metadata = mcard.getMetadata();
    try (InputStream inputStream = new ByteArrayInputStream(metadata.getBytes(StandardCharsets.UTF_8))) {
        registryObjectTypeJAXBElement = parser.unmarshal(unmarshalConfigurator, JAXBElement.class, inputStream);
    } catch (IOException e) {
        throw new ParserException("Error parsing metacards xml as ebrim", e);
    }
    if (registryObjectTypeJAXBElement == null) {
        throw new ParserException("Error parsing metacards xml as ebrim");
    }
    RegistryPackageType registryPackage = (RegistryPackageType) registryObjectTypeJAXBElement.getValue();
    if (registryPackage == null) {
        throw new ParserException("Error parsing metacards xml as ebrim. No value");
    }
    return registryPackage;
}
Also used : ParserException(org.codice.ddf.parser.ParserException) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) JAXBElement(javax.xml.bind.JAXBElement) IOException(java.io.IOException) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)

Example 3 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class RegistryPackageConverter method parseRegistryObjectList.

private static void parseRegistryObjectList(RegistryObjectListType registryObjects, MetacardImpl metacard) throws RegistryConversionException {
    Map<String, Set<String>> associations = new HashMap<>();
    Map<String, RegistryObjectType> registryIds = new HashMap<>();
    List<OrganizationType> orgs = new ArrayList<>();
    List<PersonType> contacts = new ArrayList<>();
    String nodeId = "";
    for (JAXBElement identifiable : registryObjects.getIdentifiable()) {
        RegistryObjectType registryObject = (RegistryObjectType) identifiable.getValue();
        registryIds.put(registryObject.getId(), registryObject);
        if (registryObject instanceof ExtrinsicObjectType && RegistryConstants.REGISTRY_NODE_OBJECT_TYPE.equals(registryObject.getObjectType())) {
            nodeId = registryObject.getId();
            parseNodeExtrinsicObject(registryObject, metacard);
        } else if (registryObject instanceof ServiceType && RegistryConstants.REGISTRY_SERVICE_OBJECT_TYPE.equals(registryObject.getObjectType())) {
            parseRegistryService((ServiceType) registryObject, metacard);
        } else if (registryObject instanceof OrganizationType) {
            orgs.add((OrganizationType) registryObject);
        } else if (registryObject instanceof PersonType) {
            contacts.add((PersonType) registryObject);
        } else if (registryObject instanceof AssociationType1) {
            AssociationType1 association = (AssociationType1) registryObject;
            if (associations.containsKey(association.getSourceObject())) {
                associations.get(association.getSourceObject()).add(association.getTargetObject());
            } else {
                associations.put(association.getSourceObject(), new HashSet<>(Collections.singleton(association.getTargetObject())));
            }
        }
    }
    boolean orgFound = false;
    boolean contactFound = false;
    if (associations.get(nodeId) != null) {
        Set<String> nodeAssociations = associations.get(nodeId);
        RegistryObjectType ro;
        for (String id : nodeAssociations) {
            ro = registryIds.get(id);
            if (!orgFound && ro != null && ro instanceof OrganizationType) {
                parseRegistryOrganization((OrganizationType) ro, metacard);
                orgFound = true;
            } else if (!contactFound && ro != null && ro instanceof PersonType) {
                parseRegistryPerson((PersonType) ro, metacard);
                contactFound = true;
            }
        }
    }
    if (!orgFound && !orgs.isEmpty()) {
        parseRegistryOrganization(orgs.get(0), metacard);
    }
    if (!contactFound && !contacts.isEmpty()) {
        parseRegistryPerson(contacts.get(0), metacard);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AssociationType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) PersonType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType) JAXBElement(javax.xml.bind.JAXBElement) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) ServiceType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)

Example 4 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class RegistryPackageConverter method getRegistryObjectMetacard.

public static Metacard getRegistryObjectMetacard(RegistryObjectType registryObject, MetacardType metacardType) throws RegistryConversionException {
    MetacardImpl metacard = null;
    if (registryObject == null) {
        return metacard;
    }
    validateIdentifiable(registryObject);
    metacard = new MetacardImpl(metacardType);
    parseTopLevel(registryObject, metacard);
    if (registryObject instanceof RegistryPackageType) {
        parseRegistryPackage((RegistryPackageType) registryObject, metacard);
    } else if (registryObject instanceof ExtrinsicObjectType) {
        parseNodeExtrinsicObject(registryObject, metacard);
    } else if (registryObject instanceof ServiceType) {
        parseRegistryService((ServiceType) registryObject, metacard);
    } else if (registryObject instanceof OrganizationType) {
        parseRegistryOrganization((OrganizationType) registryObject, metacard);
    } else if (registryObject instanceof PersonType) {
        parseRegistryPerson((PersonType) registryObject, metacard);
    } else {
        LOGGER.debug("Unexpected object found: {}", registryObject);
    }
    return metacard;
}
Also used : RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) ServiceType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) PersonType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Example 5 with RegistryObjectType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.

the class FederationAdminTest method getRegistryObjectFromResource.

private RegistryPackageType getRegistryObjectFromResource(String path) throws ParserException {
    RegistryObjectType registryObject = null;
    JAXBElement<RegistryObjectType> jaxbRegistryObject = parser.unmarshal(configurator, JAXBElement.class, getClass().getResourceAsStream(path));
    if (jaxbRegistryObject != null) {
        registryObject = jaxbRegistryObject.getValue();
    }
    return (RegistryPackageType) registryObject;
}
Also used : RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)

Aggregations

RegistryObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)16 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)7 Map (java.util.Map)6 Test (org.junit.Test)6 InputStream (java.io.InputStream)5 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ExternalIdentifierType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType)4 OrganizationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType)4 PersonType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType)4 ServiceType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType)4 SlotType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1)4 Metacard (ddf.catalog.data.Metacard)3 CreateRequest (ddf.catalog.operation.CreateRequest)3 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)3 JAXBElement (javax.xml.bind.JAXBElement)3 AssociationType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1)3 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)3 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)2