Package org.structr.web.entity

Examples of org.structr.web.entity.AbstractFile


      try {
        if (path.contains("/")) {

          String newParentPath = StringUtils.substringBeforeLast(path, "/");
          AbstractFile newParent = FileHelper.getFileByAbsolutePath(SecurityContext.getSuperUserInstance(), newParentPath);

          if (newParent != null && newParent instanceof Folder) {

            Folder newParentFolder = (Folder) newParent;
            structrFile.setProperty(AbstractFile.parent, newParentFolder);
View Full Code Here


   * @throws FrameworkException
   * @throws IOException
   */
  public static <T extends org.structr.dynamic.File> T transformFile(final SecurityContext securityContext, final String uuid, final Class<T> fileType) throws FrameworkException, IOException {

    AbstractFile existingFile = getFileByUuid(securityContext, uuid);

    if (existingFile != null) {

      existingFile.unlockReadOnlyPropertiesOnce();
      existingFile.setProperty(AbstractNode.type, fileType == null ? org.structr.dynamic.File.class.getSimpleName() : fileType.getSimpleName());

      existingFile = getFileByUuid(securityContext, uuid);

      return (T)(fileType != null ? fileType.cast(existingFile) : (org.structr.dynamic.File) existingFile);
    }
View Full Code Here

    props.put(Folder.name, name);
    props.put(Folder.owner, ftpUser);
    Folder dir = (Folder) createTestNodes(Folder.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;
        dir.setProperty(Folder.parent, parentFolder);
      }
    }
View Full Code Here

    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);
      }
    }
View Full Code Here

    // Find root folder
    if (parts[0].length() == 0) {
      return null;
    }

    AbstractFile currentFile = getFirstRootFileByName(securityContext, parts[0]);
    if (currentFile == null) {
      return null;
    }

    for (int i = 1; i < parts.length; i++) {

      List<AbstractFile> children = currentFile.getProperty(AbstractFile.children);

      currentFile = null;

      for (AbstractFile child : children) {
View Full Code Here

    final App app = StructrApp.getInstance();
    try (final Tx tx = app.tx()) {

      logger.log(Level.INFO, "mkdir() Folder");

      AbstractFile existing = FileHelper.getFileByAbsolutePath(SecurityContext.getSuperUserInstance(), newPath);
      if (existing != null) {
        logger.log(Level.WARNING, "File {0} already exists.", newPath);
        return false;
      }
View Full Code Here

//
//    Folder workingDir = structrUser.getProperty(org.structr.web.entity.User.workingDirectory);
//    if (workingDir == null) {
//      workingDir = structrUser.getProperty(org.structr.web.entity.User.homeDirectory);
//    }
      AbstractFile structrWorkingDir = FileHelper.getFileByAbsolutePath(SecurityContext.getSuperUserInstance(), workingDir);
      if (structrWorkingDir == null || structrWorkingDir instanceof File) {
        return new StructrFtpFolder(null);
      }

      return new StructrFtpFolder((Folder) structrWorkingDir);
View Full Code Here

        logger.log(Level.INFO, "Base path: {0}, requestedPath: {1}", new Object[]{basePath, requestedPath});

      }

      AbstractFile file = FileHelper.getFileByAbsolutePath(SecurityContext.getSuperUserInstance(), requestedPath);

      if (file != null) {

        if (file instanceof Folder) {
          return new StructrFtpFolder((Folder) file);
View Full Code Here

        while (entry != null && count++ < 50) {

          final String entryPath = "/" + PathHelper.clean(entry.getName());
          logger.log(Level.INFO, "Entry path: {0}", entryPath);

          final AbstractFile f = FileHelper.getFileByAbsolutePath(securityContext, entryPath);
          if (f == null) {

            final Folder parentFolder = createOrGetParentFolder(securityContext, entryPath);
            final String name         = PathHelper.getName(entry.getName());

            if (StringUtils.isNotEmpty(name) && (parentFolder == null || !(FileHelper.getFolderPath(parentFolder).equals(entryPath)))) {

              AbstractFile fileOrFolder = null;

              if (entry.isDirectory()) {

                fileOrFolder = app.create(Folder.class, name);

              } else {

                fileOrFolder = ImageHelper.isImageType(name)
                  ? ImageHelper.createImage(securityContext, in, null, Image.class, name, false)
                  : FileHelper.createFile(securityContext, in, null, File.class, name);
              }

              if (parentFolder != null) {
                fileOrFolder.setProperty(AbstractFile.parent, parentFolder);
              }

              logger.log(Level.INFO, "Created {0} {1} with path {2}", new Object[]{fileOrFolder.getType(), fileOrFolder, FileHelper.getFolderPath(fileOrFolder)});

              // create thumbnails while importing data
              if (fileOrFolder instanceof Image) {
                fileOrFolder.getProperty(Image.tnMid);
                fileOrFolder.getProperty(Image.tnSmall);
              }

            }
          }
View Full Code Here

    if (parentNode instanceof Folder) {

      Folder folder = (Folder) parentNode;
     
      AbstractFile file = (AbstractFile) getNode(id);

      if (file != null) {
       
        try {
          // Remove from existing parent
          Folder currentParent = (Folder)file.treeGetParent();
          if (currentParent != null) {
           
            currentParent.treeRemoveChild(file);
           
          }
View Full Code Here

TOP

Related Classes of org.structr.web.entity.AbstractFile

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.