public void createCustomArchive ( String destArchivePath , String homePath , String templateArchivePath , String templateFilename ) { Record recUser = this . getMainRecord ( ) ; Map < String , String > map = new HashMap < String , String > ( ) ; map . put ( "${email}" , recUser . getField ( UserInfo . USER_NAME ) . toString ( ) ) ; Date date = new Date ( ) ; // Today DateField dateField = new DateField ( null , null , - 1 , null , null ) ; dateField . setDate ( date , DBConstants . DISPLAY , DBConstants . INIT_MOVE ) ; map . put ( "${today}" , dateField . toString ( ) ) ; dateField . free ( ) ; URL url = this . getTask ( ) . getApplication ( ) . getResourceURL ( templateFilename , null ) ; StringBuilder sb = new StringBuilder ( Utility . transferURLStream ( url . toString ( ) , null ) ) ; sb = Utility . replace ( sb , map ) ; String templateFile = Utility . addToPath ( destArchivePath , "fixdemo.xsl" ) ; PrintWriter out = null ; try { File file = new File ( templateFile ) ; file . getParentFile ( ) . getParentFile ( ) . mkdirs ( ) ; // .tourgeek file . getParentFile ( ) . mkdirs ( ) ; // Folder file . createNewFile ( ) ; out = new PrintWriter ( file ) ; } catch ( FileNotFoundException e ) { } catch ( IOException e ) { e . printStackTrace ( ) ; } if ( out != null ) { out . print ( sb ) ; out . close ( ) ; // First, make sure the base demo files exist in the file system String workDir = templateArchivePath ; if ( workDir . lastIndexOf ( File . separator ) != - 1 ) // Always workDir = workDir . substring ( workDir . lastIndexOf ( File . separator ) + 1 ) ; String workDirPath = Utility . addToPath ( homePath , workDir ) ; this . populateSourceDir ( templateArchivePath , workDirPath ) ; // Run the xslt against the base demo files. Map < String , Object > properties = new HashMap < String , Object > ( ) ; properties . put ( "sourceDir" , workDirPath ) ; properties . put ( "destDir" , destArchivePath ) ; properties . put ( "extension" , "xml" ) ; properties . put ( "filter" , ".*" ) ; // Hack (filter is a bad name since it it used in many places) properties . put ( "listenerClass" , XMLScanListener . class . getName ( ) ) ; properties . put ( "converterPath" , templateFile ) ; BaseProcess process = new ConvertCode ( this . getTask ( ) , null , properties ) ; process . run ( ) ; process . free ( ) ; } }
CreateCustomArchive Method .