|
|
|
@ -1,6 +1,8 @@ |
|
|
|
|
package me.bearns.fias.service; |
|
|
|
|
|
|
|
|
|
import me.bearns.fias.domain.FiasVersion; |
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
import ru.nalog.fias.ArrayOfDownloadFileInfo; |
|
|
|
|
import ru.nalog.fias.DownloadFileInfo; |
|
|
|
|
import ru.nalog.fias.IDownloadService; |
|
|
|
|
import ru.nalog.fias.IDownloadService_Service; |
|
|
|
@ -13,7 +15,10 @@ import java.io.InputStream; |
|
|
|
|
import java.net.URL; |
|
|
|
|
import java.nio.file.Files; |
|
|
|
|
import java.nio.file.StandardCopyOption; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
import static javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY; |
|
|
|
|
|
|
|
|
@ -52,11 +57,60 @@ public class SOAPClient implements OnlineVersion { |
|
|
|
|
@Override |
|
|
|
|
public long getLastVersionId() { |
|
|
|
|
|
|
|
|
|
FiasVersion last = getLast(); |
|
|
|
|
if(last != null) return last.getVersionId(); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<FiasVersion> getVersionsAfter(long version) { |
|
|
|
|
|
|
|
|
|
final ArrayOfDownloadFileInfo allDownloadFileInfo = downloadService.getAllDownloadFileInfo(); |
|
|
|
|
|
|
|
|
|
if(allDownloadFileInfo != null) { |
|
|
|
|
|
|
|
|
|
final List<DownloadFileInfo> fileInfos = allDownloadFileInfo.getDownloadFileInfo(); |
|
|
|
|
|
|
|
|
|
if(fileInfos != null) { |
|
|
|
|
return fileInfos.stream() |
|
|
|
|
.filter(f -> f.getVersionId() > version) |
|
|
|
|
.map(f -> new FiasVersion(f.getVersionId(),f.getTextVersion(),f.getFiasCompleteXmlUrl(),f.getFiasDeltaXmlUrl())) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<FiasVersion> getLastVersion() { |
|
|
|
|
|
|
|
|
|
final FiasVersion last = getLast(); |
|
|
|
|
|
|
|
|
|
if(last != null) { |
|
|
|
|
|
|
|
|
|
final ArrayList<FiasVersion> list = new ArrayList<>(1); |
|
|
|
|
list.add(last); |
|
|
|
|
|
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private FiasVersion getLast() { |
|
|
|
|
|
|
|
|
|
DownloadFileInfo fileInfo = downloadService.getLastDownloadFileInfo(); |
|
|
|
|
|
|
|
|
|
if(fileInfo != null) return fileInfo.getVersionId(); |
|
|
|
|
if(fileInfo !=null) { |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
//TODO check null in getVersionId()
|
|
|
|
|
|
|
|
|
|
return new FiasVersion(fileInfo.getVersionId(), fileInfo.getTextVersion(), fileInfo.getFiasCompleteXmlUrl(), fileInfo.getFiasDeltaXmlUrl()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void setRedirect(final Object bindingProvider) { |
|
|
|
|