Fix login oauth

This commit is contained in:
Giuseppe Scorrano 2025-02-12 16:28:08 +01:00
parent d7eeeeeac2
commit 726d9fd29c
33 changed files with 208 additions and 233 deletions

View File

@ -116,6 +116,11 @@ dependencies {
implementation 'com.google.firebase:firebase-perf'
implementation 'com.google.android.gms:play-services-basement:18.5.0'
//JJWT
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

View File

@ -220,8 +220,8 @@ public class MainApplicationModule {
@Provides
@Singleton
ProduzioneRESTConsumer provideProduzioneRESTConsumer() {
return new ProduzioneRESTConsumer();
ProduzioneRESTConsumer provideProduzioneRESTConsumer(RESTBuilder restBuilder) {
return new ProduzioneRESTConsumer(restBuilder);
}
@Provides
@ -334,8 +334,8 @@ public class MainApplicationModule {
@Provides
@Singleton
MaterialiRESTConsumer provideMaterialiRESTConsumer(ExecutorService executorService) {
return new MaterialiRESTConsumer(executorService);
MaterialiRESTConsumer provideMaterialiRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
return new MaterialiRESTConsumer(restBuilder, executorService);
}
@Provides

View File

@ -0,0 +1,21 @@
package it.integry.integrywmsnative.core.authentication;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
public class JwtUtils {
private final static String SIGNING_KEY = "gICy3bjD56i/YFnBZZKe5ibiz3Snsp08nybGGziCV4ZcvyXBbyqWUnJ2wTrRXhOuf/xdljPXX0yBaqdAgvKthQ==";
public static Claims parseJwt(String token) {
Jws<Claims> jws = Jwts.parserBuilder()
.setSigningKey(Keys.hmacShaKeyFor(Decoders.BASE64.decode(SIGNING_KEY)))
.build()
.parseClaimsJws(token);
return jws.getBody();
}
}

View File

@ -16,8 +16,14 @@ import retrofit2.Response;
@Singleton
public class MenuRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public MenuRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void retrieveMenu(String rootCodOpz, RunnableArgs<StbMenu> onComplete, RunnableArgs<Exception> onFailed) {
MenuRESTConsumerService menuRESTConsumerService = RESTBuilder.getService(MenuRESTConsumerService.class);
MenuRESTConsumerService menuRESTConsumerService = restBuilder.getService(MenuRESTConsumerService.class);
menuRESTConsumerService.retrieveMenuConfig(rootCodOpz).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<StbMenu>> call, Response<ServiceRESTResponse<StbMenu>> response) {

View File

@ -2,10 +2,10 @@ package it.integry.integrywmsnative.core.rest;
import androidx.annotation.NonNull;
import com.auth0.android.jwt.JWT;
import java.io.IOException;
import io.jsonwebtoken.Claims;
import it.integry.integrywmsnative.core.authentication.JwtUtils;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.gest.login.rest.RefreshRESTConsumer;
@ -36,11 +36,11 @@ public class AuthInterceptor implements Interceptor {
try {
var response = refreshRESTConsumer.makeSynchronousRefreshTokenRequest();
JWT jwt = new JWT(response.getAccessToken());
Claims claims = JwtUtils.parseJwt(response.getAccessToken());
SettingsManager.i().getUserSession()
.setAccessToken(response.getAccessToken())
.setAccessTokenExpiryDate(UtilityDate.toLocalDateTime(jwt.getExpiresAt()))
.setAccessTokenExpiryDate(UtilityDate.toLocalDateTime(claims.getExpiration()))
.setRefreshToken(response.getRefreshToken())
.setRefreshTokenExpiryDate(response.getExpiryDate());

View File

@ -35,15 +35,17 @@ import retrofit2.Response;
@Singleton
public class ArticoloRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer systemRESTConsumer;
public ArticoloRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
public ArticoloRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.systemRESTConsumer = systemRESTConsumer;
}
public void retrieveAvailableUntMis(RunnableArgs<List<MtbUntMis>> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumerService
.retrieveAvailableUntMis()
.enqueue(new ManagedErrorCallback<>() {
@ -60,7 +62,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
}
public void retrieveAvailableGruppiMerceologici(RunnableArgs<List<MtbGrup>> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumerService
.retrieveAvailableGruppiMerceologici()
.enqueue(new ManagedErrorCallback<>() {
@ -77,7 +79,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
}
public void searchByBarcode(String barcodeProd, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
var request = new SearchArticoloByBarcodeRequestDTO()
.setBarcode(barcodeProd)
@ -101,7 +103,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
}
public void findIfIsKit(MtbAart mtbAart, RunnableArgs<MtbAart> onComplete, RunnableArgs<Exception> onFailed){
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumerService
.findIfIsKit(mtbAart)
@ -121,17 +123,12 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
}
public void getByCodMarts(List<String> codMartToFind, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
getByCodMartsStatic(codMartToFind, onComplete, onFailed);
}
public static void getByCodMartsStatic(List<String> codMartToFind, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
var codMarts = Stream.of(codMartToFind)
.withoutNulls()
.distinct().toList();
ArticoloRESTConsumerService articoloRESTConsumer = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumer = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumer
.getByCodMart(new RetrieveArticoloByCodMartRequestDTO()
.setCodMarts(codMarts))
@ -151,7 +148,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
public void getStatoPartita(String codMart, String partitaMag, RunnableArgs<List<StatoArticoloDTO>> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumer = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumer = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumer.getStatoPartita(codMart, partitaMag).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<StatoArticoloDTO>>> call, Response<ServiceRESTResponse<List<StatoArticoloDTO>>> response) {
@ -242,7 +239,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
public void updateBarcodeImballo(String codMart, String newBarcodeImballo, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
var request = new UpdateBarcodeImballoRequestDTO()
.setCodMart(codMart)
@ -267,7 +264,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
public void saveArticolo(ArticoloDTO articoloToSave, RunnableArgs<String> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class);
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
var request = new SaveArticoloRequestDTO()
.setArtToSave(articoloToSave);

View File

@ -15,8 +15,14 @@ import retrofit2.Response;
@Singleton
public class AziendaRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public AziendaRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void retrieveAzienda(RunnableArgs<Azienda> onComplete, RunnableArgs<Exception> onFailed) {
AziendaRESTConsumerService aziendaRESTConsumerService = RESTBuilder.getService(AziendaRESTConsumerService.class);
AziendaRESTConsumerService aziendaRESTConsumerService = restBuilder.getService(AziendaRESTConsumerService.class);
aziendaRESTConsumerService.retrieveDefaultAzienda().enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Azienda>> call, Response<ServiceRESTResponse<Azienda>> response) {

View File

@ -123,7 +123,7 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements
}
public void checkBarcodeUl(String barcodeUl, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed){
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class);
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.checkIfBarcodeUlAlreadyRegistered(barcodeUl)
.enqueue(new ManagedErrorCallback<>() {

View File

@ -53,15 +53,17 @@ import retrofit2.Response;
@Singleton
public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer mSystemRESTConsumer;
private final ArticoloRESTConsumer mArticoloRESTConsumer;
private final EntityRESTConsumer mEntityRESTConsumer;
private final SettingsManager mSettingsManager;
public ColliMagazzinoRESTConsumer(SystemRESTConsumer systemRESTConsumer,
public ColliMagazzinoRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer,
ArticoloRESTConsumer articoloRESTConsumer,
EntityRESTConsumer entityRESTConsumer,
SettingsManager settingsManager) {
this.restBuilder = restBuilder;
this.mSystemRESTConsumer = systemRESTConsumer;
this.mArticoloRESTConsumer = articoloRESTConsumer;
this.mEntityRESTConsumer = entityRESTConsumer;
@ -285,7 +287,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public void getBySSCC(String ssccString, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.getColloByBarcode(ssccString, onlyResiduo, throwExcIfNull).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
@ -310,10 +312,6 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
fillMtbAartsOfMtbColtsStatic(mtbColts, onComplete, onFailed);
}
public static void fillMtbAartsOfMtbColtsStatic(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
List<String> codMarts = new ArrayList<>();
for (MtbColt mtbColt : mtbColts) {
@ -325,7 +323,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
ArticoloRESTConsumer.getByCodMartsStatic(codMarts, arts -> {
mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
if (arts != null && !arts.isEmpty()) {
for (MtbColt mtbColt : mtbColts) {
@ -385,7 +383,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
testata.setMtbColr(new ObservableArrayList<>());
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.getColloInGiac(onlyResiduo, throwExcIfNull, testata)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -425,7 +423,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbColtsToMove(Collections.singletonList(mtbColtToMoveClone))
.setCreateDocAutomatically(createDocAutomatically);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService
.spostaUL(spostaUlRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -460,7 +458,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbColt(mtbColtClone)
.setCodTcol(codTcol);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService
.updateTipoUL(updateTipoULRequest)
.enqueue(new ManagedErrorCallback<>() {
@ -495,13 +493,13 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public static void retrieveBasketColli(RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
public void retrieveBasketColli(RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.getColliInBasket(SettingsManager.i().getUserSession().getDepo().getCodMdep()).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<MtbColt>>> call, Response<ServiceRESTResponse<List<MtbColt>>> response) {
analyzeAnswer(response, "getColliInBasket", mtbColts -> {
fillMtbAartsOfMtbColtsStatic(mtbColts, onComplete, onFailed);
fillMtbAartsOfMtbColts(mtbColts, onComplete, onFailed);
}, onFailed);
}
@ -522,7 +520,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setNewNumCnf(newNumCnf)
.setNewQtaCol(newQtaTot);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.creaRettificaCollo(
SettingsManager.i().getUserSession().getDepo().getCodMdep(),
rettificaULDTO
@ -557,7 +555,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setDestinationMtbColt(mtbColtDestClone)
.setFlagForceUseRefs(flagForceUseRefs);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> call, Response<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> response) {
@ -583,7 +581,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbPartitaMag(null);
}
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
@ -608,7 +606,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbPartitaMag(null);
}
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.versamentoAutomaticoUL(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<VersamentoAutomaticoULResponseDTO>> call, Response<ServiceRESTResponse<VersamentoAutomaticoULResponseDTO>> response) {
@ -656,7 +654,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone();
sourceMtbColtClone.setMtbColr(new ObservableArrayList<>());
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.confirmGiacenzaUL(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
@ -704,7 +702,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
CanULBeDeletedRequestDTO canULBeDeletedRequestDTO = new CanULBeDeletedRequestDTO()
.setMtbColt(mtbColt);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.canULBeDeleted(canULBeDeletedRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -722,7 +720,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public void deleteUL(DeleteULRequestDTO deleteULRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.deleteUL(deleteULRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -745,7 +743,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
return;
}
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.printUL(printULRequestDTO)
.enqueue(new ManagedErrorCallback<>() {

View File

@ -123,7 +123,7 @@ public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements Co
}
public void duplicateUDS(DuplicateUDSRequestDTO duplicateUDSRequestDTO, RunnableArgs<DuplicateUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class);
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.duplicateUDS(duplicateUDSRequestDTO)
.enqueue(new ManagedErrorCallback<>() {

View File

@ -19,9 +19,14 @@ import retrofit2.Response;
@Singleton
public class DocumentRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public DocumentRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void createDocsFromColli(List<LoadColliDTO> listColli, RunnableArgs<List<DtbDoct>> onComplete, RunnableArgs<Exception> onFailed) {
DocumentiRESTConsumerService documentiRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class);
DocumentiRESTConsumerService documentiRESTConsumerService = restBuilder.getService(DocumentiRESTConsumerService.class);
documentiRESTConsumerService.createDocsFromColli(listColli).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<DtbDoct>>> call, Response<ServiceRESTResponse<List<DtbDoct>>> response) {
@ -36,7 +41,7 @@ public class DocumentRESTConsumer extends _BaseRESTConsumer {
}
public void createDocFromColli(LoadColliDTO loadColliDTO, RunnableArgs<DtbDoct> onComplete, RunnableArgs<Exception> onFailed) {
DocumentiRESTConsumerService documentiRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class);
DocumentiRESTConsumerService documentiRESTConsumerService = restBuilder.getService(DocumentiRESTConsumerService.class);
documentiRESTConsumerService.createDocFromColli(loadColliDTO).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<DtbDoct>> call, Response<ServiceRESTResponse<DtbDoct>> response) {
@ -51,7 +56,7 @@ public class DocumentRESTConsumer extends _BaseRESTConsumer {
}
public void checkDocument(String fornitore, String numDoc, String dataDoc, String tipoDoc, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class);
var inventarioRESTConsumerService = restBuilder.getService(DocumentiRESTConsumerService.class);
inventarioRESTConsumerService.checkDocument(fornitore, numDoc,tipoDoc, dataDoc)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -67,7 +72,7 @@ public class DocumentRESTConsumer extends _BaseRESTConsumer {
}
public void loadDocumentAvailableArts(String codDtip, String codMgrp, String codAnagForn, RunnableArgs<RetrieveDocumentoArtsResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class);
var inventarioRESTConsumerService = restBuilder.getService(DocumentiRESTConsumerService.class);
inventarioRESTConsumerService.retrieveArts(codDtip, codMgrp, codAnagForn)
.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -20,8 +20,14 @@ import retrofit2.Response;
@Singleton
public class GestSetupRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public GestSetupRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void getValue(String gestName, String sectionName, String keySection, RunnableArgs<GestSetupDTO> onComplete, RunnableArgs<Exception> onFailed) {
GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class);
GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
service.getGestSetupValue(gestName, sectionName, keySection)
.enqueue(new ManagedErrorCallback<>() {
@ -48,7 +54,7 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
}
public void getValue(String gestName, String sectionName, String keySection, String codMdep, RunnableArgs<GestSetupDTO> onComplete, RunnableArgs<Exception> onFailed) {
GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class);
GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
service.getGestSetupValue(gestName, sectionName, keySection, codMdep).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<GestSetupDTO>> call, Response<ServiceRESTResponse<GestSetupDTO>> response) {
@ -76,7 +82,7 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
public void getValues(String codMdep, List<StbGestSetupReader> stbGestSetupList, RunnableArgs<List<StbGestSetupReader>> onComplete, RunnableArgs<Exception> onFailed) {
var stbGestSetups = stbGestSetupList.stream().map(x -> (StbGestSetup) x).collect(Collectors.toList());
GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class);
GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
service.getGestSetupValues(codMdep, stbGestSetups).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<StbGestSetup>>> call, Response<ServiceRESTResponse<List<StbGestSetup>>> response) {

View File

@ -27,15 +27,17 @@ import retrofit2.Response;
@Singleton
public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ArticoloRESTConsumer mArticoloRESTConsumer;
public GiacenzaRESTConsumer(ArticoloRESTConsumer articoloRESTConsumer) {
public GiacenzaRESTConsumer(RESTBuilder restBuilder, ArticoloRESTConsumer articoloRESTConsumer) {
this.restBuilder = restBuilder;
this.mArticoloRESTConsumer = articoloRESTConsumer;
}
public void getGiacenzeInPosizione(MtbDepoPosizione posizione, RunnableArgs<List<MvwSitArtUdcDetInventario>> onComplete, RunnableArgs<Exception> onFailed) {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class);
GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
giacenzaRESTConsumerService.retrieveAvailableItems(posizione.getPosizione()).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> call, Response<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> response) {
@ -77,7 +79,7 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
}
public void getGiacenzeInPosizione(List<String> posizioni, boolean withTestataCollo, RunnableArgs<List<ArtsInGiacenzaDTO>> onComplete, RunnableArgs<Exception> onFailed) {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class);
GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
giacenzaRESTConsumerService.retrieveAvailableItems(posizioni, withTestataCollo).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> call, Response<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> response) {
@ -119,7 +121,7 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
}
public void getGiacenzeByArticolo(String codMart, String partitaMag, RunnableArgs<List<MvwSitArtUdcDetInventario>> onComplete, RunnableArgs<Exception> onFailed) {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class);
GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
var serviceRESTResponseCall =
UtilityString.isNullOrEmpty(partitaMag) ?
giacenzaRESTConsumerService.retrieveAvailableItemsByArt(codMart) :
@ -163,7 +165,7 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
public void getInstantItemSituation(String codMdep, String codMart, String partitaMag, String codJcom, RunnableArgs<InstantItemSituationResponseDto> onComplete, RunnableArgs<Exception> onFailed) {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class);
GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
giacenzaRESTConsumerService.retrieveInstantItemSituation(codMdep, codMart, partitaMag, codJcom)
.enqueue(new ManagedErrorCallback<>() {

View File

@ -20,15 +20,17 @@ import retrofit2.Response;
@Singleton
public class ImballiRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
public ImballiRESTConsumer(ExecutorService executorService) {
public ImballiRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.executorService = executorService;
}
public List<ObservableMtbTcol> retrieveImballiSyncronized(MtbTCol.FlagUiUlEnum tipoImballo) throws Exception {
ImballiRESTConsumerService service = RESTBuilder.getService(ImballiRESTConsumerService.class);
ImballiRESTConsumerService service = restBuilder.getService(ImballiRESTConsumerService.class);
Response<ServiceRESTResponse<List<MtbTCol>>> response = service.retrieveImballi(tipoImballo)
.execute();
@ -50,7 +52,7 @@ public class ImballiRESTConsumer extends _BaseRESTConsumer {
public void registraCaricoSyncronized(String codAnag, List<ImballoQuantityDTO> imballi) throws Exception {
ImballiRESTConsumerService service = RESTBuilder.getService(ImballiRESTConsumerService.class);
ImballiRESTConsumerService service = restBuilder.getService(ImballiRESTConsumerService.class);
Response<ServiceRESTResponse<Void>> response = service.registraCarico(
new RegistraCaricoImballiRequestDTO()
.setCodAnag(codAnag)
@ -73,7 +75,7 @@ public class ImballiRESTConsumer extends _BaseRESTConsumer {
public void registraScaricoSyncronized(String codVettore, List<ImballoQuantityDTO> imballi) throws Exception {
ImballiRESTConsumerService service = RESTBuilder.getService(ImballiRESTConsumerService.class);
ImballiRESTConsumerService service = restBuilder.getService(ImballiRESTConsumerService.class);
Response<ServiceRESTResponse<Void>> response = service.registraScarico(
new RegistraScaricoImballiRequestDTO()
.setCodVettore(codVettore)

View File

@ -68,7 +68,7 @@ public class MagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public void retrieveAllPartitaMag(List<String> codMarts, Date dataScad, RunnableArgs<List<MtbPartitaMag>> onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class);
MagazzinoRESTConsumerService service = restBuilder.getService(MagazzinoRESTConsumerService.class);
service.retrieveAllPartitaMag(codMarts, UtilityDate.formatDate(dataScad, UtilityDate.COMMONS_DATE_FORMATS.YMD_SLASH))
.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -12,14 +12,16 @@ import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRe
@Singleton
public class MaterialiRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
public MaterialiRESTConsumer(ExecutorService executorService) {
public MaterialiRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.executorService = executorService;
}
public MtbColt makeSynchronousRecuperaRequest(RecuperaMaterialiRequestDTO request) throws Exception {
var materialiRESTConsumerService = RESTBuilder.getService(MaterialiRESTConsumerService.class);
var materialiRESTConsumerService = restBuilder.getService(MaterialiRESTConsumerService.class);
var response = materialiRESTConsumerService.recupera(request)
.execute();

View File

@ -23,16 +23,18 @@ import retrofit2.Response;
@Singleton
public class PosizioniRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer mSystemRESTConsumer;
public PosizioniRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
public PosizioniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.mSystemRESTConsumer = systemRESTConsumer;
}
public void getAvailablePosizioni(RunnableArgs<List<MtbDepoPosizione>> onComplete, RunnableArgs<Exception> onFailed) {
String codMdep = null;
PosizioniRESTConsumerService posizioniRESTConsumerService = RESTBuilder.getService(PosizioniRESTConsumerService.class);
PosizioniRESTConsumerService posizioniRESTConsumerService = restBuilder.getService(PosizioniRESTConsumerService.class);
posizioniRESTConsumerService.getAvailablePosizioni(codMdep).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, Response<ServiceRESTResponse<List<MtbDepoPosizione>>> response) {

View File

@ -5,7 +5,6 @@ import androidx.annotation.NonNull;
import com.annimon.stream.Stream;
import java.util.HashMap;
import java.util.List;
import javax.inject.Singleton;
@ -19,7 +18,6 @@ import it.integry.integrywmsnative.core.rest.model.JasperDTO;
import it.integry.integrywmsnative.core.rest.model.JasperPairDTO;
import it.integry.integrywmsnative.core.rest.model.ReportTypeDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.gest.spedizione.model.PrintOrderCloseDTO;
import retrofit2.Call;
import retrofit2.Response;
@ -27,31 +25,10 @@ import retrofit2.Response;
@Singleton
public class PrinterRESTConsumer extends _BaseRESTConsumer {
public enum Type {
PRIMARIA,
SECONDARIA
}
private final RESTBuilder restBuilder;
public void getAvailablePrinters(String codMdep, Type printerType, RunnableArgs<List<String>> onComplete, RunnableArgs<Exception> onFailed) {
String printerTypeStr = printerType != null ? printerType.toString() : null;
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
printerService.getAvailablePrinters(codMdep, printerTypeStr).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<String>>> call, Response<ServiceRESTResponse<List<String>>> response) {
analyzeAnswer(response, "GetAvailablePrinters", printerList -> {
printerList = Stream.of(printerList).filter(x -> !UtilityString.isNullOrEmpty(x)).toList();
onComplete.run(printerList);
}, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<List<String>>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
public PrinterRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void printCollo(MtbColt testataColloToPrint, Runnable onComplete, RunnableArgs<Exception> onFailed) {
@ -61,7 +38,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
return;
}
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class);
printerService
.printCollo(testataColloToPrint)
.enqueue(new ManagedErrorCallback<>() {
@ -92,7 +69,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
Stream.of(params)
.forEach(x -> jasperDTO.getParams().add(new JasperPairDTO(x.getKey(), x.getValue())));
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class);
printerService
.processPrintReport(printerName, quantity, jasperDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -120,7 +97,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
Stream.of(params)
.forEach(x -> reportTypeDTO.getParams().add(new JasperPairDTO(x.getKey(), x.getValue())));
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class);
printerService
.printReportType(reportTypeDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -152,7 +129,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
return;
}
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class, 240);
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class, 240);
Call<ServiceRESTResponse<Object>> callable = printerService.printClosedOrders(codMdep, dto);
callable.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -15,12 +15,16 @@ import retrofit2.Response;
@Singleton
public class ProduzioneRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public ProduzioneRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void caricoProdFin(CaricoProdFinDTO caricoProdFin, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ProduzioneRESTConsumerService service = RESTBuilder.getService(ProduzioneRESTConsumerService.class);
ProduzioneRESTConsumerService service = restBuilder.getService(ProduzioneRESTConsumerService.class);
service.caricoProdFin(caricoProdFin)
.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -36,9 +36,14 @@ import retrofit2.Response;
@Singleton
public class SystemRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public SystemRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void retrieveUpdatesInfo(final RunnableArgs<LatestAppVersionInfoDTO> onSuccess, final RunnableArgs<Exception> onFailed) {
SystemRESTConsumerService systemRESTConsumerService = RESTBuilder.getService(SystemRESTConsumerService.class);
SystemRESTConsumerService systemRESTConsumerService = restBuilder.getService(SystemRESTConsumerService.class);
systemRESTConsumerService.retrieveUpdatesInfo()
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -63,7 +68,7 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
RegisterDeviceRequestDTO registerDeviceRequestDTO = new RegisterDeviceRequestDTO()
.setApp("WMS");
SystemRESTConsumerService systemRESTConsumerService = RESTBuilder.getService(SystemRESTConsumerService.class);
SystemRESTConsumerService systemRESTConsumerService = restBuilder.getService(SystemRESTConsumerService.class);
systemRESTConsumerService.registerDevice(registerDeviceRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -80,10 +85,10 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
}
public <T> void processSql(String nativeSql, final Type clazz, final RunnableArgs<T> onComplete, final RunnableArgs<Exception> onFailed) {
NativeSqlRequestDTO nativeSqlDTO = new NativeSqlRequestDTO();
nativeSqlDTO.nativeSql = nativeSql;
NativeSqlRequestDTO nativeSqlDTO = new NativeSqlRequestDTO()
.setNativeSql(nativeSql);
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
service
.processSql(nativeSqlDTO)
.enqueue(new ManagedErrorCallback<>() {
@ -112,7 +117,7 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
public void getAvailableCodMdeps(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
service.getAvailableCodMdeps().enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> call, Response<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> response) {
@ -158,7 +163,7 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
public void sendMail(MailRequestDTO mailDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
service.sendMail(mailDTO).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<String>> call, Response<ServiceRESTResponse<String>> response) {

View File

@ -6,7 +6,6 @@ import java.net.ConnectException;
import it.integry.integrywmsnative.core.exception.InvalidConnectionException;
import it.integry.integrywmsnative.core.exception.NoPrintersFoundException;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import retrofit2.Call;
import retrofit2.Callback;
@ -15,7 +14,7 @@ public abstract class ManagedErrorCallback<T> implements Callback<T> {
@Override
public void onFailure(Call<T> call, Throwable t) {
if (t instanceof ConnectException connectException) {
t = new InvalidConnectionException(RESTBuilder.getDefaultHost(), RESTBuilder.getDefaultPort(), connectException);
t = new InvalidConnectionException(call.request().url().host(), call.request().url().port(), connectException);
} else if (t.getMessage() != null && t.getMessage().contains("Printer not found")) {
t = new NoPrintersFoundException();
}

View File

@ -22,9 +22,14 @@ import retrofit2.Response;
@Singleton
public class OrdiniAccettazioneRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public OrdiniAccettazioneRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void getOrdiniInevasi(String codMdep, RunnableArgs<List<OrdineAccettazioneInevasoDTO>> onComplete, RunnableArgs<Exception> onFailed) {
OrdiniAccettazioneRESTConsumerService service = RESTBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
OrdiniAccettazioneRESTConsumerService service = restBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
service.listOrdiniInevasi(codMdep, "A").enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<OrdineAccettazioneInevasoDTO>>> call, Response<ServiceRESTResponse<List<OrdineAccettazioneInevasoDTO>>> response) {
@ -47,7 +52,7 @@ public class OrdiniAccettazioneRESTConsumer extends _BaseRESTConsumer {
.setNumero(x.getNumero()))
.toList();
OrdiniAccettazioneRESTConsumerService service = RESTBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
OrdiniAccettazioneRESTConsumerService service = restBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
service.getArticoliFromOrdiniAccettazione(getPickingListDTOs).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<SitArtOrdDTO>>> call, Response<ServiceRESTResponse<List<SitArtOrdDTO>>> response) {

View File

@ -21,14 +21,16 @@ import retrofit2.Response;
@Singleton
public class DocInterniRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final MagazzinoRESTConsumer magazzinoRESTConsumer;
public DocInterniRESTConsumer(MagazzinoRESTConsumer magazzinoRESTConsumer) {
public DocInterniRESTConsumer(RESTBuilder restBuilder, MagazzinoRESTConsumer magazzinoRESTConsumer) {
this.restBuilder = restBuilder;
this.magazzinoRESTConsumer = magazzinoRESTConsumer;
}
public void getDocInterniSetup(RunnableArgs<DocInterniSetupDTO> onComplete, RunnableArgs<Exception> onFailed) {
DocInterniRESTConsumerService service = RESTBuilder.getService(DocInterniRESTConsumerService.class);
DocInterniRESTConsumerService service = restBuilder.getService(DocInterniRESTConsumerService.class);
service.getSetupDocInterni().enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<DocInterniSetupDTO>> call, Response<ServiceRESTResponse<DocInterniSetupDTO>> response) {
@ -43,7 +45,7 @@ public class DocInterniRESTConsumer extends _BaseRESTConsumer {
}
public void retrieveLotti(String codProd, RunnableArgs<List<RetrieveLottiDTO>> onComplete, RunnableArgs<Exception> onFailed) {
DocInterniRESTConsumerService service = RESTBuilder.getService(DocInterniRESTConsumerService.class);
DocInterniRESTConsumerService service = restBuilder.getService(DocInterniRESTConsumerService.class);
service.retrieveLotti(codProd)
.enqueue(new ManagedErrorCallback<>() {
@Override

View File

@ -4,7 +4,6 @@ public class LoginRequestDTO {
private String username;
private String password;
private String profileDb;
private String deviceId;
public String getUsername() {
@ -25,15 +24,6 @@ public class LoginRequestDTO {
return this;
}
public String getProfileDb() {
return profileDb;
}
public LoginRequestDTO setProfileDb(String profileDb) {
this.profileDb = profileDb;
return this;
}
public String getDeviceId() {
return deviceId;
}

View File

@ -1,7 +1,5 @@
package it.integry.integrywmsnative.gest.login.rest;
import android.util.Log;
import java.util.List;
import javax.inject.Inject;
@ -11,12 +9,12 @@ import it.integry.integrywmsnative.core.CommonConst;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.gest.login.dto.LoginAziendaDTO;
import it.integry.integrywmsnative.gest.login.dto.AuthenticationJwtResponseDTO;
import it.integry.integrywmsnative.gest.login.dto.LoginAziendaDTO;
import it.integry.integrywmsnative.gest.login.dto.LoginRequestDTO;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@Singleton
@ -37,16 +35,15 @@ public class AuthenticationRESTConsumer extends _BaseRESTConsumer {
int port = CommonConst.Login.Azienda.port;
AuthenticationRESTConsumerService service = restBuilder.getService(AuthenticationRESTConsumerService.class, protocol, host, port, false, true);
service.loginAzienda(codAzienda).enqueue(new Callback<>() {
service.loginAzienda(codAzienda).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Response<ServiceRESTResponse<LoginAziendaDTO>> response) {
analyzeAnswer(response, "LoginAzienda", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Throwable t) {
Log.e("LoginAzienda", t.toString());
onFailed.run(new Exception(t));
public void onFailure(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Exception e) {
onFailed.run(e);
}
});
}
@ -55,16 +52,15 @@ public class AuthenticationRESTConsumer extends _BaseRESTConsumer {
AuthenticationRESTConsumerService service = restBuilder.getService(AuthenticationRESTConsumerService.class);
service.me()
.enqueue(new Callback<>() {
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
analyzeAnswer(response, "me", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<Object>> call, Throwable t) {
Log.e("me", t.toString());
onFailed.run(new Exception(t));
public void onFailure(Call<ServiceRESTResponse<Object>> call, Exception e) {
onFailed.run(e);
}
});
}
@ -76,12 +72,11 @@ public class AuthenticationRESTConsumer extends _BaseRESTConsumer {
LoginRequestDTO loginRequestDTO = new LoginRequestDTO()
.setUsername(username)
.setPassword(password)
.setProfileDb(profileDb)
.setDeviceId(deviceSalt);
service
.loginNew(loginRequestDTO)
.enqueue(new Callback<>() {
.loginNew(profileDb, loginRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<AuthenticationJwtResponseDTO>> call, Response<ServiceRESTResponse<AuthenticationJwtResponseDTO>> response) {
@ -89,9 +84,8 @@ public class AuthenticationRESTConsumer extends _BaseRESTConsumer {
}
@Override
public void onFailure(Call<ServiceRESTResponse<AuthenticationJwtResponseDTO>> call, final Throwable t) {
Log.e("login", t.toString());
onFailed.run(new Exception(t));
public void onFailure(Call<ServiceRESTResponse<AuthenticationJwtResponseDTO>> call, final Exception e) {
onFailed.run(e);
}
});
}
@ -99,20 +93,19 @@ public class AuthenticationRESTConsumer extends _BaseRESTConsumer {
public void retrieveAvailableProfiles(String protocol, String host, int port, String username, RunnableArgs<List<String>> onComplete, RunnableArgs<Exception> onFailed) {
public void retrieveAvailableProfiles(String protocol, String host, int port, String username, String password, RunnableArgs<List<String>> onComplete, RunnableArgs<Exception> onFailed) {
AuthenticationRESTConsumerService service = restBuilder.getService(AuthenticationRESTConsumerService.class, protocol, host, port, false);
service.retreiveAvailableProfiles(username)
.enqueue(new Callback<>() {
service.retreiveAvailableProfiles(username, password)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<String>>> call, Response<ServiceRESTResponse<List<String>>> response) {
analyzeAnswer(response, "retrieveAvailableProfiles", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<List<String>>> call, Throwable t) {
Log.e("Login", t.toString());
onFailed.run(new Exception(t));
public void onFailure(Call<ServiceRESTResponse<List<String>>> call, Exception e) {
onFailed.run(e);
}
});
}

View File

@ -24,12 +24,12 @@ public interface AuthenticationRESTConsumerService {
Call<ServiceRESTResponse<LoginResponseDTO>> login(@Body LoginRequestDTO loginRequestDTO);
@POST("auth/login")
Call<ServiceRESTResponse<AuthenticationJwtResponseDTO>> loginNew(@Body LoginRequestDTO loginRequestDTO);
Call<ServiceRESTResponse<AuthenticationJwtResponseDTO>> loginNew(@Query("profileDb") String profileDb, @Body LoginRequestDTO loginRequestDTO);
@GET("auth/me")
Call<ServiceRESTResponse<Object>> me();
@GET("users/availableProfiles")
Call<ServiceRESTResponse<List<String>>> retreiveAvailableProfiles(@Query("username") String username);
Call<ServiceRESTResponse<List<String>>> retreiveAvailableProfiles(@Query("username") String username, @Query("password") String password);
}

View File

@ -1,66 +0,0 @@
package it.integry.integrywmsnative.gest.login.rest;
import androidx.annotation.NonNull;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.CommonConst;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.gest.login.dto.LoginAziendaDTO;
import it.integry.integrywmsnative.gest.login.dto.LoginRequestDTO;
import it.integry.integrywmsnative.gest.login.dto.LoginResponseDTO;
import retrofit2.Call;
import retrofit2.Response;
@Singleton
public class LoginRESTConsumer extends _BaseRESTConsumer {
public void retrieveServerData(String codAzienda, RunnableArgs<LoginAziendaDTO> onComplete, RunnableArgs<Exception> onFailed) {
String protocol = CommonConst.Login.Azienda.protocol;
String host = CommonConst.Login.Azienda.host;
int port = CommonConst.Login.Azienda.port;
LoginRESTConsumerService service = RESTBuilder.getService(LoginRESTConsumerService.class, protocol, host, port, false, true);
service.loginAzienda(codAzienda).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<LoginAziendaDTO>> call, Response<ServiceRESTResponse<LoginAziendaDTO>> response) {
analyzeAnswer(response, "LoginAzienda", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<LoginAziendaDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
}
public void authenticate(String protocol, String host, int port, String username, String password, RunnableArgs<LoginResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
LoginRESTConsumerService service = RESTBuilder.getService(LoginRESTConsumerService.class, protocol, host, port, false);
LoginRequestDTO loginRequestDTO = new LoginRequestDTO()
.setUsername(username)
.setPassword(password);
service.login(loginRequestDTO).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<LoginResponseDTO>> call, Response<ServiceRESTResponse<LoginResponseDTO>> response) {
analyzeAnswer(response, "Login", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<LoginResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
}
}

View File

@ -1,15 +1,17 @@
package it.integry.integrywmsnative.gest.login.viewmodel;
import com.auth0.android.jwt.JWT;
import com.google.firebase.installations.FirebaseInstallations;
import com.google.gson.Gson;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.stream.Collectors;
import javax.inject.Inject;
import it.integry.integrywmsnative.core.authentication.JwtUtils;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.RunnableArgsss;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
@ -47,7 +49,7 @@ public class LoginViewModel {
FirebaseInstallations.getInstance().getId().addOnCompleteListener(fid -> {
retrieveAvailableProfiles(protocol, host, port, username, selectedProfile -> {
retrieveAvailableProfiles(protocol, host, port, username, password, selectedProfile -> {
SettingsManager.i().createUserSession();
authenticate(protocol, host, port, username, password, selectedProfile, fid.getResult(), fullName -> {
@ -102,8 +104,8 @@ public class LoginViewModel {
});
}
private void retrieveAvailableProfiles(String protocol, String host, int port, String username, RunnableArgs<String> onComplete) {
mAuthenticationRESTConsumer.retrieveAvailableProfiles(protocol, host, port, username, availableProfiles -> {
private void retrieveAvailableProfiles(String protocol, String host, int port, String username, String password, RunnableArgs<String> onComplete) {
mAuthenticationRESTConsumer.retrieveAvailableProfiles(protocol, host, port, username, password, availableProfiles -> {
if (availableProfiles == null || availableProfiles.isEmpty()) {
this.sendError(new Exception("Non è stato trovato alcun profilo per l'utente: " + username));
@ -126,16 +128,19 @@ public class LoginViewModel {
private void authenticate(String protocol, String host, int port, String username, String password, String profileDb, String deviceSalt, RunnableArgs<String> onComplete) {
mAuthenticationRESTConsumer.authenticate(protocol, host, port, username, password, profileDb, deviceSalt, sessionData -> {
JWT jwt = new JWT(sessionData.getAccessToken());
var claims = jwt.getClaims();
var claims = JwtUtils.parseJwt(sessionData.getAccessToken());
var detailsMap = claims.get("details", LinkedHashMap.class);
Gson gson = new Gson();
String jsonString = gson.toJson(detailsMap);
AuthTokenClaimsDTO claimsDetails = gson.fromJson(jsonString, AuthTokenClaimsDTO.class);
AuthTokenClaimsDTO claimsDetails = claims.get("details").asObject(AuthTokenClaimsDTO.class);
SettingsManager.i().getUserSession()
.setProfileDB(profileDb)
.setDeviceId(deviceSalt)
.setAccessToken(sessionData.getAccessToken())
.setAccessTokenExpiryDate(UtilityDate.toLocalDateTime(jwt.getExpiresAt()))
.setAccessTokenExpiryDate(UtilityDate.toLocalDateTime(claims.getExpiration()))
.setRefreshToken(sessionData.getRefreshToken())
.setRefreshTokenExpiryDate(sessionData.getExpiryDate());

View File

@ -23,8 +23,14 @@ import retrofit2.Response;
@Singleton
public class ProdOrdineProduzioneRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public ProdOrdineProduzioneRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void getOrdiniInevasi(String codMdep, RunnableArgs<List<OrdineAccettazioneInevasoDTO>> onComplete, RunnableArgs<Exception> onFailed) {
OrdiniAccettazioneRESTConsumerService service = RESTBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
OrdiniAccettazioneRESTConsumerService service = restBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
service.listOrdiniInevasi(codMdep, "P").enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<OrdineAccettazioneInevasoDTO>>> call, Response<ServiceRESTResponse<List<OrdineAccettazioneInevasoDTO>>> response) {
@ -47,7 +53,7 @@ public class ProdOrdineProduzioneRESTConsumer extends _BaseRESTConsumer {
.setNumero(x.getNumero()))
.toList();
OrdiniAccettazioneRESTConsumerService service = RESTBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
OrdiniAccettazioneRESTConsumerService service = restBuilder.getService(OrdiniAccettazioneRESTConsumerService.class);
service.getArticoliFromOrdiniAccettazione(getPickingListDTOs).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<SitArtOrdDTO>>> call, Response<ServiceRESTResponse<List<SitArtOrdDTO>>> response) {

View File

@ -2,6 +2,7 @@ package it.integry.integrywmsnative.gest.prod_rientro_merce.order_detail;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer;
@ -13,12 +14,13 @@ import it.integry.integrywmsnative.gest.prod_rientro_merce.order_detail.rest.Pro
public class ProdRientroMerceOrderDetailModule {
@Provides
ProdRientroMerceOrderDetailRESTConsumer provideProdRientroMerceOrderDetailRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
return new ProdRientroMerceOrderDetailRESTConsumer(systemRESTConsumer);
ProdRientroMerceOrderDetailRESTConsumer provideProdRientroMerceOrderDetailRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new ProdRientroMerceOrderDetailRESTConsumer(restBuilder, systemRESTConsumer);
}
@Provides
ProdRientroMerceOrderDetailViewModel provideProdRientroMerceOrderDetailViewModel(
RESTBuilder restBuilder,
ProdRientroMerceOrderDetailRESTConsumer prodRientroMerceOrderDetailRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
PrinterRESTConsumer printerRESTConsumer,

View File

@ -151,7 +151,7 @@ public class ProdRientroMerceOrderDetailViewModel {
.setCodJfas(pickedQuantityDTO.getCodJfas())
.setCodAnag(currentOrder.getCodAnag())
.setCodMdep(currentOrder.getCodMdep())
.setPreparatoDa(SettingsManager.i().getUser().getUsername())
.setPreparatoDa(SettingsManager.i().getUser().getFullname())
.setEffettuaCaricoProdotto(SettingsManager.iDB().isProduzioneGeneraDocCar())
.setCreaCaricoDaCollo(true)
.setCodDtipCar(SettingsManager.iDB().getProduzioneCodDtipCar())

View File

@ -33,10 +33,12 @@ import retrofit2.Response;
@Singleton
public class ProdRientroMerceOrderDetailRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer systemRESTConsumer;
@Inject
public ProdRientroMerceOrderDetailRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
public ProdRientroMerceOrderDetailRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.systemRESTConsumer = systemRESTConsumer;
}
@ -111,7 +113,7 @@ public class ProdRientroMerceOrderDetailRESTConsumer extends _BaseRESTConsumer {
public void importColliDaProduzione(ImportColliDaProduzioneRequestDTO importColliDaProduzioneRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ProdRientroMerceOrderDetailRESTConsumerService service = RESTBuilder.getService(ProdRientroMerceOrderDetailRESTConsumerService.class);
ProdRientroMerceOrderDetailRESTConsumerService service = restBuilder.getService(ProdRientroMerceOrderDetailRESTConsumerService.class);
service.importColliDaProduzione(Collections.singletonList(importColliDaProduzioneRequestDTO))
.enqueue(new ManagedErrorCallback<>() {
@Override
@ -132,7 +134,7 @@ public class ProdRientroMerceOrderDetailRESTConsumer extends _BaseRESTConsumer {
public void deleteColloDaProduzione(MtbColt mtbColtToDelete, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ProdRientroMerceOrderDetailRESTConsumerService service = RESTBuilder.getService(ProdRientroMerceOrderDetailRESTConsumerService.class);
ProdRientroMerceOrderDetailRESTConsumerService service = restBuilder.getService(ProdRientroMerceOrderDetailRESTConsumerService.class);
service.deleteColloDaProduzione(mtbColtToDelete).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {

View File

@ -140,7 +140,6 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.card.MaterialCardView
android:id="@+id/new_card"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"