View Javadoc
1   package fr.paris.lutece.plugins.appcenter.modules.fastdeployapplication.business.fastaction.ansible;
2   
3   import java.io.ByteArrayInputStream;
4   import java.io.InputStream;
5   import java.util.HashMap;
6   import java.util.Locale;
7   
8   import fr.paris.lutece.plugins.appcenter.modules.fastdeployapplication.business.CommandResult;
9   import fr.paris.lutece.plugins.appcenter.modules.fastdeployapplication.business.FastDeployApplicationData;
10  import fr.paris.lutece.plugins.appcenter.modules.fastdeployapplication.business.ServerApplicationInstance;
11  import fr.paris.lutece.plugins.appcenter.modules.fastdeployapplication.business.fastaction.ActionParameter;
12  import fr.paris.lutece.plugins.appcenter.modules.fastdeployapplication.service.DeploymentFactory;
13  import fr.paris.lutece.plugins.appcenter.modules.fastdeployapplication.service.IFtpService;
14  import fr.paris.lutece.plugins.appcenter.modules.fastdeployapplication.util.ConstanteUtils;
15  import fr.paris.lutece.portal.service.template.AppTemplateService;
16  import fr.paris.lutece.util.html.HtmlTemplate;
17  
18  public class InitAppContextAction extends DefaultAction
19  {
20  
21      
22      @Override
23      public String run(  FastDeployApplicationData data, ServerApplicationInstance serverApplicationInstance, CommandResult commandResult, ActionParameter... parameter )
24      {
25  
26          String strResult = "true";
27          HashMap model = new HashMap( );
28          model.put( ConstanteUtils.MARK_APPLICATION,  data);
29          IFtpService ftpService=DeploymentFactory.getInstance( ).getFtpService( data.getApplicationType( ) );
30          
31          HtmlTemplate templateInitAppContext = AppTemplateService.getTemplate( ConstanteUtils.TEMPLATE_INIT_APP_CONTEXT, Locale.FRENCH, model );
32  
33          InputStream iTemplateInitAppContext = new ByteArrayInputStream( templateInitAppContext.getHtml( ).getBytes( ) );
34  
35          ftpService.uploadFile( data.getWebApp( ) + ".xml", iTemplateInitAppContext, serverApplicationInstance.getFtpInfo( ),
36                  serverApplicationInstance.getFtpDirectoryContext( ), commandResult, false );
37  
38          return strResult;
39      }
40     
41     
42     
43  }