private File generateJsonFromIndividualESAs ( Path jsonDirectory , Map < String , String > shortNameMap ) throws IOException , RepositoryException , InstallException { String dir = jsonDirectory . toString ( ) ; List < File > esas = ( List < File > ) data . get ( INDIVIDUAL_ESAS ) ; File singleJson = new File ( dir + "/SingleJson.json" ) ; for ( File esa : esas ) { try { populateFeatureNameFromManifest ( esa , shortNameMap ) ; } catch ( IOException e ) { throw new InstallException ( Messages . INSTALL_KERNEL_MESSAGES . getLogMessage ( "ERROR_ESA_NOT_FOUND" , esa . getAbsolutePath ( ) ) ) ; } SingleFileRepositoryConnection mySingleFileRepo = null ; if ( singleJson . exists ( ) ) { mySingleFileRepo = new SingleFileRepositoryConnection ( singleJson ) ; } else { try { mySingleFileRepo = SingleFileRepositoryConnection . createEmptyRepository ( singleJson ) ; } catch ( IOException e ) { throw new InstallException ( Messages . INSTALL_KERNEL_MESSAGES . getLogMessage ( "ERROR_SINGLE_REPO_CONNECTION_FAILED" , dir , esa . getAbsolutePath ( ) ) ) ; } } Parser < ? extends RepositoryResourceWritable > parser = new EsaParser ( true ) ; RepositoryResourceWritable resource = parser . parseFileToResource ( esa , null , null ) ; resource . updateGeneratedFields ( true ) ; resource . setRepositoryConnection ( mySingleFileRepo ) ; // Overload the Maven coordinates field with the file path, since the ESA should be installed from that path resource . setMavenCoordinates ( esa . getAbsolutePath ( ) ) ; resource . uploadToMassive ( new AddThenDeleteStrategy ( ) ) ; } return singleJson ; }
generate a JSON from provided individual ESA files