Examples of File


Examples of net.sourceforge.fullsync.fs.File

    Collection<File> srcFiles = src.getChildren();
    Collection<File> dstFiles = new ArrayList<File>(dst.getChildren());

    for (File sfile : srcFiles) {
      File dfile = dst.getChild(sfile.getName());
      if (dfile == null) {
        dfile = dst.createChild(sfile.getName(), sfile.isDirectory());
      }
      else {
        dstFiles.remove(dfile);
      }

      synchronizeNodes(sfile, dfile, rules, parent);
    }

    for (File dfile : dstFiles) {
      File sfile = src.getChild(dfile.getName());
      if (sfile == null) {
        sfile = src.createChild(dfile.getName(), dfile.isDirectory());
      }

      synchronizeNodes(sfile, dfile, rules, parent);
View Full Code Here

Examples of nl.oneday.data.domain.uploads.File

  @ResponseBody
  public String setProfileImage(@PathVariable(value = "imageId") Long imageId) {
    UserDetails userDetails = getCurrentUserDetails();
    User user = userService.getUserByUserName(userDetails.getUsername());
    JSONObject results = new JSONObject();
    File file = fileService.find(imageId);

      ProfileImage profileImage = new ProfileImage();
      profileImage.setFile(file);
      results.put("success", profileImageService.saveProfileImage(profileImage));
View Full Code Here

Examples of org.apache.harmony.pack200.Archive.File

            ClassReader reader = (ClassReader) iterator.next();
            classNames.add(reader.getClassName());
        }
        CPUTF8 emptyString = cpBands.getCPUtf8("");
        for (int i = 0; i < files.size(); i++) {
             File file = (File)files.get(i);
             String name = file.getName();
             if(name.endsWith(".class")) {
                 file_options[i] |= (1 << 1);
                 if(classNames.contains(name.substring(0, name.length() - 6))) {
                     fileName[i] = emptyString;
                 } else {
                     fileName[i] = cpBands.getCPUtf8(name);
                 }
             } else {
                 fileName[i] = cpBands.getCPUtf8(name);
             }
             byte[] bytes = file.getContents();
             file_size[i] = bytes.length;
             totalSize += file_size[i];
             file_modtime[i] = (int)(file.getModtime() - archiveModtime);
             file_bits[i] = file.getContents();
         }
    }
View Full Code Here

Examples of org.apache.jackrabbit.ocm.testmodel.File

      //---------------------------------------------------------------------------------------------------------     
            Resource resource = new Resource();
            resource.setData(new ByteArrayInputStream("this is the content".getBytes()));           
            resource.setLastModified(Calendar.getInstance());
            resource.setMimeType("plain/text");
            File file = new File();   
            file.setResource(resource);
           
           
            Folder folder = new Folder();
            folder.setPath("/folder1");
            folder.addChild(file);
           
            ocm.insert(folder);           
      ocm.save();
     
     
      //---------------------------------------------------------------------------------------------------------
      // Retrieve a document object
      //---------------------------------------------------------------------------------------------------------           
      folder = (Folder) ocm.getObject( "/folder1");
      assertNotNull("folder is null", folder);
      System.out.println("Folder creation date : " + folder.getCreationDate());
      assertTrue("Invalid number of children", folder.getChildren().size() == 1);
      file = (File) folder.getChildren().iterator().next();
      assertNotNull("resource is null", file.getResource())
      System.out.println("File resource calendar: " + file.getResource().getLastModified())// The prop is autocreated
     
     
    }
    catch (Exception e)
    {
View Full Code Here

Examples of org.apache.struts2.components.File

/**
* @see File
*/
public class FileDirective extends AbstractDirective {
    protected Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
        return new File(stack, req, res);
    }
View Full Code Here

Examples of org.apache.wicket.util.file.File

  @Test
  public void writeToTempFile() throws IOException
  {
    tester.startPage(TestPage.class);

    File tmp = null;
    try
    {
      tmp = FileUploadFieldTest.writeTestFile(1);
      FormTester formtester = tester.newFormTester("form");
      formtester.setFile("upload", tmp, "text/plain");
      formtester.submit();

      TestPage page = (TestPage)tester.getLastRenderedPage();
      assertNotNull(page.testFile);
    }
    finally
    {
      if (tmp != null && tmp.exists())
      {
        tmp.delete();
      }
    }
  }
View Full Code Here

Examples of org.crsh.vfs.File

        case LIFECYCLE:
          if ("login".equals(resourceId) || "logout".equals(resourceId)) {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            long timestamp = Long.MIN_VALUE;
            for (File path : dirs) {
              File f = path.child(resourceId + ".groovy");
              if (f != null) {
                Resource sub = f.getResource();
                if (sub != null) {
                  buffer.write(sub.getContent());
                  buffer.write('\n');
                  timestamp = Math.max(timestamp, sub.getTimestamp());
                }
              }
            }
            return Collections.singleton(new Resource(resourceId + ".groovy", buffer.toByteArray(), timestamp));
          }
          break;
        case COMMAND:
          // Find the resource first, we find for the first found
          for (File path : dirs) {
            File f = path.child(resourceId);
            if (f != null) {
              return Collections.singleton(f.getResource());
            }
          }
          break;
        case CONFIG:
          String path = "/" + resourceId;
          File file = confFS.get(Path.get(path));
          if (file != null) {
            return Collections.singleton(loadConf(file));
          }
      }
    } catch (IOException e) {
View Full Code Here

Examples of org.damour.base.client.objects.File

    Transaction tx = session.beginTransaction();

    try {
      for (final FileItem item : fileItems) {

        File fileObject = null;
        if (item.getContentType().contains("image")) {
          fileObject = new Photo();
        } else {
          fileObject = new File();
        }
        fileObject.setOwner(owner);

        String parentFolderId = request.getParameter("parentFolder");
        Folder parentFolder = null;
        if (parentFolderId != null && !"".equals(parentFolderId)) {
          parentFolder = (Folder) session.load(Folder.class, new Long(parentFolderId));
          if (!SecurityHelper.doesUserHavePermission(session, owner, parentFolder, PERM.WRITE)) {
            Cookie cookie = new Cookie(item.getFieldName(), "");
            cookie.setMaxAge(0);
            cookie.setPath("/");
            response.addCookie(cookie);
            response.sendError(HttpServletResponse.SC_FORBIDDEN);
            response.setStatus(HttpServletResponse.SC_FORBIDDEN);
            response.flushBuffer();
            Logger.log("Unauthorized upload requested: " + request.getRemoteAddr());
            return;
          }
        }
        fileObject.setParent(parentFolder);

        fileObject.setContentType(item.getContentType());
        String name = item.getName();
        if (name.lastIndexOf("/") >= 0) {
          name = name.substring(name.lastIndexOf("/") + 1);
        }
        if (name.lastIndexOf("\\") >= 0) {
          name = name.substring(name.lastIndexOf("\\") + 1);
        }

        fileObject.setName(name);
        fileObject.setDescription(name);
        session.save(fileObject);

        status.setStatus(FileUploadStatus.WRITING_FILE);
        java.io.File outputPath = new java.io.File(java.io.File.separatorChar + "tmp" + java.io.File.separatorChar + BaseSystem.getDomainName(request));
        java.io.File outputFile = new java.io.File(outputPath, fileObject.getId() + "_" + fileObject.getName());
        outputPath.mkdirs();
        item.write(outputFile);
        tx = session.beginTransaction();
        fileObject.setNameOnDisk(fileObject.getId() + "_" + fileObject.getName());
        fileObject.setSize(outputFile.length());
        session.save(fileObject);
        tx.commit();
        Logger.log("Wrote to file: " + outputFile.getCanonicalPath());

        status.setStatus(FileUploadStatus.WRITING_DATABASE);
        saveFileFromStream(fileObject, new FileInputStream(outputFile));

        try {

          // if we are uploading a photo, create slideshow (sane size) image and thumbnail
          if (fileObject instanceof Photo) {
            // convert file to png for faster inclusion in thumbnails
            BufferedImage bi = javax.imageio.ImageIO.read(outputFile);
            ByteArrayOutputStream pngOut = new ByteArrayOutputStream();
            ImageIO.write(bi, "png", pngOut);

            tx = session.beginTransaction();
            Photo photo = (Photo) fileObject;
            photo.setWidth(bi.getWidth());
            photo.setHeight(bi.getHeight());

            PhotoThumbnail thumbFile = new PhotoThumbnail();
            thumbFile.setHidden(true);
            thumbFile.setOwner(owner);
            thumbFile.setParent(parentFolder);
            thumbFile.setName(createFileName("", name, "_thumb"));
            thumbFile.setDescription("Thumbnail for " + name);
            session.save(thumbFile);

            PhotoThumbnail previewFile = new PhotoThumbnail();
            previewFile.setHidden(true);
            previewFile.setOwner(owner);
            previewFile.setParent(parentFolder);
            previewFile.setName(createFileName("", name, "_preview"));
            previewFile.setDescription("Preview image for " + name);
            session.save(previewFile);
           
            PhotoThumbnail slideFile = new PhotoThumbnail();
            slideFile.setHidden(true);
            slideFile.setOwner(owner);
            slideFile.setParent(parentFolder);
            slideFile.setName(createFileName("", name, "_slideshow"));
            slideFile.setDescription("Slideshow image for " + name);
            session.save(slideFile);

           
            photo.setThumbnailImage(thumbFile);
            photo.setSlideshowImage(slideFile);
            photo.setPreviewImage(previewFile);

           
            ByteArrayInputStream pngIn = new ByteArrayInputStream(pngOut.toByteArray());

            ByteArrayOutputStream thumbOutStream = new ByteArrayOutputStream();
            BufferedImage thumbbi = ImageIO.read(pngIn);
            BufferedImage convertedThumbImage = createThumbnail(thumbbi, 128, 128, true);
            thumbFile.setWidth(convertedThumbImage.getWidth());
            thumbFile.setHeight(convertedThumbImage.getHeight());

            ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next();
            // instantiate an ImageWriteParam object with default compression options
            ImageWriteParam iwp = writer.getDefaultWriteParam();

            iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
            iwp.setCompressionQuality(0.75f);
            writer.setOutput(new MemoryCacheImageOutputStream(thumbOutStream));
            IIOImage thumbimage = new IIOImage(convertedThumbImage, null, null);
            writer.write(null, thumbimage, iwp);

            pngIn.reset();
            ByteArrayOutputStream slideOutStream = new ByteArrayOutputStream();
            BufferedImage slidebi = ImageIO.read(pngIn);
            BufferedImage convertedSlideImage = createThumbnail(slidebi, 640, 400, true);
            slideFile.setWidth(convertedSlideImage.getWidth());
            slideFile.setHeight(convertedSlideImage.getHeight());
            writer.setOutput(new MemoryCacheImageOutputStream(slideOutStream));
            IIOImage slideimage = new IIOImage(convertedSlideImage, null, null);
            writer.write(null, slideimage, iwp);

            pngIn.reset();
            ByteArrayOutputStream previewOutStream = new ByteArrayOutputStream();
            BufferedImage previewbi = ImageIO.read(pngIn);
            BufferedImage convertedPreviewImage = createThumbnail(previewbi, 320, 200, true);
            previewFile.setWidth(convertedPreviewImage.getWidth());
            previewFile.setHeight(convertedPreviewImage.getHeight());
            writer.setOutput(new MemoryCacheImageOutputStream(previewOutStream));
            IIOImage previewimage = new IIOImage(convertedPreviewImage, null, null);
            writer.write(null, previewimage, iwp);           
           
            thumbFile.setContentType("image/jpeg");
            slideFile.setContentType("image/jpeg");
            previewFile.setContentType("image/jpeg");
            thumbFile.setSize(thumbOutStream.size());
            slideFile.setSize(slideOutStream.size());
            previewFile.setSize(previewOutStream.size());
            session.save(thumbFile);
            session.save(slideFile);
            session.save(previewFile);
            tx.commit();

            tx = session.beginTransaction();
            thumbFile.setNameOnDisk(createFileName(thumbFile.getId().toString() + "_", name, "_thumb"));
            slideFile.setNameOnDisk(createFileName(slideFile.getId().toString() + "_", name, "_slide"));
            previewFile.setNameOnDisk(createFileName(previewFile.getId().toString() + "_", name, "_preview"));
            tx.commit();

            saveFileFromStream(thumbFile, new ByteArrayInputStream(thumbOutStream.toByteArray()));
            saveFileFromStream(slideFile, new ByteArrayInputStream(slideOutStream.toByteArray()));
            saveFileFromStream(previewFile, new ByteArrayInputStream(previewOutStream.toByteArray()));
          }

          status.setStatus(FileUploadStatus.FINISHED);
          Logger.log("Wrote to database: " + fileObject.getName());
        } catch (Throwable t) {
          Logger.log(t);
        }
        Cookie cookie = new Cookie(item.getFieldName(), fileObject.getId().toString());
        cookie.setPath("/");
        cookie.setMaxAge(BaseService.COOKIE_TIMEOUT);
        response.addCookie(cookie);
        response.setStatus(HttpServletResponse.SC_OK);
        response.getOutputStream().close();
View Full Code Here

Examples of org.drools.compiler.compiler.io.File

                String name = entry.getName().substring( separator + 1 );

                Folder folder = mfs.getFolder( path );
                folder.create();

                File file = folder.getFile( name );
                file.create( zipFile.getInputStream( entry ) );
            }
        } catch ( IOException e ) {
            throw new RuntimeException( e );
        } finally {
            if ( zipFile != null ) {
View Full Code Here

Examples of org.drools.compiler.io.File

                String name = entry.getName().substring( separator + 1 );

                Folder folder = mfs.getFolder( path );
                folder.create();

                File file = folder.getFile( name );
                file.create( zipFile.getInputStream( entry ) );
            }
        } catch ( IOException e ) {
            throw new RuntimeException( e );
        } finally {
            if ( zipFile != null ) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.