From 3a9a5e7260ac63e76d81495c3346b705fbc3570c Mon Sep 17 00:00:00 2001 From: Jose Cardozo Date: Fri, 22 Jul 2016 18:35:52 -0500 Subject: [PATCH] IMPLEMENTATION: #6394 fixed --- .../CryptoBrokerIdentityListFragment.java | 91 +++++++++++++++++++ .../src/main/res/values/strings.xml | 1 + .../CryptoCustomerIdentityListFragment.java | 90 +++++++++++++++++- .../src/main/res/values/strings.xml | 1 + .../CryptoBrokerIdentityModuleManager.java | 9 ++ .../CryptoCustomerIdentityModuleManager.java | 9 ++ ...oBrokerIdentitySubAppModulePluginRoot.java | 7 +- ...CryptoBrokerIdentityModuleManagerImpl.java | 34 ++++++- ...ustomerIdentitySubAppModulePluginRoot.java | 7 +- ...yptoCustomerIdentityModuleManagerImpl.java | 29 +++++- 10 files changed, 269 insertions(+), 9 deletions(-) diff --git a/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-broker-identity-bitdubai/src/main/java/com/bitdubai/sub_app/crypto_broker_identity/fragments/CryptoBrokerIdentityListFragment.java b/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-broker-identity-bitdubai/src/main/java/com/bitdubai/sub_app/crypto_broker_identity/fragments/CryptoBrokerIdentityListFragment.java index e447ff71384..573ed7fbc3a 100755 --- a/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-broker-identity-bitdubai/src/main/java/com/bitdubai/sub_app/crypto_broker_identity/fragments/CryptoBrokerIdentityListFragment.java +++ b/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-broker-identity-bitdubai/src/main/java/com/bitdubai/sub_app/crypto_broker_identity/fragments/CryptoBrokerIdentityListFragment.java @@ -2,6 +2,7 @@ import android.app.Fragment; +import android.content.DialogInterface; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; @@ -17,26 +18,34 @@ import com.bitdubai.fermat_android_api.ui.enums.FermatRefreshTypes; import com.bitdubai.fermat_android_api.ui.fragments.FermatListFragment; import com.bitdubai.fermat_android_api.ui.interfaces.FermatListItemListeners; +import com.bitdubai.fermat_android_api.ui.interfaces.FermatWorkerCallBack; +import com.bitdubai.fermat_android_api.ui.util.FermatWorker; import com.bitdubai.fermat_api.FermatBroadcastReceiver; import com.bitdubai.fermat_api.FermatException; import com.bitdubai.fermat_api.FermatIntentFilter; import com.bitdubai.fermat_api.layer.all_definition.common.system.interfaces.error_manager.enums.UnexpectedSubAppExceptionSeverity; +import com.bitdubai.fermat_api.layer.all_definition.common.system.interfaces.error_manager.enums.UnexpectedUIExceptionSeverity; +import com.bitdubai.fermat_api.layer.all_definition.enums.UISource; import com.bitdubai.fermat_api.layer.all_definition.navigation_structure.enums.Activities; import com.bitdubai.fermat_api.layer.dmp_engine.sub_app_runtime.enums.SubApps; import com.bitdubai.fermat_api.layer.osa_android.broadcaster.Broadcaster; import com.bitdubai.fermat_api.layer.osa_android.broadcaster.BroadcasterType; import com.bitdubai.fermat_api.layer.osa_android.broadcaster.FermatBundle; import com.bitdubai.fermat_cbp_api.all_definition.constants.CBPBroadcasterConstants; +import com.bitdubai.fermat_cbp_api.layer.identity.crypto_customer.exceptions.CantListCryptoCustomerIdentityException; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.IdentityBrokerPreferenceSettings; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.exceptions.CantListCryptoBrokersException; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.interfaces.CryptoBrokerIdentityInformation; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.interfaces.CryptoBrokerIdentityModuleManager; +import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.exceptions.CantGetCryptoCustomerListException; +import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.interfaces.CryptoCustomerIdentityInformation; import com.bitdubai.sub_app.crypto_broker_identity.R; import com.bitdubai.sub_app.crypto_broker_identity.common.adapters.CryptoBrokerIdentityInfoAdapter; import com.bitdubai.sub_app.crypto_broker_identity.util.FragmentsCommons; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ExecutorService; import static android.widget.Toast.makeText; @@ -53,7 +62,9 @@ public class CryptoBrokerIdentityListFragment // Data private ArrayList identityInformationList; + private List identityCustomerInformationList; + private ExecutorService executor; View emptyListViewsContainer; private PresentationDialog presentationDialog; @@ -80,6 +91,7 @@ public void onCreate(Bundle savedInstanceState) { @Override public void onStart() { super.onStart(); + onRefreshCustomer(); onRefresh(); } @@ -274,6 +286,85 @@ private void cleanSessionData() { appSession.removeData(FragmentsCommons.ORIGINAL_IMAGE); } + /** + * Checking if a customer profile is already created before a broker is created + */ + public void onRefreshCustomer() { + try{ + final FermatWorker worker = new FermatWorker() { + @Override + protected Object doInBackground() throws Exception { + return getMoreDataAsyncCustomer(); + } + }; + worker.setContext(getActivity()); + worker.setCallBack(new FermatWorkerCallBack() { + @SuppressWarnings("unchecked") + @Override + public void onPostExecute(Object... result) { + if (isAttached) { + if (result != null && + result.length > 0) { + if (getActivity() != null) { + existentCustomerIdentityDialog(); + } + } + } + } + + @Override + public void onErrorOccurred(Exception ex) { + try{ + worker.shutdownNow(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + worker.execute(); + }catch (Exception ignore){ + if (executor != null) { + executor.shutdown(); + executor = null; + } + } + } + + public void existentCustomerIdentityDialog() { + try { + PresentationDialog pd = new PresentationDialog.Builder(getActivity(), appSession) + .setSubTitle(R.string.cbp_broker_identity_welcome_subTitle) + .setBody(R.string.cbp_broker_identity_existent_customer) + .setTemplateType(PresentationDialog.TemplateType.TYPE_PRESENTATION_WITHOUT_IDENTITIES) + .setIconRes(R.drawable.bi_icon) + .setCheckButtonAndTextVisible(0) + .setIsCheckEnabled(false) + .setBannerRes(R.drawable.banner_identity) + .setVIewColor(R.color.background_toolbar) + .build(); + pd.setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + getActivity().onBackPressed(); + } + }); + pd.show(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public List getMoreDataAsyncCustomer() { + List data = new ArrayList<>(); + try { + data = appSession.getModuleManager().getAllCryptoCustomersIdentities(0, 0); + } catch (CantGetCryptoCustomerListException ex) { + appSession.getErrorManager().reportUnexpectedSubAppException(SubApps.CBP_CRYPTO_BROKER_IDENTITY, + UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT, ex); + } + return data; + } + /** * Receiver class implemented */ diff --git a/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-broker-identity-bitdubai/src/main/res/values/strings.xml b/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-broker-identity-bitdubai/src/main/res/values/strings.xml index e80d28fa392..d6610343d77 100644 --- a/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-broker-identity-bitdubai/src/main/res/values/strings.xml +++ b/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-broker-identity-bitdubai/src/main/res/values/strings.xml @@ -22,6 +22,7 @@ Welcome to the Broker Identity. From here you will be able to create an Broker type identity.\n\nThis Identity, will identify you in the system as an broker, and give you access to all tasks and applications you need.\n\nOther broker or customer will be able to request connection to you by finding you with the information you provide here. Please, turn on your GPS to register your location, then others can find you and you can find peers near to you. + You already have a profile on this platform as Customer. For instance, this app will be closed since it is not allowed to create a Broker profile too. Accuracy (Km) 0 - 1000 Frequency diff --git a/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-customer-identity-bitdubai/src/main/java/com/bitdubai/sub_app/crypto_customer_identity/fragments/CryptoCustomerIdentityListFragment.java b/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-customer-identity-bitdubai/src/main/java/com/bitdubai/sub_app/crypto_customer_identity/fragments/CryptoCustomerIdentityListFragment.java index b6e38ab6bf2..7c86c0619ac 100755 --- a/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-customer-identity-bitdubai/src/main/java/com/bitdubai/sub_app/crypto_customer_identity/fragments/CryptoCustomerIdentityListFragment.java +++ b/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-customer-identity-bitdubai/src/main/java/com/bitdubai/sub_app/crypto_customer_identity/fragments/CryptoCustomerIdentityListFragment.java @@ -2,14 +2,13 @@ import android.app.Fragment; +import android.content.DialogInterface; import android.os.Build; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; @@ -22,10 +21,14 @@ import com.bitdubai.fermat_android_api.ui.enums.FermatRefreshTypes; import com.bitdubai.fermat_android_api.ui.fragments.FermatListFragment; import com.bitdubai.fermat_android_api.ui.interfaces.FermatListItemListeners; +import com.bitdubai.fermat_android_api.ui.interfaces.FermatWorkerCallBack; +import com.bitdubai.fermat_android_api.ui.util.FermatWorker; import com.bitdubai.fermat_api.FermatException; import com.bitdubai.fermat_api.layer.all_definition.common.system.interfaces.error_manager.enums.UnexpectedSubAppExceptionSeverity; import com.bitdubai.fermat_api.layer.all_definition.navigation_structure.enums.Activities; import com.bitdubai.fermat_api.layer.dmp_engine.sub_app_runtime.enums.SubApps; +import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.exceptions.CantListCryptoBrokersException; +import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.interfaces.CryptoBrokerIdentityInformation; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.IdentityCustomerPreferenceSettings; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.exceptions.CantGetCryptoCustomerListException; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.interfaces.CryptoCustomerIdentityInformation; @@ -37,6 +40,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ExecutorService; import static android.widget.Toast.makeText; @@ -58,6 +62,7 @@ public class CryptoCustomerIdentityListFragment private CryptoCustomerIdentityListFilter filter; private PresentationDialog presentationDialog; + private ExecutorService executor; private View layout; public static CryptoCustomerIdentityListFragment newInstance() { @@ -67,9 +72,8 @@ public static CryptoCustomerIdentityListFragment newInstance() { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + onRefreshBroker(); cleanSessionData(); - onRefresh(); } @@ -291,4 +295,82 @@ private void cleanSessionData() { if (appSession.getData(FragmentsCommons.ORIGINAL_IMAGE) != null) appSession.removeData(FragmentsCommons.ORIGINAL_IMAGE); } + + /** + * Checking if a broker profile is already created before a customer is created + */ + public void onRefreshBroker() { + try{ + final FermatWorker worker = new FermatWorker() { + @Override + protected Object doInBackground() throws Exception { + return getMoreDataAsyncBroker(); + } + }; + worker.setContext(getActivity()); + worker.setCallBack(new FermatWorkerCallBack() { + @SuppressWarnings("unchecked") + @Override + public void onPostExecute(Object... result) { + if (isAttached) { + if (result != null && + result.length > 0) { + if (getActivity() != null) { + existentBrokerIdentityDialog(); + } + } + } + } + + @Override + public void onErrorOccurred(Exception ex) { + try{ + worker.shutdownNow(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + worker.execute(); + }catch (Exception ignore){ + if (executor != null) { + executor.shutdown(); + executor = null; + } + } + } + + public void existentBrokerIdentityDialog() { + try { + PresentationDialog pd = new PresentationDialog.Builder(getActivity(), appSession) + .setSubTitle(R.string.cbp_customer_identity_welcome_subTitle) + .setBody(R.string.cbp_customer_identity_existent_broker) + .setTemplateType(PresentationDialog.TemplateType.TYPE_PRESENTATION_WITHOUT_IDENTITIES) + .setCheckButtonAndTextVisible(0) + .setIsCheckEnabled(false) + .setBannerRes(R.drawable.banner_identity_customer) + .setVIewColor(R.color.ccc_color_dialog_identity) + .build(); + pd.setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + getActivity().onBackPressed(); + } + }); + pd.show(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public List getMoreDataAsyncBroker() { + List data = new ArrayList<>(); + try { + data = appSession.getModuleManager().listIdentities(0, 0); + } catch (CantListCryptoBrokersException ex) { + appSession.getErrorManager().reportUnexpectedSubAppException(SubApps.CBP_CRYPTO_CUSTOMER_IDENTITY, + UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT, ex); + } + return data; + } } diff --git a/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-customer-identity-bitdubai/src/main/res/values/strings.xml b/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-customer-identity-bitdubai/src/main/res/values/strings.xml index 79ac838fae3..a6f1cccfefa 100644 --- a/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-customer-identity-bitdubai/src/main/res/values/strings.xml +++ b/CBP/android/sub_app/fermat-cbp-android-sub-app-crypto-customer-identity-bitdubai/src/main/res/values/strings.xml @@ -19,6 +19,7 @@ Welcome to the Customer Identity. From here you will be able to create an Customer type identity.\n\nThis Identity, will identify you in the system as an Customer, and give you access to all tasks and applications you need.\n\nOther broker or customer will be able to request connection to you by finding you with the information you provide here. Please, turn on your GPS to register your location, then others can find you and you can find peers near to you. + You already have a profile on this platform as Broker. For instance, this app will be closed since it is not allowed to create a Customer profile too. Accuracy (Km) 0 - 1000 Frequency diff --git a/CBP/library/api/fermat-cbp-api/src/main/java/com/bitdubai/fermat_cbp_api/layer/sub_app_module/crypto_broker_identity/interfaces/CryptoBrokerIdentityModuleManager.java b/CBP/library/api/fermat-cbp-api/src/main/java/com/bitdubai/fermat_cbp_api/layer/sub_app_module/crypto_broker_identity/interfaces/CryptoBrokerIdentityModuleManager.java index 2006855c053..b3a58a20f26 100644 --- a/CBP/library/api/fermat-cbp-api/src/main/java/com/bitdubai/fermat_cbp_api/layer/sub_app_module/crypto_broker_identity/interfaces/CryptoBrokerIdentityModuleManager.java +++ b/CBP/library/api/fermat-cbp-api/src/main/java/com/bitdubai/fermat_cbp_api/layer/sub_app_module/crypto_broker_identity/interfaces/CryptoBrokerIdentityModuleManager.java @@ -14,6 +14,7 @@ import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.exceptions.CantPublishCryptoBrokerException; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.exceptions.CantUnHideCryptoBrokerException; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.exceptions.CryptoBrokerNotFoundException; +import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.interfaces.CryptoCustomerIdentityInformation; import java.io.Serializable; import java.util.List; @@ -27,6 +28,14 @@ public interface CryptoBrokerIdentityModuleManager extends ModuleManager, ModuleSettingsImpl, Serializable { + + /** + * The method getAllCryptoCustomerIdentities returns the list of all crypto Customer + * + * @return the list of crypto Customer + * @throws com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.exceptions.CantGetCryptoCustomerListException + */ + List getAllCryptoCustomersIdentities(int max, int offset) throws com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.exceptions.CantGetCryptoCustomerListException; /** * The method createCryptoBrokerIdentity is used to create a new crypto Broker identity * diff --git a/CBP/library/api/fermat-cbp-api/src/main/java/com/bitdubai/fermat_cbp_api/layer/sub_app_module/crypto_customer_identity/interfaces/CryptoCustomerIdentityModuleManager.java b/CBP/library/api/fermat-cbp-api/src/main/java/com/bitdubai/fermat_cbp_api/layer/sub_app_module/crypto_customer_identity/interfaces/CryptoCustomerIdentityModuleManager.java index ff809c7f77a..e655e182c62 100644 --- a/CBP/library/api/fermat-cbp-api/src/main/java/com/bitdubai/fermat_cbp_api/layer/sub_app_module/crypto_customer_identity/interfaces/CryptoCustomerIdentityModuleManager.java +++ b/CBP/library/api/fermat-cbp-api/src/main/java/com/bitdubai/fermat_cbp_api/layer/sub_app_module/crypto_customer_identity/interfaces/CryptoCustomerIdentityModuleManager.java @@ -7,7 +7,9 @@ import com.bitdubai.fermat_api.layer.osa_android.location_system.exceptions.CantGetDeviceLocationException; import com.bitdubai.fermat_api.layer.all_definition.enums.GeoFrequency; import com.bitdubai.fermat_cbp_api.layer.identity.crypto_broker.exceptions.CantUpdateCustomerIdentityException; +import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.exceptions.CantListCryptoBrokersException; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.exceptions.CantPublishCryptoBrokerException; +import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.interfaces.CryptoBrokerIdentityInformation; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.IdentityCustomerPreferenceSettings; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.exceptions.CouldNotPublishCryptoCustomerException; @@ -26,6 +28,13 @@ public interface CryptoCustomerIdentityModuleManager extends ModuleManager, ModuleSettingsImpl, Serializable { + /** + * The method listIdentities returns the list of all crypto Broker published + * + * @return the list of crypto Broker published + * @throws CantListCryptoBrokersException if something goes wrong. + */ + List listIdentities(int max, int offset) throws CantListCryptoBrokersException; /** * The method createCryptoCustomerIdentity is used to create a new crypto Customer identity * diff --git a/CBP/plugin/sub_app_module/fermat-cbp-plugin-sub-app-module-crypto-broker-identity-bitdubai/src/main/java/com/bitdubai/fermat_cbp_plugin/layer/sub_app_module/crypto_broker_identity/developer/bitdubai/version_1/CryptoBrokerIdentitySubAppModulePluginRoot.java b/CBP/plugin/sub_app_module/fermat-cbp-plugin-sub-app-module-crypto-broker-identity-bitdubai/src/main/java/com/bitdubai/fermat_cbp_plugin/layer/sub_app_module/crypto_broker_identity/developer/bitdubai/version_1/CryptoBrokerIdentitySubAppModulePluginRoot.java index 69a484873ba..08593b1bf75 100644 --- a/CBP/plugin/sub_app_module/fermat-cbp-plugin-sub-app-module-crypto-broker-identity-bitdubai/src/main/java/com/bitdubai/fermat_cbp_plugin/layer/sub_app_module/crypto_broker_identity/developer/bitdubai/version_1/CryptoBrokerIdentitySubAppModulePluginRoot.java +++ b/CBP/plugin/sub_app_module/fermat-cbp-plugin-sub-app-module-crypto-broker-identity-bitdubai/src/main/java/com/bitdubai/fermat_cbp_plugin/layer/sub_app_module/crypto_broker_identity/developer/bitdubai/version_1/CryptoBrokerIdentitySubAppModulePluginRoot.java @@ -16,6 +16,7 @@ import com.bitdubai.fermat_api.layer.osa_android.file_system.PluginFileSystem; import com.bitdubai.fermat_api.layer.osa_android.location_system.LocationManager; import com.bitdubai.fermat_cbp_api.layer.identity.crypto_broker.interfaces.CryptoBrokerIdentityManager; +import com.bitdubai.fermat_cbp_api.layer.identity.crypto_customer.interfaces.CryptoCustomerIdentityManager; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.IdentityBrokerPreferenceSettings; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.interfaces.CryptoBrokerIdentityModuleManager; import com.bitdubai.fermat_cbp_plugin.layer.sub_app_module.crypto_broker_identity.developer.bitdubai.version_1.structure.CryptoBrokerIdentityModuleManagerImpl; @@ -32,6 +33,9 @@ public class CryptoBrokerIdentitySubAppModulePluginRoot extends AbstractModule implements CryptoBrokerIdentityModuleManager, Serializable { + extends ModuleManagerImpl + implements CryptoBrokerIdentityModuleManager, Serializable { private CryptoBrokerIdentityManager identityManager; private CryptoBrokerIdentitySubAppModulePluginRoot pluginRoot; private final LocationManager locationManager; + private CryptoCustomerIdentityManager identityCustomerManager; public CryptoBrokerIdentityModuleManagerImpl( CryptoBrokerIdentityManager identityManager, PluginFileSystem pluginFileSystem, UUID pluginId, CryptoBrokerIdentitySubAppModulePluginRoot pluginRoot, - LocationManager locationManager){ + LocationManager locationManager, + CryptoCustomerIdentityManager identityCustomerManager){ super(pluginFileSystem, pluginId); this.identityManager = identityManager; this.pluginRoot = pluginRoot; this.locationManager = locationManager; + this.identityCustomerManager = identityCustomerManager; } @Override @@ -187,4 +199,22 @@ public Location getLocation() throws CantGetDeviceLocationException { public Boolean itHasAssociatedWallet(String brokerPublicKey) { return null; } + + @Override + public List getAllCryptoCustomersIdentities(int max, int offset) throws com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.exceptions.CantGetCryptoCustomerListException { + try { + List cryptoCustomers = new ArrayList<>(); + for (CryptoCustomerIdentity identity : this.identityCustomerManager.listAllCryptoCustomerFromCurrentDeviceUser()) { + cryptoCustomers.add(converIdentityCustomerToInformation(identity)); + } + return cryptoCustomers; + } catch (CantListCryptoCustomerIdentityException e) { + pluginRoot.reportError(UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); + throw new com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.exceptions.CantGetCryptoCustomerListException(CantGetCryptoCustomerListException.DEFAULT_MESSAGE, e, "Crypto Customer Identity Module Manager", "Cant Get List All Crypto Customer Identity"); + } + } + + private CryptoCustomerIdentityInformation converIdentityCustomerToInformation(final CryptoCustomerIdentity identity) { + return new CryptoCustomerIdentityInformationImpl(identity.getAlias(), identity.getPublicKey(), identity.getProfileImage(), identity.isPublished() ? ExposureLevel.PUBLISH : ExposureLevel.HIDE, identity.getAccuracy(), identity.getFrequency()); + } } \ No newline at end of file diff --git a/CBP/plugin/sub_app_module/fermat-cbp-plugin-sub-app-module-crypto-customer-identity-bitdubai/src/main/java/com/bitdubai/fermat_cbp_plugin/layer/sub_app_module/crypto_customer_identity/developer/bitdubai/version_1/CryptoCustomerIdentitySubAppModulePluginRoot.java b/CBP/plugin/sub_app_module/fermat-cbp-plugin-sub-app-module-crypto-customer-identity-bitdubai/src/main/java/com/bitdubai/fermat_cbp_plugin/layer/sub_app_module/crypto_customer_identity/developer/bitdubai/version_1/CryptoCustomerIdentitySubAppModulePluginRoot.java index 34c47739b8e..60a5b84240b 100644 --- a/CBP/plugin/sub_app_module/fermat-cbp-plugin-sub-app-module-crypto-customer-identity-bitdubai/src/main/java/com/bitdubai/fermat_cbp_plugin/layer/sub_app_module/crypto_customer_identity/developer/bitdubai/version_1/CryptoCustomerIdentitySubAppModulePluginRoot.java +++ b/CBP/plugin/sub_app_module/fermat-cbp-plugin-sub-app-module-crypto-customer-identity-bitdubai/src/main/java/com/bitdubai/fermat_cbp_plugin/layer/sub_app_module/crypto_customer_identity/developer/bitdubai/version_1/CryptoCustomerIdentitySubAppModulePluginRoot.java @@ -15,6 +15,7 @@ import com.bitdubai.fermat_api.layer.modules.common_classes.ActiveActorIdentityInformation; import com.bitdubai.fermat_api.layer.osa_android.file_system.PluginFileSystem; import com.bitdubai.fermat_api.layer.osa_android.location_system.LocationManager; +import com.bitdubai.fermat_cbp_api.layer.identity.crypto_broker.interfaces.CryptoBrokerIdentityManager; import com.bitdubai.fermat_cbp_api.layer.identity.crypto_customer.interfaces.CryptoCustomerIdentityManager; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.IdentityCustomerPreferenceSettings; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.interfaces.CryptoCustomerIdentityModuleManager; @@ -31,6 +32,9 @@ public class CryptoCustomerIdentitySubAppModulePluginRoot extends AbstractModule @NeededPluginReference(platform = Platforms.CRYPTO_BROKER_PLATFORM, layer = Layers.IDENTITY, plugin = Plugins.CRYPTO_CUSTOMER) private CryptoCustomerIdentityManager identityManager; + @NeededPluginReference(platform = Platforms.CRYPTO_BROKER_PLATFORM, layer = Layers.IDENTITY, plugin = Plugins.CRYPTO_BROKER) + private CryptoBrokerIdentityManager brokerIdentityManager; + @NeededAddonReference(platform = Platforms.OPERATIVE_SYSTEM_API, layer = Layers.SYSTEM, addon = Addons.PLUGIN_FILE_SYSTEM) private PluginFileSystem pluginFileSystem; @@ -50,7 +54,8 @@ public CryptoCustomerIdentityModuleManager getModuleManager() throws CantGetModu identityManager, pluginFileSystem, pluginId, - this, locationManager); + this, locationManager, + brokerIdentityManager); return moduleManager; } diff --git a/CBP/plugin/sub_app_module/fermat-cbp-plugin-sub-app-module-crypto-customer-identity-bitdubai/src/main/java/com/bitdubai/fermat_cbp_plugin/layer/sub_app_module/crypto_customer_identity/developer/bitdubai/version_1/structure/CryptoCustomerIdentityModuleManagerImpl.java b/CBP/plugin/sub_app_module/fermat-cbp-plugin-sub-app-module-crypto-customer-identity-bitdubai/src/main/java/com/bitdubai/fermat_cbp_plugin/layer/sub_app_module/crypto_customer_identity/developer/bitdubai/version_1/structure/CryptoCustomerIdentityModuleManagerImpl.java index 923a8a97b33..f9900960683 100644 --- a/CBP/plugin/sub_app_module/fermat-cbp-plugin-sub-app-module-crypto-customer-identity-bitdubai/src/main/java/com/bitdubai/fermat_cbp_plugin/layer/sub_app_module/crypto_customer_identity/developer/bitdubai/version_1/structure/CryptoCustomerIdentityModuleManagerImpl.java +++ b/CBP/plugin/sub_app_module/fermat-cbp-plugin-sub-app-module-crypto-customer-identity-bitdubai/src/main/java/com/bitdubai/fermat_cbp_plugin/layer/sub_app_module/crypto_customer_identity/developer/bitdubai/version_1/structure/CryptoCustomerIdentityModuleManagerImpl.java @@ -10,13 +10,19 @@ import com.bitdubai.fermat_api.layer.osa_android.location_system.LocationManager; import com.bitdubai.fermat_api.layer.osa_android.location_system.exceptions.CantGetDeviceLocationException; import com.bitdubai.fermat_api.layer.all_definition.enums.GeoFrequency; +import com.bitdubai.fermat_cbp_api.layer.identity.crypto_broker.exceptions.CantListCryptoBrokerIdentitiesException; import com.bitdubai.fermat_cbp_api.layer.identity.crypto_broker.exceptions.CantUpdateCustomerIdentityException; +import com.bitdubai.fermat_cbp_api.layer.identity.crypto_broker.interfaces.CryptoBrokerIdentity; +import com.bitdubai.fermat_cbp_api.layer.identity.crypto_broker.interfaces.CryptoBrokerIdentityManager; import com.bitdubai.fermat_cbp_api.layer.identity.crypto_customer.exceptions.CantCreateCryptoCustomerIdentityException; import com.bitdubai.fermat_cbp_api.layer.identity.crypto_customer.exceptions.CantListCryptoCustomerIdentityException; import com.bitdubai.fermat_cbp_api.layer.identity.crypto_customer.exceptions.CantPublishIdentityException; import com.bitdubai.fermat_cbp_api.layer.identity.crypto_customer.exceptions.IdentityNotFoundException; import com.bitdubai.fermat_cbp_api.layer.identity.crypto_customer.interfaces.CryptoCustomerIdentity; import com.bitdubai.fermat_cbp_api.layer.identity.crypto_customer.interfaces.CryptoCustomerIdentityManager; +import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.exceptions.CantListCryptoBrokersException; +import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.interfaces.CryptoBrokerIdentityInformation; +import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.utils.CryptoBrokerIdentityInformationImpl; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer.exceptions.CantGetCryptoCustomerListException; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.IdentityCustomerPreferenceSettings; import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.exceptions.CouldNotCreateCryptoCustomerException; @@ -40,18 +46,21 @@ public class CryptoCustomerIdentityModuleManagerImpl extends ModuleManagerImpl listIdentities(int max, int offset) throws CantListCryptoBrokersException { + try { + List cryptoBrokers = new ArrayList<>(); + for(CryptoBrokerIdentity identity : this.brokerIdentityManager.listIdentitiesFromCurrentDeviceUser()){ + cryptoBrokers.add(converIdentityToInformation(identity)); + } + return cryptoBrokers; + } catch (CantListCryptoBrokerIdentitiesException e) { + throw new CantListCryptoBrokersException(CantListCryptoBrokersException.DEFAULT_MESSAGE, e, "",""); + } + } + + private CryptoBrokerIdentityInformation converIdentityToInformation(final CryptoBrokerIdentity identity){ + return new CryptoBrokerIdentityInformationImpl(identity.getAlias(), identity.getPublicKey(), identity.getProfileImage(), identity.getExposureLevel(), identity.getAccuracy(), identity.getFrequency()); + } + }