+++ /dev/null
-// Created on: 1997-08-07
-// Created by: Jean-Louis Frenkel
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _CDF_MetaDataDriverError_HeaderFile
-#define _CDF_MetaDataDriverError_HeaderFile
-
-#include <Standard_Type.hxx>
-#include <Standard_DefineException.hxx>
-#include <Standard_SStream.hxx>
-#include <Standard_Failure.hxx>
-
-//! This exception is used in the deferred methods.
-//! Programmer implementing such methods may use this
-//! exception or any exception inheriting MetaDataDriverError.
-
-class CDF_MetaDataDriverError;
-DEFINE_STANDARD_HANDLE(CDF_MetaDataDriverError, Standard_Failure)
-
-#if !defined No_Exception && !defined No_CDF_MetaDataDriverError
- #define CDF_MetaDataDriverError_Raise_if(CONDITION, MESSAGE) \
- if (CONDITION) throw CDF_MetaDataDriverError(MESSAGE);
-#else
- #define CDF_MetaDataDriverError_Raise_if(CONDITION, MESSAGE)
-#endif
-
-DEFINE_STANDARD_EXCEPTION(CDF_MetaDataDriverError, Standard_Failure)
-
-#endif // _CDF_MetaDataDriverError_HeaderFile
#include <CDF_Application.hxx>
#include <CDF_MetaDataDriver.hxx>
-#include <CDF_MetaDataDriverError.hxx>
#include <CDF_StoreList.hxx>
#include <CDM_Document.hxx>
#include <CDM_MetaData.hxx>
#include <PCDM.hxx>
#include <PCDM_Document.hxx>
#include <PCDM_StorageDriver.hxx>
-#include <Standard_ErrorHandler.hxx>
-#include <Standard_NoSuchObject.hxx>
#include <TCollection_ExtendedString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(CDF_StoreList,Standard_Transient)
TCollection_ExtendedString& aStatusAssociatedText,
const Message_ProgressRange& theRange)
{
- Handle(CDF_MetaDataDriver) theMetaDataDriver = Handle(CDF_Application)::DownCast((myMainDocument->Application()))->MetaDataDriver();
-
PCDM_StoreStatus status = PCDM_SS_OK;
+ Handle(CDF_MetaDataDriver) theMetaDataDriver = Handle(CDF_Application)::DownCast ((myMainDocument->Application()))->MetaDataDriver();
+ for (; !myStack.IsEmpty(); myStack.RemoveFirst())
{
- try {
- OCC_CATCH_SIGNALS
- for (; !myStack.IsEmpty(); myStack.RemoveFirst()) {
-
- Handle(CDM_Document) theDocument = myStack.First();
- if( theDocument == myMainDocument || theDocument->IsModified()) {
-
- Handle(CDF_Application) anApp = Handle(CDF_Application)::DownCast (theDocument->Application());
- if (anApp.IsNull())
- {
- throw Standard_Failure("Document has no application, cannot save!");
- }
- Handle(PCDM_StorageDriver) aDocumentStorageDriver =
- anApp->WriterFromFormat(theDocument->StorageFormat());
+ Handle(CDM_Document) theDocument = myStack.First();
+ if (theDocument == myMainDocument || theDocument->IsModified())
+ {
+ try
+ {
+ OCC_CATCH_SIGNALS
+ Handle(CDF_Application) anApp = Handle(CDF_Application)::DownCast (theDocument->Application());
+ if (anApp.IsNull())
+ {
+ aStatusAssociatedText = "driver failed; reason: ";
+ aStatusAssociatedText += "document has no application, cannot save!";
+ status = PCDM_SS_Failure;
+ }
+ else
+ {
+ Handle(PCDM_StorageDriver) aDocumentStorageDriver = anApp->WriterFromFormat(theDocument->StorageFormat());
if (aDocumentStorageDriver.IsNull())
{
- Standard_SStream aMsg;
- aMsg <<"No storage driver does exist for this format: " << theDocument->StorageFormat() << (char)0;
- throw Standard_Failure(aMsg.str().c_str());
- }
-
- // Reset the store-status.
- // It has sense in multi-threaded access to the storage driver - this way we reset the status for each call.
- aDocumentStorageDriver->SetStoreStatus(PCDM_SS_OK);
-
- if(!theMetaDataDriver->FindFolder(theDocument->RequestedFolder())) {
- Standard_SStream aMsg; aMsg << "could not find the active dbunit";
- aMsg << TCollection_ExtendedString(theDocument->RequestedFolder())<< (char)0;
- throw Standard_NoSuchObject(aMsg.str().c_str());
+ aStatusAssociatedText = "driver not found; reason: no storage driver does exist for this format: ";
+ aStatusAssociatedText += theDocument->StorageFormat();
+ status = PCDM_SS_UnrecognizedFormat;
}
- TCollection_ExtendedString theName=theMetaDataDriver->BuildFileName(theDocument);
-
- aDocumentStorageDriver->Write(theDocument, theName, theRange);
- status = aDocumentStorageDriver->GetStoreStatus();
- aMetaData = theMetaDataDriver->CreateMetaData(theDocument,theName);
- theDocument->SetMetaData(aMetaData);
-
- CDM_ReferenceIterator it(theDocument);
- for(; it.More();it.Next()) {
- theMetaDataDriver->CreateReference(aMetaData,it.Document()->MetaData(),it.ReferenceIdentifier(),it.DocumentVersion());
+ else
+ {
+ // Reset the store-status.
+ // It has sense in multi-threaded access to the storage driver - this way we reset the status for each call.
+ aDocumentStorageDriver->SetStoreStatus(PCDM_SS_OK);
+
+ if (!theMetaDataDriver->FindFolder(theDocument->RequestedFolder()))
+ {
+ aStatusAssociatedText = "driver not found; reason: ";
+ aStatusAssociatedText += "could not find the active dbunit ";
+ aStatusAssociatedText += theDocument->RequestedFolder();
+ status = PCDM_SS_UnrecognizedFormat;
+ }
+ else
+ {
+ TCollection_ExtendedString theName = theMetaDataDriver->BuildFileName (theDocument);
+ aDocumentStorageDriver->Write (theDocument, theName, theRange);
+ status = aDocumentStorageDriver->GetStoreStatus();
+ aMetaData = theMetaDataDriver->CreateMetaData (theDocument, theName);
+ theDocument->SetMetaData (aMetaData);
+
+ CDM_ReferenceIterator it (theDocument);
+ for (; it.More(); it.Next())
+ theMetaDataDriver->CreateReference (aMetaData, it.Document()->MetaData(), it.ReferenceIdentifier(), it.DocumentVersion());
+ }
}
}
}
- }
-
- catch (CDF_MetaDataDriverError const& anException) {
- CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("metadatadriver failed; reason:"));
- status = PCDM_SS_DriverFailure;
- }
- catch (Standard_Failure const& anException) {
- CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("driver failed; reason:"));
- status = PCDM_SS_Failure;
+ catch (Standard_Failure const& anException)
+ {
+ CAUGHT (anException, aStatusAssociatedText, TCollection_ExtendedString ("driver failed; reason: "));
+ status = PCDM_SS_DriverFailure;
+ }
}
}
#ifndef _PCDM_StoreStatus_HeaderFile
#define _PCDM_StoreStatus_HeaderFile
-
+//! Status of storage of a document on disk.
+//! If it is PCDM_SS_OK, the document is successfully saved on disk.
+//! Else - there is an error.
enum PCDM_StoreStatus
{
-PCDM_SS_OK,
-PCDM_SS_DriverFailure,
-PCDM_SS_WriteFailure,
-PCDM_SS_Failure,
-PCDM_SS_Doc_IsNull,
-PCDM_SS_No_Obj,
-PCDM_SS_Info_Section_Error,
-PCDM_SS_UserBreak
+PCDM_SS_OK, //!< Document is saved successfully
+PCDM_SS_DriverFailure, //!< Storage driver is not found
+PCDM_SS_WriteFailure, //!< Attempt to write a file on disk failed
+PCDM_SS_Failure, //!< A general error occurred (unexpected)
+PCDM_SS_Doc_IsNull, //!< Attempt to save a null document
+PCDM_SS_No_Obj, //!< Document has no objects to be saved
+PCDM_SS_Info_Section_Error, //!< Error occured on writing of an information-section
+PCDM_SS_UserBreak, //!< User interrupted the process of storage of the document on disk
+PCDM_SS_UnrecognizedFormat //!< No storage driver exist for this document format
};
#endif // _PCDM_StoreStatus_HeaderFile