/** Service Interface implementation. */ @Override public void start() throws CantStartPluginException { this.serviceStatus = ServiceStatus.STARTED; // Initializing the dao object. try { if (this.dao == null) { this.dao = new PublisherIdentityDao( this.pluginFileSystem, this.pluginDatabaseSystem, new PublisherIdentityDatabaseFactory(this.pluginDatabaseSystem), this.pluginId, this.logManager); this.dao.initializeDatabase(this.pluginId); } else { this.dao.initializeDatabase(this.pluginId); } } catch (CantInitializePublisherIdentityDatabaseException e) { /* * Catch the failure. * */ errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_WPD_PUBLISHER_IDENTITY, UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, e); throw new CantStartPluginException( "Registry failed to start", e, Plugins.BITDUBAI_WPD_PUBLISHER_IDENTITY.getKey(), ""); } catch (Exception e) { /* * Catch the failure. * */ errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_WPD_PUBLISHER_IDENTITY, UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, e); throw new CantStartPluginException( "Registry failed to start", e, Plugins.BITDUBAI_WPD_PUBLISHER_IDENTITY.getKey(), ""); } finally { logManager.log( PublisherIdentityPluginRoot.getLogLevelByClass(this.getClass().getName()), "Plugin started...", _DEFAUL_STRING, _DEFAUL_STRING); } }
/* * no params. * * @return List<PublisherIdentity> returns the list of publisher linked to the current logged device user. * @throws CantGetUserPublisherIdentitiesException */ @Override public List<PublisherIdentity> getPublishersFromCurrentDeviceUser() throws CantGetUserPublisherIdentitiesException { // Get developers from current device user. try { // Check values. if (this.dao == null) { throw new CantGetUserPublisherIdentitiesException( "Cant get developers from current device user, Dao object is null.", "Plugin Identity", "Cant get developers from current device user, Dao object is null."); } // Get developer list. logManager.log( PublisherIdentityPluginRoot.getLogLevelByClass(this.getClass().getName()), "Getting developers from current device user for : " + deviceUserManager.getLoggedInDeviceUser(), _DEFAUL_STRING, _DEFAUL_STRING); return this.dao.getPublishersFromCurrentDeviceUser(deviceUserManager.getLoggedInDeviceUser()); } catch (CantGetUserPublisherIdentitiesException ce) { // Failure CantGetLoggedInDeviceUserException. throw new CantGetUserPublisherIdentitiesException( ce.getMessage(), ce, "Plugin Identity", "Cant get developers from current device user, Cant get logged in device user failure.."); } catch (Exception e) { // Failure unknown. throw new CantGetUserPublisherIdentitiesException( e.getMessage(), e, "Plugin Identity", "Cant get developers from current device user, unknown failure."); } }
/** * throw an alias creates a new publisher (check before if the alias already exists) * * @return PublisherIdentity with the public key of the new publisher * @throws CantCreateNewPublisherException */ @Override public PublisherIdentity createNewPublisher(String alias) throws CantCreateNewPublisherException { // Create a new developer. try { // Check values. if (this.dao == null) { throw new CantGetUserPublisherIdentitiesException( "Cant create new developer, Dao object is null.", "Plugin Identity", "Cant create new developer, Dao object is null."); } logManager.log( PublisherIdentityPluginRoot.getLogLevelByClass(this.getClass().getName()), "Creating new developer for : " + alias, _DEFAUL_STRING, _DEFAUL_STRING); return this.dao.createNewDeveloper( alias, new ECCKeyPair(), deviceUserManager.getLoggedInDeviceUser()); } catch (CantGetUserPublisherIdentitiesException ce) { // Failure CantGetLoggedInDeviceUserException. throw new CantCreateNewPublisherException( ce.getMessage(), ce, "Plugin Identity", "create new developer, Cant get logged in device user failure.."); } catch (Exception e) { // Failure unknown. throw new CantCreateNewPublisherException( e.getMessage(), e, "Plugin Identity", "Cant create new developer, unknown failure."); } }