private List processResigtrationResponse()

in SdmxStructureParser/src/main/java/org/sdmxsource/sdmx/structureparser/manager/parsing/impl/RegistrationParsingManagerImpl.java [103:182]


    private List<RegistrationInformation> processResigtrationResponse(SDMX_SCHEMA schemaVersion, InputStream stream) throws IOException, XmlException {
        List<RegistrationInformation> returnList = new ArrayList<RegistrationInformation>();
        switch (schemaVersion) {
            case VERSION_TWO:
                RegistryInterfaceDocument rid = RegistryInterfaceDocument.Factory.parse(stream);
                if (rid.getRegistryInterface().getQueryRegistrationResponse() != null &&
                        rid.getRegistryInterface().getQueryRegistrationResponse().getQueryResultList() != null) {
                    for (QueryResultType resultType : rid.getRegistryInterface().getQueryRegistrationResponse().getQueryResultList()) {
                        if (resultType.getDataResult() != null) {
                            RegistrationBean registration = new RegistrationBeanImpl(resultType.getDataResult().getProvisionAgreementRef(), resultType.getDataResult().getDatasource());
                            DATASET_ACTION action = DATASET_ACTION.INFORMATION;
                            returnList.add(new RegistrationInformationImpl(action, registration));
                        }
                    }
                }
                if (rid.getRegistryInterface().getSubmitRegistrationRequest() != null &&
                        rid.getRegistryInterface().getSubmitRegistrationRequest().getRegistrationList() != null) {
                    for (RegistrationType registrationType : rid.getRegistryInterface().getSubmitRegistrationRequest().getRegistrationList()) {
                        RegistrationBean registration = new RegistrationBeanImpl(registrationType);
                        DATASET_ACTION action = DATASET_ACTION.APPEND;
                        switch (registrationType.getAction().intValue()) {
                            case org.sdmx.resources.sdmxml.schemas.v20.common.ActionType.INT_APPEND:
                                action = DATASET_ACTION.APPEND;
                                break;
                            case org.sdmx.resources.sdmxml.schemas.v20.common.ActionType.INT_DELETE:
                                action = DATASET_ACTION.DELETE;
                                break;
                            case org.sdmx.resources.sdmxml.schemas.v20.common.ActionType.INT_REPLACE:
                                action = DATASET_ACTION.REPLACE;
                                break;
                        }
                        returnList.add(new RegistrationInformationImpl(action, registration));
                    }
                }
                break;
            case VERSION_TWO_POINT_ONE:
                org.sdmx.resources.sdmxml.schemas.v21.message.RegistryInterfaceDocument rid2_1 = org.sdmx.resources.sdmxml.schemas.v21.message.RegistryInterfaceDocument.Factory.parse(stream);
                RegistryInterfaceType rit = rid2_1.getRegistryInterface();
                if (rit.getSubmitRegistrationsRequest() != null && rit.getSubmitRegistrationsRequest().getRegistrationRequestList() != null) {
                    for (org.sdmx.resources.sdmxml.schemas.v21.registry.RegistrationRequestType rt : rit.getSubmitRegistrationsRequest().getRegistrationRequestList()) {
                        DATASET_ACTION action = DATASET_ACTION.APPEND;
                        switch (rt.getAction().intValue()) {
                            case org.sdmx.resources.sdmxml.schemas.v21.common.ActionType.INT_APPEND:
                                action = DATASET_ACTION.APPEND;
                                break;
                            case org.sdmx.resources.sdmxml.schemas.v21.common.ActionType.INT_DELETE:
                                action = DATASET_ACTION.DELETE;
                                break;
                            case org.sdmx.resources.sdmxml.schemas.v21.common.ActionType.INT_REPLACE:
                                action = DATASET_ACTION.REPLACE;
                                break;
                        }
                        if (action == DATASET_ACTION.DELETE || action == DATASET_ACTION.REPLACE) {
                            if (!ObjectUtil.validString(rt.getRegistration().getId())) {
                                throw new IllegalArgumentException("Registration submissions with REPLACE or DELETE actions must contain an id identifying the Registration to perform this action on");
                            }
                        }
                        RegistrationBean registration = new RegistrationBeanImpl(rt.getRegistration());
                        returnList.add(new RegistrationInformationImpl(action, registration));
                    }
                }
                if (rit.getQueryRegistrationResponse() != null && rit.getQueryRegistrationResponse().getQueryResultList() != null) {
                    for (org.sdmx.resources.sdmxml.schemas.v21.registry.QueryResultType queryResult : rit.getQueryRegistrationResponse().getQueryResultList()) {
                        if (queryResult.getDataResult() != null && queryResult.getDataResult().getRegistration() != null) {
                            RegistrationBean registration = new RegistrationBeanImpl(queryResult.getDataResult().getRegistration());
                            returnList.add(new RegistrationInformationImpl(DATASET_ACTION.INFORMATION, registration));
                        }
                        if (queryResult.getMetadataResult() != null && queryResult.getMetadataResult().getRegistration() != null) {
                            RegistrationBean registration = new RegistrationBeanImpl(queryResult.getDataResult().getRegistration());
                            returnList.add(new RegistrationInformationImpl(DATASET_ACTION.INFORMATION, registration));
                        }
                    }
                }
                break;
            default:
                throw new IllegalArgumentException("Schema version unsupported: " + schemaVersion.toString());
        }
        return returnList;

    }