package sikd.sikd5.sikd5service;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.naming.Context;
import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;

import sikd.sikd5.sikd5bean.fault.SIKDServiceException;
import sikd.sikd5.sikd5bean.tabel.mgr.TUserAccount;
import sikd.sikd5.sikd5bean.util.PropertiesLoader;
import sikd.sikd5.sikd5bean.util.ServerUtil;
import sikd.sikd5.sikd5bean.util.SikdSessionUtil;
import sikd.sikd5.sikd5bean.util.UnzipFileUtil;
import sikd.sikd5.sikd5bean.util.XmlServiceUtil;
import sikd.sikd5.sikd5bean.ws.ref.VersiAplikasi_WS;
import sikd.sikd5.sikd5bean.ws.transaksi.Headerlog_WS;
import sikd.sikd5.sikd5ejb.session.TransaksiSessionBeanRemote;
import sikd.sikd5.sikd5ejb.session.login.LoginSessionBeanRemote;
import sikd.sikd5.sikd5service.util.XmlSikdUtil;

/**
 * @oleh : agus
 * @tanggal : Apr 8, 2019
 */
@WebService(serviceName = "TransaksiService")
@Stateless
public class TransaksiService {
	 @Resource
	  WebServiceContext wsContext;

//    @WebMethod(operationName = "inputBelanjas")
//    @SuppressWarnings("null")
//    public Headerlog_WS inputBelanjas(
//            @WebParam(name = "userName") String userName,
//            @WebParam(name = "password") String password,
//            @WebParam(name = "headerlog") Headerlog_WS headerlog)
//            throws SIKDServiceException {
//        Headerlog_WS result = new Headerlog_WS();
//        try {
//            Context ctxOffice = ServerUtil.getOfficeContextV3();
//            TransaksiSessionBeanRemote session = (TransaksiSessionBeanRemote) ctxOffice.lookup(SikdSessionUtil.TRANSAKSI_SESSION);
////			result = "Format Benar.. data belum masuk, untuk kirim data silahkan menggunakan method kirimPerkiraanBelanjaXmlZip";
////            session.insert(perkiraanBelanja, nmfile);
//            LoginSessionBeanRemote sessionLogin = (LoginSessionBeanRemote) ctxOffice
//                    .lookup(SikdSessionUtil.LOGIN_SESSION);
//            TUserAccount tuserAccount = sessionLogin.getUserAccountbyName(userName);
//
//            if (userName == null) {
//                throw new SIKDServiceException("Username kosong..");
//            }
//            if (password == null) {
//                throw new SIKDServiceException("Password kosong..");
//            }
//            if (headerlog == null) {
//                throw new SIKDServiceException("Header kosong..");
//            }
//            if (headerlog.getKodesatker() == null) {
//                throw new SIKDServiceException("Kode Satker kosong..");
//            }
//            if (headerlog.getKodepemda() == null) {
//                throw new SIKDServiceException("Kode Pemda kosong..");
//            }
//
//            XmlSikdUtil.cekLoginService(headerlog.getKodesatker(), headerlog.getKodepemda(), userName, password, tuserAccount);
//            result = session.inputBelanja(headerlog);
//        } catch (Exception e) {
//            result.setKet(e.getMessage());
//        }
//        return result;
//    }
	@WebMethod(operationName = "inputJurnals")
	@SuppressWarnings("null")
	public Headerlog_WS inputJurnals(
			@WebParam(name = "userName") String userName,
			@WebParam(name = "password") String password,
			@WebParam(name = "headerlog") Headerlog_WS headerlog)
			throws SIKDServiceException {
		Headerlog_WS result = new Headerlog_WS();
		try {
			Context ctxOffice = ServerUtil.getOfficeContextV3();
			TransaksiSessionBeanRemote session = (TransaksiSessionBeanRemote) ctxOffice.lookup(SikdSessionUtil.TRANSAKSI_SESSION);
//			result = "Format Benar.. data belum masuk, untuk kirim data silahkan menggunakan method kirimPerkiraanBelanjaXmlZip";
//            session.insert(perkiraanBelanja, nmfile);
			LoginSessionBeanRemote sessionLogin = (LoginSessionBeanRemote) ctxOffice
					.lookup(SikdSessionUtil.LOGIN_SESSION);
			TUserAccount tuserAccount = sessionLogin.getUserAccountbyName(userName);

			if (userName == null) {
				throw new SIKDServiceException("Username kosong..");
			}
			if (password == null) {
				throw new SIKDServiceException("Password kosong..");
			}
			if (headerlog == null) {
				throw new SIKDServiceException("Header kosong..");
			}
			if (headerlog.getKodesatker() == null) {
				throw new SIKDServiceException("Kode Satker kosong..");
			}
			if (headerlog.getKodepemda() == null) {
				throw new SIKDServiceException("Kode Pemda kosong...");
			}

			XmlSikdUtil.cekLoginService(headerlog.getKodesatker(), headerlog.getKodepemda(), userName, password, tuserAccount);
			result = session.inputJurnal(headerlog);
		} catch (Exception e) {
			result.setKet(e.getMessage());
			throw new SIKDServiceException(e.getMessage());
		}
		return result;
	}

	@WebMethod(operationName = "coba")
	@SuppressWarnings("null")
	public String coba() {
		return "Berhasil coba...";
	}

	@WebMethod(operationName = "inputApbds")
	@SuppressWarnings("null")
	public Headerlog_WS inputApbds(
			@WebParam(name = "userName") String userName,
			@WebParam(name = "password") String password,
			@WebParam(name = "headerlog") Headerlog_WS headerlog)
			throws SIKDServiceException {
		Headerlog_WS result = new Headerlog_WS();
		try {
			Context ctxOffice = ServerUtil.getOfficeContextV3();
			TransaksiSessionBeanRemote session = (TransaksiSessionBeanRemote) ctxOffice.lookup(SikdSessionUtil.TRANSAKSI_SESSION);
//			result = "Format Benar.. data belum masuk, untuk kirim data silahkan menggunakan method kirimPerkiraanBelanjaXmlZip";
//            session.insert(perkiraanBelanja, nmfile);
			LoginSessionBeanRemote sessionLogin = (LoginSessionBeanRemote) ctxOffice
					.lookup(SikdSessionUtil.LOGIN_SESSION);

			if (userName == null) {
				throw new SIKDServiceException("Username kosong..");
			}
			if (password == null) {
				throw new SIKDServiceException("Password kosong..");
			}
			if (headerlog == null) {
				throw new SIKDServiceException("Header kosong..");
			}
			if (headerlog.getKodesatker() == null) {
				throw new SIKDServiceException("Kode Satker kosong..");
			}
			if (headerlog.getKodepemda() == null) {
				throw new SIKDServiceException("Kode Pemda kosong...");
			}
			TUserAccount tuserAccount = sessionLogin.getUserAccountbyName(userName);
			XmlSikdUtil.cekLoginService(headerlog.getKodesatker(), headerlog.getKodepemda(), userName, password, tuserAccount);
			result = session.inputApbd(headerlog);
		} catch (Exception e) {
			result.setKet(e.getMessage());
			throw new SIKDServiceException(e.getMessage());
		}
		return result;
	}
//int nomorSkpd,String namaskpd,String sha256skpd
	@WebMethod(operationName = "inputApbdPerSkpd")
	@SuppressWarnings("null")
	public Headerlog_WS inputApbdPerSkpd(
			@WebParam(name = "userName") String userName,
			@WebParam(name = "password") String password,
			@WebParam(name = "headerlog") Headerlog_WS headerlog,
			@WebParam(name = "nomorSkpd") int nomorSkpd,
			@WebParam(name = "namaskpd") String namaskpd,
			@WebParam(name = "sha256skpd") String sha256skpd
			)
			throws SIKDServiceException {
		Headerlog_WS result = new Headerlog_WS();
		try {
			Context ctxOffice = ServerUtil.getOfficeContextV3();
			TransaksiSessionBeanRemote session = (TransaksiSessionBeanRemote) ctxOffice.lookup(SikdSessionUtil.TRANSAKSI_SESSION);
			LoginSessionBeanRemote sessionLogin = (LoginSessionBeanRemote) ctxOffice
					.lookup(SikdSessionUtil.LOGIN_SESSION);

			if (userName == null) {
				throw new SIKDServiceException("Username kosong..");
			}
			if (password == null) {
				throw new SIKDServiceException("Password kosong..");
			}
			if (headerlog == null) {
				throw new SIKDServiceException("Header kosong..");
			}
			if (headerlog.getKodesatker() == null) {
				throw new SIKDServiceException("Kode Satker kosong..");
			}
			if (headerlog.getKodepemda() == null) {
				throw new SIKDServiceException("Kode Pemda kosong...");
			}
			TUserAccount tuserAccount = sessionLogin.getUserAccountbyName(userName);
			XmlSikdUtil.cekLoginService(headerlog.getKodesatker(), headerlog.getKodepemda(), userName, password, tuserAccount);
			result = session.inputApbdPerSkpd(headerlog,nomorSkpd,namaskpd,sha256skpd);
		} catch (Exception e) {
			result.setKet(e.getMessage());
			throw new SIKDServiceException(e.getMessage());
		}
		return result;
	}

	@WebMethod(operationName = "inputApbdsZip")
	@SuppressWarnings("null")
	public Headerlog_WS inputApbdsZip(
			@WebParam(name = "userName") String userName,
			@WebParam(name = "password") String password,
			@WebParam(name = "headerlog") Headerlog_WS headerlog,
			@WebParam(name = "berkasApbd") byte[] berkasApbd
			)
			throws SIKDServiceException {
		Headerlog_WS result = new Headerlog_WS();
		try {
			Context ctxOffice = ServerUtil.getOfficeContextV3();
			TransaksiSessionBeanRemote session = (TransaksiSessionBeanRemote) ctxOffice.lookup(SikdSessionUtil.TRANSAKSI_SESSION);
			LoginSessionBeanRemote sessionLogin = (LoginSessionBeanRemote) ctxOffice
					.lookup(SikdSessionUtil.LOGIN_SESSION);

			if (userName == null) {
				throw new SIKDServiceException("Username kosong..");
			}
			if (password == null) {
				throw new SIKDServiceException("Password kosong..");
			}
			if (headerlog == null) {
				throw new SIKDServiceException("Header kosong..");
			}
			if (headerlog.getKodesatker() == null) {
				throw new SIKDServiceException("Kode Satker kosong..");
			}
			if (headerlog.getKodepemda() == null) {
				throw new SIKDServiceException("Kode Pemda kosong...");
			}
			TUserAccount tuserAccount = sessionLogin.getUserAccountbyName(userName);
//            XmlSikdUtil.cekLoginService(headerlog.getKodesatker(), headerlog.getKodepemda(), userName, password, tuserAccount);
//            XmlSikdUtil.cekBerkasZip(berkasApbd);
//            Headerlog_WS berkasUnzip = getHeader_WS(berkasApbd);
//            
//            if(berkasUnzip.getHeaderapbd()!=null) {
//                result = session.inputApbd(berkasUnzip);
//            }
			Headerlog_WS berkasUnzip = getHeaderlogWS_ags(berkasApbd);
			if (berkasUnzip.getHeaderapbd() == null) {
				throw new SIKDServiceException("Berkas APBD kosong...");
			}
			result = session.inputApbd(berkasUnzip);
//            result.setKet(" inputApbds Masih dibuat ya...");
		} catch (Exception e) {
			result.setKet(e.getMessage());
			throw new SIKDServiceException(e.getMessage());
		}
		return result;
	}
        
	@WebMethod(operationName = "inputApbdsPerSkpdZip")
	@SuppressWarnings("null")
	public Headerlog_WS inputApbdPerSkpdZip(
			@WebParam(name = "userName") String userName,
			@WebParam(name = "password") String password,
			@WebParam(name = "headerlog") Headerlog_WS headerlog,
			@WebParam(name = "berkasApbd") byte[] berkasApbd,
			@WebParam(name = "nomorSkpd") int nomorSkpd,
			@WebParam(name = "namaskpd") String namaskpd,
			@WebParam(name = "sha256skpd") String sha256skpd
			)
			throws SIKDServiceException {
		Headerlog_WS result = new Headerlog_WS();
		try {
			Context ctxOffice = ServerUtil.getOfficeContextV3();
			TransaksiSessionBeanRemote session = (TransaksiSessionBeanRemote) ctxOffice.lookup(SikdSessionUtil.TRANSAKSI_SESSION);
			LoginSessionBeanRemote sessionLogin = (LoginSessionBeanRemote) ctxOffice
					.lookup(SikdSessionUtil.LOGIN_SESSION);

			if (userName == null) {
				throw new SIKDServiceException("Username kosong..");
			}
			if (password == null) {
				throw new SIKDServiceException("Password kosong..");
			}
			if (headerlog == null) {
				throw new SIKDServiceException("Header kosong..");
			}
			if (headerlog.getKodesatker() == null) {
				throw new SIKDServiceException("Kode Satker kosong..");
			}
			if (headerlog.getKodepemda() == null) {
				throw new SIKDServiceException("Kode Pemda kosong...");
			}
			TUserAccount tuserAccount = sessionLogin.getUserAccountbyName(userName);
			Headerlog_WS berkasUnzip = getHeaderlogWS_ags(berkasApbd);
			if (berkasUnzip.getHeaderapbd() == null) {
				throw new SIKDServiceException("Berkas APBD kosong...");
			}
			result = session.inputApbdPerSkpd(berkasUnzip,nomorSkpd,namaskpd,sha256skpd);
		} catch (Exception e) {
			result.setKet(e.getMessage());
			throw new SIKDServiceException(e.getMessage());
		}
		return result;
	}

	private static Headerlog_WS getHeader_WS(byte[] contents) throws Exception {
		Headerlog_WS result = null;
		String uploadPath = ((Properties) PropertiesLoader.loadProperties("sikd.properties")).getProperty("uploadPath");
		String[] filenya = UnzipFileUtil.simpanExtract(uploadPath, contents);
		File fxml = new File(filenya[1]);
		String fileName = fxml.getName();
		if (fxml.exists()) {
			Object obj = XmlServiceUtil.parsingXML(filenya[1]);
			if (obj != null) {
				if (obj instanceof Headerlog_WS) {
					result = (Headerlog_WS) obj;
					if (result.getHeaderapbd() != null) {
						result.getHeaderapbd().setNmfile(fileName);
					}
				}
			}
		}
		return result;
	}

	private static Headerlog_WS getHeaderlogWS_ags(byte[] contenzip) throws Exception {
		byte[] contenUnzip = unzipByte(contenzip);
		JAXBContext jc = JAXBContext.newInstance(Headerlog_WS.class);
		Unmarshaller um = jc.createUnmarshaller();
		InputStream ins = new ByteArrayInputStream(contenUnzip);
		return um.unmarshal(new StreamSource(ins), Headerlog_WS.class).getValue();
	}

	@WebMethod(operationName = "inputDths")
	@SuppressWarnings("null")
	public Headerlog_WS inputDths(
			@WebParam(name = "userName") String userName,
			@WebParam(name = "password") String password,
			@WebParam(name = "headerlog") Headerlog_WS headerlog)
			throws SIKDServiceException {
		Headerlog_WS result = new Headerlog_WS();
		try {
			Context ctxOffice = ServerUtil.getOfficeContextV3();
			TransaksiSessionBeanRemote session = (TransaksiSessionBeanRemote) ctxOffice.lookup(SikdSessionUtil.TRANSAKSI_SESSION);
//			result = "Format Benar.. data belum masuk, untuk kirim data silahkan menggunakan method kirimPerkiraanBelanjaXmlZip";
//            session.insert(perkiraanBelanja, nmfile);
			LoginSessionBeanRemote sessionLogin = (LoginSessionBeanRemote) ctxOffice
					.lookup(SikdSessionUtil.LOGIN_SESSION);

			if (userName == null) {
				throw new SIKDServiceException("Username kosong..");
			}
			if (password == null) {
				throw new SIKDServiceException("Password kosong..");
			}
			if (headerlog == null) {
				throw new SIKDServiceException("Header kosong..");
			}
			if (headerlog.getKodesatker() == null) {
				throw new SIKDServiceException("Kode Satker kosong..");
			}
			if (headerlog.getKodepemda() == null) {
				throw new SIKDServiceException("Kode Pemda kosong...");
			}
			TUserAccount tuserAccount = sessionLogin.getUserAccountbyName(userName);
			XmlSikdUtil.cekLoginService(headerlog.getKodesatker(), headerlog.getKodepemda(), userName, password, tuserAccount);
			result = session.inputDth(headerlog);
//            result.setKet(" inputDThs Masih dibuat ya...");
		} catch (Exception e) {
			result.setKet(e.getMessage());
			throw new SIKDServiceException(e.getMessage());
		}
		return result;
	}

	@WebMethod(operationName = "inputDthsZip")
	@SuppressWarnings("null")
	public Headerlog_WS inputDthsZip(
			@WebParam(name = "userName") String userName,
			@WebParam(name = "password") String password,
			@WebParam(name = "headerlog") Headerlog_WS headerlog,
			@WebParam(name = "berkasDth") byte[] berkasDth)
			throws SIKDServiceException {
		Headerlog_WS result = new Headerlog_WS();
		try {
			Context ctxOffice = ServerUtil.getOfficeContextV3();
			TransaksiSessionBeanRemote session = (TransaksiSessionBeanRemote) ctxOffice.lookup(SikdSessionUtil.TRANSAKSI_SESSION);
//			result = "Format Benar.. data belum masuk, untuk kirim data silahkan menggunakan method kirimPerkiraanBelanjaXmlZip";
//            session.insert(perkiraanBelanja, nmfile);
			LoginSessionBeanRemote sessionLogin = (LoginSessionBeanRemote) ctxOffice
					.lookup(SikdSessionUtil.LOGIN_SESSION);

			if (userName == null) {
				throw new SIKDServiceException("Username kosong..");
			}
			if (password == null) {
				throw new SIKDServiceException("Password kosong..");
			}
			if (headerlog == null) {
				throw new SIKDServiceException("Header kosong..");
			}
			if (headerlog.getKodesatker() == null) {
				throw new SIKDServiceException("Kode Satker kosong..");
			}
			if (headerlog.getKodepemda() == null) {
				throw new SIKDServiceException("Kode Pemda kosong...");
			}
//            FileOutputStream fileOuputStream = new FileOutputStream("/home/agus/tmp_sikd/tes_zipdth.zip");
//            fileOuputStream.write(berkasDth);
//            fileOuputStream.close();
//            XmlSikdUtil.cekLoginService(headerlog.getKodesatker(), headerlog.getKodepemda(), userName, password, tuserAccount);
//            XmlSikdUtil.cekBerkasZip(berkasDth);
//            Headerlog_WS berkasUnzip = getHeader_WS(berkasDth);
//            
//            if(berkasUnzip.getHeaderdths()!=null) {
//                result = session.inputDth(berkasUnzip);
//            }
			TUserAccount tuserAccount = sessionLogin.getUserAccountbyName(userName);
			Headerlog_WS berkasUnzip = getHeaderlogWS_ags(berkasDth);
			if (berkasUnzip.getHeaderdths() == null) {
				throw new SIKDServiceException("Berkas DTH kosong...");
			}
			result = session.inputDth(berkasUnzip);
//            result.setKet(" inputApbds Masih dibuat ya...");
		} catch (Exception e) {
			result.setKet(e.getMessage());
			throw new SIKDServiceException(e.getMessage());
		}
		return result;
	}

	@WebMethod(operationName = "inputJurnalsZip")
	@SuppressWarnings("null")
	public Headerlog_WS inputJurnalsZip(
			@WebParam(name = "userName") String userName,
			@WebParam(name = "password") String password,
			@WebParam(name = "headerlog") Headerlog_WS headerlog,
			@WebParam(name = "berkasJurnal") byte[] berkasJurnal)
			throws SIKDServiceException {
		Headerlog_WS result = new Headerlog_WS();
		try {
			Context ctxOffice = ServerUtil.getOfficeContextV3();
			TransaksiSessionBeanRemote session = (TransaksiSessionBeanRemote) ctxOffice.lookup(SikdSessionUtil.TRANSAKSI_SESSION);
//			result = "Format Benar.. data belum masuk, untuk kirim data silahkan menggunakan method kirimPerkiraanBelanjaXmlZip";
//            session.insert(perkiraanBelanja, nmfile);
//            FileOutputStream fileOuputStream = new FileOutputStream("/home/agus/tmp_sikd/tes_zipdefault.zip");
//            fileOuputStream.write(berkasJurnal);
//            fileOuputStream.close();
//            
//
//            byte[] outputUnzip = unzipByte(berkasJurnal);
//            
//            FileOutputStream fileOuputStream2 = new FileOutputStream("/home/agus/tmp_sikd/tes_zipdefault.xml");
//            fileOuputStream2.write(outputUnzip);
//            fileOuputStream2.close();
//            

			LoginSessionBeanRemote sessionLogin = (LoginSessionBeanRemote) ctxOffice
					.lookup(SikdSessionUtil.LOGIN_SESSION);

			if (userName == null) {
				throw new SIKDServiceException("Username kosong..");
			}
			if (password == null) {
				throw new SIKDServiceException("Password kosong..");
			}
			if (headerlog == null) {
				throw new SIKDServiceException("Header kosong..");
			}
			if (headerlog.getKodesatker() == null) {
				throw new SIKDServiceException("Kode Satker kosong..");
			}
			if (headerlog.getKodepemda() == null) {
				throw new SIKDServiceException("Kode Pemda kosong...");
			}

//            XmlSikdUtil.cekLoginService(headerlog.getKodesatker(), headerlog.getKodepemda(), userName, password, tuserAccount);
//            XmlSikdUtil.cekBerkasZip(berkasJurnal);
//            Headerlog_WS berkasUnzip = getHeader_WS(berkasJurnal);
			TUserAccount tuserAccount = sessionLogin.getUserAccountbyName(userName);
			Headerlog_WS berkasUnzip = getHeaderlogWS_ags(berkasJurnal);
			if (berkasUnzip.getHeaderjurnals() == null) {
				throw new SIKDServiceException("Berkas kosong...");
			}
			result = session.inputJurnal(berkasUnzip);
			// result.setKet(" inputApbds Masih dibuat ya...");
		} catch (Exception e) {
			System.out.println(e.getMessage());
			result.setKet(e.getMessage());
			e.printStackTrace();
			throw new SIKDServiceException(e.getMessage());
		}
		return result;
	}

	public static byte[] unzipByte(byte[] input) throws IOException {
		ByteArrayInputStream bais = new ByteArrayInputStream(input);
		ZipInputStream zis = new java.util.zip.ZipInputStream(bais);
		ZipEntry zipEntry = zis.getNextEntry();
		byte[] buffer = new byte[1024];
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream(input.length);
		while (zipEntry != null) {
			int len;
			while ((len = zis.read(buffer)) > 0) {
				outputStream.write(buffer, 0, len);
			}
//            fos.close();
			zipEntry = zis.getNextEntry();
		}
		zis.closeEntry();
		zis.close();
		return outputStream.toByteArray();
	}

	@WebMethod(operationName = "cekVersiAplikasi")
	@SuppressWarnings("null")
	public VersiAplikasi_WS cekVersiAplikasi(
			@WebParam(name = "kodesatker") String kodesatker,
			@WebParam(name = "ip") String ip,
			@WebParam(name = "tanggalLocal") Date tanggalLocal,
			@WebParam(name = "namaAplikasi") String namaAplikasi,
			@WebParam(name = "versiAplikasi") String versiAplikasi)
			throws SIKDServiceException {
		VersiAplikasi_WS result = new VersiAplikasi_WS();
		Context ctxOffice;
		try {
			 MessageContext mc = wsContext.getMessageContext();
			    HttpServletRequest req = (HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST); 
			    System.out.println("Client IP = " + req.getRemoteAddr()); 
			    ip = req.getRemoteAddr();
			ctxOffice = ServerUtil.getOfficeContextV3();
			TransaksiSessionBeanRemote session = (TransaksiSessionBeanRemote) ctxOffice.lookup(SikdSessionUtil.TRANSAKSI_SESSION);
                        result = session.cekVersiAplikasi(kodesatker, ip, tanggalLocal, namaAplikasi, versiAplikasi);
		} catch (Exception e) {
			System.out.println(e.getMessage());
			result.setKet(e.getMessage());
			e.printStackTrace();
			throw new SIKDServiceException(e.getMessage());
		}

		return result;
	}
}
