diff --git a/README.md b/README.md index cc0b1ec9..b18f3e23 100644 --- a/README.md +++ b/README.md @@ -98,4 +98,4 @@ No support for X-Road Catalog deployment is provided here. * X-Road Catalog was originally developed by the [Finnish Digital Agency](https://dvv.fi/en) during 2016-2023. * In 2023 it was agreed that [Nordic Institute for Interoperability Solutions (NIIS)](https://www.niis.org/) takes -maintenance responsibility. \ No newline at end of file +maintenance responsibility. diff --git a/doc/xroad_catalog_user_guide.md b/doc/xroad_catalog_user_guide.md index 317d9458..aa730bde 100644 --- a/doc/xroad_catalog_user_guide.md +++ b/doc/xroad_catalog_user_guide.md @@ -1,5 +1,5 @@ # X-Road Catalog User Guide -Version: 4.2.0 +Version: 4.2.1 Doc. ID: UG-XRDCAT --- @@ -25,6 +25,7 @@ Doc. ID: UG-XRDCAT | 22.03.2023 | 4.0.0 | Split document into X-Road Catalog Installation Guide and User Guide | Petteri Kivimäki | | 16.08.2023 | 4.1.0 | Update Catalog Lister port number from `8080` to `8070` | Petteri Kivimäki | | 09.09.2023 | 4.2.0 | Update REST endpoint descriptions | Petteri Kivimäki | +| 17.11.2023 | 4.2.1 | Update response of ListMembers and service types for GetServiceType | Bert Viikmäe | ## Table of Contents @@ -204,6 +205,7 @@ Contents of the XML response of the request clientReg + SOAP 1584692751893_da8be621-5d6b-4920-91c9-d8c359dddbad 2020-03-20T10:25:51.892+02:00 @@ -216,12 +218,14 @@ Contents of the XML response of the request respa.tampere.fi + REST 2020-03-20T10:25:51.632+02:00 2020-03-20T10:25:51.632+02:00 2020-03-20T12:31:07.223+02:00 authCertDeletion + SOAP 1584692751942_ab002cbd-bbbd-43c7-a311-b0dc5adf3af1 2020-03-20T10:25:51.936+02:00 @@ -234,6 +238,7 @@ Contents of the XML response of the request clientDeletion + SOAP 1584692751908_5bdde30d-3a5f-42c0-9f45-d884f5810996 2020-03-20T10:25:51.906+02:00 @@ -246,6 +251,7 @@ Contents of the XML response of the request ownerChange + SOAP 1584692751888_07141c5a-bfe0-4c84-b621-e5e4a9db01fa 2020-03-20T10:25:51.884+02:00 @@ -258,6 +264,7 @@ Contents of the XML response of the request PetStoreNew + REST 2020-03-20T10:25:51.632+02:00 2020-03-20T10:25:51.632+02:00 2020-03-20T12:31:07.223+02:00 @@ -296,6 +303,7 @@ The XML response has a `` element with the following structure: * `services` * `service` * `serviceCode` + * `serviceType` * `wsdl` (if the given service description is a WSDL description) * `externalId` @@ -456,7 +464,7 @@ The following request fields need to be filled: The XML response has a `` element with the following structure: * `GetServiceTypeResponse` - * `type` (values: `REST`/`OPENAPI3`/`WSDL`) + * `type` (values: `REST`/`OPENAPI3`/`WSDL`/`UNKNOWN`) ### 3.1.5 Check if member is provider diff --git a/xroad-catalog-collector/CHANGELOG.md b/xroad-catalog-collector/CHANGELOG.md index d956a081..485a24a9 100644 --- a/xroad-catalog-collector/CHANGELOG.md +++ b/xroad-catalog-collector/CHANGELOG.md @@ -2,6 +2,21 @@ All notable changes to this project will be documented in this file. +## [3.0.7] - 2023-11-17 + +# Changed +- Refactor ListMembers endpoint to have extra field "serviceType" + +## [3.0.6] - 2023-11-09 + +# Changed +- Refactor fetch of companies + +## [3.0.5] - 2023-11-07 + +# Changed +- Pull latest version from NIIS develop branch + ## [3.0.4] - 2023-02-13 # Changed diff --git a/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/XRoadCatalogCollector.java b/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/XRoadCatalogCollector.java index 5c11232a..1017ed7d 100644 --- a/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/XRoadCatalogCollector.java +++ b/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/XRoadCatalogCollector.java @@ -18,7 +18,6 @@ import akka.actor.ActorSystem; import akka.event.Logging; import akka.event.LoggingAdapter; -import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -28,7 +27,6 @@ import java.util.Arrays; import java.util.concurrent.TimeUnit; -@Slf4j @SpringBootApplication public class XRoadCatalogCollector { diff --git a/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/actors/CatalogSupervisor.java b/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/actors/CatalogSupervisor.java index 2ed1fdb5..e699e205 100644 --- a/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/actors/CatalogSupervisor.java +++ b/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/actors/CatalogSupervisor.java @@ -19,7 +19,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import scala.concurrent.duration.Duration; @@ -34,7 +33,6 @@ @Component("CatalogSupervisor") @Scope("prototype") @Slf4j -@Profile("!fi") // remove, so that this will be used for all profiles public class CatalogSupervisor extends XRoadCatalogActor { public static final String LIST_CLIENTS_ACTOR_ROUTER = "list-clients-actor-router"; diff --git a/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/actors/FetchCompaniesActor.java b/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/actors/FetchCompaniesActor.java index 7dffe236..2f468d80 100644 --- a/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/actors/FetchCompaniesActor.java +++ b/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/actors/FetchCompaniesActor.java @@ -14,7 +14,6 @@ import fi.vrk.xroad.catalog.collector.util.OrganizationUtil; import fi.vrk.xroad.catalog.collector.wsimport.ClientType; -import fi.vrk.xroad.catalog.collector.wsimport.XRoadClientIdentifierType; import fi.vrk.xroad.catalog.persistence.CatalogService; import fi.vrk.xroad.catalog.persistence.CompanyService; import fi.vrk.xroad.catalog.persistence.entity.BusinessAddress; @@ -36,7 +35,6 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; - import java.util.ArrayList; import java.util.List; @@ -48,6 +46,9 @@ public class FetchCompaniesActor extends XRoadCatalogActor { @Value("${xroad-catalog.fetch-companies-url}") private String fetchCompaniesUrl; + @Value("${xroad-catalog.fetch-companies-limit}") + private Integer fetchCompaniesLimit; + @Autowired protected CatalogService catalogService; @@ -63,13 +64,19 @@ public void preStart() throws Exception { protected boolean handleMessage(Object message) { if (message instanceof ClientType) { ClientType clientType = (ClientType) message; - XRoadClientIdentifierType client = clientType.getId(); - log.info("Fetching data for company with businessCode {}", client.getMemberCode()); - String businessCode = clientType.getId().getMemberCode(); - JSONObject companyJson = OrganizationUtil.getCompany(clientType, fetchCompaniesUrl, businessCode, + JSONObject companiesJson = OrganizationUtil.getCompanies(clientType, fetchCompaniesLimit, fetchCompaniesUrl, catalogService); - saveData(companyJson.optJSONArray("results")); - log.info("Successfully saved data for company with businessCode {}", businessCode); + JSONArray companiesArray = companiesJson.optJSONArray("results"); + int numberOfCompanies = companiesArray.length(); + log.info("Fetching data for {} companies", numberOfCompanies); + companiesArray.forEach(item -> { + JSONObject company = (JSONObject) item; + String businessCode = company.optString("businessId"); + JSONObject companyJson = OrganizationUtil.getCompany(clientType, fetchCompaniesUrl, businessCode, + catalogService); + saveData(companyJson.optJSONArray("results")); + }); + log.info("Successfully saved data for {} companies", numberOfCompanies); return true; } else { return false; diff --git a/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/actors/OrganizationsActor.java b/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/actors/OrganizationsActor.java index 9c5e879a..4930e868 100644 --- a/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/actors/OrganizationsActor.java +++ b/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/actors/OrganizationsActor.java @@ -43,6 +43,8 @@ public class OrganizationsActor extends XRoadCatalogActor { private boolean organizationsFetched = false; + private boolean companiesFetched = false; + private static final String SERVICE_TYPE_REST = "REST"; @Value("${xroad-catalog.security-server-host}") @@ -139,7 +141,10 @@ private void fetchOrganizations(ClientType clientType) { private void fetchCompanies(ClientType clientType) { if (MethodListUtil.shouldFetchCompanies(fetchCompaniesUnlimited, fetchCompaniesTimeAfterHour, fetchCompaniesTimeBeforeHour)) { - fetchCompaniesPoolRef.tell(clientType, getSelf()); + if (Boolean.FALSE.equals(companiesFetched)) { + fetchCompaniesPoolRef.tell(clientType, getSelf()); + companiesFetched = true; + } } } @@ -186,4 +191,3 @@ private void saveSubsystemsAndServices(ClientType clientType) { } } } - diff --git a/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/configuration/ProductionConfiguration.java b/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/configuration/ProductionConfiguration.java index 1842ceb3..f56f892f 100644 --- a/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/configuration/ProductionConfiguration.java +++ b/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/configuration/ProductionConfiguration.java @@ -12,13 +12,11 @@ */ package fi.vrk.xroad.catalog.collector.configuration; -import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; @Configuration @Profile({ "production", "sshtest" }) -@Slf4j public class ProductionConfiguration extends ApplicationConfiguration { // dont override anything from ApplicationConfiguration diff --git a/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/util/OrganizationUtil.java b/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/util/OrganizationUtil.java index e038b0a3..2dc97a04 100644 --- a/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/util/OrganizationUtil.java +++ b/xroad-catalog-collector/src/main/java/fi/vrk/xroad/catalog/collector/util/OrganizationUtil.java @@ -79,6 +79,9 @@ @Slf4j public final class OrganizationUtil { + private static final String TOTAL_RESULTS = "true"; + private static final String RESULTS_FROM = "0"; + private static final String REGISTRATION_FROM = "1970-01-01"; private static final String WITH_BUSINESS_CODE = "with businessCode "; private static final String DESCRIPTION = "description"; private static final String LANGUAGE = "language"; @@ -93,6 +96,50 @@ private OrganizationUtil() { } + public static JSONObject getCompanies(ClientType clientType, + Integer fetchCompaniesLimit, + String url, + CatalogService catalogService) { + final String fetchCompaniesUrl = new StringBuilder() + .append(url) + .append("?totalResults=").append(TOTAL_RESULTS) + .append("&maxResults=").append(String.valueOf(fetchCompaniesLimit)) + .append("&resultsFrom=").append(RESULTS_FROM) + .append("&companyRegistrationFrom=").append(REGISTRATION_FROM) + .toString(); + JSONObject jsonObject = new JSONObject(); + try { + String ret = getResponseBody(fetchCompaniesUrl); + jsonObject = new JSONObject(ret); + return jsonObject; + } catch (KeyStoreException e) { + ErrorLog errorLog = MethodListUtil.createErrorLog(clientType, + "KeyStoreException occurred when fetching list of companies from url " + url, + "500"); + catalogService.saveErrorLog(errorLog); + log.error("KeyStoreException occurred when fetching companies from url {}", url); + } catch (NoSuchAlgorithmException e) { + ErrorLog errorLog = MethodListUtil.createErrorLog(clientType, + "NoSuchAlgorithmException occurred when fetching companies from url " + url, + "500"); + catalogService.saveErrorLog(errorLog); + log.error("NoSuchAlgorithmException occurred when fetching companies from url", url); + } catch (KeyManagementException e) { + ErrorLog errorLog = MethodListUtil.createErrorLog(clientType, + "KeyManagementException occurred when fetching companies from url " + url, + "500"); + catalogService.saveErrorLog(errorLog); + log.error("KeyManagementException occurred when fetching companies from url {}", url); + } catch (Exception e) { + ErrorLog errorLog = MethodListUtil.createErrorLog(clientType, + "Exception occurred when fetching companies from url " + url, + "500"); + catalogService.saveErrorLog(errorLog); + log.error("Exception occurred when fetching companies from url {}", url); + } + return jsonObject; + } + public static JSONObject getCompany(ClientType clientType, String url, String businessCode, CatalogService catalogService) { final String fetchCompaniesUrl = new StringBuilder().append(url) @@ -104,47 +151,35 @@ public static JSONObject getCompany(ClientType clientType, String url, String bu return jsonObject; } catch (KeyStoreException e) { ErrorLog errorLog = MethodListUtil.createErrorLog(clientType, - "KeyStoreException occurred when fetching companies from url " - + url - + WITH_BUSINESS_CODE - + businessCode, + "KeyStoreException occurred when fetching companies from url " + url + + WITH_BUSINESS_CODE + businessCode, "500"); catalogService.saveErrorLog(errorLog); log.error("KeyStoreException occurred when fetching companies from url {} with businessCode {}", - url, - businessCode); + url, businessCode); } catch (NoSuchAlgorithmException e) { ErrorLog errorLog = MethodListUtil.createErrorLog(clientType, - "NoSuchAlgorithmException occurred when fetching companies from url " - + url - + WITH_BUSINESS_CODE - + businessCode, + "NoSuchAlgorithmException occurred when fetching companies from url " + url + + WITH_BUSINESS_CODE + businessCode, "500"); catalogService.saveErrorLog(errorLog); log.error("NoSuchAlgorithmException occurred when fetching companies from url {} with businessCode {}", - url, - businessCode); + url, businessCode); } catch (KeyManagementException e) { ErrorLog errorLog = MethodListUtil.createErrorLog(clientType, - "KeyManagementException occurred when fetching companies from url " - + url - + WITH_BUSINESS_CODE - + businessCode, + "KeyManagementException occurred when fetching companies from url " + url + + WITH_BUSINESS_CODE + businessCode, "500"); catalogService.saveErrorLog(errorLog); log.error("KeyManagementException occurred when fetching companies from url {} with businessCode {}", - url, - businessCode); + url, businessCode); } catch (Exception e) { ErrorLog errorLog = MethodListUtil.createErrorLog(clientType, - "Exception occurred when fetching companies from url " - + url - + WITH_BUSINESS_CODE - + businessCode, + "Exception occurred when fetching companies from url " + url + + WITH_BUSINESS_CODE + businessCode, "500"); catalogService.saveErrorLog(errorLog); - log.error("Exception occurred when fetching companies from url {} with businessCode {}", - url, + log.error("Exception occurred when fetching companies from url {} with businessCode {}", url, businessCode); } return jsonObject; @@ -152,15 +187,13 @@ public static JSONObject getCompany(ClientType clientType, String url, String bu public static List getOrganizationIdsList(ClientType clientType, String url, Integer fetchOrganizationsLimit, CatalogService catalogService) - throws KeyStoreException, NoSuchAlgorithmException, - KeyManagementException { + throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException { List idsList = new ArrayList<>(); try { String response = getResponseBody(url); JSONObject json = new JSONObject(response); JSONArray itemList = json.optJSONArray("itemList"); - int totalFetchAmount = itemList.length() > fetchOrganizationsLimit - ? fetchOrganizationsLimit + int totalFetchAmount = itemList.length() > fetchOrganizationsLimit ? fetchOrganizationsLimit : itemList.length(); for (int i = 0; i < totalFetchAmount; i++) { String id = itemList.optJSONObject(i).optString("id"); @@ -173,8 +206,7 @@ public static List getOrganizationIdsList(ClientType clientType, String + url, "500"); catalogService.saveErrorLog(errorLog); - log.error("KeyStoreException occurred when fetching organization ids with from url {}", - url); + log.error("KeyStoreException occurred when fetching organization ids with from url {}", url); } catch (NoSuchAlgorithmException e) { ErrorLog errorLog = MethodListUtil.createErrorLog(clientType, "NoSuchAlgorithmException occurred when fetching organization ids with from url " @@ -189,29 +221,22 @@ public static List getOrganizationIdsList(ClientType clientType, String + url, "500"); catalogService.saveErrorLog(errorLog); - log.error("KeyManagementException occurred when fetching organizations with from url {}", - url); + log.error("KeyManagementException occurred when fetching organizations with from url {}", url); } catch (Exception e) { - log.error("Exception occurred when fetching organization ids: " - + e.getMessage()); + log.error("Exception occurred when fetching organization ids: " + e.getMessage()); ErrorLog errorLog = ErrorLog.builder() .created(LocalDateTime.now()) - .message("Exception occurred when fetching organization ids: " - + e.getMessage()) + .message("Exception occurred when fetching organization ids: " + e.getMessage()) .code("500") - .xRoadInstance(clientType.getId() - .getXRoadInstance()) + .xRoadInstance(clientType.getId().getXRoadInstance()) .memberClass(clientType.getId().getMemberClass()) .memberCode(clientType.getId().getMemberCode()) .groupCode(clientType.getId().getGroupCode()) - .securityCategoryCode(clientType.getId() - .getSecurityCategoryCode()) + .securityCategoryCode(clientType.getId().getSecurityCategoryCode()) .serverCode(clientType.getId().getServerCode()) .serviceCode(clientType.getId().getServiceCode()) - .serviceVersion(clientType.getId() - .getServiceVersion()) - .subsystemCode(clientType.getId() - .getSubsystemCode()) + .serviceVersion(clientType.getId().getServiceVersion()) + .subsystemCode(clientType.getId().getSubsystemCode()) .build(); catalogService.saveErrorLog(errorLog); } @@ -221,10 +246,8 @@ public static List getOrganizationIdsList(ClientType clientType, String public static Organization createOrganization(JSONObject jsonObject) { return Organization.builder().businessCode(jsonObject.optString("businessCode")) .guid(jsonObject.optString("id")) - .organizationType(jsonObject.optString( - "organizationType")) - .publishingStatus(jsonObject.optString( - "publishingStatus")) + .organizationType(jsonObject.optString("organizationType")) + .publishingStatus(jsonObject.optString("publishingStatus")) .build(); } @@ -233,13 +256,10 @@ public static List createEmails(JSONArray jsonArray) { for (int i = 0; i < jsonArray.length(); i++) { emails.add(Email.builder() .description(replaceUnicodeControlCharacters( - jsonArray.optJSONObject(i).optString( - DESCRIPTION))) - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) + jsonArray.optJSONObject(i).optString(DESCRIPTION))) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) .value(replaceUnicodeControlCharacters( - jsonArray.optJSONObject(i).optString( - VALUE))) + jsonArray.optJSONObject(i).optString(VALUE))) .build()); } return emails; @@ -250,13 +270,10 @@ public static List createWebPages(JSONArray jsonArray) { for (int i = 0; i < jsonArray.length(); i++) { webPages.add(WebPage.builder() .url(replaceUnicodeControlCharacters( - jsonArray.optJSONObject(i).optString( - "url"))) - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) + jsonArray.optJSONObject(i).optString("url"))) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) .value(replaceUnicodeControlCharacters( - jsonArray.optJSONObject(i).optString( - VALUE))) + jsonArray.optJSONObject(i).optString(VALUE))) .build()); } return webPages; @@ -266,21 +283,16 @@ public static List createDescriptions(JSONArray jsonArr List organizationDescriptions = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { organizationDescriptions.add(OrganizationDescription.builder() - .type(jsonArray.optJSONObject(i).optString( - "type")) - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) + .type(jsonArray.optJSONObject(i).optString("type")) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) .value(replaceUnicodeControlCharacters( - jsonArray.optJSONObject(i).optString( - VALUE))) + jsonArray.optJSONObject(i).optString(VALUE))) .build()); } return organizationDescriptions; } - @SuppressWarnings("squid:S6035") private static String replaceUnicodeControlCharacters(String input) { - // TODO: Check if there is a better way to remove control characters return input.replaceAll( "[\\x{0000}-\\x{0009}]|[\\x{000b}-\\x{000c}]|[\\x{000e}-\\x{000f}]|[\\x{0010}-\\x{001f}]", ""); @@ -290,13 +302,10 @@ public static List createNames(JSONArray jsonArray) { List organizationNames = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { organizationNames.add(OrganizationName.builder() - .type(jsonArray.optJSONObject(i).optString( - "type")) - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) + .type(jsonArray.optJSONObject(i).optString("type")) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) .value(replaceUnicodeControlCharacters( - jsonArray.optJSONObject(i).optString( - VALUE))) + jsonArray.optJSONObject(i).optString(VALUE))) .build()); } return organizationNames; @@ -306,13 +315,9 @@ public static List
createAddresses(JSONArray jsonArray) { List
addresses = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { addresses.add(Address.builder() - .type(jsonArray.optJSONObject(i).optString( - "type")) - .subType(jsonArray.optJSONObject(i) - .optString("subType")) - .country(jsonArray.optJSONObject(i) - .optString("country")) - .build()); + .type(jsonArray.optJSONObject(i).optString("type")) + .subType(jsonArray.optJSONObject(i).optString("subType")) + .country(jsonArray.optJSONObject(i).optString("country")).build()); } return addresses; } @@ -323,9 +328,7 @@ public static StreetAddress createStreetAddress(JSONObject jsonObject) { .postalCode(jsonObject.optString("postalCode")) .latitude(jsonObject.optString("latitude")) .longitude(jsonObject.optString("longitude")) - .coordinateState(jsonObject.optString( - "coordinateState")) - .build(); + .coordinateState(jsonObject.optString("coordinateState")).build(); } public static StreetAddressMunicipality createStreetAddressMunicipality(JSONObject jsonObject) { @@ -333,17 +336,12 @@ public static StreetAddressMunicipality createStreetAddressMunicipality(JSONObje .code(jsonObject.optString("code")).build(); } - public static List createStreetAddressMunicipalityNames( - JSONArray jsonArray) { + public static List createStreetAddressMunicipalityNames(JSONArray jsonArray) { List streetAddressMunicipalityNames = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { - streetAddressMunicipalityNames.add(StreetAddressMunicipalityName - .builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .value(jsonArray.optJSONObject(i) - .optString(VALUE)) - .build()); + streetAddressMunicipalityNames.add(StreetAddressMunicipalityName.builder() + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .value(jsonArray.optJSONObject(i).optString(VALUE)).build()); } return streetAddressMunicipalityNames; } @@ -352,13 +350,10 @@ public static List createStreetAddressAdditi JSONArray jsonArray) { List additionalInformationList = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { - additionalInformationList.add(StreetAddressAdditionalInformation - .builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) + additionalInformationList.add(StreetAddressAdditionalInformation.builder() + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) .value(replaceUnicodeControlCharacters( - jsonArray.optJSONObject(i).optString( - VALUE))) + jsonArray.optJSONObject(i).optString(VALUE))) .build()); } return additionalInformationList; @@ -368,11 +363,8 @@ public static List createStreetAddressPostOffices(JSONA List postOffices = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { postOffices.add(StreetAddressPostOffice.builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .value(jsonArray.optJSONObject(i) - .optString(VALUE)) - .build()); + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .value(jsonArray.optJSONObject(i).optString(VALUE)).build()); } return postOffices; } @@ -381,11 +373,8 @@ public static List createStreets(JSONArray jsonArray) { List streets = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { streets.add(Street.builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .value(jsonArray.optJSONObject(i) - .optString(VALUE)) - .build()); + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .value(jsonArray.optJSONObject(i).optString(VALUE)).build()); } return streets; } @@ -399,13 +388,10 @@ public static List createPostOfficeBo JSONArray jsonArray) { List additionalInformationList = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { - additionalInformationList.add(PostOfficeBoxAddressAdditionalInformation - .builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) + additionalInformationList.add(PostOfficeBoxAddressAdditionalInformation.builder() + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) .value(replaceUnicodeControlCharacters( - jsonArray.optJSONObject(i).optString( - VALUE))) + jsonArray.optJSONObject(i).optString(VALUE))) .build()); } return additionalInformationList; @@ -415,11 +401,8 @@ public static List createPostOfficeBoxes(JSONArray jsonArray) { List postOfficeBoxes = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { postOfficeBoxes.add(PostOfficeBox.builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .value(jsonArray.optJSONObject(i) - .optString(VALUE)) - .build()); + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .value(jsonArray.optJSONObject(i).optString(VALUE)).build()); } return postOfficeBoxes; } @@ -428,17 +411,13 @@ public static List createPostOffice(JSONArray jsonArray) { List postOffices = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { postOffices.add(PostOffice.builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .value(jsonArray.optJSONObject(i) - .optString(VALUE)) - .build()); + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .value(jsonArray.optJSONObject(i).optString(VALUE)).build()); } return postOffices; } - public static PostOfficeBoxAddressMunicipality createPostOfficeBoxAddressMunicipality( - JSONObject jsonObject) { + public static PostOfficeBoxAddressMunicipality createPostOfficeBoxAddressMunicipality(JSONObject jsonObject) { return PostOfficeBoxAddressMunicipality.builder() .code(jsonObject.optString("code")).build(); } @@ -447,13 +426,9 @@ public static List createPostOfficeBoxAddr JSONArray jsonArray) { List streetAddressMunicipalityNames = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { - streetAddressMunicipalityNames.add(PostOfficeBoxAddressMunicipalityName - .builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .value(jsonArray.optJSONObject(i) - .optString(VALUE)) - .build()); + streetAddressMunicipalityNames.add(PostOfficeBoxAddressMunicipalityName.builder() + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .value(jsonArray.optJSONObject(i).optString(VALUE)).build()); } return streetAddressMunicipalityNames; } @@ -463,24 +438,15 @@ public static List createPhoneNumbers(JSONArray jsonArray) { for (int i = 0; i < jsonArray.length(); i++) { phoneNumbers.add(PhoneNumber.builder() .additionalInformation(replaceUnicodeControlCharacters( - jsonArray.optJSONObject(i).optString( - "additionalInformation"))) - .number(jsonArray.optJSONObject(i) - .optString("number")) + jsonArray.optJSONObject(i).optString("additionalInformation"))) + .number(jsonArray.optJSONObject(i).optString("number")) .isFinnishServiceNumber( - jsonArray.optJSONObject(i).getBoolean( - "isFinnishServiceNumber")) - .prefixNumber(jsonArray.optJSONObject(i) - .optString("prefixNumber")) - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .chargeDescription( - replaceUnicodeControlCharacters(jsonArray - .optJSONObject(i) - .optString("chargeDescription"))) - .serviceChargeType(jsonArray.optJSONObject( - i) - .optString("serviceChargeType")) + jsonArray.optJSONObject(i).getBoolean("isFinnishServiceNumber")) + .prefixNumber(jsonArray.optJSONObject(i).optString("prefixNumber")) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .chargeDescription(replaceUnicodeControlCharacters( + jsonArray.optJSONObject(i).optString("chargeDescription"))) + .serviceChargeType(jsonArray.optJSONObject(i).optString("serviceChargeType")) .build()); } return phoneNumbers; @@ -491,8 +457,7 @@ public static Company createCompany(JSONObject jsonObject) { .companyForm(jsonObject.optString("companyForm")) .detailsUri(jsonObject.optString("detailsUri")) .name(jsonObject.optString("name")) - .registrationDate(parseDateFromString(jsonObject - .optString(REGISTRATION_DATE))) + .registrationDate(parseDateFromString(jsonObject.optString(REGISTRATION_DATE))) .build(); } @@ -500,30 +465,18 @@ public static List createBusinessAddresses(JSONArray jsonArray) List businessAddresses = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { businessAddresses.add(BusinessAddress.builder() - .careOf(jsonArray.optJSONObject(i) - .optString("careOf")) - .city(jsonArray.optJSONObject(i).optString( - "city")) - .country(jsonArray.optJSONObject(i) - .optString("country")) - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .postCode(jsonArray.optJSONObject(i) - .optString("postCode")) - .source(jsonArray.optJSONObject(i) - .optLong(SOURCE)) - .type(jsonArray.optJSONObject(i).optLong( - "type")) - .version(jsonArray.optJSONObject(i) - .optLong(VERSION)) - .street(jsonArray.optJSONObject(i) - .optString("street")) + .careOf(jsonArray.optJSONObject(i).optString("careOf")) + .city(jsonArray.optJSONObject(i).optString("city")) + .country(jsonArray.optJSONObject(i).optString("country")) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .postCode(jsonArray.optJSONObject(i).optString("postCode")) + .source(jsonArray.optJSONObject(i).optLong(SOURCE)) + .type(jsonArray.optJSONObject(i).optLong("type")) + .version(jsonArray.optJSONObject(i).optLong(VERSION)) + .street(jsonArray.optJSONObject(i).optString("street")) .registrationDate(parseDateFromString( - jsonArray.optJSONObject(i).optString( - REGISTRATION_DATE))) - .endDate(parseDateFromString(jsonArray - .optJSONObject(i) - .optString(END_DATE))) + jsonArray.optJSONObject(i).optString(REGISTRATION_DATE))) + .endDate(parseDateFromString(jsonArray.optJSONObject(i).optString(END_DATE))) .build()); } return businessAddresses; @@ -533,22 +486,14 @@ public static List createBusinessAuxiliaryNames(JSONArray List businessAuxiliaryNames = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { businessAuxiliaryNames.add(BusinessAuxiliaryName.builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .name(jsonArray.optJSONObject(i).optString( - "name")) - .ordering(jsonArray.optJSONObject(i) - .optLong(ORDER)) - .source(jsonArray.optJSONObject(i) - .optLong(SOURCE)) - .version(jsonArray.optJSONObject(i) - .optLong(VERSION)) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .name(jsonArray.optJSONObject(i).optString("name")) + .ordering(jsonArray.optJSONObject(i).optLong(ORDER)) + .source(jsonArray.optJSONObject(i).optLong(SOURCE)) + .version(jsonArray.optJSONObject(i).optLong(VERSION)) .registrationDate(parseDateFromString( - jsonArray.optJSONObject(i).optString( - REGISTRATION_DATE))) - .endDate(parseDateFromString(jsonArray - .optJSONObject(i) - .optString(END_DATE))) + jsonArray.optJSONObject(i).optString(REGISTRATION_DATE))) + .endDate(parseDateFromString(jsonArray.optJSONObject(i).optString(END_DATE))) .build()); } return businessAuxiliaryNames; @@ -558,24 +503,14 @@ public static List createBusinessIdChanges(JSONArray jsonArray List businessIdChanges = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { businessIdChanges.add(BusinessIdChange.builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .change(jsonArray.optJSONObject(i) - .optString("change")) - .changeDate(jsonArray.optJSONObject(i) - .optString("changeDate")) - .description(jsonArray.optJSONObject(i) - .optString(DESCRIPTION)) - .reason(jsonArray.optJSONObject(i) - .optString("reason")) - .oldBusinessId(jsonArray.optJSONObject( - i) - .optString("oldBusinessId")) - .newBusinessId(jsonArray.optJSONObject( - i) - .optString("newBusinessId")) - .source(jsonArray.optJSONObject(i) - .optLong(SOURCE)) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .change(jsonArray.optJSONObject(i).optString("change")) + .changeDate(jsonArray.optJSONObject(i).optString("changeDate")) + .description(jsonArray.optJSONObject(i).optString(DESCRIPTION)) + .reason(jsonArray.optJSONObject(i).optString("reason")) + .oldBusinessId(jsonArray.optJSONObject(i).optString("oldBusinessId")) + .newBusinessId(jsonArray.optJSONObject(i).optString("newBusinessId")) + .source(jsonArray.optJSONObject(i).optLong(SOURCE)) .build()); } return businessIdChanges; @@ -585,22 +520,14 @@ public static List createBusinessLines(JSONArray jsonArray) { List businessLines = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { businessLines.add(BusinessLine.builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .name(jsonArray.optJSONObject(i).optString( - "name")) - .ordering(jsonArray.optJSONObject(i) - .optLong(ORDER)) - .source(jsonArray.optJSONObject(i) - .optLong(SOURCE)) - .version(jsonArray.optJSONObject(i) - .optLong(VERSION)) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .name(jsonArray.optJSONObject(i).optString("name")) + .ordering(jsonArray.optJSONObject(i).optLong(ORDER)) + .source(jsonArray.optJSONObject(i).optLong(SOURCE)) + .version(jsonArray.optJSONObject(i).optLong(VERSION)) .registrationDate(parseDateFromString( - jsonArray.optJSONObject(i).optString( - REGISTRATION_DATE))) - .endDate(parseDateFromString(jsonArray - .optJSONObject(i) - .optString(END_DATE))) + jsonArray.optJSONObject(i).optString(REGISTRATION_DATE))) + .endDate(parseDateFromString(jsonArray.optJSONObject(i).optString(END_DATE))) .build()); } return businessLines; @@ -610,22 +537,14 @@ public static List createBusinessNames(JSONArray jsonArray) { List businessNames = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { businessNames.add(BusinessName.builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .name(jsonArray.optJSONObject(i).optString( - "name")) - .ordering(jsonArray.optJSONObject(i) - .optLong(ORDER)) - .source(jsonArray.optJSONObject(i) - .optLong(SOURCE)) - .version(jsonArray.optJSONObject(i) - .optLong(VERSION)) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .name(jsonArray.optJSONObject(i).optString("name")) + .ordering(jsonArray.optJSONObject(i).optLong(ORDER)) + .source(jsonArray.optJSONObject(i).optLong(SOURCE)) + .version(jsonArray.optJSONObject(i).optLong(VERSION)) .registrationDate(parseDateFromString( - jsonArray.optJSONObject(i).optString( - REGISTRATION_DATE))) - .endDate(parseDateFromString(jsonArray - .optJSONObject(i) - .optString(END_DATE))) + jsonArray.optJSONObject(i).optString(REGISTRATION_DATE))) + .endDate(parseDateFromString(jsonArray.optJSONObject(i).optString(END_DATE))) .build()); } return businessNames; @@ -635,22 +554,14 @@ public static List createCompanyForms(JSONArray jsonArray) { List companyForms = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { companyForms.add(CompanyForm.builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .name(jsonArray.optJSONObject(i).optString( - "name")) - .source(jsonArray.optJSONObject(i) - .optLong(SOURCE)) - .type(jsonArray.optJSONObject(i).optLong( - "type")) - .version(jsonArray.optJSONObject(i) - .optLong(VERSION)) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .name(jsonArray.optJSONObject(i).optString("name")) + .source(jsonArray.optJSONObject(i).optLong(SOURCE)) + .type(jsonArray.optJSONObject(i).optLong("type")) + .version(jsonArray.optJSONObject(i).optLong(VERSION)) .registrationDate(parseDateFromString( - jsonArray.optJSONObject(i).optString( - REGISTRATION_DATE))) - .endDate(parseDateFromString(jsonArray - .optJSONObject(i) - .optString(END_DATE))) + jsonArray.optJSONObject(i).optString(REGISTRATION_DATE))) + .endDate(parseDateFromString(jsonArray.optJSONObject(i).optString(END_DATE))) .build()); } return companyForms; @@ -660,22 +571,14 @@ public static List createContactDetails(JSONArray jsonArray) { List contactDetails = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { contactDetails.add(ContactDetail.builder() - .version(jsonArray.optJSONObject(i) - .optLong(VERSION)) - .type(jsonArray.optJSONObject(i).optString( - "type")) - .source(jsonArray.optJSONObject(i) - .optLong(SOURCE)) - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .value(jsonArray.optJSONObject(i) - .optString(VALUE)) + .version(jsonArray.optJSONObject(i).optLong(VERSION)) + .type(jsonArray.optJSONObject(i).optString("type")) + .source(jsonArray.optJSONObject(i).optLong(SOURCE)) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .value(jsonArray.optJSONObject(i).optString(VALUE)) .registrationDate(parseDateFromString( - jsonArray.optJSONObject(i).optString( - REGISTRATION_DATE))) - .endDate(parseDateFromString(jsonArray - .optJSONObject(i) - .optString(END_DATE))) + jsonArray.optJSONObject(i).optString(REGISTRATION_DATE))) + .endDate(parseDateFromString(jsonArray.optJSONObject(i).optString(END_DATE))) .build()); } return contactDetails; @@ -685,20 +588,13 @@ public static List createLanguages(JSONArray jsonArray) { List languages = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { languages.add(Language.builder() - .version(jsonArray.optJSONObject(i) - .optLong(VERSION)) - .source(jsonArray.optJSONObject(i) - .optLong(SOURCE)) - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .name(jsonArray.optJSONObject(i).optString( - "name")) + .version(jsonArray.optJSONObject(i).optLong(VERSION)) + .source(jsonArray.optJSONObject(i).optLong(SOURCE)) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .name(jsonArray.optJSONObject(i).optString("name")) .registrationDate(parseDateFromString( - jsonArray.optJSONObject(i).optString( - REGISTRATION_DATE))) - .endDate(parseDateFromString(jsonArray - .optJSONObject(i) - .optString(END_DATE))) + jsonArray.optJSONObject(i).optString(REGISTRATION_DATE))) + .endDate(parseDateFromString(jsonArray.optJSONObject(i).optString(END_DATE))) .build()); } return languages; @@ -708,16 +604,11 @@ public static List createLiquidations(JSONArray jsonArray) { List liquidations = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { liquidations.add(Liquidation.builder() - .version(jsonArray.optJSONObject(i) - .optLong(VERSION)) - .source(jsonArray.optJSONObject(i) - .optLong(SOURCE)) - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .name(jsonArray.optJSONObject(i).optString( - "name")) - .type(jsonArray.optJSONObject(i).optLong( - "type")) + .version(jsonArray.optJSONObject(i).optLong(VERSION)) + .source(jsonArray.optJSONObject(i).optLong(SOURCE)) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .name(jsonArray.optJSONObject(i).optString("name")) + .type(jsonArray.optJSONObject(i).optLong("type")) .registrationDate(LocalDateTime.now()) .endDate(LocalDateTime.now()) .build()); @@ -729,22 +620,14 @@ public static List createRegisteredEntries(JSONArray jsonArray) List registeredEntries = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { registeredEntries.add(RegisteredEntry.builder() - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .description(jsonArray.optJSONObject(i) - .optString(DESCRIPTION)) - .register(jsonArray.optJSONObject(i) - .optLong("register")) - .status(jsonArray.optJSONObject(i) - .optLong("status")) - .authority(jsonArray.optJSONObject(i) - .optLong("authority")) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .description(jsonArray.optJSONObject(i).optString(DESCRIPTION)) + .register(jsonArray.optJSONObject(i).optLong("register")) + .status(jsonArray.optJSONObject(i).optLong("status")) + .authority(jsonArray.optJSONObject(i).optLong("authority")) .registrationDate(parseDateFromString( - jsonArray.optJSONObject(i).optString( - REGISTRATION_DATE))) - .endDate(parseDateFromString(jsonArray - .optJSONObject(i) - .optString(END_DATE))) + jsonArray.optJSONObject(i).optString(REGISTRATION_DATE))) + .endDate(parseDateFromString(jsonArray.optJSONObject(i).optString(END_DATE))) .build()); } return registeredEntries; @@ -754,22 +637,14 @@ public static List createRegisteredOffices(JSONArray jsonArray List registeredOffices = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { registeredOffices.add(RegisteredOffice.builder() - .source(jsonArray.optJSONObject(i) - .optLong(SOURCE)) - .language(jsonArray.optJSONObject(i) - .optString(LANGUAGE)) - .name(jsonArray.optJSONObject(i).optString( - "name")) - .ordering(jsonArray.optJSONObject(i) - .optLong(ORDER)) - .version(jsonArray.optJSONObject(i) - .optLong(VERSION)) + .source(jsonArray.optJSONObject(i).optLong(SOURCE)) + .language(jsonArray.optJSONObject(i).optString(LANGUAGE)) + .name(jsonArray.optJSONObject(i).optString("name")) + .ordering(jsonArray.optJSONObject(i).optLong(ORDER)) + .version(jsonArray.optJSONObject(i).optLong(VERSION)) .registrationDate(parseDateFromString( - jsonArray.optJSONObject(i).optString( - REGISTRATION_DATE))) - .endDate(parseDateFromString(jsonArray - .optJSONObject(i) - .optString(END_DATE))) + jsonArray.optJSONObject(i).optString(REGISTRATION_DATE))) + .endDate(parseDateFromString(jsonArray.optJSONObject(i).optString(END_DATE))) .build()); } return registeredOffices; @@ -803,12 +678,10 @@ public static JSONArray getDataByIds(ClientType clientType, List guids, return itemList; } catch (KeyStoreException e) { ErrorLog errorLog = MethodListUtil.createErrorLog(clientType, - "KeyStoreException occurred when fetching organizations with from url " - + url, + "KeyStoreException occurred when fetching organizations with from url " + url, "500"); catalogService.saveErrorLog(errorLog); - log.error("KeyStoreException occurred when fetching organizations with from url {}", - url); + log.error("KeyStoreException occurred when fetching organizations with from url {}", url); } catch (NoSuchAlgorithmException e) { ErrorLog errorLog = MethodListUtil.createErrorLog(clientType, "NoSuchAlgorithmException occurred when fetching organizations with from url " @@ -823,29 +696,22 @@ public static JSONArray getDataByIds(ClientType clientType, List guids, + url, "500"); catalogService.saveErrorLog(errorLog); - log.error("KeyManagementException occurred when fetching organizations with from url {}", - url); + log.error("KeyManagementException occurred when fetching organizations with from url {}", url); } catch (Exception e) { - log.error("Exception occurred when fetching organization data: " - + e.getMessage()); + log.error("Exception occurred when fetching organization data: " + e.getMessage()); ErrorLog errorLog = ErrorLog.builder() .created(LocalDateTime.now()) .message("Exception occurred when fetching organization data: " + e.getMessage()) .code("500") - .xRoadInstance(clientType.getId() - .getXRoadInstance()) + .xRoadInstance(clientType.getId().getXRoadInstance()) .memberClass(clientType.getId().getMemberClass()) .memberCode(clientType.getId().getMemberCode()) .groupCode(clientType.getId().getGroupCode()) - .securityCategoryCode(clientType.getId() - .getSecurityCategoryCode()) .serverCode(clientType.getId().getServerCode()) .serviceCode(clientType.getId().getServiceCode()) - .serviceVersion(clientType.getId() - .getServiceVersion()) - .subsystemCode(clientType.getId() - .getSubsystemCode()) + .serviceVersion(clientType.getId().getServiceVersion()) + .subsystemCode(clientType.getId().getSubsystemCode()) .build(); catalogService.saveErrorLog(errorLog); } @@ -861,15 +727,13 @@ public static String getResponseBody(String url) headers.setAccept(mediaTypes); final HttpEntity entity = new HttpEntity<>(headers); RestTemplate restTemplate = createTemplate(); - ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, entity, - String.class); + ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class); return response.getBody(); } private static RestTemplate createTemplate() - throws KeyStoreException, NoSuchAlgorithmException, - KeyManagementException { + throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException { TrustStrategy acceptingTrustStrategy = new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] x509Certificates, String s) diff --git a/xroad-catalog-collector/src/main/resources/collector-production.properties b/xroad-catalog-collector/src/main/resources/collector-production.properties index 0bfdde0f..d8f9f105 100644 --- a/xroad-catalog-collector/src/main/resources/collector-production.properties +++ b/xroad-catalog-collector/src/main/resources/collector-production.properties @@ -18,6 +18,7 @@ xroad-catalog.fetch-companies-url=https://avoindata.prh.fi/bis/v1 # 100 is maximum per request for the api xroad-catalog.max-organizations-per-request=100 xroad-catalog.fetch-organizations-limit=2000 +xroad-catalog.fetch-companies-limit=1000 xroad-catalog.fetch-companies-run-unlimited=false xroad-catalog.fetch-companies-time-after-hour=3 @@ -46,4 +47,4 @@ xroad-catalog.fetch-companies-pool-size=10 # Do not change except in development spring.main.web_environment=false -spring.main.allow-bean-definition-overriding=true +spring.main.allow-bean-definition-overriding=true \ No newline at end of file diff --git a/xroad-catalog-collector/src/main/resources/collector-sshtest.properties b/xroad-catalog-collector/src/main/resources/collector-sshtest.properties index 26608054..9af0e7b9 100644 --- a/xroad-catalog-collector/src/main/resources/collector-sshtest.properties +++ b/xroad-catalog-collector/src/main/resources/collector-sshtest.properties @@ -23,6 +23,7 @@ xroad-catalog.fetch-companies-url=https://avoindata.prh.fi/bis/v1 # 100 is maximum per request for the api xroad-catalog.max-organizations-per-request=100 xroad-catalog.fetch-organizations-limit=2000 +xroad-catalog.fetch-companies-limit=1000 xroad-catalog.fetch-companies-run-unlimited=false xroad-catalog.fetch-companies-time-after-hour=3 diff --git a/xroad-catalog-collector/src/main/resources/collector.properties b/xroad-catalog-collector/src/main/resources/collector.properties index 70bd4a4f..be990d2f 100644 --- a/xroad-catalog-collector/src/main/resources/collector.properties +++ b/xroad-catalog-collector/src/main/resources/collector.properties @@ -21,6 +21,7 @@ xroad-catalog.fetch-companies-url=https://avoindata.prh.fi/bis/v1 # 100 is maximum per request for the api xroad-catalog.max-organizations-per-request=100 xroad-catalog.fetch-organizations-limit=2000 +xroad-catalog.fetch-companies-limit=1000 xroad-catalog.fetch-companies-run-unlimited=false xroad-catalog.fetch-companies-time-after-hour=3 @@ -44,4 +45,4 @@ xroad-catalog.fetch-companies-pool-size=1 # SSL keystore parameters xroad-catalog.ssl-keystore=/etc/xroad/xroad-catalog/keystore -xroad-catalog.ssl-keystore-password=changeit +xroad-catalog.ssl-keystore-password=changeit \ No newline at end of file diff --git a/xroad-catalog-collector/src/test/java/fi/vrk/xroad/catalog/collector/actors/FetchCompanyActorTest.java b/xroad-catalog-collector/src/test/java/fi/vrk/xroad/catalog/collector/actors/FetchCompanyActorTest.java index 1f5fb5ac..49729a12 100644 --- a/xroad-catalog-collector/src/test/java/fi/vrk/xroad/catalog/collector/actors/FetchCompanyActorTest.java +++ b/xroad-catalog-collector/src/test/java/fi/vrk/xroad/catalog/collector/actors/FetchCompanyActorTest.java @@ -28,10 +28,14 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.TestPropertySource; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; @SpringBootTest(classes = DevelopmentConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@TestPropertySource(properties = { "xroad-catalog.fetch-companies-run-unlimited=true" }) +@TestPropertySource(properties = { + "xroad-catalog.fetch-companies-limit=3", + "xroad-catalog.fetch-companies-run-unlimited=true" +}) public class FetchCompanyActorTest { @MockBean @@ -61,25 +65,7 @@ public void testBasicPlumbing() { value.setObjectType(XRoadObjectType.SERVICE); clientType.setId(value); fetchCompanyActor.tell(clientType, ActorRef.noSender()); - verify(companyService, times(1)).saveCompany(any()); - } - - @Test - public void testBasicPlumbingWithInvalidData() { - TestActorRef fetchCompanyActor = TestActorRef.create(actorSystem, - springExtension.props("fetchCompaniesActor", null)); - ClientType clientType = new ClientType(); - XRoadClientIdentifierType value = new XRoadClientIdentifierType(); - value.setXRoadInstance("INSTANCE"); - value.setMemberClass("COM"); - value.setMemberCode("abc"); - value.setSubsystemCode("SUBSYSTEM"); - value.setServiceCode("aService"); - value.setServiceVersion("v1"); - value.setObjectType(XRoadObjectType.SERVICE); - clientType.setId(value); - fetchCompanyActor.tell(clientType, ActorRef.noSender()); - verify(catalogService, times(1)).saveErrorLog(any()); + verify(companyService, times(3)).saveCompany(any()); } @Test diff --git a/xroad-catalog-collector/src/test/java/fi/vrk/xroad/catalog/collector/actors/ListMethodsActorTest.java b/xroad-catalog-collector/src/test/java/fi/vrk/xroad/catalog/collector/actors/ListMethodsActorTest.java index 5f9e5aab..f43cd2b0 100644 --- a/xroad-catalog-collector/src/test/java/fi/vrk/xroad/catalog/collector/actors/ListMethodsActorTest.java +++ b/xroad-catalog-collector/src/test/java/fi/vrk/xroad/catalog/collector/actors/ListMethodsActorTest.java @@ -36,6 +36,7 @@ @SpringBootTest(classes = DevelopmentConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestPropertySource(properties = { "xroad-catalog.fetch-organizations-limit=3", + "xroad-catalog.fetch-companies-limit=3", "xroad-catalog.max-organizations-per-request=3" }) public class ListMethodsActorTest { diff --git a/xroad-catalog-collector/src/test/java/fi/vrk/xroad/catalog/collector/actors/OrganizationsActorTest.java b/xroad-catalog-collector/src/test/java/fi/vrk/xroad/catalog/collector/actors/OrganizationsActorTest.java index 5c1d0c48..388e532b 100644 --- a/xroad-catalog-collector/src/test/java/fi/vrk/xroad/catalog/collector/actors/OrganizationsActorTest.java +++ b/xroad-catalog-collector/src/test/java/fi/vrk/xroad/catalog/collector/actors/OrganizationsActorTest.java @@ -36,6 +36,7 @@ @SpringBootTest(classes = DevelopmentConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestPropertySource(properties = { "xroad-catalog.fetch-organizations-limit=3", + "xroad-catalog.fetch-companies-limit=3", "xroad-catalog.max-organizations-per-request=3", "xroad-catalog.fetch-companies-run-unlimited=true", "xroad-catalog.flush-log-time-after-hour=0", diff --git a/xroad-catalog-lister/CHANGELOG.md b/xroad-catalog-lister/CHANGELOG.md index 1994bd88..8eca5c58 100644 --- a/xroad-catalog-lister/CHANGELOG.md +++ b/xroad-catalog-lister/CHANGELOG.md @@ -2,6 +2,21 @@ All notable changes to this project will be documented in this file. +## [3.0.7] - 2023-11-17 + +# Changed +- Refactor ListMembers endpoint to have extra field "serviceType" + +## [3.0.6] - 2023-11-09 + +# Changed +- Refactor fetch of companies + +## [3.0.5] - 2023-11-07 + +# Changed +- Pull latest version from NIIS develop branch + ## [3.0.4] - 2023-02-13 # Changed diff --git a/xroad-catalog-lister/src/main/java/fi/vrk/xroad/catalog/lister/ServiceEndpointImpl.java b/xroad-catalog-lister/src/main/java/fi/vrk/xroad/catalog/lister/ServiceEndpointImpl.java index 39cad7e1..a271cb88 100644 --- a/xroad-catalog-lister/src/main/java/fi/vrk/xroad/catalog/lister/ServiceEndpointImpl.java +++ b/xroad-catalog-lister/src/main/java/fi/vrk/xroad/catalog/lister/ServiceEndpointImpl.java @@ -115,7 +115,7 @@ public IsProviderResponse isProvider(@RequestPayload IsProvider request) { member.getAllSubsystems().forEach(subsystem -> { subsystem.getAllServices().forEach(service -> { - if (service.hasWsdl() || service.hasOpenApi()) { + if (service.hasWsdl() || service.hasOpenApi() || service.hasRest()) { isProvider.set(Boolean.TRUE); } }); diff --git a/xroad-catalog-lister/src/main/java/fi/vrk/xroad/catalog/lister/util/JaxbServiceUtil.java b/xroad-catalog-lister/src/main/java/fi/vrk/xroad/catalog/lister/util/JaxbServiceUtil.java index b661e0dd..4d819bfc 100644 --- a/xroad-catalog-lister/src/main/java/fi/vrk/xroad/catalog/lister/util/JaxbServiceUtil.java +++ b/xroad-catalog-lister/src/main/java/fi/vrk/xroad/catalog/lister/util/JaxbServiceUtil.java @@ -40,6 +40,15 @@ public static fi.vrk.xroad.catalog.lister.generated.Service convertService(Servi cs.setRemoved(toXmlGregorianCalendar(service.getStatusInfo().getRemoved())); cs.setServiceCode(service.getServiceCode()); cs.setServiceVersion(service.getServiceVersion()); + if (service.hasWsdl()) { + cs.setServiceType("SOAP"); + } else if (service.hasOpenApi()) { + cs.setServiceType("OPENAPI"); + } else if (service.hasRest()) { + cs.setServiceType("REST"); + } else { + cs.setServiceType("UNKNOWN"); + } Wsdl wsdl = null; if (onlyActiveChildren) { if (service.getWsdl() != null && !service.getWsdl().getStatusInfo().isRemoved()) { diff --git a/xroad-catalog-lister/src/main/resources/services.wsdl b/xroad-catalog-lister/src/main/resources/services.wsdl index 02506568..de38c0a0 100644 --- a/xroad-catalog-lister/src/main/resources/services.wsdl +++ b/xroad-catalog-lister/src/main/resources/services.wsdl @@ -1000,6 +1000,7 @@ http://x-road.eu/xsd/identifiers "> + diff --git a/xroad-catalog-persistence/CHANGELOG.md b/xroad-catalog-persistence/CHANGELOG.md index ba1fdc9e..e5b91b6c 100644 --- a/xroad-catalog-persistence/CHANGELOG.md +++ b/xroad-catalog-persistence/CHANGELOG.md @@ -2,6 +2,18 @@ All notable changes to this project will be documented in this file. +## 3.0.7 - 2023-11-17 + +- Refactor ListMembers endpoint to have extra field "serviceType" + +## 3.0.6 - 2023-11-09 + +- Refactor fetch of companies + +## 3.0.5 - 2023-11-07 + +- Pull latest version from NIIS develop branch + ## 3.0.4 - 2023-02-13 - Bugfixes, updates to systemd service specs