private void process ( String input , String output ) throws MPXJException , IOException { // // Extract the project data // MPPReader reader = new MPPReader ( ) ; m_project = reader . read ( input ) ; String varDataFileName ; String projectDirName ; int mppFileType = NumberHelper . getInt ( m_project . getProjectProperties ( ) . getMppFileType ( ) ) ; switch ( mppFileType ) { case 8 : { projectDirName = " 1" ; varDataFileName = "FixDeferFix 0" ; break ; } case 9 : { projectDirName = " 19" ; varDataFileName = "Var2Data" ; break ; } case 12 : { projectDirName = " 112" ; varDataFileName = "Var2Data" ; break ; } case 14 : { projectDirName = " 114" ; varDataFileName = "Var2Data" ; break ; } default : { throw new IllegalArgumentException ( "Unsupported file type " + mppFileType ) ; } } // // Load the raw file // FileInputStream is = new FileInputStream ( input ) ; POIFSFileSystem fs = new POIFSFileSystem ( is ) ; is . close ( ) ; // // Locate the root of the project file system // DirectoryEntry root = fs . getRoot ( ) ; m_projectDir = ( DirectoryEntry ) root . getEntry ( projectDirName ) ; // // Process Tasks // Map < String , String > replacements = new HashMap < String , String > ( ) ; for ( Task task : m_project . getTasks ( ) ) { mapText ( task . getName ( ) , replacements ) ; } processReplacements ( ( ( DirectoryEntry ) m_projectDir . getEntry ( "TBkndTask" ) ) , varDataFileName , replacements , true ) ; // // Process Resources // replacements . clear ( ) ; for ( Resource resource : m_project . getResources ( ) ) { mapText ( resource . getName ( ) , replacements ) ; mapText ( resource . getInitials ( ) , replacements ) ; } processReplacements ( ( DirectoryEntry ) m_projectDir . getEntry ( "TBkndRsc" ) , varDataFileName , replacements , true ) ; // // Process project properties // replacements . clear ( ) ; ProjectProperties properties = m_project . getProjectProperties ( ) ; mapText ( properties . getProjectTitle ( ) , replacements ) ; processReplacements ( m_projectDir , "Props" , replacements , true ) ; replacements . clear ( ) ; mapText ( properties . getProjectTitle ( ) , replacements ) ; mapText ( properties . getSubject ( ) , replacements ) ; mapText ( properties . getAuthor ( ) , replacements ) ; mapText ( properties . getKeywords ( ) , replacements ) ; mapText ( properties . getComments ( ) , replacements ) ; processReplacements ( root , "\005SummaryInformation" , replacements , false ) ; replacements . clear ( ) ; mapText ( properties . getManager ( ) , replacements ) ; mapText ( properties . getCompany ( ) , replacements ) ; mapText ( properties . getCategory ( ) , replacements ) ; processReplacements ( root , "\005DocumentSummaryInformation" , replacements , false ) ; // // Write the replacement raw file // FileOutputStream os = new FileOutputStream ( output ) ; fs . writeFilesystem ( os ) ; os . flush ( ) ; os . close ( ) ; fs . close ( ) ; }
Process an MPP file to make it anonymous .