Esempio n. 1
0
 /**
  * Writes collection of {@link DefaultData} objects to the storage.
  *
  * @param storageData Storage to write.
  * @param dataToWrite Data to write.
  * @param dataProcessors Processors that will be used for data writing. Can be null. In this case,
  *     the direct write is done.
  * @param synchronously If write will be done synchronously or not.
  * @throws BusinessException If storage is used as a recording storage.
  * @throws SerializationException If serialization fails during auto-finalization.
  * @throws IOException If {@link IOException} occurs during auto-finalization.
  */
 public void writeToStorage(
     StorageData storageData,
     Collection<? extends DefaultData> dataToWrite,
     Collection<AbstractDataProcessor> dataProcessors,
     boolean synchronously)
     throws BusinessException, IOException, SerializationException {
   StorageData local = getLocalStorageDataObject(storageData);
   StorageWriter writer = openedStoragesMap.get(local);
   if (writer != null) {
     if (synchronously) {
       writer.processSynchronously(dataToWrite, dataProcessors);
     } else {
       writer.process(dataToWrite, dataProcessors);
     }
   } else if (Objects.equals(local, recorderStorageData)) {
     throw new BusinessException(
         "Write data to storage " + local + ".", StorageErrorCodeEnum.WRITE_FAILED);
   } else if (local.getState() == StorageState.CLOSED) {
     throw new BusinessException(
         "Write data to storage " + local + ".", StorageErrorCodeEnum.STORAGE_ALREADY_CLOSED);
   } else {
     log.error("Writer for the not closed storage " + local + " is not available.");
     throw new RuntimeException(
         "Writer for the not closed storage " + local + " is not available.");
   }
 }