Examples of ProjectInfo


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

      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

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

          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

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

      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

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

      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

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

      }
      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

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

    //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

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

  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

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

    //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

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

    //make sure required fields are set
    if (name == null)
      name = request.getHeader(ProtocolConstants.HEADER_SLUG);
    if (!validateProjectName(workspace, name, request, response))
      return null;
    ProjectInfo project = new ProjectInfo();
    if (id != null)
      project.setUniqueId(id);
    project.setFullName(name);
    project.setWorkspaceId(workspace.getUniqueId());
    String content = toAdd.optString(ProtocolConstants.KEY_CONTENT_LOCATION, null);
    if (!isAllowedLinkDestination(content, request.getRemoteUser())) {
      String msg = NLS.bind("Cannot link to server path {0}. Use the orion.file.allowedPaths property to specify server locations where content can be linked.", content);
      statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, msg, null));
      return null;
    }

    try {
      computeProjectLocation(request, project, content, getInit(toAdd));
      //project creation will assign unique project id
      getMetaStore().createProject(project);
    } catch (CoreException e) {
      String msg = "Error persisting project state";
      statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e));
      return null;
    }
    try {
      getMetaStore().updateProject(project);
    } catch (CoreException e) {
      boolean authFail = handleAuthFailure(request, response, e);

      //delete the project so we don't end up with a project in a bad location
      try {
        getMetaStore().deleteProject(workspace.getUniqueId(), project.getFullName());
      } catch (CoreException e1) {
        //swallow secondary error
        LogHelper.log(e1);
      }
      if (authFail) {
        return null;
      }
      //we are unable to write in the platform location!
      String msg = NLS.bind("Cannot create project: {0}", project.getFullName());
      statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e));
      return null;
    }

    return project;
View Full Code Here

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

    if (path.segmentCount() != 3)
      return false;
    String workspaceId = path.segment(0);
    String projectName = path.segment(2);
    try {
      ProjectInfo project = getMetaStore().readProject(workspaceId, projectName);
      if (project == null) {
        //nothing to do if project does not exist
        return true;
      }
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.