ee.datel.client.kr.DetailandmedService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xtee6-client-kr Show documentation
Show all versions of xtee6-client-kr Show documentation
Library for XROAD KR service clints
The newest version!
package ee.datel.client.kr;
/*-
* ==========================LICENSE_START===================================
* ee.datel.xtee6:xtee6-client-kr
*
* Copyright (C) 2018 - 2024 AS Datel
*
* Redistribution and use in binary form, without modification, are permitted
* provided that the following conditions are met:
*
* 1. Redistributions must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 2. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ===========================LICENSE_END====================================
*/
import ee.datel.client.utils.ServiceUtils;
import ee.datel.xtee.fault.ServiceFaultException;
import ee.xtee6.kr.dm.ArrayOfJagu0;
import ee.xtee6.kr.dm.ArrayOfJagu1;
import ee.xtee6.kr.dm.ArrayOfJagu2;
import ee.xtee6.kr.dm.ArrayOfJagu3;
import ee.xtee6.kr.dm.ArrayOfJagu4;
import ee.xtee6.kr.dm.Client;
import ee.xtee6.kr.dm.Detailandmed;
import ee.xtee6.kr.dm.IKr;
import ee.xtee6.kr.dm.KinnistuDetailandmedRequest;
import ee.xtee6.kr.dm.KinnistuDetailandmedResponse;
import ee.xtee6.kr.dm.Kr;
import ee.xtee6.kr.dm.Service;
import jakarta.xml.ws.Holder;
import jakarta.xml.ws.WebServiceException;
public class DetailandmedService extends KrCommon {
protected static Kr srv = new Kr();
protected DetailandmedService() {}
public static KinnistuDetailandmedResponse getKinnistuAjaloolisedAndmed(DetailandmedXRoadParams params,
String userid, String roNumber, String jaoNumbrid) throws ServiceFaultException {
return getKinnistuAndmed(params, userid, roNumber, jaoNumbrid, "0");
}
public static KinnistuDetailandmedResponse getKinnistuAndmed(DetailandmedXRoadParams params, String userid,
String roNumber, String jaoNumbrid) throws ServiceFaultException {
return getKinnistuAndmed(params, userid, roNumber, jaoNumbrid, "1");
}
private static KinnistuDetailandmedResponse getKinnistuAndmed(DetailandmedXRoadParams params, String userid,
String roNumber, String jaoNumbrid, String kehtivad) throws ServiceFaultException {
KinnistuDetailandmedRequest request = new KinnistuDetailandmedRequest();
request.setRegistriosaNr(roNumber);
request.setKandeKehtivus(kehtivad);
if (jaoNumbrid != null) {
request.setJaoNr(jaoNumbrid);
}
Holder detailandmed = new Holder<>();
Holder jagu0 = new Holder<>();
Holder jagu1 = new Holder<>();
Holder jagu2 = new Holder<>();
Holder jagu3 = new Holder<>();
Holder jagu4 = new Holder<>();
Holder kood = new Holder<>();
Holder teade = new Holder<>();
var id = ServiceUtils.getRequestId();
try {
params.getPort().kinnistuDetailandmed(request, detailandmed, jagu0, jagu1, jagu2, jagu3, jagu4, kood, teade,
params.getClient(), params.getService(), userid, id, ServiceUtils.getProtocolVersion());
} catch (WebServiceException ex) {
throw new ServiceFaultException(ex.getClass().getSimpleName(), ex.getMessage(), id);
}
if (kood.value != 0) {
throw new ServiceFaultException(kood.value.toString(), teade.value, id);
}
KinnistuDetailandmedResponse response = new KinnistuDetailandmedResponse();
if (roNumber.equals(detailandmed.value.getRegistriosaNr())) {
response.setDetailandmed(detailandmed.value);
response.setJagu0(jagu0.value);
response.setJagu1(jagu1.value);
response.setJagu2(jagu2.value);
response.setJagu3(jagu3.value);
response.setJagu4(jagu4.value);
}
return response;
}
protected static Service getServiceIdentifier(String xroadInstance) {
return getServiceIdentifier(xroadInstance, memberClass, serviceCode, subsystemCode, "Kinnistu_Detailandmed",
null);
}
protected static IKr getServicePort(String serverUrl) {
IKr port = srv.getBasicHttpBindingIKr();
ServiceUtils.connectPort(port, serverUrl);
return port;
}
protected static Client getClientIdentifier(String xroadInstance, String memberClass, String memberCode,
String subsystemCode) {
var client = new Client();
ServiceUtils.getXRoadIdentifierType(client, xroadInstance, memberClass, memberCode, subsystemCode);
return client;
}
protected static Service getServiceIdentifier(String xroadInstance, String memberClass, String memberCode,
String subsystemCode, String serviceCode, String serviceVersion) {
var server = new Service();
ServiceUtils.getXRoadIdentifierType(server, xroadInstance, memberClass, memberCode, subsystemCode, serviceCode,
serviceVersion);
return server;
}
public static class DetailandmedXRoadParams {
private IKr port;
private Client client;
private Service service;
public DetailandmedXRoadParams(String serverUrl, String xRoadInstance, String memberClass, String memberCode,
String subsystemCode) {
port = getServicePort(serverUrl);
client = getClientIdentifier(xRoadInstance, memberClass, memberCode, subsystemCode);
service = getServiceIdentifier(xRoadInstance);
}
public Service getService() {
return service;
}
public Client getClient() {
return client;
}
public IKr getPort() {
return port;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy