Package org.eclipse.core.filesystem

Examples of org.eclipse.core.filesystem.IFileStore


        // the user has no workspaces so no projects
        return null;
      }
      String workspaceId = workspaceIds.get(0);

      IFileStore workspaceContentLocation = metaStore.getWorkspaceContentLocation(workspaceId);
      String localVolume = workspaceContentLocation.toLocalFile(EFS.NONE, null).getAbsolutePath();
      String volume = localVolume + ":/home/" + user + ":rw";
      if (logger.isDebugEnabled()) {
        logger.debug("Created Docker Volume \"" + volume + "\" for user " + user);
      }
      return volume;
View Full Code Here


  @Override
  public Object customizeContext(Object context, Dictionary<String, ?> settings) {
    if (context instanceof ServletContextHandler) {
      ServletContextHandler jettyContext = (ServletContextHandler) context;

      IFileStore fileStore = OrionConfiguration.getRootLocation();
      File rootLocation = null;
      try {
        rootLocation = fileStore.toLocalFile(EFS.NONE, null);
      } catch (CoreException e) {
        Logger logger = LoggerFactory.getLogger("org.eclipse.orion.server.config"); //$NON-NLS-1$
        logger.error("Could not initialize NCSA Request Log", e); //$NON-NLS-1$
      }
View Full Code Here

          IPath contentPath = new Path(path.startsWith("/") ? path : "/" + path); //$NON-NLS-1$ //$NON-NLS-2$
          if (!AuthorizationService.checkRights(userId, contentPath.toString(), "GET")) //$NON-NLS-1$ //$NON-NLS-2$
            return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, "Forbidden access to application contents", null);

          IFileStore contentLocation = NewFileServlet.getFileStore(null, contentPath.removeFirstSegments(1));
          if (!contentLocation.fetchInfo().isDirectory())
            contentLocation = contentLocation.getParent();

          /* check if the application has a manifest */
          ManifestParseTree manifest = null;
          ParseManifestCommand parseManifestCommand = new ParseManifestCommand(null, userId, contentPath.toString()); /* TODO: set target */
          parseManifestCommand.setApplicationAnalyzer(new ApplicationReconstructor());
View Full Code Here

    }
    representation.put(ProtocolConstants.KEY_EXPORT_LOCATION, link);
  }

  private boolean isEmptyDirectory(HttpServletRequest request, IPath targetPath) {
    IFileStore store = NewFileServlet.getFileStore(request, targetPath);
    //if an error occurred we can't tell, so assume non-empty to be safe
    if (store == null) {
      return false;
    }
    try {
      return store.childNames(EFS.NONE, null).length == 0;
    } catch (CoreException e) {
      //this isn't the place for reporting this failure, so assume non-empty
      return false;
    }
  }
View Full Code Here

    List<String> options = getOptions();
    boolean override = options.contains(ProtocolConstants.OPTION_OVERWRITE_OLDER);

    IPath destPath = new Path(getPath()).append(getFileName());
    try {
      IFileStore source = EFS.getStore(new File(getStorageDirectory(), FILE_DATA).toURI());
      IFileStore destination = NewFileServlet.getFileStore(req, destPath);
      if (!override && destination.fetchInfo().exists()) {
        String msg = NLS.bind("Failed to complete file transfer on {0}. The file could not be overwritten.", destPath.toString());
        JSONObject jsonData = new JSONObject();
        jsonData.put("ExistingFiles", getFileName());
        statusHandler.handleRequest(req, resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, msg, jsonData, null));
        return false;
View Full Code Here

    if (req.getParameter(ProtocolConstants.PARAM_EXCLUDE) != null) {
      excludedFiles = Arrays.asList(req.getParameter(ProtocolConstants.PARAM_EXCLUDE).split(",")); //$NON-NLS-1$
    }

    /* exclude .git if already present in the destination root, see bug 428657 */
    IFileStore destinationRoot = NewFileServlet.getFileStore(req, destPath);
    IFileStore dotGitStorage = destinationRoot.getChild(".git"); //$NON-NLS-1$
    if (dotGitStorage.fetchInfo().exists())
      excludedFiles.add(".git"); //$NON-NLS-1$

    try {
      ZipFile source = new ZipFile(new File(getStorageDirectory(), FILE_DATA));

      Enumeration<? extends ZipEntry> entries = source.entries();
      while (entries.hasMoreElements()) {
        ZipEntry entry = entries.nextElement();
        IFileStore destination = destinationRoot.getChild(entry.getName());
        if (!destinationRoot.isParentOf(destination) || hasExcludedParent(destination, destinationRoot, excludedFiles)) {
          //file should not be imported
          continue;
        }
        if (entry.isDirectory())
          destination.mkdir(EFS.NONE, null);
        else {
          if (!force && destination.fetchInfo().exists()) {
            filesFailed.add(entry.getName());
            continue;
          }
          destination.getParent().mkdir(EFS.NONE, null);
          // this filter will throw an IOException if a zip entry is larger than 100MB
          FilterInputStream maxBytesReadInputStream = new FilterInputStream(source.getInputStream(entry)) {
            private static final int maxBytes = 0x6400000; // 100MB
            private int totalBytes;

            private void addByteCount(int count) throws IOException {
              totalBytes += count;
              if (totalBytes > maxBytes) {
                throw new IOException("Zip file entry too large");
              }
            }

            @Override
            public int read() throws IOException {
              int c = super.read();
              if (c != -1) {
                addByteCount(1);
              }
              return c;
            }

            @Override
            public int read(byte[] b, int off, int len) throws IOException {
              int read = super.read(b, off, len);
              if (read != -1) {
                addByteCount(read);
              }
              return read;
            }
          };
          boolean fileWritten = false;
          try {
            IOUtilities.pipe(maxBytesReadInputStream, destination.openOutputStream(EFS.NONE, null), false, true);
            fileWritten = true;
          } finally {
            if (!fileWritten) {
              try {
                destination.delete(EFS.NONE, null);
              } catch (CoreException ce) {
                // best effort
              }
            }
          }
View Full Code Here

      IPath contentPath = new Path(contentLocation).removeFirstSegments(1);
      ServerStatus accessStatus = canAccess(contentPath);
      if (!accessStatus.isOK())
        return accessStatus;

      IFileStore fileStore = NewFileServlet.getFileStore(null, contentPath);
      if (!fileStore.fetchInfo().isDirectory()) {
        fileStore = fileStore.getParent();
        contentPath = contentPath.removeLastSegments(1);
      }

      if (fileStore == null)
        return cannotFindManifest(contentPath);

      /* lookup the manifest description */
      IFileStore manifestStore = fileStore.getChild(ManifestConstants.MANIFEST_FILE_NAME);
      if (!manifestStore.fetchInfo().exists())
        return cannotFindManifest(contentPath);

      /* parse within the project sandbox */
      ProjectInfo project = OrionConfiguration.getMetaStore().readProject(contentPath.segment(0), contentPath.segment(1));
      IFileStore projectStore = NewFileServlet.getFileStore(null, project);

      /* parse the manifest */
      ManifestParseTree manifest = null;
      String targetBase = null;

View Full Code Here

  private void initializeFileSystem() {
    IPath location = getFileSystemLocation();
    if (location == null)
      throw new RuntimeException("Unable to compute base file system location"); //$NON-NLS-1$

    IFileStore rootStore = EFS.getLocalFileSystem().getStore(location);
    try {
      rootStore.mkdir(EFS.NONE, null);
      rootStoreURI = rootStore.toURI();
    } catch (CoreException e) {
      throw new RuntimeException("Instance location is read only: " + rootStore, e); //$NON-NLS-1$
    }
  }
View Full Code Here

      IPath contentPath = new Path(contentLocation).removeFirstSegments(1);
      ServerStatus accessStatus = canAccess(contentPath);
      if (!accessStatus.isOK())
        return accessStatus;

      IFileStore fileStore = NewFileServlet.getFileStore(null, contentPath);
      if (!fileStore.fetchInfo().isDirectory()) {
        fileStore = fileStore.getParent();
        contentPath = contentPath.removeLastSegments(1);
      }

      /* parse the manifest */
      manifest = ManifestUtils.parse(manifestJSON);
View Full Code Here

    while (iterator.hasNext()) {
      SolrDocument doc = iterator.next();
      URI uri;
      try {
        uri = new URI((String) doc.getFieldValue(ProtocolConstants.KEY_ID));
        IFileStore file = null;

        if (uri.isAbsolute()) {
          file = EFS.getLocalFileSystem().getStore(URIUtil.toPath(uri));
        } else {
          file = EFS.getStore(uri);
        }

        if (!file.fetchInfo().exists())
          listIds.add((String) doc.getFieldValue(ProtocolConstants.KEY_ID));

      } catch (Exception e) {
        handleIndexingFailure(e);
        continue;
View Full Code Here

TOP

Related Classes of org.eclipse.core.filesystem.IFileStore

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.