@@ -100,7 +100,7 @@ private void notifyFileSystemChange(final PluginStateChange newState,
100100 final String pluginKey ,
101101 final String pluginVersion ) {
102102 try {
103- logger .info ("Notifying Kill Bill: state='{}', pluginKey='{}', pluginVersion={}" , newState , pluginKey , pluginVersion );
103+ logger .info ("Notifying Kill Bill of plugin state change : state='{}', pluginKey='{}', pluginVersion={}" , newState , pluginKey , pluginVersion );
104104
105105 killbillApi .getSecurityApi ().login (adminUsername , adminPassword );
106106
@@ -110,6 +110,8 @@ private void notifyFileSystemChange(final PluginStateChange newState,
110110 pluginNamingResolver .getPluginName (),
111111 pluginVersion ,
112112 null /* Unused */ );
113+
114+ logger .info ("Successfully notified Kill Bill of plugin state change: pluginKey={}, pluginVersion={}" , pluginKey , pluginVersion );
113115 } finally {
114116 killbillApi .getSecurityApi ().logout ();
115117 }
@@ -118,6 +120,7 @@ private void notifyFileSystemChange(final PluginStateChange newState,
118120 @ Override
119121 public GetAvailablePluginsModel getAvailablePlugins (@ Nonnull final String kbVersion ,
120122 final boolean forceDownload ) throws KPMPluginException {
123+ logger .info ("Fetching available plugins for Kill Bill version: {}, forceDownload: {}" , kbVersion , forceDownload );
121124 final GetAvailablePluginsModel result = new GetAvailablePluginsModel ();
122125
123126 final VersionsProvider versionsProvider = availablePluginsComponentsFactory .createVersionsProvider (kbVersion , forceDownload );
@@ -133,14 +136,16 @@ public GetAvailablePluginsModel getAvailablePlugins(@Nonnull final String kbVers
133136 .getPlugins ();
134137 plugins .forEach (entry -> result .addPlugins (entry .getPluginKey (), entry .getPluginVersion ()));
135138
139+ logger .info ("Successfully fetched {} available plugins for Kill Bill version: {}" , plugins .size (), kbVersion );
140+
136141 return result ;
137142 }
138143
139144 @ Override
140145 public void install (@ Nonnull final String uri ,
141146 @ Nonnull final String pluginKey ,
142147 @ Nonnull final String pluginVersion ) throws KPMPluginException {
143- logger .debug ( "Installing plugin via URL for key: {}, pluginVersion: {}, uri: {}" , pluginKey , pluginVersion , uri );
148+ logger .info ( "Starting installation of plugin: pluginKey= {}, pluginVersion= {}, uri= {}" , pluginKey , pluginVersion , uri );
144149
145150 Path downloadedFile = null ;
146151 final PluginNamingResolver namingResolver = PluginNamingResolver .of (pluginKey , pluginVersion , uri );
@@ -161,6 +166,7 @@ public void install(@Nonnull final String uri,
161166
162167 notifyFileSystemChange (PluginStateChange .NEW_VERSION , pluginKey , fixedVersion );
163168
169+ logger .info ("Plugin installed successfully: pluginKey={}, pluginVersion={}" , pluginKey , pluginVersion );
164170 } catch (final InvalidRequest e ) {
165171 String responseInfo = "" ;
166172 if (e .getResponse () != null ) {
@@ -207,8 +213,8 @@ public void install(@Nonnull final String pluginKey,
207213 String artifactId ,
208214 String pluginVersion ,
209215 final boolean forceDownload ) throws KPMPluginException {
210- logger .info ("Install plugin via coordinate. key:{}, kbVersion:{}, version:{}, groupId:{}, artifactId:{}" ,
211- pluginKey , kbVersion , pluginVersion , groupId , artifactId );
216+ logger .info ("Starting coordinate-based plugin installation: " +
217+ "pluginKey={}, kbVersion={}, version={}, groupId={}, artifactId={}" , pluginKey , kbVersion , pluginVersion , groupId , artifactId );
212218
213219 DownloadResult downloadResult = null ;
214220 Path installedPath = null ;
@@ -230,9 +236,12 @@ public void install(@Nonnull final String pluginKey,
230236 pluginIdentifiersDAO .add (pluginKey , groupId , artifactId , pluginVersion );
231237
232238 notifyFileSystemChange (PluginStateChange .NEW_VERSION , pluginKey , pluginVersion );
233- logger .info ("Plugin key: {} installed successfully via coordinate." , pluginKey );
239+
240+ logger .info ("Successfully installed plugin via coordinate: pluginKey={}, version={}" , pluginKey , pluginVersion );
234241 } catch (final Exception e ) {
235- logger .error ("Error when install pluginKey: '{}' with coordinate. Exception: {}" , pluginKey , e .getMessage ());
242+ logger .error ("Error installing plugin via coordinate: pluginKey={}, version={}, error={}" ,
243+ pluginKey , pluginVersion , e .getMessage (), e );
244+
236245 // If exception happened, installed file should be deleted.
237246 FilesUtils .deleteIfExists (installedPath );
238247 throw new KPMPluginException (e );
@@ -245,21 +254,30 @@ public void install(@Nonnull final String pluginKey,
245254
246255 @ Override
247256 public void uninstall (final String pluginKey , final String version ) throws KPMPluginException {
248- // Uninstall from bundlesPath
249- final Path nextPluginByKey = pluginInstaller .uninstall (pluginKey , version );
250- // Update plugin_identifiers.json
251- final String nextPluginVersion = (nextPluginByKey == null || nextPluginByKey .getFileName () == null ) ?
252- null :
253- PluginNamingResolver .getVersionFromString (nextPluginByKey .getFileName ().toString ());
254- if (Strings .isNullOrEmpty (nextPluginVersion )) {
255- // Last plugin by pluginKey. Just remove it.
256- pluginIdentifiersDAO .remove (pluginKey );
257- } else {
258- // Replace the version value
259- pluginIdentifiersDAO .add (pluginKey , nextPluginVersion );
260- }
257+ logger .info ("Starting uninstallation of plugin: pluginKey={}, version={}" , pluginKey , version );
261258
262- // What if notifyFileSystemChange() implementation fails? Like, wrong username/password?
263- notifyFileSystemChange (PluginStateChange .DISABLED , pluginKey , version );
259+ try {
260+ // Uninstall from bundlesPath
261+ final Path nextPluginByKey = pluginInstaller .uninstall (pluginKey , version );
262+ // Update plugin_identifiers.json
263+ final String nextPluginVersion = (nextPluginByKey == null || nextPluginByKey .getFileName () == null ) ?
264+ null :
265+ PluginNamingResolver .getVersionFromString (nextPluginByKey .getFileName ().toString ());
266+ if (Strings .isNullOrEmpty (nextPluginVersion )) {
267+ // Last plugin by pluginKey. Just remove it.
268+ pluginIdentifiersDAO .remove (pluginKey );
269+ } else {
270+ // Replace the version value
271+ pluginIdentifiersDAO .add (pluginKey , nextPluginVersion );
272+ }
273+
274+ // What if notifyFileSystemChange() implementation fails? Like, wrong username/password?
275+ notifyFileSystemChange (PluginStateChange .DISABLED , pluginKey , version );
276+
277+ logger .info ("Successfully uninstalled plugin: pluginKey={}, version={}" , pluginKey , version );
278+ } catch (final Exception e ) {
279+ logger .error ("Error uninstalling plugin: pluginKey={}, version={}, error={}" , pluginKey , version , e .getMessage (), e );
280+ throw new KPMPluginException ("Uninstallation failed for plugin " + pluginKey , e );
281+ }
264282 }
265283}
0 commit comments