Logo Search packages:      
Sourcecode: pcalendar version File versions  Download package

void net::sf::linuxorg::pcal::engine::Engine::loadFromFile ( final File  file,
char[]  password 
) throws SAXException, IOException, ParserConfigurationException, PasswordRequiredException [inline]

Load the data from file. If the file was opened with a password, Engine will store the password internally so transparent "Save" operation will be performed without re-requesting the password entry.

file- a file to be loaded
password- a password to be used for the file. If the file appears to be unencrypted, this parameter is ignored.
SAXException- file content format is unparsable
IOException- can not read a file specified
ParserConfigurationException- can not set up the file parser - internal error
PasswordRequiredExceptionis thrown if password parameter is empty but the file is encrypted

Definition at line 578 of file Engine.java.

References net::sf::linuxorg::pcal::engine::EngineXMLCrypter::decryptXML(), net::sf::linuxorg::pcal::engine::EngineXMLCrypter::generateSecretKey(), getDocumentType(), loadFromFileDates(), loadFromFileDateValues(), loadFromFileProperties(), modified, recalculate(), and setWorkFile().

Referenced by net::sf::linuxorg::pcal::MainWindow::loadFileHandler(), net::sf::linuxorg::pcal::engine::EngineTest::testEncryptedLoadSave(), and net::sf::linuxorg::pcal::engine::EngineTest::testLoadSave().

            FileInputStream fileStream = new FileInputStream(file);
            GZIPInputStream f;
            SecretKey secretKey = null;

            fileStream = new FileInputStream(file);
            f = new GZIPInputStream(fileStream);

            Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f);

            int docType = getDocumentType(doc);

            switch(docType) {
            case FILE_TYPE_UNKNOWN:
                  throw new SAXException(Messages.getString("Engine.0")); //$NON-NLS-1$
            case FILE_TYPE_ENCRYPTED: {
                  if((password == null) || (password.length==0)) {
                        throw new PasswordRequiredException();
                  secretKey = EngineXMLCrypter.generateSecretKey(password);
                  doc = EngineXMLCrypter.decryptXML(doc, secretKey);

                  //check if the encryption container contains a regular plain file
                  int internalDocType = getDocumentType(doc);
                  if(internalDocType != FILE_TYPE_PLAIN) {
                        throw new SAXException(Messages.getString("Engine.0")); //$NON-NLS-1$
            case FILE_TYPE_PLAIN:
                  // actually - nothing to do here. The file is ready for parsing.

            //reinitialize the containers

            //load the date types (mens, pregnancy, birh)

            //load the dates with the associated values (notes, BBT values, integers)

            //load the file properties

            // store the password if applicable
            if(docType == FILE_TYPE_ENCRYPTED) {
                  workFileKey = secretKey; 

            modified = false;

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index