Package org.structr.cloud.message

Examples of org.structr.cloud.message.FileNodeDataContainer


    fileMap.put(container.getSourceNodeId(), container);
  }

  public void finishFile(final FileNodeEndChunk endChunk) throws FrameworkException {

    final FileNodeDataContainer container = fileMap.get(endChunk.getContainerId());
    if (container == null) {

      logger.log(Level.WARNING, "Received file end chunk for ID {0} without file, this should not happen!", endChunk.getContainerId());

    } else {

      container.flushAndCloseTemporaryFile();

      final NodeInterface newNode = storeNode(container);
      final String filesPath = StructrApp.getConfigurationValue(Services.FILES_PATH);
      final String relativePath = newNode.getProperty(File.relativeFilePath);
      String newPath = null;

      if (filesPath.endsWith("/")) {

        newPath = filesPath + relativePath;

      } else {

        newPath = filesPath + "/" + relativePath;
      }

      try {
        container.persistTemporaryFile(newPath);

      } catch (Throwable t) {

        // do not catch specific exception only, we need to be able to shut
        // down the connection gracefully, so we must make sure not to be
View Full Code Here


    }
  }

  public void fileChunk(final FileNodeChunk chunk) {

    final FileNodeDataContainer container = fileMap.get(chunk.getContainerId());

    if (container == null) {

      logger.log(Level.WARNING, "Received file chunk for ID {0} without file, this should not happen!", chunk.getContainerId());

    } else {

      container.addChunk(chunk);
    }
  }
View Full Code Here

   * @throws java.io.IOException
   */
  public static void sendFile(final CloudConnection client, final File file, final int chunkSize) throws FrameworkException, IOException {

    // send file container first
    FileNodeDataContainer container = new FileNodeDataContainer(file);
    client.send(container);

    // send chunks
    for (FileNodeChunk chunk : FileNodeDataContainer.getChunks(file, chunkSize)) {
      client.send(chunk);
    }

    // mark end of file with special chunk
    client.send(new FileNodeEndChunk(container.getSourceNodeId(), container.getFileSize()));
  }
View Full Code Here

TOP

Related Classes of org.structr.cloud.message.FileNodeDataContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.