package io.liveoak.container.tenancy.service;

import java.io.File;
import java.util.function.Consumer;

import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;

/**
 * @author Ken Finnigan
 */
public class ApplicationGitInstallCommitService implements Service<Void> {
    public ApplicationGitInstallCommitService(Consumer<File> gitCommit, File installDir) {
        this.gitCommit = gitCommit;
        this.installDir = installDir;
    }

    @Override
    public void start(StartContext context) throws StartException {
        this.gitCommit.accept(this.installDir);

        // remove ourselves
        context.getController().setMode(ServiceController.Mode.REMOVE);
    }

    @Override
    public void stop(StopContext context) {
    }

    @Override
    public Void getValue() throws IllegalStateException, IllegalArgumentException {
        return null;
    }

    private Consumer<File> gitCommit;
    private File installDir;
}

@@ -98,16 +98,49 @@
 sumer;%0A%0A
+import org.jboss.logging.Logger;%0A
 import o
@@ -169,16 +169,16 @@
 ervice;%0A
-
 import o
@@ -701,32 +701,50 @@
 tartException %7B%0A
+        try %7B%0A    
         this.git
@@ -775,17 +775,157 @@
 llDir);%0A
-%0A
+        %7D catch (RuntimeException re) %7B%0A            log.error(%22Unable to commit to git on application install%22, re);%0A        %7D finally %7B%0A    
         
@@ -944,16 +944,20 @@
 rselves%0A
+    
         
@@ -1020,16 +1020,26 @@
 EMOVE);%0A
+        %7D%0A
     %7D%0A%0A 
@@ -1262,24 +1262,24 @@
  gitCommit;%0A
-
     private 
@@ -1295,10 +1295,108 @@
 allDir;%0A
+    private static final Logger log = Logger.getLogger(ApplicationGitInstallCommitService.class);%0A
 %7D%0A

Improve error handling of git process to commit installation of application. Mainly of use in tests