Package org.structr.dynamic

Examples of org.structr.dynamic.File


    final Object value = serverConnection.getValue(key + "Nodes");
    if (value instanceof List) {

      final List<NodeInterface> nodes = (List<NodeInterface>)value;
      final NodeInterface node        = nodes.get(nodeIndex);
      final File file                 = (File)node;

      serverConnection.send(new FileNodeDataContainer(file));
    }
  }
View Full Code Here


    FileUploadHandler newHandler = null;

    try {

      File file = (File) StructrApp.getInstance(securityContext).get(uuid);

      if (file != null) {

        newHandler = new FileUploadHandler(file);
View Full Code Here

        throw new FrameworkException(400, "Please specify name.");
      }

      try (final Tx tx = app.tx()) {

        final File file = FileHelper.createFile(securityContext, new byte[0], "application/zip", File.class, fileName);

        // make file visible for auth. users
        file.setProperty(File.visibleToAuthenticatedUsers, true);

        // Don't include files
        SyncCommand.exportToStream(file.getOutputStream(), app.nodeQuery(NodeInterface.class).getAsList(), app.relationshipQuery(RelationshipInterface.class).getAsList(), null, false);

        tx.success();
      }

    } catch (Throwable t) {
View Full Code Here

    final App app                         = StructrApp.getInstance(securityContext);

    try {

      final String id = (String) webSocketData.getId();
      final File file;

      try (final Tx tx = app.tx()) {

        file = app.get(File.class, id);

        if (file == null) {
          getWebSocket().send(MessageBuilder.status().code(400).message("File not found: ".concat(id)).build(), true);
          return;
        }

        final String fileExtension = StringUtils.substringAfterLast(file.getName(), ".");
        if (!supportedByArchiveStreamFactory.contains(fileExtension)) {

          getWebSocket().send(MessageBuilder.status().code(400).message("Unsupported archive format: ".concat(fileExtension)).build(), true);
          return;
        }
View Full Code Here

        }

      }

      final File file = (File) getNode(uuid);

      if (!securityContext.isAllowed(file, Permission.write)) {

        logger.log(Level.WARNING, "No write permission for {0} on {1}", new Object[] {getWebSocket().getCurrentUser().toString(), file.toString()});
        getWebSocket().send(MessageBuilder.status().message("No write permission").code(400).build(), true);
        return;

      }

      getWebSocket().handleFileChunk(uuid, sequenceNumber, chunkSize, data, chunks);

      if (sequenceNumber+1 == chunks) {

        final long checksum = FileHelper.getChecksum(file);
        final long size     = FileHelper.getSize(file);

        file.setProperty(File.checksum, checksum);
        file.setProperty(File.size, size);
        file.increaseVersion();

        getWebSocket().removeFileUploadHandler(uuid);

        logger.log(Level.FINE, "File upload finished. Checksum: {0}, size: {1}", new Object[]{ checksum, size });

      }

      final long currentSize = (long)(sequenceNumber * chunkSize) + data.length;

      // This should trigger setting of lastModifiedDate in any case
      getWebSocket().send(MessageBuilder.status().code(200).message("{\"id\":\"" + file.getUuid() + "\", \"name\":\"" + file.getName() + "\",\"size\":" + currentSize + "}").build(), true);

    } catch (IOException | FrameworkException ex) {

      String msg = ex.toString();

View Full Code Here

      Logger.getLogger(FilesTest.class.getName()).log(Level.SEVERE, null, ex);
    }

    try (final Tx tx = app.tx()) {

      File file1 = (File) app.create(File.class, "file1");
      assertNotNull(file1);
      assertEquals(FileHelper.getFolderPath(file1), "/file1");

      file1.setProperty(File.parent, folder1);
      assertEquals(FileHelper.getFolderPath(file1), "/folder1/file1");

      tx.success();

    } catch (FrameworkException ex) {
View Full Code Here

TOP

Related Classes of org.structr.dynamic.File

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.