Package org.structr.dynamic

Examples of org.structr.dynamic.File


    try {

      if (!(fileExists(fileName, checksum))) {

        File fileNode;

        if (ImageHelper.isImageType(fileName)) {

          fileNode = createImageNode(uuid, fileName, ct, size, checksum);
        } else {

          fileNode = createFileNode(uuid, fileName, ct, size, checksum);
        }

        if (fileNode != null) {

          Folder parent = FileHelper.createFolderPath(securityContext, path);

          if (parent != null) {

            fileNode.setProperty(File.parent, parent);

          }

          if (contentType.equals("text/css")) {
View Full Code Here



  private File createFileNode(final String uuid, final String name, final String contentType, final long size, final long checksum) throws FrameworkException {

    String relativeFilePath = File.getDirectoryPath(uuid) + "/" + uuid;
    File fileNode = app.create(File.class,
      new NodeAttribute(GraphObject.id, uuid),
      new NodeAttribute(AbstractNode.name, name),
      new NodeAttribute(File.relativeFilePath, relativeFilePath),
      new NodeAttribute(File.contentType, contentType),
      new NodeAttribute(File.size, size),
View Full Code Here

    try {

      final String name    = (String) webSocketData.getNodeData().get("name");
      final String rawData = (String) webSocketData.getNodeData().get("fileData");
      File newFile     = FileHelper.createFileBase64(securityContext, rawData, null);

      newFile.setProperty(AbstractNode.name, name);

    } catch (Throwable t) {

      String msg = t.toString();
View Full Code Here

        }

        if (rootElement == null) { // No page found

          // Look for a file
          File file = findFile(securityContext, request, path);
          if (file != null) {

            streamFile(securityContext, file, request, response, edit);
            return;
View Full Code Here

      Folder folderE = folders.get(5);
      folderE.setProperty(AbstractNode.name, "folderE");
      Folder folderF = folders.get(6);
      folderF.setProperty(AbstractNode.name, "folderF");

      File file1 = files.get(0);
      file1.setProperty(AbstractNode.name, "file1");
      File file2 = files.get(1);
      file2.setProperty(AbstractNode.name, "file2");
      File file3 = files.get(2);
      file3.setProperty(AbstractNode.name, "file3");
      File file4 = files.get(3);
      file4.setProperty(AbstractNode.name, "file4");
      File file5 = files.get(4);
      file5.setProperty(AbstractNode.name, "file5");
      File file6 = files.get(5);
      file6.setProperty(AbstractNode.name, "file6");
      File file7 = files.get(6);
      file7.setProperty(AbstractNode.name, "file7");

      rootNode.treeAppendChild(folderA);
      rootNode.treeAppendChild(folderB);
      rootNode.treeAppendChild(file1);
      rootNode.treeAppendChild(file2);
View Full Code Here

      final List<File> files = createTestNodes(File.class, 6);

      assertEquals(6, files.size());

      File nodeA = files.get(0);
      nodeA.setProperty(AbstractNode.name, "fileA");
      File nodeB = files.get(1);
      nodeB.setProperty(AbstractNode.name, "fileB");
      File nodeC = files.get(2);
      nodeC.setProperty(AbstractNode.name, "fileC");
      File nodeD = files.get(3);
      nodeD.setProperty(AbstractNode.name, "fileD");
      File nodeE = files.get(4);
      nodeE.setProperty(AbstractNode.name, "fileE");
      File nodeF = files.get(5);
      nodeF.setProperty(AbstractNode.name, "fileF");

      // create dom tree
      Element html = doc.createElement("html");
      Element body = doc.createElement("body");
      Element b = doc.createElement("b");
View Full Code Here

  protected File createFTPFile(final String path, final String name) throws FrameworkException {
    PropertyMap props = new PropertyMap();
    props.put(File.name, name);
    props.put(File.size, 0L);
    props.put(File.owner, ftpUser);
    File file = (File) createTestNodes(File.class, 1, props).get(0);

    if (StringUtils.isNotBlank(path)) {
      AbstractFile parent = FileHelper.getFileByAbsolutePath(SecurityContext.getSuperUserInstance(), path);
      if (parent != null && parent instanceof Folder) {
        Folder parentFolder = (Folder) parent;
        file.setProperty(Folder.parent, parentFolder);
      }
    }

    logger.log(Level.INFO, "FTP file {0} created successfully.", file);
View Full Code Here

          final String fileName = fileEntry.getKey();
          final byte[] content  = fileEntry.getValue();

          try {
            final File file = FileHelper.createFile(securityContext, content, null, File.class, fileName);
            assertEquals("MIME type detection failed", mimeType, file.getContentType());

          } catch (IOException ioex) {

            ioex.printStackTrace();
            fail("Unexpected exception");
View Full Code Here

          final String fileName = fileEntry.getKey();
          final byte[] content  = fileEntry.getValue();

          try {
            final File file = FileHelper.createFile(securityContext, content, null, File.class, fileName);
            assertEquals("MIME type detection failed for " + fileName, mimeType, file.getContentType());

          } catch (IOException ioex) {

            ioex.printStackTrace();
            fail("Unexpected exception");
View Full Code Here

        }

        if (rootElement == null) { // No page found

          // Look for a file
          File file = findFile(securityContext, request, path);
          if (file != null) {

            //streamFile(securityContext, file, request, response, edit);
            return;
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.