Package org.eclipse.orion.server.core.metastore

Examples of org.eclipse.orion.server.core.metastore.ProjectInfo


    //path format is /file/{workspaceId}/{projectName}[/path]
    final IMetaStore metaStore = OrionConfiguration.getMetaStore();
    WorkspaceInfo workspace = metaStore.readWorkspace(path.segment(1));
    assertNotNull(workspace);
    ProjectInfo wp = metaStore.readProject(workspace.getUniqueId(), path.segment(2));
    assertNotNull(wp);
    String userId = workspace.getUserId();
    assertNotNull(userId);
    IFileStore fsStore = getProjectStore(wp, userId);
    fsStore = fsStore.getFileStore(path.removeFirstSegments(3));
View Full Code Here


  protected IFileStore tempGetFileStore(IPath path) {
    //path format is /workspaceId/projectName/[suffix]
    if (path.segmentCount() <= 1)
      return null;
    try {
      ProjectInfo project = OrionConfiguration.getMetaStore().readProject(path.segment(0), path.segment(1));
      if (project == null)
        return null;
      return project.getProjectStore().getFileStore(path.removeFirstSegments(2));
    } catch (CoreException e) {
      logger.error(NLS.bind("An error occurred when getting file store for path {0}", path), e);
      // fallback and return null
    }
    return null;
View Full Code Here

      return;
    String scm = PreferenceHelper.getString(ServerConstants.CONFIG_FILE_DEFAULT_SCM, "").toLowerCase(); //$NON-NLS-1$
    if (!"git".equals(scm)) //$NON-NLS-1$
      return;
    try {
      ProjectInfo project = getProjectForLocation(representation.getString(ProtocolConstants.KEY_LOCATION));
      if (project == null)
        return;
      IFileStore store = project.getProjectStore();
      // create repository in each project if it doesn't already exist
      File localFile = store.toLocalFile(EFS.NONE, null);
      File gitDir = GitUtils.getGitDir(localFile);
      if (gitDir == null) {
        gitDir = new File(localFile, Constants.DOT_GIT);
View Full Code Here

          return getFileStore(request, workspace);
        }
        return null;
      }
      //path format is /workspaceId/projectName/[suffix]
      ProjectInfo project = OrionConfiguration.getMetaStore().readProject(path.segment(0), path.segment(1));
      if (project != null) {
        return getFileStore(request, project).getFileStore(path.removeFirstSegments(2));
      }
      // Bug 415700: handle path format /workspaceId/[file]
      if (path.segmentCount() == 2) {
View Full Code Here

      if (userInfo.getWorkspaceIds().size() > 0) {
        for (String workspaceId : userInfo.getWorkspaceIds()) {
          WorkspaceInfo workspaceInfo = metastore.readWorkspace(workspaceId);
          if (workspaceInfo.getProjectNames().size() > 0) {
            for (String projectName : workspaceInfo.getProjectNames()) {
              ProjectInfo projectInfo = metastore.readProject(workspaceId, projectName);
              if (projectInfo != null) {
                WorkspaceResourceHandler.removeProject(userId, workspaceInfo, projectInfo);
              }
            }
          }
View Full Code Here

      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

      }
      IPath path = resourcePath.makeRelativeTo(basePath);
      //nothing to do if request is not a folder or file
      if (path.segmentCount() < 2)
        return;
      ProjectInfo project = OrionConfiguration.getMetaStore().readProject(path.segment(0), path.segment(1));
      //nothing to do if project does not exist
      if (project == null) {
        return;
      }
      addParents(base, representation, project, path);
      //set the name of the project file to be the project name
      if (path.segmentCount() == 2) {
        String projectName = project.getFullName();
        if (projectName != null)
          representation.put(ProtocolConstants.KEY_NAME, projectName);
      }
    } catch (Exception e) {
      //don't let problems in decorator propagate
View Full Code Here

    //add children element to conform to file API structure
    JSONArray children = new JSONArray();
    IMetaStore metaStore = OrionConfiguration.getMetaStore();
    for (String projectName : workspace.getProjectNames()) {
      try {
        ProjectInfo project = metaStore.readProject(workspace.getUniqueId(), projectName);
        //augment project objects with their location
        JSONObject projectObject = new JSONObject();
        projectObject.put(ProtocolConstants.KEY_ID, project.getUniqueId());
        //this is the location of the project metadata
        projectObject.put(ProtocolConstants.KEY_LOCATION, URIUtil.append(projectBaseLocation, projectName));
        projects.put(projectObject);

        //remote folders are listed separately
        IFileStore projectStore = null;
        try {
          projectStore = project.getProjectStore();
        } catch (CoreException e) {
          //ignore and treat as local
        }
        JSONObject child = new JSONObject();
        child.put(ProtocolConstants.KEY_NAME, project.getFullName());
        child.put(ProtocolConstants.KEY_DIRECTORY, true);
        //this is the location of the project file contents
        URI contentLocation = computeProjectURI(baseLocation, workspace, project);
        child.put(ProtocolConstants.KEY_LOCATION, contentLocation);
        try {
          if (projectStore != null)
            child.put(ProtocolConstants.KEY_LOCAL_TIMESTAMP, projectStore.fetchInfo(EFS.NONE, null).getLastModified());
        } catch (CoreException coreException) {
          //just omit the timestamp in this case because the project location is unreachable
        }
        try {
          child.put(ProtocolConstants.KEY_CHILDREN_LOCATION, new URI(contentLocation.getScheme(), contentLocation.getUserInfo(), contentLocation.getHost(), contentLocation.getPort(), contentLocation.getPath(), ProtocolConstants.PARM_DEPTH + "=1", contentLocation.getFragment())); //$NON-NLS-1$
        } catch (URISyntaxException e) {
          throw new RuntimeException(e);
        }
        child.put(ProtocolConstants.KEY_ID, project.getUniqueId());
        children.put(child);
      } catch (Exception e) {
        //ignore malformed children
      }
    }
View Full Code Here

  private boolean handleCopyMoveProject(HttpServletRequest request, HttpServletResponse response, WorkspaceInfo workspace, JSONObject data) throws ServletException, IOException {
    //resolve the source location to a file system location
    String sourceLocation = data.optString(ProtocolConstants.HEADER_LOCATION);
    IFileStore source = null;
    ProjectInfo sourceProject = null;
    try {
      if (sourceLocation != null) {
        //could be either a workspace or file location
        if (sourceLocation.startsWith(Activator.LOCATION_WORKSPACE_SERVLET)) {
          sourceProject = projectForMetadataLocation(getMetaStore(), toOrionLocation(request, sourceLocation));
          if (sourceProject != null)
            source = sourceProject.getProjectStore();
        } else {
          //file location - remove servlet name prefix
          source = resolveSourceLocation(request, sourceLocation);
        }
      }
    } catch (Exception e) {
      handleError(request, response, HttpServletResponse.SC_BAD_REQUEST, NLS.bind("Invalid source location: {0}", sourceLocation), e);
      return true;
    }
    //null result means we didn't find a matching project
    if (source == null) {
      handleError(request, response, HttpServletResponse.SC_BAD_REQUEST, NLS.bind("Source does not exist: {0}", sourceLocation));
      return true;
    }
    int options1 = getCreateOptions(request);
    if (!validateOptions(request, response, options1))
      return true;

    //get the slug first
    String destinationName = request.getHeader(ProtocolConstants.HEADER_SLUG);
    //If the data has a name then it must be used due to UTF-8 issues with names Bug 376671
    try {
      if (data.has(ProtocolConstants.KEY_NAME)) {
        destinationName = data.getString(ProtocolConstants.KEY_NAME);
      }
    } catch (JSONException e) {
      //key is valid so cannot happen
    }

    if (!validateProjectName(workspace, destinationName, request, response))
      return true;

    if ((options1 & CREATE_MOVE) != 0) {
      return handleMoveProject(request, response, workspace, source, sourceProject, sourceLocation, destinationName);
    } else if ((options1 & CREATE_COPY) != 0) {
      //first create the destination project
      JSONObject projectObject = new JSONObject();
      try {
        projectObject.put(ProtocolConstants.KEY_NAME, destinationName);
      } catch (JSONException e) {
        //should never happen
        throw new RuntimeException(e);
      }

      //copy the project data from source
      ProjectInfo destinationProject = createProject(request, response, workspace, projectObject);
      String sourceName = source.getName();
      try {
        source.copy(destinationProject.getProjectStore(), EFS.OVERWRITE, null);
      } catch (CoreException e) {
        handleError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, NLS.bind("Error copying project {0} to {1}", sourceName, destinationName));
        return true;
      }
      URI baseLocation = getURI(request);
View Full Code Here

    //if we got here, it isn't a copy or a move, so we don't know how to handle the request
    return false;
  }

  private ProjectInfo handleAddProject(HttpServletRequest request, HttpServletResponse response, WorkspaceInfo workspace, JSONObject data) throws IOException, ServletException {
    ProjectInfo project = createProject(request, response, workspace, data);
    if (project == null)
      return null;

    //serialize the new project in the response
View Full Code Here

TOP

Related Classes of org.eclipse.orion.server.core.metastore.ProjectInfo

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.