Package org.eclipse.core.filesystem

Examples of org.eclipse.core.filesystem.IFileStore


   *
   * @return the root location.
   */
  public static IFileStore getRootLocation() {
    URI platformLocationURI = Activator.getDefault().getRootLocationURI();
    IFileStore root = null;
    try {
      root = EFS.getStore(platformLocationURI);
    } catch (CoreException e) {
      //this is fatal, we can't access the platform instance location
      throw new Error("Failed to access platform instance location", e); //$NON-NLS-1$
View Full Code Here


    if (locationString == null) {
      statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, "Copy or move request must specify source location", null));
      return false;
    }
    try {
      IFileStore source = resolveSourceLocation(request, locationString);
      if (source == null) {
        statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("Source does not exist: ", locationString), null));
        return false;
      } else if (source.isParentOf(toCreate)) {
        statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, "The destination cannot be a descendent of the source location", null));
        return false;
      }
      boolean allowOverwrite = (options & CREATE_NO_OVERWRITE) == 0;
      int efsOptions = allowOverwrite ? EFS.OVERWRITE : EFS.NONE;
      try {
        if (isCopy) {
          source.copy(toCreate, efsOptions, null);
        } else {
          source.move(toCreate, efsOptions, null);
          // Path format is /file/workspaceId/projectId/[location to folder]
          Path path = new Path(locationString);
          if (path.segmentCount() == 3 && path.segment(0).equals("file")) {
            // The folder is a project, remove the metadata
            OrionConfiguration.getMetaStore().deleteProject(path.segment(1), source.getName());
          }
        }
      } catch (CoreException e) {
        if (!source.fetchInfo(EFS.NONE, null).exists()) {
          statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("Source does not exist: ", locationString), e));
          return false;
        }
        if (e.getStatus().getCode() == EFS.ERROR_EXISTS) {
          statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_PRECONDITION_FAILED, "A file or folder with the same name already exists at this location", null));
View Full Code Here

    }
    return other;
  }

  public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
    IFileStore mkdir = wrapped.mkdir(options, monitor);

    notifyOfWrite(new ChangeEvent(source, ChangeType.MKDIR, mkdir));

    // Tested by CoreFilesTest.testListenerCreateDirectory()
    return wrap(source, mkdir);
View Full Code Here

    //don't allow anyone to mess with metadata
    if (path.segmentCount() > 0 && ".metadata".equals(path.segment(0))) { //$NON-NLS-1$
      handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, NLS.bind("Forbidden: {0}", pathInfo), null));
      return;
    }
    IFileStore file = getFileStore(req, path);
    IFileStore testLink = file;
    while (testLink != null) {
      IFileInfo info = testLink.fetchInfo();
      if (info.getAttribute(EFS.ATTRIBUTE_SYMLINK)) {
        if (file == testLink) {
          handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, NLS.bind("Forbidden: {0}", EncodingUtils.encodeForHTML(pathInfo.toString())), null));
        } else {
          handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("File not found: {0}", EncodingUtils.encodeForHTML(pathInfo.toString())), null));
        }
        return;
      }
      testLink = testLink.getParent();
    }

    if (file == null) {
      handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("File not found: {0}", EncodingUtils.encodeForHTML(pathInfo.toString())), null));
      return;
View Full Code Here

  public static IFileStore getFileStore(HttpServletRequest request, WorkspaceInfo workspace) {
    try {
      if (workspace.getUniqueId() == null) {
        return null;
      }
      IFileStore fileStore = OrionConfiguration.getMetaStore().getWorkspaceContentLocation(workspace.getUniqueId());
      return wrap(workspace, fileStore);
    } catch (CoreException e) {
      LogHelper.log(new Status(IStatus.WARNING, Activator.PI_SERVER_SERVLETS, 1, "An error occurred when getting workspace store for path", e));
      // fallback and return null
    }
View Full Code Here

    IPath localPath = new Path(location.getPath());
    if (localPath.isAbsolute()) {
      return wrap(project, EFS.getLocalFileSystem().getStore(localPath));
    }
    //treat relative location as relative to the file system root
    IFileStore root = OrionConfiguration.getMetaStore().getUserHome(request.getRemoteUser());
    return wrap(project, root.getChild(location.toString()));
  }
View Full Code Here

  @Override
  public File getDeploymentPackage(IFileStore contentLocation) throws IOException, CoreException {

    /* require a package.json file present */
    IFileStore packageStore = contentLocation.getChild(NodeJSConstants.PACKAGE_JSON);
    if (!packageStore.fetchInfo().exists())
      return null;

    InputStream is = null;
    JSONObject packageJSON = null;

    try {

      is = packageStore.openInputStream(EFS.NONE, null);
      packageJSON = new JSONObject(new JSONTokener(new InputStreamReader(is)));

      if (!packageJSON.has(NodeJSConstants.DEPENDENCIES))
        packageJSON.put(NodeJSConstants.DEPENDENCIES, new JSONObject());

View Full Code Here

          Target target = computeTarget.getTarget();

          /* parse the application manifest */
          String manifestAppName = null;
          ManifestParseTree manifest = null;
          IFileStore appStore = null;

          if (contentLocation != null && state == null) {

            /* check for non-manifest deployment */
            if (manifestJSON != null) {

              ParseManifestJSONCommand parseManifestJSONCommand = new ParseManifestJSONCommand(manifestJSON, userId, contentLocation);
              status = parseManifestJSONCommand.doIt();
              if (!status.isOK())
                return status;

              /* get the manifest name */
              manifest = parseManifestJSONCommand.getManifest();
              appStore = parseManifestJSONCommand.getAppStore();

              if (manifest != null) {
                ManifestParseTree applications = manifest.get(CFProtocolConstants.V2_KEY_APPLICATIONS);
                if (applications.getChildren().size() > 0)
                  manifestAppName = applications.get(0).get(CFProtocolConstants.V2_KEY_NAME).getValue();

                if (persistManifest) {
                  /* non-manifest deployment - persist at contentLocation/manifest.yml */
                  IFileStore persistBaseLocation = parseManifestJSONCommand.getPersistBaseLocation();
                  IFileStore persistLocation = persistBaseLocation.getChild(ManifestConstants.MANIFEST_FILE_NAME);
                  manifest.persist(persistLocation);
                }
              }

            } else {
View Full Code Here

  @Override
  public Plan getDeploymentPlan(IFileStore contentLocation, ManifestParseTree manifest) {

    /* a present package.json file determines a node.js application */
    IFileStore packageStore = contentLocation.getChild(NodeJSConstants.PACKAGE_JSON);
    if (!packageStore.fetchInfo().exists())
      return null;

    /* do not support multi-aplication manifests */
    if (manifest != null && ManifestUtils.hasMultipleApplications(manifest))
      return null;

    try {

      if (manifest == null)
        manifest = ManifestUtils.createBoilerplate(getApplicationName(contentLocation));

      ManifestParseTree application = manifest.get(ManifestConstants.APPLICATIONS).get(0);
      String defaultName = getApplicationName(contentLocation);

      set(application, ManifestConstants.NAME, defaultName);
      set(application, ManifestConstants.HOST, ManifestUtils.slugify(defaultName));

      set(application, ManifestConstants.MEMORY, ManifestUtils.DEFAULT_MEMORY);
      set(application, ManifestConstants.INSTANCES, ManifestUtils.DEFAULT_INSTANCES);
      set(application, ManifestConstants.PATH, ManifestUtils.DEFAULT_PATH);

      /* node.js application require a start command */
      if (application.has(ManifestConstants.COMMAND))
        return new Plan(getId(), getWizardId(), TYPE, manifest);

      InputStream is = null;
      try {

        is = packageStore.openInputStream(EFS.NONE, null);
        JSONObject packageJSON = new JSONObject(new JSONTokener(new InputStreamReader(is)));
        if (packageJSON.has(NodeJSConstants.SCRIPTS)) {
          JSONObject scripts = packageJSON.getJSONObject(NodeJSConstants.SCRIPTS);
          if (scripts.has(NodeJSConstants.START)) {
            application.put(ManifestConstants.COMMAND, scripts.getString(NodeJSConstants.START));
            return new Plan(getId(), getWizardId(), TYPE, manifest);
          }
        }

      } catch (JSONException ex) {
        /* can't parse the package.json, fail */
        return null;

      } finally {
        IOUtilities.safeClose(is);
      }

      /* look for server.js or app.js files */
      IFileStore serverJS = contentLocation.getChild(NodeJSConstants.SERVER_JS);
      if (serverJS.fetchInfo().exists()) {
        application.put(ManifestConstants.COMMAND, NodeJSConstants.NODE_SERVER_JS);
        return new Plan(getId(), getWizardId(), TYPE, manifest);
      }

      IFileStore appJS = contentLocation.getChild(NodeJSConstants.APP_JS);
      if (appJS.fetchInfo().exists()) {
        application.put(ManifestConstants.COMMAND, NodeJSConstants.NODE_APP_JS);
        return new Plan(getId(), getWizardId(), TYPE, manifest);
      }

      /* could not deduce command, mark as required */
 
View Full Code Here

        return;
      }
      String workspaceId = workspaceIds.get(0);

      // see if the .bashrc already exists
      IFileStore workspaceContentLocation = metaStore.getWorkspaceContentLocation(workspaceId);
      IFileStore bashrc = workspaceContentLocation.getChild(".bashrc");
      if (bashrc.fetchInfo().exists()) {
        // .bashrc already exists, return
        return;
      }

      // copy the default bashrc if one exists on this system
      File skelFile = new File("/etc/skel/.bashrc");
      IFileStore skel = EFS.getLocalFileSystem().fromLocalFile(skelFile);
      if (skel.fetchInfo().exists()) {
        skel.copy(bashrc, EFS.NONE, null);
      }
      File bashrcFile = bashrc.toLocalFile(EFS.NONE, null);

      // append lines to the bashrc
      String lines = new String("set -o vi\nPS1=\"\\u:\\w[\\!] % \"\n");
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.