Mercurial > hg > orthanc
comparison OrthancServer/Sources/main.cpp @ 5783:56352ae88120 find-refactoring
wip: new ReadOnly configuration
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 16 Sep 2024 18:31:37 +0200 |
parents | a6f121707dfe |
children | b4e7a85cde80 |
comparison
equal
deleted
inserted
replaced
5782:f1ccb67fce31 | 5783:56352ae88120 |
---|---|
823 PrintErrorCode(ErrorCode_DatabaseCannotSerialize, "Database could not serialize access due to concurrent update, the transaction should be retried"); | 823 PrintErrorCode(ErrorCode_DatabaseCannotSerialize, "Database could not serialize access due to concurrent update, the transaction should be retried"); |
824 PrintErrorCode(ErrorCode_Revision, "A bad revision number was provided, which might indicate conflict between multiple writers"); | 824 PrintErrorCode(ErrorCode_Revision, "A bad revision number was provided, which might indicate conflict between multiple writers"); |
825 PrintErrorCode(ErrorCode_MainDicomTagsMultiplyDefined, "A main DICOM Tag has been defined multiple times for the same resource level"); | 825 PrintErrorCode(ErrorCode_MainDicomTagsMultiplyDefined, "A main DICOM Tag has been defined multiple times for the same resource level"); |
826 PrintErrorCode(ErrorCode_ForbiddenAccess, "Access to a resource is forbidden"); | 826 PrintErrorCode(ErrorCode_ForbiddenAccess, "Access to a resource is forbidden"); |
827 PrintErrorCode(ErrorCode_DuplicateResource, "Duplicate resource"); | 827 PrintErrorCode(ErrorCode_DuplicateResource, "Duplicate resource"); |
828 PrintErrorCode(ErrorCode_IncompatibleConfigurations, "Your configuration file contains configuration that are mutually incompatible"); | |
828 PrintErrorCode(ErrorCode_SQLiteNotOpened, "SQLite: The database is not opened"); | 829 PrintErrorCode(ErrorCode_SQLiteNotOpened, "SQLite: The database is not opened"); |
829 PrintErrorCode(ErrorCode_SQLiteAlreadyOpened, "SQLite: Connection is already open"); | 830 PrintErrorCode(ErrorCode_SQLiteAlreadyOpened, "SQLite: Connection is already open"); |
830 PrintErrorCode(ErrorCode_SQLiteCannotOpen, "SQLite: Unable to open the database"); | 831 PrintErrorCode(ErrorCode_SQLiteCannotOpen, "SQLite: Unable to open the database"); |
831 PrintErrorCode(ErrorCode_SQLiteStatementAlreadyUsed, "SQLite: This cached statement is already being referred to"); | 832 PrintErrorCode(ErrorCode_SQLiteStatementAlreadyUsed, "SQLite: This cached statement is already being referred to"); |
832 PrintErrorCode(ErrorCode_SQLiteExecute, "SQLite: Cannot execute a command"); | 833 PrintErrorCode(ErrorCode_SQLiteExecute, "SQLite: Cannot execute a command"); |
834 PrintErrorCode(ErrorCode_SQLiteCommitWithoutTransaction, "SQLite: Committing a nonexistent transaction"); | 835 PrintErrorCode(ErrorCode_SQLiteCommitWithoutTransaction, "SQLite: Committing a nonexistent transaction"); |
835 PrintErrorCode(ErrorCode_SQLiteRegisterFunction, "SQLite: Unable to register a function"); | 836 PrintErrorCode(ErrorCode_SQLiteRegisterFunction, "SQLite: Unable to register a function"); |
836 PrintErrorCode(ErrorCode_SQLiteFlush, "SQLite: Unable to flush the database"); | 837 PrintErrorCode(ErrorCode_SQLiteFlush, "SQLite: Unable to flush the database"); |
837 PrintErrorCode(ErrorCode_SQLiteCannotRun, "SQLite: Cannot run a cached statement"); | 838 PrintErrorCode(ErrorCode_SQLiteCannotRun, "SQLite: Cannot run a cached statement"); |
838 PrintErrorCode(ErrorCode_SQLiteCannotStep, "SQLite: Cannot step over a cached statement"); | 839 PrintErrorCode(ErrorCode_SQLiteCannotStep, "SQLite: Cannot step over a cached statement"); |
839 PrintErrorCode(ErrorCode_SQLiteBindOutOfRange, "SQLite: Bing a value while out of range (serious error)"); | 840 PrintErrorCode(ErrorCode_SQLiteBindOutOfRange, "SQLite: Bind a value while out of range (serious error)"); |
840 PrintErrorCode(ErrorCode_SQLitePrepareStatement, "SQLite: Cannot prepare a cached statement"); | 841 PrintErrorCode(ErrorCode_SQLitePrepareStatement, "SQLite: Cannot prepare a cached statement"); |
841 PrintErrorCode(ErrorCode_SQLiteTransactionAlreadyStarted, "SQLite: Beginning the same transaction twice"); | 842 PrintErrorCode(ErrorCode_SQLiteTransactionAlreadyStarted, "SQLite: Beginning the same transaction twice"); |
842 PrintErrorCode(ErrorCode_SQLiteTransactionCommit, "SQLite: Failure when committing the transaction"); | 843 PrintErrorCode(ErrorCode_SQLiteTransactionCommit, "SQLite: Failure when committing the transaction"); |
843 PrintErrorCode(ErrorCode_SQLiteTransactionBegin, "SQLite: Cannot start a transaction"); | 844 PrintErrorCode(ErrorCode_SQLiteTransactionBegin, "SQLite: Cannot start a transaction"); |
844 PrintErrorCode(ErrorCode_DirectoryOverFile, "The directory to be created is already occupied by a regular file"); | 845 PrintErrorCode(ErrorCode_DirectoryOverFile, "The directory to be created is already occupied by a regular file"); |
1561 ServerContext context(database, storageArea, false /* not running unit tests */, maxCompletedJobs); | 1562 ServerContext context(database, storageArea, false /* not running unit tests */, maxCompletedJobs); |
1562 | 1563 |
1563 { | 1564 { |
1564 OrthancConfiguration::ReaderLock lock; | 1565 OrthancConfiguration::ReaderLock lock; |
1565 | 1566 |
1566 context.SetCompressionEnabled(lock.GetConfiguration().GetBooleanParameter("StorageCompression", false)); | 1567 // New option in Orthanc 1.12.5 |
1567 context.SetStoreMD5ForAttachments(lock.GetConfiguration().GetBooleanParameter("StoreMD5ForAttachments", true)); | 1568 context.SetReadOnly(lock.GetConfiguration().GetBooleanParameter("ReadOnly", false)); |
1568 | 1569 |
1569 // New option in Orthanc 1.4.2 | 1570 if (context.IsReadOnly()) |
1570 context.SetOverwriteInstances(lock.GetConfiguration().GetBooleanParameter("OverwriteInstances", false)); | 1571 { |
1571 | 1572 LOG(WARNING) << "READ-ONLY SYSTEM: ignoring these configurations: StorageCompression, StoreMD5ForAttachments, OverwriteInstances, MaximumPatientCount, MaximumStorageSize, MaximumStorageMode"; |
1572 try | 1573 |
1573 { | 1574 if (context.IsSaveJobs()) |
1574 context.GetIndex().SetMaximumPatientCount(lock.GetConfiguration().GetUnsignedIntegerParameter("MaximumPatientCount", 0)); | 1575 { |
1575 } | 1576 throw OrthancException(ErrorCode_IncompatibleConfigurations, "\"SaveJobs\" can not be true when \"ReadOnly\" is true"); |
1576 catch (...) | 1577 } |
1577 { | 1578 } |
1578 context.GetIndex().SetMaximumPatientCount(0); | 1579 else |
1579 } | 1580 { |
1580 | 1581 context.SetCompressionEnabled(lock.GetConfiguration().GetBooleanParameter("StorageCompression", false)); |
1581 try | 1582 context.SetStoreMD5ForAttachments(lock.GetConfiguration().GetBooleanParameter("StoreMD5ForAttachments", true)); |
1582 { | 1583 |
1583 uint64_t size = lock.GetConfiguration().GetUnsignedIntegerParameter("MaximumStorageSize", 0); | 1584 // New option in Orthanc 1.4.2 |
1584 context.GetIndex().SetMaximumStorageSize(size * 1024 * 1024); | 1585 context.SetOverwriteInstances(lock.GetConfiguration().GetBooleanParameter("OverwriteInstances", false)); |
1585 } | 1586 |
1586 catch (...) | 1587 try |
1587 { | 1588 { |
1588 context.GetIndex().SetMaximumStorageSize(0); | 1589 context.GetIndex().SetMaximumPatientCount(lock.GetConfiguration().GetUnsignedIntegerParameter("MaximumPatientCount", 0)); |
1589 } | 1590 } |
1590 | 1591 catch (...) |
1591 try | 1592 { |
1592 { | 1593 context.GetIndex().SetMaximumPatientCount(0); |
1593 std::string mode = lock.GetConfiguration().GetStringParameter("MaximumStorageMode", "Recycle"); | 1594 } |
1594 context.GetIndex().SetMaximumStorageMode(StringToMaxStorageMode(mode)); | 1595 |
1595 } | 1596 try |
1596 catch (...) | 1597 { |
1597 { | 1598 uint64_t size = lock.GetConfiguration().GetUnsignedIntegerParameter("MaximumStorageSize", 0); |
1598 context.GetIndex().SetMaximumStorageMode(MaxStorageMode_Recycle); | 1599 context.GetIndex().SetMaximumStorageSize(size * 1024 * 1024); |
1599 } | 1600 } |
1600 | 1601 catch (...) |
1602 { | |
1603 context.GetIndex().SetMaximumStorageSize(0); | |
1604 } | |
1605 | |
1606 try | |
1607 { | |
1608 std::string mode = lock.GetConfiguration().GetStringParameter("MaximumStorageMode", "Recycle"); | |
1609 context.GetIndex().SetMaximumStorageMode(StringToMaxStorageMode(mode)); | |
1610 } | |
1611 catch (...) | |
1612 { | |
1613 context.GetIndex().SetMaximumStorageMode(MaxStorageMode_Recycle); | |
1614 } | |
1615 } | |
1616 | |
1617 // note: this config is valid in ReadOnlyMode | |
1601 try | 1618 try |
1602 { | 1619 { |
1603 uint64_t size = lock.GetConfiguration().GetUnsignedIntegerParameter("MaximumStorageCacheSize", 128); | 1620 uint64_t size = lock.GetConfiguration().GetUnsignedIntegerParameter("MaximumStorageCacheSize", 128); |
1604 context.SetMaximumStorageCacheSize(size * 1024 * 1024); | 1621 context.SetMaximumStorageCacheSize(size * 1024 * 1024); |
1605 } | 1622 } |