public void handleLobs(long fromTime, long toTime, CDOLobHandler handler) throws IOException {
   for (DB4OBlob db4oBlob : DB4OStore.getElementsOfType(getObjectContainer(), DB4OBlob.class)) {
     byte[] id = HexUtil.hexToBytes(db4oBlob.getId());
     byte[] blob = db4oBlob.getValue();
     ByteArrayInputStream in = new ByteArrayInputStream(blob);
     OutputStream out = handler.handleBlob(id, blob.length);
     if (out != null) {
       try {
         IOUtil.copyBinary(in, out, blob.length);
       } finally {
         IOUtil.close(out);
       }
     }
   }
   for (DB4OClob db4oClob : DB4OStore.getElementsOfType(getObjectContainer(), DB4OClob.class)) {
     byte[] id = HexUtil.hexToBytes(db4oClob.getId());
     char[] clob = db4oClob.getValue();
     CharArrayReader in = new CharArrayReader(clob);
     Writer out = handler.handleClob(id, clob.length);
     if (out != null) {
       try {
         IOUtil.copyCharacter(in, out, clob.length);
       } finally {
         IOUtil.close(out);
       }
     }
   }
 }
  // A fake because afterClass does not seem to work :(
  @AfterClass
  public void testTearDown() throws IOException {
    String ext = "NATIVE";
    if (isConfig(LEGACY)) {
      ext = "LEGACY";
    }

    String location =
        System.getProperty("user.home")
            + "/cdo_Performance_"
            + ext
            + "_"
            + new Date().getTime()
            + ".csv";
    System.out.println("Writing performance results to: " + location);
    File file = new File(location);
    FileWriter fileWriter = new FileWriter(file);

    try {
      StringBuffer stringBuffer = new StringBuffer();
      for (String key : results.keySet()) {
        stringBuffer.append(key + ";" + results.get(key).getTiming() + "\n");
      }

      fileWriter.write(stringBuffer.toString());
    } finally {
      IOUtil.close(fileWriter);
    }
  }
  void saveNode(Node node) {
    OutputStream out = null;

    try {
      File folder = node.getFolder();
      folder.mkdirs();

      File file = new File(folder, NODE_PROPERTIES);
      out = new FileOutputStream(file);
      node.getSettings().store(out, "Node Settings");
    } catch (IOException ex) {
      throw new IORuntimeException(ex);
    } finally {
      IOUtil.close(out);
    }
  }
  private void commitBlob() throws Exception {
    InputStream inputStream = null;

    try {
      Image image = getModel3Factory().createImage();
      image.setWidth(320);
      image.setHeight(200);

      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOResource resource = transaction.createResource(getResourcePath("res"));
      resource.getContents().add(image);

      transaction.commit();
    } finally {
      IOUtil.close(inputStream);
    }
  }
  private Properties loadProperties(File folder) {
    File file = new File(folder, NODE_PROPERTIES);
    if (file.isFile()) {
      InputStream in = null;

      try {
        in = new FileInputStream(file);

        Properties properties = new Properties();
        properties.load(in);
        return properties;
      } catch (IOException ex) {
        throw new IORuntimeException(ex);
      } finally {
        IOUtil.close(in);
      }
    }

    return null;
  }
Exemple #6
0
  public synchronized Properties getHomeProperties() {
    if (homeProperties == null) {
      homeProperties = new Properties();
      String home = System.getProperty("user.home");
      if (home != null) {
        File file = new File(home, ".cdo_config_test.properties");
        if (file.exists()) {
          FileInputStream stream = IOUtil.openInputStream(file);

          try {
            homeProperties.load(stream);
          } catch (IOException ex) {
            throw WrappedException.wrap(ex);
          } finally {
            IOUtil.close(stream);
          }
        }
      }
    }

    return homeProperties;
  }