@Override public Artist createArtistIdentity( String userName, byte[] profileImage, String password, ExternalPlatform externalPlatform, ExposureLevel exposureLevel, ArtistAcceptConnectionsType artistAcceptConnectionsType) throws CantCreateArtistIdentityException, ArtistIdentityAlreadyExistsException, WrongTokenlyUserCredentialsException { try { DeviceUser deviceUser = deviceUserManager.getLoggedInDeviceUser(); ECCKeyPair keyPair = new ECCKeyPair(); UUID id = UUID.randomUUID(); String publicKey = keyPair.getPublicKey(); String privateKey = keyPair.getPrivateKey(); User user = null; try { if (externalPlatform == ExternalPlatform.DEFAULT_EXTERNAL_PLATFORM) user = tokenlyApiManager.validateTokenlyUser(userName, password); } catch (CantGetUserException | InterruptedException | ExecutionException e) { throw new CantCreateArtistIdentityException( e, "Validating Tokenly User", "Cannot create Tokenly User"); } getArtistIdentityDao() .createNewUser( user, id, publicKey, privateKey, deviceUser, profileImage, password, externalPlatform, exposureLevel, artistAcceptConnectionsType); return new TokenlyArtistIdentityRecord( user, id, publicKey, profileImage, externalPlatform, exposureLevel, artistAcceptConnectionsType); } catch (CantGetLoggedInDeviceUserException e) { throw new CantCreateArtistIdentityException( "CAN'T CREATE NEW ARTIST IDENTITY", e, "Error getting current logged in device user", ""); } catch (Exception e) { throw new CantCreateArtistIdentityException( "CAN'T CREATE NEW ARTIST IDENTITY", FermatException.wrapException(e), "", ""); } }
@Override public Artist updateArtistIdentity( String username, String password, UUID id, String publicKey, byte[] profileImage, ExternalPlatform externalPlatform, ExposureLevel exposureLevel, ArtistAcceptConnectionsType artistAcceptConnectionsType) throws CantUpdateArtistIdentityException, WrongTokenlyUserCredentialsException { try { User user = null; try { if (externalPlatform == ExternalPlatform.DEFAULT_EXTERNAL_PLATFORM) user = tokenlyApiManager.validateTokenlyUser(username, password); } catch (CantGetUserException | InterruptedException | ExecutionException e) { throw new CantUpdateArtistIdentityException( e, "Validating Tokenly User", "Cannot create Tokenly User"); } getArtistIdentityDao() .updateIdentityArtistUser( user, password, id, publicKey, profileImage, externalPlatform, exposureLevel, artistAcceptConnectionsType); return getArtistIdentityDao().getIdentityArtist(id); } catch (CantInitializeTokenlyArtistIdentityDatabaseException e) { e.printStackTrace(); } catch (CantGetArtistIdentityException e) { e.printStackTrace(); } return null; }